StEventDisplayMaker/StGlobalFilterTest.cxx

00001 // $Id: StGlobalFilterTest.cxx,v 1.9 2006/11/13 05:13:32 fine Exp $ 00002 #include "TError.h" 00003 #include "TSystem.h" 00004 #include "TCanvas.h" 00005 #include "TH1F.h" 00006 #include "TH2F.h" 00007 #if ROOT_VERSION_CODE < 331013 00008 #include "TCL.h" 00009 #else 00010 #include "TCernLib.h" 00011 #endif 00012 #include "StGlobalFilterTest.h" 00013 #include "TObjArray.h" 00014 #include "StEventHelper.h" 00015 #include "StThreeVectorD.hh" 00016 #include "StThreeVectorF.hh" 00017 #include "StPhysicalHelixD.hh" 00018 #include "THelixTrack.h" 00019 #include "StContainers.h" 00020 #include "StHit.h" 00021 #include "THack.h" 00022 00023 00024 ClassImp(StGlobalFilterTest) 00025 //_____________________________________________________________________________ 00026 StGlobalFilterTest::StGlobalFilterTest(): StGlobalFilterABC("Test","Test") 00027 { 00028 memset(fHRes,0,sizeof(fHRes)); 00029 fCanvas[0] = new TCanvas("RESID","Track Residuals",1); 00030 fHRes[0] = new TH1F("RESH0","max resuduals ",100,0,2.); 00031 fHRes[1] = new TH1F("RESH1","max resuduals SVT",100,0,2.); 00032 fHRes[2] = new TH1F("RESH2","ave resuduals ",100,0,2.); 00033 fHRes[3] = new TH1F("RESH3","ave resuduals SVT",100,0,2.); 00034 fHRes[4] = new TH1F("RESH4","big resuduals ",100,-3.,3.); 00035 int nhres = sizeof(fHRes)/sizeof(void*); 00036 fCanvas[0]->Divide(1,nhres); 00037 for (int i=0;i<nhres;i++) { 00038 fCanvas[0]->cd(i+1); fHRes[i]->Draw();fHRes[i]->StatOverflows();} 00039 00040 } 00041 //_____________________________________________________________________________ 00042 void StGlobalFilterTest::Filter(TObjArray *eArr,int flag) 00043 { 00044 static int nKount=0; 00045 int kind,nTot=0,nSel=0,iSel=0;; 00046 TObject *to; 00047 00048 int n = eArr->GetLast()+1; 00049 for (int ioj=0;ioj<n-1;ioj++) 00050 { 00051 to = eArr->At(ioj); 00052 if (!to) continue; 00053 kind = StEventHelper::Kind(to); 00054 if (!(kind&kTRK)) continue; 00055 StTrack *trk = (StTrack *)to; 00056 to = eArr->At(ioj+1); 00057 if (!to) continue; 00058 kind = StEventHelper::Kind(to); 00059 if (!(kind&kHRR)) { eArr->AddAt(0,ioj);continue;} 00060 StPtrVecHit *hr = (StPtrVecHit *)to; 00061 int nhits = hr->size(); 00062 // if (nhits<10) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00063 nTot++; 00064 StTrackHelper th(trk); 00065 // double len = th.GetLength(); 00066 // double mom = th.GetMom().mag(); 00067 // if (mom<0.3) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00068 if (th.GetFlag()<0) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00069 // Only bad tracks 00070 00071 iSel=0; 00072 00073 00074 StPhysicalHelixD *hlx[2] ={0,0}; 00075 THelixTrack myHlx[2]; 00076 double myBeg[2][3],myDir[2][3]; 00077 for (int i=0;i<2;i++) { 00078 nKount++; 00079 hlx[i]=th.GetHelix(i); 00080 StEventHelper::MyHelix(myHlx+i,hlx[i]); 00081 if (i) myHlx[i].Backward(); 00082 myHlx[i].Step(0.,myBeg[i],myDir[i]); 00083 } 00084 double rho[2],drho,dlen; 00085 rho[0]=myHlx[0].GetRho(); 00086 rho[1]=myHlx[1].GetRho(); 00087 dlen = myHlx[0].Step(myBeg[1])*myHlx[0].GetCos(); 00088 drho = ((-rho[1])-rho[0])/dlen; 00089 myHlx[0].Set(rho[0],drho); 00090 myHlx[1].Set(rho[1],drho); 00091 00092 00093 00094 double maxRes[2] = {0,0}; 00095 double aveRes[2] = {0,0}; 00096 int ncount[2] = {0,0}; 00097 int svt=0; 00098 for (int ih=0;ih<nhits;ih++) { 00099 StHit *hit = hr->at(ih); 00100 int bad = hit->detector()==kSvtId; 00101 if (hit->detector()==kSvtId) svt++; 00102 StHitHelper hh(hit); 00103 if (!hh.IsFit()) continue; 00104 StThreeVectorD pnt = hh.GetPoint(); 00105 double dist ; 00106 double myHit[3],myClose[2][3],myDlose[2][3],myDist[3][3],s[3]; 00107 s[2] = hlx[0]->pathLength(pnt); 00108 double per = hlx[0]->period(); 00109 while (s[2]<-per/2) s[2]+=per; 00110 while (s[2]> per ) s[2]-=per; 00111 00112 myHit[0]=pnt.x();myHit[1]=pnt.y(); myHit[2]=pnt.z(); 00113 per = myHlx[0].GetPeriod(); 00114 for (int i=0;i<2;i++) { 00115 s[i]=myHlx[i].Step(myHit,myClose[i],myDlose[i]); 00116 while (s[i]> per) s[i]-=per; 00117 while (s[i]<-0.1*per) s[i]+=per; 00118 TCL::vsub(myHit,myClose[i],myDist[i],3); 00119 double tmp = sqrt(TCL::vdot(myDist[i],myDist[i],3)); 00120 int noProblem = (i || tmp>2. || fabs(s[0]-s[2])< 5.1 ); 00121 if (!noProblem) { 00122 printf("***Problem*** tmp=%g,s[0]=%g, s[2]=%g\n",tmp,s[0],s[2]); 00123 printf("MyHit = %g, %g, %g\n",myHit[0],myHit[1],myHit[2]); 00124 myHlx[0].Print(); 00125 // R__ASSERT(noProblem); 00126 } 00127 } 00128 double wt0 = pow(s[0],3); 00129 double wt1 = pow(s[1],3); 00130 double wtn = wt0+wt1; 00131 wt0/=wtn;wt1/=wtn; 00132 TCL::vlinco(myDist[0],wt1,myDist[1],wt0,myDist[2],3); 00133 dist = sqrt(TCL::vdot(myDist[2],myDist[2],3)); 00134 fHRes[4]->Fill(log10(dist)); 00135 ncount[bad]++; 00136 aveRes[bad]+= dist*dist; 00137 if(dist>maxRes[bad]) maxRes[bad] = dist; 00138 } 00139 00140 if (flag&kHIT){ 00141 for (int ib=0;ib<2;ib++) { 00142 if(!ncount[ib]) continue; 00143 aveRes[ib] = sqrt(aveRes[ib]/ncount[ib]); 00144 fHRes[ib+0]->Fill(maxRes[ib]); 00145 fHRes[ib+2]->Fill(aveRes[ib]); 00146 } 00147 00148 } 00149 iSel = 1; //select all 00150 if (maxRes[0]>0.6) iSel|=64; 00151 if (iSel) {nSel++;continue;} 00152 (*eArr)[ioj]=0;(*eArr)[ioj+1]=0; 00153 } 00154 THack::PadRefresh(fCanvas[0]); 00155 // THack::PadRefresh(fCanvas[1]); 00156 printf("\nStGlobalFilterTest: %d tracks %d were selected\n",nTot,nSel); 00157 } 00158 //_____________________________________________________________________________ 00159 void StGlobalFilterTest::NewEvent(int nrun,int nevt) 00160 { 00161 fHRes[0]->Reset(); 00162 fHRes[1]->Reset(); 00163 fHRes[2]->Reset(); 00164 }

Generated on Sun Mar 15 04:54:27 2009 for StRoot by doxygen 1.3.7