2.11.2011 Kamil Sedlak

1) Correcting bugs with the (multi)map treatment in routines
   musrCounter.cxx and musrScintSD.cc - the elements of the (multi)maps
   were erased in a loop over the (multi)maps, which is wrong.
2) Also the time variation is moved back to "process event" rather
   then "end of event" in the musrScintSD.cc  (is probably more realistic).
This commit is contained in:
2011-11-02 14:45:44 +00:00
parent f93a3c070b
commit db0c8f35ee
3 changed files with 80 additions and 29 deletions

View File

@ -168,6 +168,8 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t&
// std::cout<<" musrCounter::GetNextGoodMuon timeBinMin="<<timeBinMin<<std::endl;
if (hitMap.empty()) return false;
if (counterType!='M') {std::cout<<"\n!!! FATAL ERROR !!! musrCounter::GetNextGoodMuon: not the muon counter! ==> S T O P !!!\n"; exit(1);}
std::list<hitMap_TYPE::iterator> it_muon_hits_to_be_deleted;
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
Long64_t timeBinOfCount_tmp = it->first;
@ -178,20 +180,25 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t&
if (eventNumber!=evtID) continue; // This trigger hit does not correspond to the currently processed event
// ==> skip it, because it was already proceesed or will be processed in future
numberOfMuonCandidates++;
if (bool_debugingRequired) {if (debugEventMap[evtID]>3) std::cout<<"GetNextGoodMuon: muon candidate found ("<<timeBinOfNextHit<<")"<<std::endl;}
// Hit candidate was found. Now check its coincidences and vetos
Bool_t bool_coincidenceConditions = true;
for (counterMapType::const_iterator itCounter = koincidenceCounterMap.begin(); itCounter!=koincidenceCounterMap.end(); ++itCounter) {
if (!( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'M') )) { // no coincidence found ==> skip hit
if (bool_ignoreUnperfectMuons) hitMap.erase(it);
// if (bool_ignoreUnperfectMuons) hitMap.erase(it);
if (bool_ignoreUnperfectMuons) it_muon_hits_to_be_deleted.push_back(it);
bool_coincidenceConditions = false;
if (bool_debugingRequired) {if (debugEventMap[evtID]>3) std::cout<<"GetNextGoodMuon: muon candidate not in koincidence ("<<timeBinOfNextHit<<")"<<std::endl;}
goto MuonCoincidencesChecked;
}
}
for (counterMapType::const_iterator itCounter = vetoCounterMap.begin(); itCounter!=vetoCounterMap.end(); ++itCounter) {
if ( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'M') ) { // coincidence with veto found ==> skip hit
if (bool_ignoreUnperfectMuons) hitMap.erase(it);
// if (bool_ignoreUnperfectMuons) hitMap.erase(it);
if (bool_ignoreUnperfectMuons) it_muon_hits_to_be_deleted.push_back(it);
bool_coincidenceConditions = false;
if (bool_debugingRequired) {if (debugEventMap[evtID]>3) std::cout<<"GetNextGoodMuon: muon candidate vetoed ("<<timeBinOfNextHit<<")"<<std::endl;}
goto MuonCoincidencesChecked;
}
}
@ -199,17 +206,27 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t&
MuonCoincidencesChecked:
if (!bool_coincidenceConditions) continue; // This hit does not fulfill coincidence and veto criteria
numberOfMuonCandidatesAfterVK++;
if (bool_debugingRequired) {if (debugEventMap[evtID]>3) std::cout<<"GetNextGoodMuon: muon candidate after VK ("<<timeBinOfNextHit<<")"<<std::endl;}
if ( CheckForPileupMuons(timeBinOfNextHit) ) {
// std::cout<<"CheckForPileupMuons=true"<<std::endl;
if (bool_debugingRequired) {if (debugEventMap[evtID]>3) std::cout<<"GetNextGoodMuon: muon candidate killed by pileup muon ("<<timeBinOfNextHit<<")"<<std::endl;}
continue; // This muon candidate is killed due to a double hit rejection.
}
kEntry = (it->second)->eventEntry;
idet = (it->second)->det_i;
idetID = (it->second)->det_id;
idetEdep = (it->second)->det_edep;
if (bool_debugingRequired) {if (debugEventMap[evtID]>1) std::cout<<"GetNextGoodMuon: GOOD muon candidate found ("
<<timeBinOfNextHit<<" "<<evtID<<")"<<std::endl;}
for(std::list<hitMap_TYPE::iterator>::iterator itt = it_muon_hits_to_be_deleted.begin(); itt != it_muon_hits_to_be_deleted.end(); ++itt) {
hitMap.erase(*itt);
}
return true;
}
for(std::list<hitMap_TYPE::iterator>::iterator itt = it_muon_hits_to_be_deleted.begin(); itt != it_muon_hits_to_be_deleted.end(); ++itt) {
hitMap.erase(*itt);
}
return false;
}
@ -254,15 +271,16 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
// = 3 ... double hit
// Loop over the hits in the counter
Int_t positronQuality=0;
if (bool_debugingRequired) {if (debugEventMap[evtID]>4) myPrintThisCounter(evtID);}
if (bool_debugingRequired) {if (debugEventMap[evtID]>4) myPrintThisCounter(evtID,0);}
if (hitMap.empty()) return 0;
if (counterType!='P') {std::cout<<"\n!!! FATAL ERROR !!! musrCounter::GetNextGoodPositron: not the positron counter! ==> S T O P !!!\n"; exit(1);}
std::list<hitMap_TYPE::iterator> it_positron_hits_to_be_deleted;
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
// Int_t eventNumber = (it->second)->eventIDnumber;
Long64_t timeBinOfCount_tmp = it->first;
if ((timeBinOfCount_tmp <= timeBinMin) || (timeBinOfCount_tmp > timeBinMax)) {
if (bool_debugingRequired) {
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Hit out of data interval"<<std::endl;}
if (debugEventMap[evtID]>3) {std::cout<<"GetNextGoodPositron: Hit out of data interval"<<std::endl;}
}
continue; // This hit is out of the data interval ==> skip it
}
@ -275,9 +293,10 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
}
if (!( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'P') )) {
if (bool_debugingRequired) {
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Coincidence required but not found"<<std::endl;}
if (debugEventMap[evtID]>3) {std::cout<<"GetNextGoodPositron: Coincidence required but not found (timeBin="<<timeBinOfCount_tmp<<")"<<std::endl;}
}
if (bool_ignoreUnperfectPositrons) hitMap.erase(it); // no coincidence found ==> remove the candidate.
// if (bool_ignoreUnperfectPositrons) hitMap.erase(it); // no coincidence found ==> remove the candidate.
if (bool_ignoreUnperfectPositrons) it_positron_hits_to_be_deleted.push_back(it);
bool_coincidenceConditions = false;
goto CoincidencesChecked;
// goto endOfThisHit; // no coincidence found ==> skip hit
@ -286,9 +305,10 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
for (counterMapType::const_iterator itCounter = vetoCounterMap.begin(); itCounter!=vetoCounterMap.end(); ++itCounter) {
if ( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'P') ) {
if (bool_debugingRequired) {
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Coincidence vith veto detector found"<<std::endl;}
if (debugEventMap[evtID]>3) {std::cout<<"GetNextGoodPositron: Coincidence vith veto detector found (timeBin="<<timeBinOfCount_tmp<<")"<<std::endl;}
}
if (bool_ignoreUnperfectPositrons) hitMap.erase(it); // coincidence with veto found ==> remove the candidate.
// if (bool_ignoreUnperfectPositrons) hitMap.erase(it); // coincidence with veto found ==> remove the candidate.
if (bool_ignoreUnperfectPositrons) it_positron_hits_to_be_deleted.push_back(it);
bool_coincidenceConditions = false;
goto CoincidencesChecked;
// goto endOfThisHit; // coincidence with veto found ==> skip hit
@ -297,7 +317,12 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
CoincidencesChecked:
if (!bool_coincidenceConditions) continue; // This hit does not fulfill coincidence and veto criteria
if (positronQuality==2) return 3; // An electron was already found before, and now again ==> double hit
if (positronQuality==2) {
for(std::list<hitMap_TYPE::iterator>::iterator itt = it_positron_hits_to_be_deleted.begin(); itt != it_positron_hits_to_be_deleted.end(); ++itt) {
hitMap.erase(*itt);
}
return 3; // An electron was already found before, and now again ==> double hit
}
else positronQuality=2;
kEntry = (it->second)->eventEntry;
@ -307,9 +332,13 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
timeBinOfNextGoodHit = timeBinOfCount_tmp;
timeBinOfNextGoodHit_phaseShifted = (it->second) -> timeBin2;
if (bool_debugingRequired) {
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Good positron candidate found in this counter."<<std::endl;}
if (debugEventMap[evtID]>3) {std::cout<<"GetNextGoodPositron: Good positron candidate found in this counter. (timeBin="<<timeBinOfCount_tmp<<" "<<(it->second)->eventIDnumber<<")"<<std::endl;}
}
}
for(std::list<hitMap_TYPE::iterator>::iterator itt = it_positron_hits_to_be_deleted.begin(); itt != it_positron_hits_to_be_deleted.end(); ++itt) {
hitMap.erase(*itt);
}
return positronQuality;
}