#include "hparticlebooker.h" #include "hades.h" #include "hcategory.h" #include "hparticledef.h" #include "hparticlecand.h" #include "hparticletool.h" #include "hcategorymanager.h" #include #include ClassImp(HParticleBooker) //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////////////////////////// // // // HParticleBooker // // Creates maps form each Detctor hit index to the list // of HParticleCands in the current event who are using // a given hit // //----------------------------------------------------------------------------- // USAGE: // #include "hparticlebooker.h" // #include "hcategorymanager.h" // #include "hcategory.h" // #include "hades.h" // #include "hparticlecand.h" // #include "hparticledef.h" // #include // using namespace std; // .... // // // { // // setup HLoop etc .... // // .... // //--------------------------------------------- // // HPARTICLEBOOKER SETUP : // HParticleBooker booker; // //--------------------------------------------- // // vector vCandidates; // // HCategory* catCand = HCategoryManager::getCategory(catParticleCand); // if(!catCand) { exit(1); } // // for (Int_t i=0; i < entries; i++) { // Int_t nbytes = loop.nextEvent(i); // get next event. categories will be cleared before // if(nbytes <= 0) { cout<getEntries();j++){ // cand = HCategoryManager::getObject(cand,catCand,j); // // do something .... // Int_t n =booker.getSameMeta(cand,vCandidates); // fill a list of all cand sharing the same metahit // // // } // end loop cand // } //catCand // } //////////////////////////////////////////////////////////////////////////////// HParticleBooker::HParticleBooker() { } HParticleBooker::~HParticleBooker() { mTofHittoCand .clear(); mTofClsttoCand .clear(); mRpcClsttoCand .clear(); mShowertoCand .clear(); mInnerMdctoCand.clear(); mOuterMdctoCand.clear(); mRichtoCand .clear(); } void HParticleBooker::bookHits(HParticleCand* cand1) { // add candidate hits to maps if(cand1->getRichInd() !=-1 ) { if(mRichtoCand.find(cand1->getRichInd()) == mRichtoCand.end()){ vector v; v.push_back(cand1); mRichtoCand[cand1->getRichInd()] = v; } else { mRichtoCand[cand1->getRichInd()].push_back(cand1); } } if(cand1->getInnerSegInd() !=-1 ) { if(mInnerMdctoCand.find(cand1->getInnerSegInd()) == mInnerMdctoCand.end()){ vector v; v.push_back(cand1); mInnerMdctoCand[cand1->getInnerSegInd()] = v; } else { mInnerMdctoCand[cand1->getInnerSegInd()].push_back(cand1); } } if(cand1->getOuterSegInd() !=-1 ) { if(mOuterMdctoCand.find(cand1->getOuterSegInd()) == mOuterMdctoCand.end()){ vector v; v.push_back(cand1); mOuterMdctoCand[cand1->getOuterSegInd()] = v; } else { mOuterMdctoCand[cand1->getOuterSegInd()].push_back(cand1); } } if(cand1->getSystemUsed() != -1){ Int_t meta = cand1->getMetaHitInd(); if(cand1->isTofHitUsed()){ if(mTofHittoCand.find(meta) == mTofHittoCand.end()){ vector v; v.push_back(cand1); mTofHittoCand[meta] = v; } else { mTofHittoCand[meta].push_back(cand1); } } else if (cand1->isTofClstUsed()){ if(mTofClsttoCand.find(meta) == mTofClsttoCand.end()){ vector v; v.push_back(cand1); mTofClsttoCand[meta] = v; } else { mTofClsttoCand[meta].push_back(cand1); } } else if (cand1->isRpcClstUsed()){ if(mRpcClsttoCand.find(meta) == mRpcClsttoCand.end()){ vector v; v.push_back(cand1); mRpcClsttoCand[meta] = v; } else { mRpcClsttoCand[meta].push_back(cand1); } } else if (cand1->isShowerUsed()){ if(mShowertoCand.find(meta) == mShowertoCand.end()){ vector v; v.push_back(cand1); mShowertoCand[meta] = v; } else { mShowertoCand[meta].push_back(cand1); } } } } void HParticleBooker::nextEvent() { mTofHittoCand .clear(); mTofClsttoCand .clear(); mRpcClsttoCand .clear(); mShowertoCand .clear(); mInnerMdctoCand.clear(); mOuterMdctoCand.clear(); mRichtoCand .clear(); HCategory* candCat = (HCategory*) gHades->getCurrentEvent()->getCategory(catParticleCand); if(candCat){ UInt_t n = candCat->getEntries(); HParticleCand* cand1 = 0 ; //------------------------------------------------------- // fill lists for reference and others for(UInt_t i=0; i < n; i++){ cand1 = HCategoryManager::getObject(cand1,candCat,i); //------------------------------------------------------- // book the hits -> candiate lists bookHits(cand1); //------------------------------------------------------- } } } Int_t HParticleBooker::getSameRich(HParticleCand* cand,vector& candidates,UInt_t flag,Bool_t isReference) { // fills list of candidates which share the same RICH. If the RICH is not found // at all -1 is returned, other wise the number of candidates found for the hit. // The input candidate will be not included in candidates. Candidates can be filtered // by flag ( 0 == no filter, see flags eClosePairSelect+ ePairCase (hparticledef.h)). // The input candidate will be treated as refererence if isReference == kTRUE. candidates.clear(); if(cand->getRichInd() !=-1 ){ map >::iterator it = mRichtoCand.find(cand->getRichInd()); if(it != mRichtoCand.end()){ vector& v = it->second; for(UInt_t i = 0 ; i < v.size(); i++){ if(v[i] != cand) { // skip same cand if(flag == 0 ) candidates.push_back(v[i]); else { Bool_t fl = kFALSE; if(!isReference) fl=HParticleTool::evalPairsFlags(fl,cand,v[i]); else fl=HParticleTool::evalPairsFlags(fl,v[i],cand); if(fl){ candidates.push_back(v[i]); } } } } //end loop } else return -1; } return candidates.size(); } Int_t HParticleBooker::getSameInnerMdc(HParticleCand* cand,vector& candidates,UInt_t flag,Bool_t isReference) { // fills list of candidates which share the same inner MDC seg. If the seg is not found // at all -1 is returned, other wise the number of candidates found for the hit. // The input candidate will be not included in candidates. Candidates can be filtered // by flag ( 0 == no filter, see flags eClosePairSelect+ ePairCase (hparticledef.h)). // The input candidate will be treated as refererence if isReference == kTRUE. candidates.clear(); if(cand->getInnerSegInd() !=-1 ){ map >::iterator it = mInnerMdctoCand.find(cand->getInnerSegInd()); if(it != mInnerMdctoCand.end()){ vector& v = it->second; for(UInt_t i = 0 ; i < v.size(); i++){ if(v[i] != cand) { // skip same cand if(flag == 0 ) candidates.push_back(v[i]); else { Bool_t fl = kFALSE; if(!isReference) fl=HParticleTool::evalPairsFlags(fl,cand,v[i]); else fl=HParticleTool::evalPairsFlags(fl,v[i],cand); if(fl){ candidates.push_back(v[i]); } } } } //end loop } else return -1; } return candidates.size(); } Int_t HParticleBooker::getSameOuterMdc(HParticleCand* cand,vector& candidates,UInt_t flag,Bool_t isReference) { // fills list of candidates which share the same outer MDC seg. If the seg is not found // at all -1 is returned, other wise the number of candidates found for the hit. // The input candidate will be not included in candidates. Candidates can be filtered // by flag ( 0 == no filter, see flags eClosePairSelect+ ePairCase (hparticledef.h)). // The input candidate will be treated as refererence if isReference == kTRUE. candidates.clear(); if(cand->getOuterSegInd() !=-1 ){ map >::iterator it = mOuterMdctoCand.find(cand->getOuterSegInd()); if(it != mOuterMdctoCand.end()){ vector& v = it->second; for(UInt_t i = 0 ; i < v.size(); i++){ if(v[i] != cand) { // skip same cand if(flag == 0 ) candidates.push_back(v[i]); else { Bool_t fl = kFALSE; if(!isReference) fl=HParticleTool::evalPairsFlags(fl,cand,v[i]); else fl=HParticleTool::evalPairsFlags(fl,v[i],cand); if(fl){ candidates.push_back(v[i]); } } } } //end loop } else return -1; } return candidates.size(); } Int_t HParticleBooker::getSameMeta(HParticleCand* cand,vector& candidates,UInt_t flag,Bool_t isReference) { // fills list of candidates which share the same META hit. The number of candidates // found for the hit is returned or -1 if the hit is not found at all.. // The input candidate will be not included in candidates. Candidates can be filtered // by flag ( 0 == no filter, see flags eClosePairSelect+ ePairCase (hparticledef.h)). // The input candidate will be treated as refererence if isReference == kTRUE. candidates.clear(); Int_t metaind = cand->getMetaHitInd(); Int_t sel = cand->getSelectedMeta(); if(metaind != -1 ){ map >* mp =0; if (sel == kTofClst) mp = &mTofClsttoCand; else if(sel == kTofHit1||sel==kTofHit2) mp = &mTofHittoCand; else if(sel == kRpcClst) mp = &mRpcClsttoCand; else if(sel == kShowerHit) mp = &mShowertoCand; else { Error("getSameMeta()","unknown Meta case!"); return 0; } map >::iterator it = mp->find(metaind); if(it != mp->end()){ vector& v = it->second; for(UInt_t i = 0 ; i < v.size(); i++){ if(v[i] != cand) { // skip same cand if(flag == 0 ) candidates.push_back(v[i]); else { Bool_t fl = kFALSE; if(!isReference) fl=HParticleTool::evalPairsFlags(fl,cand,v[i]); else fl=HParticleTool::evalPairsFlags(fl,v[i],cand); if(fl){ candidates.push_back(v[i]); } } } } //end loop } else return -1; } return candidates.size(); }