// $Id: hrichevtfilter.cc,v 1.11 2009-07-15 11:39:22 halo Exp $ // Last update by Thomas Eberl: 04/04/23 10:53:40 // using namespace std; #include "hrichevtfilter.h" #include "hlinearcategory.h" #include "hmatrixcategory.h" #include "hevent.h" #include "hspectrometer.h" #include "hdetector.h" #include "hrichdetector.h" #include "hcategory.h" #include "hiterator.h" #include "hrichhit.h" #include "hades.h" #include "richdef.h" #include "hmdcdef.h" #include "hmdcseg.h" #include "tofinodef.h" #include "htofhitsim.h" #include "tofdef.h" #include "kickdef.h" #include "hhitmatch.h" #include "hhitmatchheader.h" #include "hrichcuttracklet.h" #include #include ClassImp(HRichEvtFilter) HRichEvtFilter::HRichEvtFilter(const Text_t *name,const Text_t *title,TString opt,Int_t m) : HReconstructor(name,title) { filterOption=opt; nMult=m; } HRichEvtFilter::HRichEvtFilter() { } HRichEvtFilter::~HRichEvtFilter(void) { } Bool_t HRichEvtFilter::init() { if (gHades) { HEvent *event=gHades->getCurrentEvent(); HRuntimeDb *rtdb=gHades->getRuntimeDb(); HSpectrometer *spec=gHades->getSetup(); if (event && rtdb) { if (filterOption.Contains("tofmult")) { HDetector *tofino = spec->getDetector("Tofino"); if (tofino){ fTofinoCal = event->getCategory(catTofinoCal); } HDetector *tof=spec->getDetector("Tof"); if (tof) { // TOF fTofHits=event->getCategory(catTofHit); if (!fTofHits) { Error("init","No TOF input"); return kFALSE; } } fTofIter=(HIterator *)fTofHits->MakeIterator(); } if (filterOption.Contains("mdcmult")) { HDetector *mdc = spec->getDetector("Mdc"); if (mdc) { // MDC fMdcSeg=event->getCategory(catMdcSeg); if (!fMdcSeg) { Error("init","No MDC segment category defined"); return kFALSE; } else fMdcSegIter=(HIterator *)fMdcSeg->MakeIterator(); } } if (filterOption.Contains("kickmult")) { fKickTrackCat=event->getCategory(catKickTrack); if (!fKickTrackCat) { Error("init","No KICK category defined"); return kFALSE; } else fKickIter=(HIterator *)fKickTrackCat->MakeIterator("native"); } if (filterOption.Contains("ringmult")) { HDetector *rich = spec->getDetector("Rich"); if (rich) { //Has the user set up a RICH? // RICH HIT container pHitRichCat=gHades->getCurrentEvent()->getCategory(catRichHit); if (!pHitRichCat) Warning("HRichEvtFilter","init():no Rich Hit cat"); if (pHitRichCat) fRichIter = (HIterator*) pHitRichCat->MakeIterator(); } } if (filterOption.Contains("corrmult")||filterOption.Contains("goodcorr")|| filterOption.Contains("vertex")) { pHitMatchCat=event->getCategory(catMatchHit); if (pHitMatchCat) pIterMatchHit = (HIterator*)getHitMatchCat()->MakeIterator("native"); pHitMatchHeaderCat=event->getCategory(catMatchHitHeader); if (pHitMatchHeaderCat) pIterMatchHitHeader = (HIterator*)getHitMatchHeaderCat() -> MakeIterator("native"); } } } resetCounters(); return kTRUE; } Bool_t HRichEvtFilter::finalize() { cout<<"Number of rejected evts: "<Reset(); Int_t nC=0; while(( pHM= (HHitMatch *)pIterMatchHit->Next())) { if (pHM->getMatchedRichMdc()==1) nC++; } if (nC==0) { cout<<"/////////////////// RINGS ///////////////////"<Reset(); while((pRH = (HRichHit *)fRichIter->Next())) { pRH->dumpToStdout(); } // if (nC) r=kTRUE; // cout< nb of RichHits in evt"<Reset(); while(( pHM= (HHitMatch *)pIterMatchHit->Next())) { pHM->dumpToStdout(); } } if (nC) r=kTRUE; //cout< nb of RICH-MDC-Corrs in evt"<getEntries(); //if (n>nTrkNb) r=kTRUE; // check if counted MDC segment is before magnet HMdcSeg *pMdcSeg = 0; Int_t nC=0; fMdcSegIter->Reset(); while((pMdcSeg = (HMdcSeg *)fMdcSegIter->Next())) { if ( pMdcSeg->getIOSeg() == 0 ) nC++; } if (nC>nTrkNb) r=kTRUE; // cout< nb of MDC Segments in evt"<getEntries(); if (n>nTrkNb) r=kTRUE; return r; } Bool_t HRichEvtFilter::isDoubleRingEvt() { // currently a Double_t ring is defined by a ring // which occurs twice in two different tracklets HHitMatch *pHM=0; pIterMatchHit->Reset(); Int_t nHM = ((HLinearCategory*)getHitMatchCat())->getEntries(); Int_t *nRInd = new Int_t[nHM]; for (Int_t i=0;iNext())) { Int_t nRind = pHM->getRichInd(); nRInd[ntc]=nRind; ntc++; } Int_t *six = new Int_t[nHM]; // sorted indexes TMath::Sort(nHM,nRInd,six); // descending Bool_t hasPair = kFALSE; for (Int_t j=1;j -1 ) // not a default value { if ( nRInd[idx] == nRInd[idx-1] ) // it is the same RICH ring { hasPair=kTRUE; break; //((HHitMatch*)getHitMatchCat()->getObject(nHMInd[idx])) //->dumpToStdout(); } } } return hasPair; } Bool_t HRichEvtFilter::containsRichHit() { Bool_t r=kFALSE; Int_t nRH=0; nRH = ((HLinearCategory*)getHitRichCat())->getEntries(); // cout<<"number of Rich hits in evt: "<Reset(); // while(pRH = (HRichHit *)fRichHitIter->Next()) // { // nC++; // } // if (nC) r=kTRUE; // cout< nb of RichHits in evt"<getEntries(); Int_t nTiH=0; nTiH = ((HMatrixCategory*)getCalTofinoCat())->getEntries(); // cout<<"TOF Mult: "<= nMult) r=kTRUE; return r; } Bool_t HRichEvtFilter::containsCorrRichHit() { Bool_t r=kFALSE; HHitMatch *pHM=0; pIterMatchHit->Reset(); Int_t nC=0; while(( pHM= (HHitMatch *)pIterMatchHit->Next())) { if (pHM->getRichInd()!=-1) nC++; } if (nC>=nMult) r=kTRUE; return r; } Bool_t HRichEvtFilter::containsGoodCorr() { Bool_t r=kFALSE; HHitMatch *pHM=0; pIterMatchHit->Reset(); Int_t nC=0; HRichCutTracklet *trackcut = new HRichCutTracklet("trackcut","default"); trackcut->switchTo("angularMatch"); while(( pHM= (HHitMatch *)pIterMatchHit->Next())) { if (trackcut->check(pHM)) nC++; } if (nC) r=kTRUE; delete trackcut; return r; } Bool_t HRichEvtFilter::isTargetEvt() { Bool_t r=kFALSE; HHitMatchHeader *pHM=0; pIterMatchHitHeader->Reset(); while(( pHM= (HHitMatchHeader *)pIterMatchHitHeader->Next())) { // there should be only one entry .... Float_t x = pHM->getEvtVrtX(); Float_t y = pHM->getEvtVrtY(); Float_t z = pHM->getEvtVrtZ(); // for nov01 in mm if (x>=-4. && x<=-1. && y>=-2. && y<=1. && z>=-32. && z<=-30.) { // cout<<"x: "<