diff --git a/musrSimAna/musrAnalysis.cxx b/musrSimAna/musrAnalysis.cxx index 289e833..7efc8eb 100644 --- a/musrSimAna/musrAnalysis.cxx +++ b/musrSimAna/musrAnalysis.cxx @@ -218,6 +218,12 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) { bool_debugingRequired=true; debugEventMap.insert(std::pair(ieventToDebug_tmp,iLevelToDebug_tmp)); } + else if (strcmp(tmpString0,"USE_UNPERFECT_POSITRONS_IN_DOUBLE_HITS")==0) { + musrCounter::bool_ignoreUnperfectPositrons = false; + } + else if (strcmp(tmpString0,"USE_UNPERFECT_MUONS_IN_DOUBLE_HITS")==0) { + musrCounter::bool_ignoreUnperfectMuons = false; + } else if (strncmp(tmpString0,"musrTH",strlen("musrTH"))==0) { // Definition of the histograms - either musrTH1D or musrTH2D int beginningOfHistoTitle=0, endOfHistoTitle =0; @@ -1007,12 +1013,13 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) { Int_t idetP = 0; Int_t idetP_ID = 0; Double_t idetP_edep = 0.; - Bool_t doubleHitM = false; - Bool_t doubleHitP = false; + //cks 4.10.2011 Bool_t doubleHitM = false; + //cks 4.10.2011 Bool_t doubleHitP = false; // std::cout<<" FillHistograms: timeBinOfThePreviouslyProcessedHit = "<GetNextGoodHitInThisEvent(eventID,timeBinOfThePreviouslyProcessedHit,0,'M',timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM); - mCounterHitExistsForThisEventID = mCounter->GetNextGoodMuon(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM); + // mCounterHitExistsForThisEventID = mCounter->GetNextGoodMuon(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM); + mCounterHitExistsForThisEventID = MuonCounterHit(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep); timeBinOfThePreviouslyProcessedHit = timeBin0; //___________________________________________________________ @@ -1044,7 +1051,7 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) { numberOfGoodMuons++; Long64_t dataBinMin = timeBin0+dataWindowBinMin; Long64_t dataBinMax = timeBin0+dataWindowBinMax; - pCounterHitExistsForThisEventID = PositronCounterHit(eventID,dataBinMin,dataBinMax,timeBin1,timeBin2,posEntry,idetP,idetP_ID,idetP_edep,doubleHitP); + pCounterHitExistsForThisEventID = PositronCounterHit(eventID,dataBinMin,dataBinMax,timeBin1,timeBin2,posEntry,idetP,idetP_ID,idetP_edep); //cDEL if (pCounterHitExistsForThisEventID) std::cout<<" timeBin1-timeBin2 = "<0)) { @@ -1217,7 +1224,8 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) { // Check whether there is a good trigger in the next event // std::cout<<" FillHistograms: timeBinOfThePreviouslyProcessedHit = "<GetNextGoodHitInThisEvent(eventID,timeBinOfThePreviouslyProcessedHit,0,'M',timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM); - mCounterHitExistsForThisEventID = mCounter->GetNextGoodMuon(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM); + // mCounterHitExistsForThisEventID = mCounter->GetNextGoodMuon(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM); + mCounterHitExistsForThisEventID = MuonCounterHit(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep); timeBinOfThePreviouslyProcessedHit = timeBin0; // if (mCounterHitExistsForThisEventID) std::cout<<" YYYYYYYYYYYYYYYYYYY check this : LOOOPING AGAIN"<GetNextGoodMuon(evID,timeBinMin,timeBin0,kEntry,idet,idetID,idetEdep); + if (!mCounterHitCanditateExists) return false; + // Check for other muons within the pileup window: + if ( mCounter->CheckForPileupMuons(timeBin0,kEntry) ) return false; // This muon candidate is killed due to a double hit rejection. + return true; +} + +//================================================================ +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:"<second)->GetNextGoodHitInThisEvent(evID,dataBinMin,dataBinMax,'P',tBin1,kEntry,idetP,idetP_ID,idetP_edep,doubleHit); - // Bool_t thereWasHit = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep,doubleHit); - Int_t positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep,doubleHit); - // std::cout<<"000000000000 tBin1="<1) goodPositronFound = true; - } + // std::cout<<"Debug 20"<second)->GetNextGoodPositron(evID,dataBinMinimum,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep); + // std::cout<<"Debug 40 positronQuality="<0) { + // std::cout<<"Debug 50"< double hit ==> through away this event. + // std::cout<<"Debug 60"<2) {std::cout<<"DEBUGEVENT:"<1) goodPositronFound = true; + } + // std::cout<<"Debug 80"<0); + // std::cout<<"Debug 90"< debugEventMapType; debugEventMapType debugEventMap; Bool_t bool_debugingRequired; +Bool_t musrCounter::bool_ignoreUnperfectMuons = true; +Bool_t musrCounter::bool_ignoreUnperfectPositrons = true; + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... musrCounter::musrCounter(int CHANNEL_NR, char CHANNEL_NAME[200], char CHANNEL_TYPE, float E_THRESH, int TIME_SHIFT) { @@ -152,12 +155,11 @@ Bool_t musrCounter::IsInCoincidence(Long64_t timeBin, char motherCounter, Bool_t } //================================================================ -Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t& timeBinOfNextHit, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep, Bool_t& doubleHitFound) { +Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t& timeBinOfNextHit, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep) { // This function searches for a good muon, i.e. the muon // 1) belongs to the currently analysed event // 2) is in coincidence with all required coincidence detectors // 3) is not in coincidence with veto detectors - // 4) is not in coincidence with other muons (more precisely - with hits in m-counter). // INPUT PARAMETERS: evtID, timeBinMin // OUTPUT PARAMETERS: timeBinOfNextHit // @@ -165,7 +167,6 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t& // std::cout<<" musrCounter::GetNextGoodMuon timeBinMin="< S T O P !!!\n"; exit(1);} - doubleHitFound = false; for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) { Long64_t timeBinOfCount_tmp = it->first; @@ -179,23 +180,19 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t& // std::cout<<"*** "<second)->eventEntry; idet = (it->second)->det_i; @@ -211,7 +208,39 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t& } //================================================================ -Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_t timeBinMax, Long64_t& timeBinOfNextGoodHit, Long64_t& timeBinOfNextGoodHit_phaseShifted, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep, Bool_t& doubleHitFound) { +Bool_t musrCounter::CheckForPileupMuons(Long64_t timeBin0, Int_t kEntry_NN) { + // Check for pileup muons. If double hit in M-counter is found, return true. + + Long64_t timeBinMinimum = timeBin0; + for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) { + Long64_t timeBinOfCount_tmp = it->first; + if (timeBinOfCount_tmp < timeBinMinimum+coincidenceTimeWindowMin_M) continue; // This hit happened too long ago + if (timeBinOfCount_tmp > timeBinMinimum+coincidenceTimeWindowMax_M) break; // This hit happened too late + if ((timeBinOfCount_tmp == timeBinMinimum)&&( ((it->second)->eventEntry) == kEntry_NN)) continue; + // This is the M-counter hit for which we check the pileup -> ignore this hit in this double-hit check. + + // We have found the hit, which could be the double hit. If it is required, we now have + // to check the coincidences and anticoincidences of this double-hit muon: + if (!bool_ignoreUnperfectMuons) { + return true; // In this case we do not check for coincidences and anticoincidences ==> double hit found. + } + for (counterMapType::const_iterator itCounter = koincidenceCounterMap.begin(); itCounter!=koincidenceCounterMap.end(); ++itCounter) { + if (!( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'M') )) goto endOfThisHit; // no coincidence found ==> skip hit + } + for (counterMapType::const_iterator itCounter = vetoCounterMap.begin(); itCounter!=vetoCounterMap.end(); ++itCounter) { + if ( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'M') ) goto endOfThisHit; // coincidence with veto found ==> skip hit + } + // The double hit was found (the pileup muon fulfils all veto and coincidence requirements) ==> end of the search + return true; + + endOfThisHit: + ; + } + numberOfMuonCandidatesAfterVKandDoubleHitRemoval++; + return false; +} +//================================================================ +Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_t timeBinMax, Long64_t& timeBinOfNextGoodHit, Long64_t& timeBinOfNextGoodHit_phaseShifted, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep) { // INPUT PARAMETERS: evtID, timeBinMin // OUTPUT PARAMETERS: timeBinOfNextGoodHit // positronQuality = 0 ... no positron candidate found @@ -222,7 +251,6 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_ if (bool_debugingRequired) {if (debugEventMap[evtID]>4) myPrintThisCounter(evtID);} 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);} - doubleHitFound = false; for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) { Int_t eventNumber = (it->second)->eventIDnumber; Long64_t timeBinOfCount_tmp = it->first; @@ -243,6 +271,7 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_ if (bool_debugingRequired) { if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"< remove the candidate. goto endOfThisHit; // no coincidence found ==> skip hit } } @@ -251,22 +280,10 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_ if (bool_debugingRequired) { if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"< remove the candidate. goto endOfThisHit; // coincidence with veto found ==> skip hit } } - // Check coincidences with other P counters - // Coincidences with other P counters must be checked in musrAnalysis.cxx - // - // ADD HERE THE CHECK THAT THE POSITRON IS FOUND WITHIN THE DATA INTERVAL, i.e. within . - // AND ALSO CHECK THAT THIS IS TRUE FOR THE COINCIDENCE WITH OTHER POSITRON COUNTERS!!! - if (this->IsInCoincidence(timeBinOfCount_tmp,'P',true,timeBinMin,timeBinMax) ) { // coincidence with another P-counter hit ==> skip hit - if (bool_debugingRequired) { - if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<