//#include #include "musrCounter.hh" #include "TCanvas.h" //....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)>(timeBinLimit+maxCoincidenceTimeWindow-counterTimeShift)) return; //note that maxCoincidenceTimeWindow is usually negative number else { // std::cout<<" Deleting hit from counter "<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, 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 + counterTimeShift - counterTimeShiftOfRequestingCounter; Long64_t timeBinToTest = timeBin; // 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). Long64_t timeBinMin = (timeBinMinimum==-123456789) ? timeBinToTest + coincidenceTimeWindowMin : timeBinToTest + timeBinMinimum; Long64_t timeBinMax = (timeBinMaximum==-123456789) ? timeBinToTest + coincidenceTimeWindowMax : timeBinToTest + 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; } //================================================================ Bool_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 // // Loop over the hits in the counter if (hitMap.empty()) return false; 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)) continue; // This hit is out of the data interval ==> skip it // Hit candidate was found. Now check its coincidences and vetos for (counterMapType::const_iterator itCounter = koincidenceCounterMap.begin(); itCounter!=koincidenceCounterMap.end(); ++itCounter) { // if (!( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,counterTimeShift) )) goto endOfThisHit; // no coincidence found ==> skip hit if (!( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp) )) goto endOfThisHit; // no coincidence found ==> skip hit } for (counterMapType::const_iterator itCounter = vetoCounterMap.begin(); itCounter!=vetoCounterMap.end(); ++itCounter) { // if ( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,counterTimeShift) ) goto endOfThisHit; // coincidence with veto found ==> skip hit if ( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp) ) 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 // if (this->IsInCoincidence(timeBinOfCount_tmp,counterTimeShift,true) ) { // coincidence with another P-counter hit ==> skip hit // hovno // 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,true,timeBinMin,timeBinMax) ) { // coincidence with another P-counter hit ==> skip hit doubleHitFound = true; // std::cout<<"tttttttttttttttttttt doubleHitN="<second)->eventEntry; idet = (it->second)->det_i; idetID = (it->second)->det_id; idetEdep = (it->second)->det_edep; timeBinOfNextGoodHit = timeBinOfCount_tmp; timeBinOfNextGoodHit_phaseShifted = (it->second) -> timeBin2; //cDEL std::cout<<"timeBinOfNextGoodHit ="< S T O P !!!"<second)->SetMaxCoincidenceTimeWindow(maxCoinc); (it->second)->SetCoincidenceTimeWindow(min,max); } } //================================================================ void musrCounter::SetCoincidenceTimeWindowOfAllVetoDetectors(Long64_t maxCoinc, Long64_t min, Long64_t max) { for (counterMapType::const_iterator it = vetoCounterMap.begin(); it!=vetoCounterMap.end(); ++it) { if ( ( ((it->second)->GetMaxCoincidenceTimeWindow()) !=0) && ( ((it->second)->GetMaxCoincidenceTimeWindow()) !=maxCoinc) ) { std::cout<<" !!!! ERROR SetCoincidenceTimeWindowOfAllVetoDetectors : coincidenceTimeWindow set multiple times! ==> S T O P !!!"<second)->SetMaxCoincidenceTimeWindow(maxCoinc); (it->second)->SetCoincidenceTimeWindow(min,max); } } //================================================================ void musrCounter::myPrintThisCounter(Int_t evtID) { Bool_t eventMixing=false; std::cout<<"musrCounter::myPrintThisCounter: counterNr="<first<<" "<<(it->second)->eventIDnumber<<","; if (evtID != (it->second)->eventIDnumber) {eventMixing=true;} } if (eventMixing) {std::cout<<" Potential event mmmmmmmmixing";} std::cout<