diff --git a/musrSimAna/musrAnalysis.cxx b/musrSimAna/musrAnalysis.cxx index eddf752..6dad6a9 100644 --- a/musrSimAna/musrAnalysis.cxx +++ b/musrSimAna/musrAnalysis.cxx @@ -218,7 +218,14 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) { int ieventToDebug_tmp, iLevelToDebug_tmp; sscanf(&line[0],"%*s %d %d",&ieventToDebug_tmp,&iLevelToDebug_tmp); bool_debugingRequired=true; - debugEventMap.insert(std::pair(ieventToDebug_tmp,iLevelToDebug_tmp)); + if (ieventToDebug_tmp>-1) { + debugEventMap.insert(std::pair(ieventToDebug_tmp,iLevelToDebug_tmp)); + } + else { + for (int j=0; j<=-ieventToDebug_tmp;j++) { + debugEventMap.insert(std::pair(j,iLevelToDebug_tmp)); + } + } } else if (strcmp(tmpString0,"WRITE_OUT_DUMP_FILE")==0) { // int clock_channelID_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 "<0) {std::cout<<"DEBUGEVENT "<lastPreprocessedEntry)||(((nextUnfilledEventTime-currentTime)GetEntry(iiiEntry); InitialiseEvent(); if (bool_debugingRequired) { if (debugEventMap[eventID]>2) PrintHitsInAllCounters(); - if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<1) {std::cout<<"DEBUGEVENT "<myPrintThisCounter(eventID); // } if (bool_debugingRequired) { - if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<1) {std::cout<<"DEBUGEVENT "<1) {std::cout<<"DEBUGEVENT "<1) {std::cout<<"DEBUGEVENT "<1) {std::cout<<"____________________________________________________________________"<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 ("<3) {std::cout<<"PositronCounterHit: positron candidate killed - double hit in a different counter"< S T O P !!!\n"; exit(1);} + + std::list 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 ("<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 ("<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 ("<3) std::cout<<"GetNextGoodMuon: muon candidate after VK ("<3) std::cout<<"GetNextGoodMuon: muon candidate killed by pileup muon ("<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 (" + <::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::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 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:"<3) {std::cout<<"GetNextGoodPositron: Hit out of 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:"<3) {std::cout<<"GetNextGoodPositron: Coincidence required but not found (timeBin="< 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:"<3) {std::cout<<"GetNextGoodPositron: Coincidence vith veto detector found (timeBin="< 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::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:"<3) {std::cout<<"GetNextGoodPositron: Good positron candidate found in this counter. (timeBin="<second)->eventIDnumber<<")"<::iterator itt = it_positron_hits_to_be_deleted.begin(); itt != it_positron_hits_to_be_deleted.end(); ++itt) { + hitMap.erase(*itt); + } + return positronQuality; } diff --git a/src/musrScintSD.cc b/src/musrScintSD.cc index 9a901a1..288733d 100644 --- a/src/musrScintSD.cc +++ b/src/musrScintSD.cc @@ -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(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(tmpTime,APDcellID)); + // } + // } // Simulate cross talk if requested. Even if not requested, generate the random numbers in order to // have reproducible simulation.