//#include #include "musrCounter.hh" #include "TCanvas.h" typedef std::map debugEventMapType; debugEventMapType debugEventMap; Bool_t bool_debugingRequired; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... musrCounter::musrCounter(int CHANNEL_NR, char CHANNEL_NAME[200], char CHANNEL_TYPE, float E_THRESH, int TIME_SHIFT) { // pointerToAnalysis=this; counterNr = CHANNEL_NR; strcpy(counterName,CHANNEL_NAME); counterType = CHANNEL_TYPE; couterEThreshold = E_THRESH; counterTimeShift = (Long64_t) TIME_SHIFT; std::cout<<"musrCounter::musrCounter: Creating counter "<Fill(variable,vaha); } //================================================================ void musrCounter::DrawTDChistogram() { char canvasName[501]; sprintf(canvasName,"c%s",TDC_histoName); TCanvas* cTmp = new TCanvas(canvasName,canvasName); histTDC->Draw(); } //================================================================ void musrCounter::FillHitInCounter(Double_t edep, Long64_t timeBin, Long64_t timeBin2, Int_t kEntry, Int_t eveID, Int_t iDet, Int_t detectorID){ //cDEL std::cout<<"FillHitInCounter: timeBin="<=couterEThreshold) { hitInfo* hInfo = new hitInfo(kEntry,eveID,iDet,detectorID,edep,timeBin2-counterTimeShift); //cDEL std::cout<first; // int tempEvnr= it->second; // hitMap_TMP.insert( std::pair(tempBinT-timeBinsToRewind,tempEvnr) ); hitInfo* tempEvnr= it->second; tempEvnr->RewindTimeBin2(timeBinsToRewind); hitMap_TMP.insert( std::pair(tempBinT-timeBinsToRewind,tempEvnr) ); } hitMap.swap(hitMap_TMP); } //================================================================ Bool_t musrCounter::IsInCoincidence(Long64_t timeBin, char motherCounter, Bool_t ignoreHitsAtBinZero, Long64_t timeBinMinimum, Long64_t timeBinMaximum){ // timeBin ... time bin, at which the coincidence is searched // counterTimeShiftOfRequestingCounter ... time shift (in bin units) of the counter, for which the coincidence is searched // ignoreHitsAtBinZero ... if "true", hits at timeBin will be ignored (needed for searching of coincidence of M counter // with other M counters or P counters with other P counters) // "false" should be used for coincidence detectors and vetos. if (hitMap.empty()) return false; // Long64_t timeBinToTest = timeBin; Long64_t timeBinMin; Long64_t timeBinMax; // If timeBinMinimum and timeBinMaximum are not specified, use internal time window of the detector (koincidence or veto detectors). // Otherwise use timeBinMinimum and timeBinMaximum (e.g.coincidence of a positron counter with other positron counters). if (timeBinMinimum!=-123456789) timeBinMin = timeBin + timeBinMinimum; // time window requested through "timeBinMinimum" else if (counterType == 'V') timeBinMin = timeBin + antiCoincidenceTimeWindowMin; // this is veto detector else if (motherCounter=='M') timeBinMin = timeBin + coincidenceTimeWindowMin_M; // this is coinc. detector (or M counter) connected to M else if (motherCounter=='P') timeBinMin = timeBin + coincidenceTimeWindowMin_P; // this is coinc. detector connected to P if (timeBinMaximum!=-123456789) timeBinMax = timeBin + timeBinMaximum; // time window requested through "timeBinMinimum" else if (counterType == 'V') timeBinMax = timeBin + antiCoincidenceTimeWindowMax; // this is veto detector else if (motherCounter=='M') timeBinMax = timeBin + coincidenceTimeWindowMax_M; // this is coinc. detector (or M counter) connected to M else if (motherCounter=='P') timeBinMax = timeBin + coincidenceTimeWindowMax_P; // this is coinc. detector connected to P // Long64_t timeBinMin = (timeBinMinimum==-123456789) ? timeBin + coincidenceTimeWindowMin : timeBin + timeBinMinimum; // Long64_t timeBinMax = (timeBinMaximum==-123456789) ? timeBin + coincidenceTimeWindowMax : timeBin + timeBinMaximum; for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) { Long64_t timeBinOfCount_tmp = it->first; if ((timeBinOfCount_tmp >= timeBinMin) && (timeBinOfCount_tmp <= timeBinMax)) { if ((timeBin!=timeBinOfCount_tmp)||(!ignoreHitsAtBinZero)) { return true; } } else if (timeBinOfCount_tmp > timeBinMax) return false; } return false; } //================================================================ 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) { // 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 // // Loop over the hits in the counter // 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; timeBinOfNextHit = timeBinOfCount_tmp; if (timeBinOfCount_tmp <= timeBinMin) continue; // This hit was already processed previously ==> skip it Int_t eventNumber = (it->second)->eventIDnumber; if (eventNumber!=evtID) continue; // This trigger hit does not correspond to the currently processed event // ==> skip it, becuase it was already proceesed or will be processed in future numberOfMuonCandidates++; // std::cout<<"*** "<second)->eventEntry; idet = (it->second)->det_i; idetID = (it->second)->det_id; idetEdep = (it->second)->det_edep; // timeBinOfNextHit = timeBinOfCount_tmp; return true; endOfThisHit: continue; } 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, Bool_t& doubleHitFound) { // INPUT PARAMETERS: evtID, timeBinMin // OUTPUT PARAMETERS: timeBinOfNextGoodHit // positronQuality = 0 ... no positron candidate found // = 1 ... positron candidate found, but vetoed or not in a required coincidence with other detector // = 2 ... good positron found // Loop over the hits in the counter Int_t positronQuality=0; 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; if ((timeBinOfCount_tmp <= timeBinMin) || (timeBinOfCount_tmp > timeBinMax)) { if (bool_debugingRequired) { if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"< skip it } // Hit candidate was found. Now check its coincidences and vetos positronQuality=1; for (counterMapType::const_iterator itCounter = koincidenceCounterMap.begin(); itCounter!=koincidenceCounterMap.end(); ++itCounter) { if (bool_debugingRequired) { if (debugEventMap[evtID]>4) { (itCounter->second)->myPrintThisCounter(evtID); } } if (!( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'P') )) { if (bool_debugingRequired) { if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"< skip hit } } 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:"< 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:"< S T O P "<second)->GetMaxCoincidenceTimeWindow()); if (maxCoinc < maxCoinc_AlreadySet) (it->second)->SetMaxCoincidenceTimeWindow(maxCoinc); (it->second)->SetAntiCoincidenceTimeWindow(min,max); } } //================================================================ void musrCounter::myPrintThisCounter(Int_t evtID, Int_t detail) { Bool_t eventMixing=false; if ((hitMap.begin()==hitMap.end()) && (detail<=1) ) return; if (detail>1) std::cout<<"musrCounter::myPrintThisCounter: counterNr = "<first<<" "<<(it->second)->eventIDnumber<<","; if (evtID != (it->second)->eventIDnumber) {eventMixing=true;} } if (eventMixing) {std::cout<<" Potential event mixing";} std::cout<