StEventDisplayMaker/StGlobalFilterRand.cxx

00001 // $Id: StGlobalFilterRand.cxx,v 1.4 2006/11/13 04:00:27 fine Exp $ 00002 #include "TError.h" 00003 #include "TRandom.h" 00004 #include "TSystem.h" 00005 #if ROOT_VERSION_CODE < 331013 00006 #include "TCL.h" 00007 #else 00008 #include "TCernLib.h" 00009 #endif 00010 #include "StGlobalFilterRand.h" 00011 #include "TObjArray.h" 00012 #include "StEventHelper.h" 00013 #include "StThreeVectorD.hh" 00014 #include "StThreeVectorF.hh" 00015 #include "StPhysicalHelixD.hh" 00016 #include "THelixTrack.h" 00017 #include "StContainers.h" 00018 #include "StHit.h" 00019 #include "StTrack.h" 00020 00021 enum BadGood {kBadTrk=1,kGoodTrk=2,kGarbTrk=4,kNGarbTrk=8}; 00022 ClassImp(StGlobalFilterRand) 00023 //_____________________________________________________________________________ 00024 StGlobalFilterRand::StGlobalFilterRand(int BadGood,int maxNum): StGlobalFilterABC("Rand","") 00025 { 00026 fMode = BadGood; fMaxNum =maxNum; 00027 } 00028 //_____________________________________________________________________________ 00029 void StGlobalFilterRand::Filter(TObjArray *eArr,int flag) 00030 { 00031 static int nKount=0;nKount++; 00032 int kind,nTot=0,nZel=0,nSel=0,iSel; 00033 TObject *to; 00034 StErrorHelper errh; 00035 00036 int n = eArr->GetLast()+1; 00037 for (int ioj=0;ioj<n-1;ioj++) 00038 { 00039 to = eArr->At(ioj); 00040 if (!to) continue; 00041 kind = StEventHelper::Kind(to); 00042 if (!(kind&kTRK)) continue; 00043 nTot++; 00044 StTrack *trk = (StTrack *)to; 00045 to = eArr->At(ioj+1); 00046 if (!to) continue; 00047 kind = StEventHelper::Kind(to); 00048 if (!(kind&kHRR)) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00049 StPtrVecHit *hr = (StPtrVecHit *)to; 00050 int nhits = hr->size(); 00051 if (nhits<10 && !(fMode&kGarbTrk )) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00052 if (nhits>10 && !(fMode&kNGarbTrk)) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00053 StTrackHelper th(trk); 00054 double len = th.GetLength(); if(len){}; 00055 double mom = th.GetMom().mag(); 00056 if (mom<0.1 && !(fMode&kGarbTrk )) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00057 if (mom>0.1 && !(fMode&kNGarbTrk)) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00058 nZel++; 00059 int bad = trk->bad(); 00060 errh.Add(bad); 00061 iSel = bad && (fMode&1); 00062 iSel |= !bad && (fMode&2); 00063 if (!iSel) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00064 if (bad==21) {(*eArr)[ioj]=0;(*eArr)[ioj+1]=0;continue;} 00065 // Only selected tracks 00066 nSel++; 00067 } 00068 eArr->Compress(); 00069 errh.Print("StGlobalFilterRand"); 00070 00071 00072 if (!nSel) return; 00073 n = eArr->GetLast()+1; 00074 if (n<=1) return; 00075 double prob = double(fMaxNum)/nSel; 00076 TRandom rnd; 00077 for (int ioj=0;ioj<n-1;ioj++) 00078 { 00079 to = eArr->At(ioj); 00080 if (!to) continue; 00081 kind = StEventHelper::Kind(to); 00082 if (!(kind&kTRK)) continue; 00083 to = eArr->At(ioj+1); 00084 int ihit=0; 00085 if (to) { 00086 kind = StEventHelper::Kind(to); 00087 ihit = (kind&kHRR); 00088 } 00089 if (rnd.Rndm()<prob) continue; 00090 eArr->AddAt(0,ioj); 00091 if (ihit) eArr->AddAt(0,ioj+1); 00092 } 00093 00094 printf("\nStGlobalFilterRand: %d(%d(%d)) tracks selected \n",nSel,nZel,nTot); 00095 }

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