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:
sedlak 2011-11-02 14:45:44 +00:00
parent f93a3c070b
commit db0c8f35ee
3 changed files with 80 additions and 29 deletions

View File

@ -218,8 +218,15 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
int ieventToDebug_tmp, iLevelToDebug_tmp;
sscanf(&line[0],"%*s %d %d",&ieventToDebug_tmp,&iLevelToDebug_tmp);
bool_debugingRequired=true;
if (ieventToDebug_tmp>-1) {
debugEventMap.insert(std::pair<int,int>(ieventToDebug_tmp,iLevelToDebug_tmp));
}
else {
for (int j=0; j<=-ieventToDebug_tmp;j++) {
debugEventMap.insert(std::pair<int,int>(j,iLevelToDebug_tmp));
}
}
}
else if (strcmp(tmpString0,"WRITE_OUT_DUMP_FILE")==0) {
// int clock_channelID_tmp;
// int clock_interval_tmp;
@ -933,7 +940,7 @@ void musrAnalysis::AnalyseEvent(Long64_t iiiEntry) {
// Loop over several next event and preprocess them (i.e. fill
// them into the lists/maps of the class musrCounter).
if (bool_debugingRequired) {
if (debugEventMap[eventID]>0) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(before \"PreprocessEvent\"_________"<<std::endl;}
if (debugEventMap[eventID]>0) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________ \"Preprocessing Event\"_________"<<std::endl;}
}
while (((iiiEntry>lastPreprocessedEntry)||(((nextUnfilledEventTime-currentTime)<safeTimeWindow))&&(!boolInfinitelyLowMuonRate)) && (lastPreprocessedEntry+1<nentries)) {
Double_t deltaT = PreprocessEvent(lastPreprocessedEntry+1);
@ -942,7 +949,7 @@ void musrAnalysis::AnalyseEvent(Long64_t iiiEntry) {
fChain->GetEntry(iiiEntry); InitialiseEvent();
if (bool_debugingRequired) {
if (debugEventMap[eventID]>2) PrintHitsInAllCounters();
if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(after \"PreprocessEvent\"_________"<<std::endl;}
// if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(after \"PreprocessEvent\"_________"<<std::endl;}
}
// Loop over all interesting "moments", which are:
@ -959,11 +966,12 @@ void musrAnalysis::AnalyseEvent(Long64_t iiiEntry) {
// (*it).second->myPrintThisCounter(eventID);
// }
if (bool_debugingRequired) {
if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(before \"FillHistograms\"_________"<<std::endl;}
if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(\"Filling Histograms\"_________"<<std::endl;}
}
FillHistograms(iiiEntry);
if (bool_debugingRequired) {
if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(after \"FillHistograms\"_________"<<std::endl;}
// if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(after \"FillHistograms\"_________"<<std::endl;}
if (debugEventMap[eventID]>1) {std::cout<<"____________________________________________________________________"<<std::endl;}
}
@ -1015,7 +1023,7 @@ void musrAnalysis::RewindAllTimeInfo() {
//================================================================
void musrAnalysis::PrintHitsInAllCounters() {
std::cout<<"___________________\n";
// std::cout<<"___________________\n";
for (counterMapType::const_iterator it = allCounterMap.begin(); it!=allCounterMap.end(); ++it) {
(*it).second->myPrintThisCounter(eventID,0);
}
@ -1080,6 +1088,10 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) {
Long64_t dataBinMin = timeBin0+dataWindowBinMin;
Long64_t dataBinMax = timeBin0+dataWindowBinMax;
pCounterHitExistsForThisEventID = PositronCounterHit(eventID,dataBinMin,dataBinMax,timeBin1,timeBin2,posEntry,idetP,idetP_ID,idetP_edep);
if (debugEventMap[eventID]>2) {
if (pCounterHitExistsForThisEventID) {std::cout<<"FillHistograms: GOOD positron candidate found ("<<timeBin1<<")"<<std::endl;}
else {std::cout<<"FillHistograms: NO positron candidate found"<<std::endl;}
}
//cDEL if (pCounterHitExistsForThisEventID) std::cout<<" timeBin1-timeBin2 = "<<timeBin1<<"-"<<timeBin2<<"="<<timeBin1-timeBin2 <<std::endl;
//
if (pCounterHitExistsForThisEventID&&(posEntry>0)) {
@ -1381,7 +1393,7 @@ Double_t musrAnalysis::PreprocessEvent(Long64_t iEn) {
Bool_t musrAnalysis::PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_t dataBinMax, Long64_t& tBin1, Long64_t& tBin2, Int_t& kEntry, Int_t& idetP, Int_t& idetP_ID, Double_t& idetP_edep) {
if (bool_debugingRequired) {
if (debugEventMap[eventID]>2) {std::cout<<"DEBUGEVENT:"<<eventID<<"\"PositronCounterHit\": pCounterMap.size()="<<pCounterMap.size()<<std::endl;}
if (debugEventMap[eventID]>4) {std::cout<<"PositronCounterHit: pCounterMap.size()="<<pCounterMap.size()<<std::endl;}
}
if (pCounterMap.empty()) return false;
@ -1393,9 +1405,15 @@ Bool_t musrAnalysis::PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_
// Loop over all positron counters
for (counterMapType::const_iterator it = pCounterMap.begin(); it!=pCounterMap.end(); ++it) {
positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep);
if (positronQuality==3) return false; // double hit was found in the same counter
if (positronQuality==3) { // double hit was found in the same counter
if (debugEventMap[eventID]>3) {std::cout<<"PositronCounterHit: positron candidate killed - double hit in the same counter"<<std::endl;}
return false;
}
if (positronQuality==2) {
if (goodPositronFound) return false; // double hit was found in a different counter
if (goodPositronFound) {
if (debugEventMap[eventID]>3) {std::cout<<"PositronCounterHit: positron candidate killed - double hit in a different counter"<<std::endl;}
return false; // double hit was found in a different counter
}
goodPositronFound = true;
}
}

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;
}

View File

@ -270,9 +270,13 @@ void musrScintSD::ProcessOpticalPhoton(G4Step* aStep) {
//non-zero efficiency
// Do APD cell variation time if requested. Even if not requested, generate the random numbers in order to
// have reproducible simulation.
G4double APDcellsTimeVariation = G4RandGauss::shoot(0,APDcellsTimeVariationSigma);
if (APDcellsTimeVariationRequested) tmpTime += APDcellsTimeVariation;
// If the simulation of the effect of the finite number of cells in APD is requested, find out
// whether a given cell already fired - if so, do not store the photon.
// G4bool APDcellAlreadyFired = false;
G4int APDcellID = (APDcellsEffectRequested) ? FindAPDcellID(aStep) : 0;
FireAPDcell(optHitDetectorMap,APDcellID,tmpTime);
// if (APDcellsEffectRequested) {
@ -595,15 +599,15 @@ void musrScintSD::EndOfEvent_OptiacalPhotons() {
// Do APD cell variation time if requested. Even if not requested, generate the random numbers in order to
// have reproducible simulation.
for (optHitDetectorMapType::iterator it2 = optHitDetectorMap->begin(); it2 != optHitDetectorMap->end(); it2++ ) {
G4double APDcellsTimeVariation = G4RandGauss::shoot(0,APDcellsTimeVariationSigma);
if (APDcellsTimeVariationRequested) {
G4int APDcellID = it2->second;
G4double tmpTime = it2->first + APDcellsTimeVariation;
optHitDetectorMap->erase(it2);
optHitDetectorMap->insert(std::pair<G4double,G4int>(tmpTime,APDcellID));
}
}
// for (optHitDetectorMapType::iterator it2 = optHitDetectorMap->begin(); it2 != optHitDetectorMap->end(); it2++ ) {
// G4double APDcellsTimeVariation = G4RandGauss::shoot(0,APDcellsTimeVariationSigma);
// if (APDcellsTimeVariationRequested) {
// G4int APDcellID = it2->second;
// G4double tmpTime = it2->first + APDcellsTimeVariation;
// optHitDetectorMap->erase(it2);
// optHitDetectorMap->insert(std::pair<G4double,G4int>(tmpTime,APDcellID));
// }
// }
// Simulate cross talk if requested. Even if not requested, generate the random numbers in order to
// have reproducible simulation.