Kamil Sedlak 7.2.2013
Implemented changes of James Lord. Compiling was possible, but no testing was done so far.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,12 @@
|
||||
//#include "musrTH.hh"
|
||||
#include <math.h>
|
||||
|
||||
const double pi=3.14159265358979324; // initialise here instead JSL
|
||||
const double microsecond=1.;
|
||||
const double nanosecond=0.001;
|
||||
const double picosecond=0.000001;
|
||||
|
||||
|
||||
class musrTH;
|
||||
|
||||
//#include "musrSimGlobal.hh"
|
||||
@ -192,6 +198,7 @@ public :
|
||||
Double_t eventID_double;
|
||||
Double_t muDecayDetID_double;
|
||||
Double_t det_n_double;
|
||||
Double_t det_multifirst_double;
|
||||
Double_t muDecayPosR;
|
||||
Double_t wght;
|
||||
Double_t det_m0edep;
|
||||
@ -219,6 +226,7 @@ public :
|
||||
Double_t pos_Phi_MINUS_muDecayPol_Phi360;
|
||||
Double_t pos_detID;
|
||||
Double_t pos_detID_doubleHit;
|
||||
Double_t pos_doubleHit_dPhi;
|
||||
// Double_t det_time0;
|
||||
// Double_t get_time0;
|
||||
// Double_t det_time1;
|
||||
@ -229,6 +237,7 @@ public :
|
||||
Double_t det_time20;
|
||||
Double_t det_time31;
|
||||
Double_t det_time1_MINUS_muDecayTime;
|
||||
Double_t det_multi_interval;
|
||||
Double_t detP_x;
|
||||
Double_t detP_y;
|
||||
Double_t detP_z;
|
||||
@ -254,6 +263,7 @@ public :
|
||||
Bool_t alwaysTrue;
|
||||
Bool_t oncePerEvent;
|
||||
Bool_t muonDecayedInSample_gen;
|
||||
Bool_t muonDecayedInSampleOnce_gen;
|
||||
Bool_t muonTriggered_gen;
|
||||
Bool_t muonTriggered_gen_AND_muonDecayedInSample_gen;
|
||||
Bool_t muonTriggered_det;
|
||||
@ -264,6 +274,12 @@ public :
|
||||
Bool_t pileupEventCandidate;
|
||||
Bool_t pileupEvent;
|
||||
Bool_t goodEvent_det_AND_muonDecayedInSample_gen;
|
||||
Bool_t goodEvent_F_det_AND_muonDecayedInSample_gen;
|
||||
Bool_t goodEvent_B_det_AND_muonDecayedInSample_gen;
|
||||
Bool_t goodEvent_U_det_AND_muonDecayedInSample_gen;
|
||||
Bool_t goodEvent_D_det_AND_muonDecayedInSample_gen;
|
||||
Bool_t goodEvent_L_det_AND_muonDecayedInSample_gen;
|
||||
Bool_t goodEvent_R_det_AND_muonDecayedInSample_gen;
|
||||
Bool_t goodEvent_F_det;
|
||||
Bool_t goodEvent_B_det;
|
||||
Bool_t goodEvent_U_det;
|
||||
@ -284,6 +300,25 @@ public :
|
||||
Bool_t promptPeakL;
|
||||
Bool_t promptPeakR;
|
||||
Bool_t doubleHit;
|
||||
// pulsed:
|
||||
// goodEvent_det = (discrim triggered, however happened)
|
||||
// goodEvent_gen = (1st or only over-threshold event, even if killed by dead time)
|
||||
// doubleHitEvent_gen = (2nd onwards of a double hit sequence, whether detected or dead)
|
||||
Bool_t doubleHitEvent_gen;
|
||||
// doubleHit = (2nd and subsequent hits, counted)
|
||||
// to subdivide double counting among banks (2nd and subsequent)
|
||||
Bool_t goodEvent_F_det_AND_doubleHit;
|
||||
Bool_t goodEvent_B_det_AND_doubleHit;
|
||||
Bool_t goodEvent_U_det_AND_doubleHit;
|
||||
Bool_t goodEvent_D_det_AND_doubleHit;
|
||||
Bool_t goodEvent_L_det_AND_doubleHit;
|
||||
Bool_t goodEvent_R_det_AND_doubleHit;
|
||||
// singleHitEvent_gen = (single hits only)
|
||||
Bool_t singleHitEvent_gen;
|
||||
// stackedEvent_gen = (multiple small hits adding to threshold, muon details refer to last one)
|
||||
Bool_t stackedEvent_gen;
|
||||
// pileupEvent = (all events killed by dead time)
|
||||
// ..._AND_pileupEvent = subdivided by bank (note the _det isn't appropriate here)
|
||||
|
||||
musrAnalysis(TTree *tree=0);
|
||||
virtual ~musrAnalysis();
|
||||
@ -298,6 +333,7 @@ public :
|
||||
virtual void CreateHistograms();
|
||||
virtual void AnalyseEvent(Long64_t iiiEntry);
|
||||
virtual void FillHistograms(Int_t iiiEntry);
|
||||
virtual void FillHistogramsPulsed(Int_t iiiEntry1, Int_t iiiEntry2);
|
||||
virtual void SaveHistograms(char* runChar,char* v1190FileName);
|
||||
virtual void RemoveOldHitsFromCounters(Long64_t timeBinLimit);
|
||||
// virtual void RewindAllTimeInfo(Double_t timeToRewind);
|
||||
@ -319,11 +355,13 @@ public :
|
||||
TH1D* hGeantParameters;
|
||||
TH1D* hInfo;
|
||||
|
||||
typedef std::multimap<double,int> doubleHitSorterType;
|
||||
|
||||
// typedef std::map<int,int> debugEventMapType;
|
||||
// debugEventMapType debugEventMap;
|
||||
// Bool_t bool_debugingRequired;
|
||||
|
||||
static const Double_t pi=3.14159265358979324;
|
||||
//JSL static const Double_t pi=3.14159265358979324;
|
||||
static musrWriteDump* myWriteDump;
|
||||
|
||||
private:
|
||||
@ -335,9 +373,10 @@ public :
|
||||
Int_t mdelay;
|
||||
Int_t pdelay;
|
||||
Int_t mcoincwin;
|
||||
Int_t pcoincwin;
|
||||
Int_t pcoincwin; // pulsed: for dead time or add-up overlap. Model as exponential decay of this time constant?
|
||||
Int_t vcoincwin;
|
||||
Double_t muonRateFactor;
|
||||
Double_t muonRateFactor; // also mean rate for pulsed mode
|
||||
Double_t muonPulseWidthFactor; // pulsed
|
||||
Double_t dataWindowMin;
|
||||
Double_t dataWindowMax;
|
||||
Double_t pileupWindowMin;
|
||||
@ -346,16 +385,22 @@ public :
|
||||
Double_t promptPeakWindowMax;
|
||||
Int_t overallBinDelay;
|
||||
Bool_t boolInfinitelyLowMuonRate;
|
||||
|
||||
char musrMode; // D = time diferential; I = time integral;
|
||||
Double_t frameInterval; // JSL: pulsed: to divide muons into frames
|
||||
Double_t detRecoveryTime; // JSL: pulsed: for dead time effects
|
||||
Bool_t doPartialFrameAtEnd; // process the left over muons if the beam goes off mid frame having done some complete frames
|
||||
// Bool_t processInBulk; // do all the muons in one go rather than re-filtering at end of run
|
||||
Double_t commonThreshold; // set all thresholds to this value regardless of individual settings
|
||||
|
||||
char musrMode; // D = time diferential; I = time integral; P = pulsed time differential
|
||||
Double_t safeTimeWindow;
|
||||
Double_t currentTime;
|
||||
// Double_t nextEventTime;
|
||||
Double_t nextUnfilledEventTime;
|
||||
Long64_t numberOfRewinds;
|
||||
Long64_t numberOfRewinds; // JSL: number of frames for Pulsed Mode
|
||||
Long64_t numberOfGoodMuons;
|
||||
// Int_t currentEventID;
|
||||
Long64_t lastPreprocessedEntry;
|
||||
Long64_t firstPreprocessedEntry; // JSL: first in this frame
|
||||
musrCounter* mCounter;
|
||||
typedef std::map<int,musrCounter*> counterMapType;
|
||||
counterMapType pCounterMap;
|
||||
@ -367,9 +412,9 @@ public :
|
||||
Bool_t bool_muDecayTimeTransformation;
|
||||
Double_t muDecayTime_Transformation_min, muDecayTime_Transformation_max, muDecayTime_t_min, muDecayTime_t_max;
|
||||
|
||||
static const Double_t microsecond=1.;
|
||||
static const Double_t nanosecond=0.001;
|
||||
static const Double_t picosecond=0.000001;
|
||||
// static const Double_t microsecond=1.;
|
||||
// static const Double_t nanosecond=0.001;
|
||||
// static const Double_t picosecond=0.000001;
|
||||
// static const Double_t rewindTime=1000000.;
|
||||
// static const Double_t rewindTime=1000.;
|
||||
// static const Long64_t rewindTimeBins=1000000000000000; // Max Long64_t can be +9,223,372,036,854,775,807
|
||||
@ -383,6 +428,7 @@ public :
|
||||
public:
|
||||
static const Int_t nrConditions = 31;
|
||||
Bool_t condition[nrConditions];
|
||||
Long64_t conditionCounter[nrConditions];
|
||||
static Long64_t rewindTimeBins;
|
||||
// static Int_t clock_channelID;
|
||||
// static Long64_t clock_interval;
|
||||
@ -488,7 +534,10 @@ musrAnalysis::musrAnalysis(TTree *tree)
|
||||
variableMap["posIniMomZ"]=&posIniMomZ;
|
||||
// variableMap["nFieldNomVal"]=&nFieldNomVal_double;
|
||||
// variableMap["fieldNomVal0"]=...; //[nFieldNomVal]
|
||||
variableMap["fieldNomVal0"]=&fieldNomVal[0]; // JSL: allow nominal field especially for background muons stopping elsewhere in map
|
||||
variableMap["fieldNomVal1"]=&fieldNomVal[1]; // a second field if defined. Could add more?
|
||||
variableMap["det_n"]=&det_n_double;
|
||||
variableMap["det_multifirst"]=&det_multifirst_double;
|
||||
//
|
||||
variableMap["muDecayPosR"]=&muDecayPosR;
|
||||
variableMap["wght"]=&wght;
|
||||
@ -517,6 +566,7 @@ musrAnalysis::musrAnalysis(TTree *tree)
|
||||
variableMap["pos_Phi_MINUS_muDecayPol_Phi360"]=&pos_Phi_MINUS_muDecayPol_Phi360;
|
||||
variableMap["pos_detID"]=&pos_detID;
|
||||
variableMap["pos_detID_doubleHit"]=&pos_detID_doubleHit;
|
||||
variableMap["pos_doubleHit_dPhi"]=&pos_doubleHit_dPhi;
|
||||
// variableMap["det_time0"]=&det_time0;
|
||||
// variableMap["gen_time0"]=&gen_time0;
|
||||
// variableMap["det_time1"]=&det_time1;
|
||||
@ -525,6 +575,7 @@ musrAnalysis::musrAnalysis(TTree *tree)
|
||||
variableMap["gen_time10"]=&gen_time10;
|
||||
variableMap["det_time10_MINUS_gen_time10"]=&det_time10_MINUS_gen_time10;
|
||||
variableMap["det_time1_MINUS_muDecayTime"]=&det_time1_MINUS_muDecayTime;
|
||||
variableMap["multiHitInterval"]=&det_multi_interval;
|
||||
variableMap["detP_x"]=&detP_x;
|
||||
variableMap["detP_y"]=&detP_x;
|
||||
variableMap["detP_z"]=&detP_x;
|
||||
|
@ -1,413 +1,523 @@
|
||||
//#include <iostream>
|
||||
#include "musrCounter.hh"
|
||||
#include "TCanvas.h"
|
||||
#include "musrAnalysis.hh"
|
||||
|
||||
typedef std::map<int,int> debugEventMapType;
|
||||
debugEventMapType debugEventMap;
|
||||
Bool_t bool_debugingRequired;
|
||||
|
||||
Bool_t musrCounter::bool_ignoreUnperfectMuons = true;
|
||||
Bool_t musrCounter::bool_ignoreUnperfectPositrons = true;
|
||||
Bool_t musrCounter::bool_WriteDataToDumpFile = false;
|
||||
//Long64_t musrCounter::previousClock = -1;
|
||||
//Long64_t musrCounter::CLOCK_INTERVAL = 512000;
|
||||
//ofstream musrCounter::dumpFile;
|
||||
|
||||
//....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 "<<counterNr<<" "<<counterName<<" "<<counterType<<" "<<couterEThreshold<<" "<<counterTimeShift<<std::endl;
|
||||
strcpy(TDC_histoName,"Unset");
|
||||
TDC_t0=0;
|
||||
TDC_t1=0;
|
||||
TDC_t2=0;
|
||||
TDC_histoNrAdd=0;
|
||||
antiCoincidenceTimeWindowMin=0;
|
||||
antiCoincidenceTimeWindowMax=0;
|
||||
coincidenceTimeWindowMin_M=0;
|
||||
coincidenceTimeWindowMax_M=0;
|
||||
coincidenceTimeWindowMin_P=0;
|
||||
coincidenceTimeWindowMax_P=0;
|
||||
maxCoincidenceTimeWindow=0;
|
||||
strcpy(TDC_histoNameAdd,"Unset");
|
||||
doubleHitN=0;
|
||||
numberOfMuonCandidates=0;
|
||||
numberOfMuonCandidatesAfterVK=0;
|
||||
numberOfMuonCandidatesAfterVKandDoubleHitRemoval=0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
musrCounter::~musrCounter() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void musrCounter::SetTDChistogram(char hName[200],int t0,int t1,int t2,int hNr,char hNameAdd[200]) {
|
||||
strcpy(TDC_histoName,hName);
|
||||
TDC_t0=t0;
|
||||
TDC_t1=t1;
|
||||
TDC_t2=t2;
|
||||
TDC_histoNrAdd=hNr;
|
||||
strcpy(TDC_histoNameAdd,hNameAdd);
|
||||
std::cout<<"TDC_histogram: "<<TDC_histoName<<" "<<TDC_t0<<" "<<TDC_t1<<" "<<TDC_t2<<" "<<TDC_histoNrAdd<<" "<<TDC_histoNameAdd<<std::endl;
|
||||
histTDC = new TH1D(TDC_histoName,TDC_histoName,t2,0.,float(t2));
|
||||
}
|
||||
//================================================================
|
||||
void musrCounter::FillTDChistogram(Double_t variable, Double_t vaha) {
|
||||
histTDC->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, Int_t eventNum){
|
||||
//cDEL std::cout<<"FillHitInCounter: timeBin="<<timeBin<<" timeBin2="<<timeBin2<<" counterTimeShift="<< counterTimeShift<<std::endl;
|
||||
//cDEL std::cout<<" FillHitInCounter I: timeBin-counterTimeShift="<<timeBin-counterTimeShift<<" timeBin2-counterTimeShift="<<timeBin2-counterTimeShift<<std::endl;
|
||||
// std::cout<<"musrCounter::FillHitInCounter:"<<counterNr<<std::endl;
|
||||
if (edep>=couterEThreshold) {
|
||||
|
||||
hitInfo* hInfo = new hitInfo(kEntry,eveID,iDet,detectorID,edep,timeBin2-counterTimeShift);
|
||||
//cDEL std::cout<<detectorID<<" FillHitInCounter II: timeBin-counterTimeShift="<<timeBin-counterTimeShift<<" timeBin2-counterTimeShift="<<timeBin2-counterTimeShift<<std::endl;
|
||||
hitMap.insert( std::pair<Long64_t,hitInfo*>(timeBin-counterTimeShift,hInfo) );
|
||||
if (bool_WriteDataToDumpFile) { // write data into an output file
|
||||
// CheckClockInfo(timeBin);
|
||||
// dumpFile<<eventNum<<"\t"<<detectorID<<"\t"<<timeBin<<"\n";
|
||||
DumpInfoToDumpFile(eventNum,detectorID,timeBin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
void musrCounter::RemoveHitsInCounter(Long64_t timeBinLimit) {
|
||||
// Remove the obsolete hits (i.e. hits that happaned well before t0) from the Counter class
|
||||
if (hitMap.empty()) return;
|
||||
// myPrintThisCounter();
|
||||
// if (counterNr==1) {std::cout<<"ooooo1 timeBinLimit="<<timeBinLimit<<std::endl; myPrintThisCounter();}
|
||||
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
|
||||
// std::cout<<" musrCounter::RemoveHitsInCounter: counterNr="<<counterNr<<" timeBinLimit="<<timeBinLimit<<" maxCoincidenceTimeWindow="<<maxCoincidenceTimeWindow<<" counterTimeShift="<<counterTimeShift<<std::endl;
|
||||
if ((it->first)>(timeBinLimit+maxCoincidenceTimeWindow-counterTimeShift)) return; //note that maxCoincidenceTimeWindow is usually negative number
|
||||
else {
|
||||
// std::cout<<" Deleting hit from counter "<<counterNr<<", time bin = "<<(it->first)<<std::endl;
|
||||
delete (it->second);
|
||||
hitMap.erase(it);
|
||||
}
|
||||
}
|
||||
// if (counterNr==1) {std::cout<<"ooooo2"<<std::endl; myPrintThisCounter();}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
//void musrCounter::RewindHitsInCounter(Long64_t timeBinsToRewind) {
|
||||
void musrCounter::RewindHitsInCounter() {
|
||||
// Reset time in hits from the Counter class
|
||||
if (hitMap.empty()) return;
|
||||
|
||||
// Long64_t timeBinsToRewind = musrAnalysis::rewindTimeBins;
|
||||
hitMap_TYPE hitMap_TMP;
|
||||
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
|
||||
Long64_t tempBinT = it->first;
|
||||
hitInfo* tempEvnr= it->second;
|
||||
tempEvnr->RewindTimeBin2(musrAnalysis::rewindTimeBins);
|
||||
hitMap_TMP.insert( std::pair<Long64_t,hitInfo*>(tempBinT-musrAnalysis::rewindTimeBins,tempEvnr) );
|
||||
}
|
||||
hitMap.swap(hitMap_TMP);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
Bool_t musrCounter::IsInCoincidence(Long64_t timeBin, char motherCounter){
|
||||
// timeBin ... time bin, at which the coincidence is searched
|
||||
|
||||
if (hitMap.empty()) return false;
|
||||
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 (counterType == 'V') timeBinMin = timeBin + antiCoincidenceTimeWindowMin; // this is veto detector
|
||||
else if (motherCounter=='M') timeBinMin = timeBin + coincidenceTimeWindowMin_M; // this is coinc. detector connected to M
|
||||
else if (motherCounter=='P') timeBinMin = timeBin + coincidenceTimeWindowMin_P; // this is coinc. detector connected to P
|
||||
|
||||
if (counterType == 'V') timeBinMax = timeBin + antiCoincidenceTimeWindowMax; // this is veto detector
|
||||
else if (motherCounter=='M') timeBinMax = timeBin + coincidenceTimeWindowMax_M; // this is coinc. detector connected to M
|
||||
else if (motherCounter=='P') timeBinMax = timeBin + coincidenceTimeWindowMax_P; // this is coinc. detector connected to P
|
||||
|
||||
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) {
|
||||
// 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
|
||||
// INPUT PARAMETERS: evtID, timeBinMin
|
||||
// OUTPUT PARAMETERS: timeBinOfNextHit
|
||||
//
|
||||
// Loop over the hits in the counter
|
||||
// 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;
|
||||
timeBinOfNextHit = timeBinOfCount_tmp;
|
||||
Int_t modulo = timeBinOfNextHit % 524288;
|
||||
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, 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<<" , "<<modulo<<")"<<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) 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<<" , "<<modulo<<")"<<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) 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<<" , "<<modulo<<")"<<std::endl;}
|
||||
goto MuonCoincidencesChecked;
|
||||
}
|
||||
}
|
||||
|
||||
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<<" , "<<modulo<<")"<<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<<" , "<<modulo<<")"<<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<<" , "<<modulo<<" ; "<<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;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
Bool_t musrCounter::CheckForPileupMuons(Long64_t timeBin0) {
|
||||
// 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;
|
||||
// std::cout<<"timeBin0="<<timeBin0<<" timeBinOfCount_tmp="<<timeBinOfCount_tmp<<std::endl;
|
||||
if (timeBinOfCount_tmp < timeBinMinimum+musrAnalysis::pileupWindowBinMin) continue; // This hit happened too long ago
|
||||
if (timeBinOfCount_tmp > timeBinMinimum+musrAnalysis::pileupWindowBinMax) break; // This hit happened too late
|
||||
// if ((timeBinOfCount_tmp == timeBinMinimum)&&( ((it->second)->eventEntry) == kEntry_NN)) continue;
|
||||
if (timeBinOfCount_tmp == timeBinMinimum) 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
|
||||
// = 2 ... good positron found
|
||||
// = 3 ... double hit
|
||||
// Loop over the hits in the counter
|
||||
Int_t positronQuality=0;
|
||||
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;
|
||||
Int_t modulo = timeBinOfCount_tmp % 524288;
|
||||
if ((timeBinOfCount_tmp <= timeBinMin) || (timeBinOfCount_tmp > timeBinMax)) {
|
||||
if (bool_debugingRequired) {
|
||||
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
|
||||
}
|
||||
|
||||
// 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 (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<<"GetNextGoodPositron: Coincidence required but not found (timeBin="<<timeBinOfCount_tmp<<" , "<<modulo<<")"<<std::endl;}
|
||||
}
|
||||
// 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
|
||||
}
|
||||
}
|
||||
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<<"GetNextGoodPositron: Coincidence vith veto detector found (timeBin="<<timeBinOfCount_tmp<<" , "<<modulo<<")"<<std::endl;}
|
||||
}
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
CoincidencesChecked:
|
||||
if (!bool_coincidenceConditions) continue; // This hit does not fulfill coincidence and veto criteria
|
||||
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;
|
||||
idet = (it->second)->det_i;
|
||||
idetID = (it->second)->det_id;
|
||||
idetEdep = (it->second)->det_edep;
|
||||
timeBinOfNextGoodHit = timeBinOfCount_tmp;
|
||||
timeBinOfNextGoodHit_phaseShifted = (it->second) -> timeBin2;
|
||||
if (bool_debugingRequired) {
|
||||
if (debugEventMap[evtID]>3) {std::cout<<"GetNextGoodPositron: Good positron candidate found in this counter. (timeBin="<<timeBinOfCount_tmp<<" , "<<modulo<<" "<<(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;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
void musrCounter::SetCoincidenceTimeWindowOfAllCoincidenceDetectors(char motherCounter, Long64_t maxCoinc, Long64_t min, Long64_t max) {
|
||||
// std::cout<<"QQQQQQQQQQQQQQQQQQQQQ koincidenceCounterMap.size()="<<koincidenceCounterMap.size()<<std::endl;
|
||||
for (counterMapType::const_iterator it = koincidenceCounterMap.begin(); it!=koincidenceCounterMap.end(); ++it) {
|
||||
Long64_t maxCoinc_AlreadySet = ((it->second)->GetMaxCoincidenceTimeWindow());
|
||||
if (maxCoinc < maxCoinc_AlreadySet) (it->second)->SetMaxCoincidenceTimeWindow(maxCoinc);
|
||||
|
||||
if (motherCounter=='M') (it->second)->SetCoincidenceTimeWindow_M(min,max);
|
||||
else if (motherCounter=='P') (it->second)->SetCoincidenceTimeWindow_P(min,max);
|
||||
else {
|
||||
std::cout<<"musrCounter::SetCoincidenceTimeWindowOfAllCoincidenceDetectors ERROR: Strange motherCounter "
|
||||
<<motherCounter<<"\n ==> S T O P "<<std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
void musrCounter::SetCoincidenceTimeWindowOfAllVetoDetectors(Long64_t maxCoinc, Long64_t min, Long64_t max) {
|
||||
for (counterMapType::const_iterator it = vetoCounterMap.begin(); it!=vetoCounterMap.end(); ++it) {
|
||||
musrCounter* counter = it->second;
|
||||
Long64_t maxCoinc_AlreadySet = counter->GetMaxCoincidenceTimeWindow();
|
||||
Long64_t min_AlreadySet = counter->GetAntiCoincidenceTimeWindowMin();
|
||||
Long64_t max_AlreadySet = counter->GetAntiCoincidenceTimeWindowMax();
|
||||
if (maxCoinc < maxCoinc_AlreadySet) counter->SetMaxCoincidenceTimeWindow(maxCoinc);
|
||||
if (min < min_AlreadySet) counter->SetAntiCoincidenceTimeWindowMin(min);
|
||||
if (max > max_AlreadySet) counter->SetAntiCoincidenceTimeWindowMax(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 = "<<counterNr<<": ";
|
||||
// else
|
||||
std::cout<<" counter = "<<counterNr<<": ";
|
||||
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
|
||||
std::cout<<"\t"<<it->first<<" ("<<(it->first)%524288 <<") "<<(it->second)->eventIDnumber<<",";
|
||||
if (evtID != (it->second)->eventIDnumber) {eventMixing=true;}
|
||||
}
|
||||
if (eventMixing) {std::cout<<" Potential event mixing";}
|
||||
std::cout<<std::endl;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
//void musrCounter::CheckClockInfo(Long64_t timeBin) {
|
||||
// Int_t clock_detectorID=musrAnalysis::clock_channelID;
|
||||
// if (timeBin > (previousClock+musrAnalysis::clock_interval)) {
|
||||
// previousClock += musrAnalysis::clock_interval;
|
||||
// // dumpFile<<"-1\t"<<clock_detectorID<<"\t"<<previousClock<<"\n";
|
||||
// DumpInfoToDumpFile(-1,clock_detectorID,previousClock);
|
||||
// }
|
||||
//}
|
||||
//================================================================
|
||||
void musrCounter::DumpInfoToDumpFile(Int_t eventNr, Int_t detID, Long64_t tdcBin) {
|
||||
if (tdcBin>=musrAnalysis::rewindTimeBins) tdcBin -= musrAnalysis::rewindTimeBins;
|
||||
else if (tdcBin<0) tdcBin += musrAnalysis::rewindTimeBins;
|
||||
// Int_t tdc = (tdcBin<musrAnalysis::rewindTimeBins) ? tdcBin : tdcBin-musrAnalysis::rewindTimeBins;
|
||||
// dumpFile<<eventNr<<"\t"<<detID<<"\t"<<tdcBin<<"\n";
|
||||
musrAnalysis::myWriteDump->send_to_dump(detID,tdcBin,false);
|
||||
}
|
||||
//================================================================
|
||||
void musrCounter::WriteRewindIntoDumpFile() {
|
||||
DumpInfoToDumpFile(-2,1000,0);
|
||||
}
|
||||
//================================================================
|
||||
//#include <iostream>
|
||||
#include "musrCounter.hh"
|
||||
#include "TCanvas.h"
|
||||
#include "musrAnalysis.hh"
|
||||
|
||||
typedef std::map<int,int> debugEventMapType;
|
||||
debugEventMapType debugEventMap;
|
||||
Bool_t bool_debugingRequired;
|
||||
|
||||
Bool_t musrCounter::bool_ignoreUnperfectMuons = true;
|
||||
Bool_t musrCounter::bool_ignoreUnperfectPositrons = true;
|
||||
Bool_t musrCounter::bool_WriteDataToDumpFile = false;
|
||||
//Long64_t musrCounter::previousClock = -1;
|
||||
//Long64_t musrCounter::CLOCK_INTERVAL = 512000;
|
||||
//ofstream musrCounter::dumpFile;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
musrCounter::musrCounter(int CHANNEL_NR, char CHANNEL_NAME[200], char CHANNEL_TYPE, float E_THRESH, int TIME_SHIFT, double DEADTIME, Bool_t KEEP_BELOW_THRESH) {
|
||||
// pointerToAnalysis=this;
|
||||
counterNr = CHANNEL_NR;
|
||||
strcpy(counterName,CHANNEL_NAME);
|
||||
counterType = CHANNEL_TYPE;
|
||||
couterEThreshold = E_THRESH;
|
||||
counterTimeShift = (Long64_t) TIME_SHIFT;
|
||||
keepBelowThresholdHits = KEEP_BELOW_THRESH;
|
||||
discriminatorRecoveryTime = DEADTIME;
|
||||
std::cout<<"musrCounter::musrCounter: Creating counter "<<counterNr<<" "<<counterName<<" "<<counterType<<" "<<couterEThreshold<<" "<<counterTimeShift<<std::endl;
|
||||
strcpy(TDC_histoName,"Unset");
|
||||
TDC_t0=0;
|
||||
TDC_t1=0;
|
||||
TDC_t2=0;
|
||||
TDC_histoNrAdd=0;
|
||||
antiCoincidenceTimeWindowMin=0;
|
||||
antiCoincidenceTimeWindowMax=0;
|
||||
coincidenceTimeWindowMin_M=0;
|
||||
coincidenceTimeWindowMax_M=0;
|
||||
coincidenceTimeWindowMin_P=0;
|
||||
coincidenceTimeWindowMax_P=0;
|
||||
maxCoincidenceTimeWindow=0;
|
||||
strcpy(TDC_histoNameAdd,"Unset");
|
||||
doubleHitN=0;
|
||||
numberOfMuonCandidates=0;
|
||||
numberOfMuonCandidatesAfterVK=0;
|
||||
numberOfMuonCandidatesAfterVKandDoubleHitRemoval=0;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
musrCounter::~musrCounter() {}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void musrCounter::SetTDChistogram(char hName[200],int t0,int t1,int t2,int hNr,char hNameAdd[200]) {
|
||||
strcpy(TDC_histoName,hName);
|
||||
TDC_t0=t0;
|
||||
TDC_t1=t1;
|
||||
TDC_t2=t2;
|
||||
TDC_histoNrAdd=hNr;
|
||||
strcpy(TDC_histoNameAdd,hNameAdd);
|
||||
std::cout<<"TDC_histogram: "<<TDC_histoName<<" "<<TDC_t0<<" "<<TDC_t1<<" "<<TDC_t2<<" "<<TDC_histoNrAdd<<" "<<TDC_histoNameAdd<<std::endl;
|
||||
histTDC = new TH1D(TDC_histoName,TDC_histoName,t2,0.,float(t2));
|
||||
}
|
||||
//================================================================
|
||||
void musrCounter::FillTDChistogram(Double_t variable, Double_t vaha) {
|
||||
histTDC->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, Int_t eventNum, Int_t& multiCtr){
|
||||
static hitInfo *hFlagged; // common to all histograms
|
||||
//cDEL std::cout<<"FillHitInCounter: timeBin="<<timeBin<<" timeBin2="<<timeBin2<<" counterTimeShift="<< counterTimeShift<<std::endl;
|
||||
//cDEL std::cout<<" FillHitInCounter I: timeBin-counterTimeShift="<<timeBin-counterTimeShift<<" timeBin2-counterTimeShift="<<timeBin2-counterTimeShift<<std::endl;
|
||||
// std::cout<<"musrCounter::FillHitInCounter:"<<counterNr<<std::endl;
|
||||
// JSL: allow keeping of small hits (but label them)
|
||||
if ((edep>=couterEThreshold) || ((counterType=='P') && keepBelowThresholdHits)) {
|
||||
// multiple count labelling (JSL)
|
||||
// counter provided by caller (per event across all counters), reset for new muon
|
||||
// first big hit numbered 0
|
||||
// first hit relabelled 1 when second significant hit comes in
|
||||
// second and subsequent big hits labelled 2,3,etc
|
||||
// small ones labelled -1 regardless of sequence
|
||||
// Only for P counters; V,K,M all labelled 0.
|
||||
Int_t multiCtrTmp;
|
||||
if(counterType=='P') {
|
||||
if(edep>=couterEThreshold) {
|
||||
if((multiCtr==1) && hFlagged) {
|
||||
// a second good hit, relabel the first hit
|
||||
// std::cout << "flagged double count in event "<<kEntry<<" hist "<<detectorID<<" time "<<timeBin<<std::endl;
|
||||
hFlagged->multiHitCtr = 1;
|
||||
// hFlagged=NULL;
|
||||
multiCtr++;
|
||||
}
|
||||
multiCtrTmp=multiCtr;
|
||||
multiCtr++;
|
||||
} else {
|
||||
multiCtrTmp=-1;
|
||||
}
|
||||
} else {
|
||||
multiCtrTmp=0; // M, V or K counter
|
||||
}
|
||||
hitInfo* hInfo = new hitInfo(kEntry,eveID,iDet,detectorID,edep,timeBin-counterTimeShift,timeBin2-counterTimeShift, multiCtrTmp, NULL,0);
|
||||
if((multiCtrTmp==0) && (counterType=='P')) { hFlagged=hInfo; } // save pointer to the first hit
|
||||
if(multiCtrTmp>0) {
|
||||
hInfo->firstMulti = hFlagged;
|
||||
}
|
||||
//cDEL std::cout<<detectorID<<" FillHitInCounter II: timeBin-counterTimeShift="<<timeBin-counterTimeShift<<" timeBin2-counterTimeShift="<<timeBin2-counterTimeShift<<std::endl;
|
||||
hitMap.insert( std::pair<Long64_t,hitInfo*>(timeBin-counterTimeShift,hInfo) );
|
||||
if (bool_WriteDataToDumpFile) { // write data into an output file
|
||||
// CheckClockInfo(timeBin);
|
||||
// dumpFile<<eventNum<<"\t"<<detectorID<<"\t"<<timeBin<<"\n";
|
||||
DumpInfoToDumpFile(eventNum,detectorID,timeBin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
void musrCounter::RemoveHitsInCounter(Long64_t timeBinLimit) {
|
||||
// Remove the obsolete hits (i.e. hits that happaned well before t0) from the Counter class
|
||||
hitMap_TYPE::iterator it2; // JSL
|
||||
if (hitMap.empty()) return;
|
||||
// myPrintThisCounter();
|
||||
// if (counterNr==1) {std::cout<<"ooooo1 timeBinLimit="<<timeBinLimit<<std::endl; myPrintThisCounter();}
|
||||
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end();) { // JSL: move ++it into body
|
||||
// std::cout<<" musrCounter::RemoveHitsInCounter: counterNr="<<counterNr<<" timeBinLimit="<<timeBinLimit<<" maxCoincidenceTimeWindow="<<maxCoincidenceTimeWindow<<" counterTimeShift="<<counterTimeShift<<std::endl;
|
||||
if ((it->first)>(timeBinLimit+maxCoincidenceTimeWindow-counterTimeShift)) return; //note that maxCoincidenceTimeWindow is usually negative number
|
||||
else {
|
||||
// std::cout<<" Deleting hit from counter "<<counterNr<<", time bin = "<<(it->first)<<std::endl;
|
||||
it2=it;
|
||||
it2++;
|
||||
delete (it->second);
|
||||
hitMap.erase(it);
|
||||
it=it2;
|
||||
}
|
||||
}
|
||||
// if (counterNr==1) {std::cout<<"ooooo2"<<std::endl; myPrintThisCounter();}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
//void musrCounter::RewindHitsInCounter(Long64_t timeBinsToRewind) {
|
||||
void musrCounter::RewindHitsInCounter() {
|
||||
// Reset time in hits from the Counter class
|
||||
if (hitMap.empty()) return;
|
||||
|
||||
// Long64_t timeBinsToRewind = musrAnalysis::rewindTimeBins;
|
||||
hitMap_TYPE hitMap_TMP;
|
||||
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
|
||||
Long64_t tempBinT = it->first;
|
||||
hitInfo* tempEvnr= it->second;
|
||||
tempEvnr->RewindTimeBin2(musrAnalysis::rewindTimeBins);
|
||||
hitMap_TMP.insert( std::pair<Long64_t,hitInfo*>(tempBinT-musrAnalysis::rewindTimeBins,tempEvnr) );
|
||||
}
|
||||
hitMap.swap(hitMap_TMP);
|
||||
}
|
||||
|
||||
//================================================================
|
||||
Bool_t musrCounter::IsInCoincidence(Long64_t timeBin, char motherCounter){
|
||||
// timeBin ... time bin, at which the coincidence is searched
|
||||
|
||||
if (hitMap.empty()) return false;
|
||||
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 (counterType == 'V') timeBinMin = timeBin + antiCoincidenceTimeWindowMin; // this is veto detector
|
||||
else if (motherCounter=='M') timeBinMin = timeBin + coincidenceTimeWindowMin_M; // this is coinc. detector connected to M
|
||||
else if (motherCounter=='P') timeBinMin = timeBin + coincidenceTimeWindowMin_P; // this is coinc. detector connected to P
|
||||
|
||||
if (counterType == 'V') timeBinMax = timeBin + antiCoincidenceTimeWindowMax; // this is veto detector
|
||||
else if (motherCounter=='M') timeBinMax = timeBin + coincidenceTimeWindowMax_M; // this is coinc. detector connected to M
|
||||
else if (motherCounter=='P') timeBinMax = timeBin + coincidenceTimeWindowMax_P; // this is coinc. detector connected to P
|
||||
|
||||
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) {
|
||||
// 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
|
||||
// INPUT PARAMETERS: evtID, timeBinMin
|
||||
// OUTPUT PARAMETERS: timeBinOfNextHit
|
||||
//
|
||||
// Loop over the hits in the counter
|
||||
// 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;
|
||||
timeBinOfNextHit = timeBinOfCount_tmp;
|
||||
Int_t modulo = timeBinOfNextHit % 524288;
|
||||
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, 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<<" , "<<modulo<<")"<<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) 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<<" , "<<modulo<<")"<<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) 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<<" , "<<modulo<<")"<<std::endl;}
|
||||
goto MuonCoincidencesChecked;
|
||||
}
|
||||
}
|
||||
|
||||
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<<" , "<<modulo<<")"<<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<<" , "<<modulo<<")"<<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<<" , "<<modulo<<" ; "<<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;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
Bool_t musrCounter::CheckForPileupMuons(Long64_t timeBin0) {
|
||||
// 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;
|
||||
// std::cout<<"timeBin0="<<timeBin0<<" timeBinOfCount_tmp="<<timeBinOfCount_tmp<<std::endl;
|
||||
if (timeBinOfCount_tmp < timeBinMinimum+musrAnalysis::pileupWindowBinMin) continue; // This hit happened too long ago
|
||||
if (timeBinOfCount_tmp > timeBinMinimum+musrAnalysis::pileupWindowBinMax) break; // This hit happened too late
|
||||
// if ((timeBinOfCount_tmp == timeBinMinimum)&&( ((it->second)->eventEntry) == kEntry_NN)) continue;
|
||||
if (timeBinOfCount_tmp == timeBinMinimum) 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
|
||||
// = 2 ... good positron found
|
||||
// = 3 ... double hit
|
||||
// Loop over the hits in the counter
|
||||
Int_t positronQuality=0;
|
||||
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;
|
||||
Int_t modulo = timeBinOfCount_tmp % 524288;
|
||||
if ((timeBinOfCount_tmp <= timeBinMin) || (timeBinOfCount_tmp > timeBinMax)) {
|
||||
if (bool_debugingRequired) {
|
||||
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
|
||||
}
|
||||
|
||||
// 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 (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<<"GetNextGoodPositron: Coincidence required but not found (timeBin="<<timeBinOfCount_tmp<<" , "<<modulo<<")"<<std::endl;}
|
||||
}
|
||||
// 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
|
||||
}
|
||||
}
|
||||
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<<"GetNextGoodPositron: Coincidence vith veto detector found (timeBin="<<timeBinOfCount_tmp<<" , "<<modulo<<")"<<std::endl;}
|
||||
}
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
CoincidencesChecked:
|
||||
if (!bool_coincidenceConditions) continue; // This hit does not fulfill coincidence and veto criteria
|
||||
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;
|
||||
idet = (it->second)->det_i;
|
||||
idetID = (it->second)->det_id;
|
||||
idetEdep = (it->second)->det_edep;
|
||||
timeBinOfNextGoodHit = timeBinOfCount_tmp;
|
||||
timeBinOfNextGoodHit_phaseShifted = (it->second) -> timeBin2;
|
||||
if (bool_debugingRequired) {
|
||||
if (debugEventMap[evtID]>3) {std::cout<<"GetNextGoodPositron: Good positron candidate found in this counter. (timeBin="<<timeBinOfCount_tmp<<" , "<<modulo<<" "<<(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;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
Int_t musrCounter::GetNextGoodPositronPulsed(Int_t entWanted1, Int_t entWanted2, 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, Int_t& idetFirstMulti, hitInfo*& hitStruct) {
|
||||
// pulsed. Sort through one detector
|
||||
// return positron quality: (>= -1 are "counted" events, 0,1,-2,-3 are "ideal")
|
||||
// -1000: no more positron candidates
|
||||
// 0: a normal "good" positron, the only above threshold hit for that muon
|
||||
// 1..n: "good" positrons, but double count events. 1 - 1st such hit 2=2nd, etc
|
||||
// -1: "stacked" event, this positron plus remaining "charge" adds to threshold (double hit status of such events not recorded)
|
||||
// -2..-999: "dead" event, good positron but will not be counted. -2=only hit -3=1st of double -4=2nd of double, etc
|
||||
Int_t positronQuality=-1000;
|
||||
Int_t idMin=+1000000000;
|
||||
Int_t idMax=-1000000000;
|
||||
//
|
||||
// entWanted: must be in range
|
||||
// timeBinMin, timeBinMax: range to search
|
||||
// timeBinOfNextGoodHit: starting point on entry, filled with time. If < timeBinMin, reset discriminator to beginning and run through pre-time-window events
|
||||
// timeBinOfNextGoodHit_phaseShifted: adjusted (out only)
|
||||
// kEntry: entry number for this event
|
||||
// idet: detector number
|
||||
// idetID:
|
||||
// idetEdep: energy deposited by this positron event (may be < threshold!)
|
||||
//
|
||||
// may no longer need to unpackage all the vars?
|
||||
|
||||
if(timeBinOfNextGoodHit < timeBinMin || timeBinOfNextGoodHit < discriminatorLastTime) {
|
||||
// rewind discriminator
|
||||
discriminatorLastVolts = 0.0;
|
||||
discriminatorLastTime = timeBinOfNextGoodHit;
|
||||
discriminatorIterator = hitMap.begin();
|
||||
}
|
||||
// process events until a good hit found, or end
|
||||
while((discriminatorIterator != hitMap.end()) && (discriminatorIterator->first <= timeBinMax)) {
|
||||
if(discriminatorIterator->second->eventEntry > idMax) { idMax=discriminatorIterator->second->eventEntry; }
|
||||
if(discriminatorIterator->second->eventEntry < idMin) { idMin=discriminatorIterator->second->eventEntry; }
|
||||
Long_t dT=((discriminatorIterator->first)-discriminatorLastTime);
|
||||
double discriminatorDropVolts=discriminatorLastVolts * exp(-dT/discriminatorRecoveryTime);
|
||||
discriminatorLastVolts=discriminatorDropVolts + discriminatorIterator->second->det_edep;
|
||||
discriminatorLastTime=discriminatorIterator->first;
|
||||
// discriminate it!
|
||||
Bool_t discriminatorTriggered = (discriminatorDropVolts < couterEThreshold && discriminatorLastVolts > couterEThreshold);
|
||||
// have we found the wanted event?
|
||||
if ((((discriminatorIterator->second->eventEntry >= entWanted1) && (discriminatorIterator->second->eventEntry <= entWanted2)) && discriminatorIterator->first > timeBinMin) && (discriminatorTriggered || (discriminatorIterator->second->det_edep > couterEThreshold))) {
|
||||
//yes
|
||||
if(discriminatorTriggered) {
|
||||
positronQuality=discriminatorIterator->second->multiHitCtr; // already checked to see if it was above threshold on its own and/or double
|
||||
} else { // a missed good count, record these too
|
||||
positronQuality= -2 - discriminatorIterator->second->multiHitCtr;
|
||||
}
|
||||
kEntry = (discriminatorIterator->second)->eventEntry;
|
||||
idet = (discriminatorIterator->second)->det_i;
|
||||
idetID = (discriminatorIterator->second)->det_id;
|
||||
idetEdep = (discriminatorIterator->second)->det_edep;
|
||||
timeBinOfNextGoodHit = discriminatorIterator->first;
|
||||
timeBinOfNextGoodHit_phaseShifted = (discriminatorIterator->second) -> timeBin2;
|
||||
if(((discriminatorIterator->second)->multiHitCtr > 1) && (discriminatorIterator->second)->firstMulti) {
|
||||
idetFirstMulti = (discriminatorIterator->second)->firstMulti->det_i;
|
||||
} else {
|
||||
idetFirstMulti = -1000; // not a second or subsequent multi hit, or not recorded for some reason
|
||||
}
|
||||
hitStruct = discriminatorIterator->second;
|
||||
discriminatorIterator->second->posQual = positronQuality;
|
||||
discriminatorIterator++;
|
||||
break;
|
||||
} else {
|
||||
discriminatorIterator++;
|
||||
hitStruct = NULL;
|
||||
}
|
||||
}
|
||||
if(positronQuality==-1000 && ((idMax>idMin) && timeBinOfNextGoodHit<0)) {
|
||||
// std::cout << "Didn't find entry " << entWanted << " but only range " << idMin << " to " << idMax << " from " << timeBinOfNextGoodHit << std::endl;
|
||||
}
|
||||
return positronQuality;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
void musrCounter::SetCoincidenceTimeWindowOfAllCoincidenceDetectors(char motherCounter, Long64_t maxCoinc, Long64_t min, Long64_t max) {
|
||||
// std::cout<<"QQQQQQQQQQQQQQQQQQQQQ koincidenceCounterMap.size()="<<koincidenceCounterMap.size()<<std::endl;
|
||||
for (counterMapType::const_iterator it = koincidenceCounterMap.begin(); it!=koincidenceCounterMap.end(); ++it) {
|
||||
Long64_t maxCoinc_AlreadySet = ((it->second)->GetMaxCoincidenceTimeWindow());
|
||||
if (maxCoinc < maxCoinc_AlreadySet) (it->second)->SetMaxCoincidenceTimeWindow(maxCoinc);
|
||||
|
||||
if (motherCounter=='M') (it->second)->SetCoincidenceTimeWindow_M(min,max);
|
||||
else if (motherCounter=='P') (it->second)->SetCoincidenceTimeWindow_P(min,max);
|
||||
else {
|
||||
std::cout<<"musrCounter::SetCoincidenceTimeWindowOfAllCoincidenceDetectors ERROR: Strange motherCounter "
|
||||
<<motherCounter<<"\n ==> S T O P "<<std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================
|
||||
void musrCounter::SetCoincidenceTimeWindowOfAllVetoDetectors(Long64_t maxCoinc, Long64_t min, Long64_t max) {
|
||||
for (counterMapType::const_iterator it = vetoCounterMap.begin(); it!=vetoCounterMap.end(); ++it) {
|
||||
musrCounter* counter = it->second;
|
||||
Long64_t maxCoinc_AlreadySet = counter->GetMaxCoincidenceTimeWindow();
|
||||
Long64_t min_AlreadySet = counter->GetAntiCoincidenceTimeWindowMin();
|
||||
Long64_t max_AlreadySet = counter->GetAntiCoincidenceTimeWindowMax();
|
||||
if (maxCoinc < maxCoinc_AlreadySet) counter->SetMaxCoincidenceTimeWindow(maxCoinc);
|
||||
if (min < min_AlreadySet) counter->SetAntiCoincidenceTimeWindowMin(min);
|
||||
if (max > max_AlreadySet) counter->SetAntiCoincidenceTimeWindowMax(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 = "<<counterNr<<": ";
|
||||
// else
|
||||
std::cout<<" counter = "<<counterNr<<": ";
|
||||
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
|
||||
std::cout<<"\t"<<it->first<<" ("<<(it->first)%524288 <<") "<<(it->second)->eventIDnumber<<",";
|
||||
if (evtID != (it->second)->eventIDnumber) {eventMixing=true;}
|
||||
}
|
||||
if (eventMixing) {std::cout<<" Potential event mixing";}
|
||||
std::cout<<std::endl;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
//void musrCounter::CheckClockInfo(Long64_t timeBin) {
|
||||
// Int_t clock_detectorID=musrAnalysis::clock_channelID;
|
||||
// if (timeBin > (previousClock+musrAnalysis::clock_interval)) {
|
||||
// previousClock += musrAnalysis::clock_interval;
|
||||
// // dumpFile<<"-1\t"<<clock_detectorID<<"\t"<<previousClock<<"\n";
|
||||
// DumpInfoToDumpFile(-1,clock_detectorID,previousClock);
|
||||
// }
|
||||
//}
|
||||
//================================================================
|
||||
void musrCounter::DumpInfoToDumpFile(Int_t eventNr, Int_t detID, Long64_t tdcBin) {
|
||||
if (tdcBin>=musrAnalysis::rewindTimeBins) tdcBin -= musrAnalysis::rewindTimeBins;
|
||||
else if (tdcBin<0) tdcBin += musrAnalysis::rewindTimeBins;
|
||||
// Int_t tdc = (tdcBin<musrAnalysis::rewindTimeBins) ? tdcBin : tdcBin-musrAnalysis::rewindTimeBins;
|
||||
// dumpFile<<eventNr<<"\t"<<detID<<"\t"<<tdcBin<<"\n";
|
||||
musrAnalysis::myWriteDump->send_to_dump(detID,tdcBin,false);
|
||||
}
|
||||
//================================================================
|
||||
void musrCounter::WriteRewindIntoDumpFile() {
|
||||
DumpInfoToDumpFile(-2,1000,0);
|
||||
}
|
||||
//================================================================
|
||||
|
@ -1,112 +1,123 @@
|
||||
#ifndef musrCounter_h
|
||||
#define musrCounter_h 1
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <TApplication.h>
|
||||
#include <TSystem.h>
|
||||
#include <TH1.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
class hitInfo {
|
||||
public:
|
||||
hitInfo(Int_t kEntry, Int_t evID, Int_t deI, Int_t detectorID, Double_t deEDEP, Long64_t timeBIN2) {eventEntry=kEntry; eventIDnumber=evID; det_i=deI; det_id = detectorID; det_edep=deEDEP; timeBin2=timeBIN2;}
|
||||
~hitInfo() {}
|
||||
void RewindTimeBin2(Long64_t timeBinsToRewind) {timeBin2-=timeBinsToRewind;}
|
||||
Int_t eventEntry;
|
||||
Int_t eventIDnumber;
|
||||
Int_t det_i;
|
||||
Int_t det_id;
|
||||
Double_t det_edep;
|
||||
Long64_t timeBin2;
|
||||
|
||||
// extern double GlobalKamil;
|
||||
// typedef std::map<int,int> debugEventMapType;
|
||||
// extern debugEventMapType debugEventMap;
|
||||
// extern Bool_t bool_debugingRequired;
|
||||
};
|
||||
|
||||
class musrCounter {
|
||||
public:
|
||||
musrCounter(int CHANNEL_NR, char CHANNEL_NAME[200], char CHANNEL_TYPE, float E_THRESH, int TIME_SHIFT);
|
||||
~musrCounter();
|
||||
int GetCounterNr() {return counterNr;}
|
||||
char GetCounterType() {return counterType;}
|
||||
void SetCoincidenceCounter(musrCounter* c, int icNr) {
|
||||
int cNr = abs(icNr);
|
||||
if (icNr>0) {
|
||||
std::cout<<"SetCoincidenceCounter: Adding counter ="<<cNr<<" to coincidence with the counter "<<counterNr<<std::endl;
|
||||
koincidenceCounterMap[cNr] = c;
|
||||
}
|
||||
else {
|
||||
std::cout<<"SetCoincidenceCounter: Adding counter ="<<cNr<<" as veto to the counter "<<counterNr<<std::endl;
|
||||
vetoCounterMap[cNr] = c;
|
||||
}
|
||||
}
|
||||
void SetMaxCoincidenceTimeWindow(Long64_t val) {maxCoincidenceTimeWindow=val;}
|
||||
Long64_t GetMaxCoincidenceTimeWindow() {return maxCoincidenceTimeWindow;}
|
||||
void SetCoincidenceTimeWindowOfAllCoincidenceDetectors(char motherCounter, Long64_t maxCoinc, Long64_t min, Long64_t max);
|
||||
void SetCoincidenceTimeWindowOfAllVetoDetectors(Long64_t maxCoinc, Long64_t min, Long64_t max);
|
||||
void SetCoincidenceTimeWindow_M(Long64_t min, Long64_t max) {coincidenceTimeWindowMin_M=min; coincidenceTimeWindowMax_M=max;}
|
||||
void SetCoincidenceTimeWindow_P(Long64_t min, Long64_t max) {coincidenceTimeWindowMin_P=min; coincidenceTimeWindowMax_P=max;}
|
||||
void SetAntiCoincidenceTimeWindowMin(Long64_t min) {antiCoincidenceTimeWindowMin=min;}
|
||||
void SetAntiCoincidenceTimeWindowMax(Long64_t max) {antiCoincidenceTimeWindowMax=max;}
|
||||
Long64_t GetAntiCoincidenceTimeWindowMin() {return antiCoincidenceTimeWindowMin;}
|
||||
Long64_t GetAntiCoincidenceTimeWindowMax() {return antiCoincidenceTimeWindowMax;}
|
||||
void SetTDChistogram(char hName[200],int t0,int t1,int t2,int hNr,char hNameAdd[200]);
|
||||
void FillTDChistogram(Double_t variable, Double_t vaha);
|
||||
void DrawTDChistogram();
|
||||
void FillHitInCounter(Double_t edep, Long64_t timeBin, Long64_t timeBin2, Int_t kEntry, Int_t eveID, Int_t iDet, Int_t detectorID, Int_t eventNum);
|
||||
void RemoveHitsInCounter(Long64_t timeBinLimit);
|
||||
// void RewindHitsInCounter(Long64_t timeBinsToRewind);
|
||||
void RewindHitsInCounter();
|
||||
Bool_t IsInCoincidence(Long64_t timeBin, char motherCounter);
|
||||
Bool_t GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t& timeBinOfNextHit, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep);
|
||||
Bool_t CheckForPileupMuons(Long64_t timeBin0);
|
||||
Int_t 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);
|
||||
void myPrintThisCounter(Int_t evtID, Int_t detail=2);
|
||||
// void CheckClockInfo(Long64_t timeBin);
|
||||
Long64_t GetNumberOfMuonCandidates(){return numberOfMuonCandidates;}
|
||||
Long64_t GetNumberOfMuonCandidatesAfterVK(){return numberOfMuonCandidatesAfterVK;}
|
||||
Long64_t GetNumberOfMuonCandidatesAfterVKandDoubleHitRemoval(){return numberOfMuonCandidatesAfterVKandDoubleHitRemoval;}
|
||||
void DumpInfoToDumpFile(Int_t eventNr, Int_t detID, Long64_t tdcBin);
|
||||
void WriteRewindIntoDumpFile();
|
||||
|
||||
private:
|
||||
// static musrCounter* pointerToAnalysis;
|
||||
int counterNr;
|
||||
char counterName[200];
|
||||
char counterType;
|
||||
double couterEThreshold;
|
||||
Long64_t counterTimeShift;
|
||||
typedef std::map<int,musrCounter*> counterMapType;
|
||||
counterMapType koincidenceCounterMap;
|
||||
counterMapType vetoCounterMap;
|
||||
char TDC_histoName[200];
|
||||
int TDC_t0, TDC_t1, TDC_t2, TDC_histoNrAdd;
|
||||
char TDC_histoNameAdd[200];
|
||||
TH1D* histTDC;
|
||||
Long64_t antiCoincidenceTimeWindowMin, coincidenceTimeWindowMin_M, coincidenceTimeWindowMin_P;
|
||||
Long64_t antiCoincidenceTimeWindowMax, coincidenceTimeWindowMax_M, coincidenceTimeWindowMax_P;
|
||||
Long64_t maxCoincidenceTimeWindow;
|
||||
// typedef std::map<Long64_t,Int_t> hitMap_TYPE; // Long64_t = timeBin, Int_t=eventID
|
||||
typedef std::map<Long64_t,hitInfo*> hitMap_TYPE; // Long64_t = timeBin, hitInfo = eventID and det_i
|
||||
hitMap_TYPE hitMap;
|
||||
// std::list<Double_t> timeOfHitsList;
|
||||
|
||||
Int_t doubleHitN;
|
||||
Long64_t numberOfMuonCandidates;
|
||||
Long64_t numberOfMuonCandidatesAfterVK;
|
||||
Long64_t numberOfMuonCandidatesAfterVKandDoubleHitRemoval;
|
||||
|
||||
public:
|
||||
static Bool_t bool_ignoreUnperfectMuons;
|
||||
static Bool_t bool_ignoreUnperfectPositrons;
|
||||
static Bool_t bool_WriteDataToDumpFile;
|
||||
// static ofstream dumpFile;
|
||||
// static Long64_t previousClock;
|
||||
// static Long64_t CLOCK_INTERVAL;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef musrCounter_h
|
||||
#define musrCounter_h 1
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <TApplication.h>
|
||||
#include <TSystem.h>
|
||||
#include <TH1.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
class hitInfo {
|
||||
public:
|
||||
hitInfo(Int_t kEntry, Int_t evID, Int_t deI, Int_t detectorID, Double_t deEDEP, Long64_t timeBIN1, Long64_t timeBIN2, Int_t multiCtr, hitInfo* firstMulti, Int_t posQuality) {eventEntry=kEntry; eventIDnumber=evID; det_i=deI; det_id = detectorID; det_edep=deEDEP; timeBin1=timeBIN1; timeBin2=timeBIN2; multiHitCtr=multiCtr; firstMulti=NULL;posQual=posQuality;}
|
||||
~hitInfo() {}
|
||||
void RewindTimeBin2(Long64_t timeBinsToRewind) {timeBin2-=timeBinsToRewind;}
|
||||
Int_t eventEntry;
|
||||
Int_t eventIDnumber;
|
||||
Int_t det_i;
|
||||
Int_t det_id;
|
||||
Double_t det_edep;
|
||||
Long64_t timeBin1; // repeated here in case this is not stored in a Map with First=timeBin1
|
||||
Long64_t timeBin2;
|
||||
Int_t multiHitCtr;
|
||||
hitInfo* firstMulti;
|
||||
Int_t posQual;
|
||||
|
||||
// extern double GlobalKamil;
|
||||
// typedef std::map<int,int> debugEventMapType;
|
||||
// extern debugEventMapType debugEventMap;
|
||||
// extern Bool_t bool_debugingRequired;
|
||||
};
|
||||
|
||||
class musrCounter {
|
||||
public:
|
||||
musrCounter(int CHANNEL_NR, char CHANNEL_NAME[200], char CHANNEL_TYPE, float E_THRESH, int TIME_SHIFT, double DEADTIME, Bool_t KEEP_BELOW_THRESH);
|
||||
~musrCounter();
|
||||
int GetCounterNr() {return counterNr;}
|
||||
char GetCounterType() {return counterType;}
|
||||
void SetCoincidenceCounter(musrCounter* c, int icNr) {
|
||||
int cNr = abs(icNr);
|
||||
if (icNr>0) {
|
||||
std::cout<<"SetCoincidenceCounter: Adding counter ="<<cNr<<" to coincidence with the counter "<<counterNr<<std::endl;
|
||||
koincidenceCounterMap[cNr] = c;
|
||||
}
|
||||
else {
|
||||
std::cout<<"SetCoincidenceCounter: Adding counter ="<<cNr<<" as veto to the counter "<<counterNr<<std::endl;
|
||||
vetoCounterMap[cNr] = c;
|
||||
}
|
||||
}
|
||||
void SetMaxCoincidenceTimeWindow(Long64_t val) {maxCoincidenceTimeWindow=val;}
|
||||
Long64_t GetMaxCoincidenceTimeWindow() {return maxCoincidenceTimeWindow;}
|
||||
void SetCoincidenceTimeWindowOfAllCoincidenceDetectors(char motherCounter, Long64_t maxCoinc, Long64_t min, Long64_t max);
|
||||
void SetCoincidenceTimeWindowOfAllVetoDetectors(Long64_t maxCoinc, Long64_t min, Long64_t max);
|
||||
void SetCoincidenceTimeWindow_M(Long64_t min, Long64_t max) {coincidenceTimeWindowMin_M=min; coincidenceTimeWindowMax_M=max;}
|
||||
void SetCoincidenceTimeWindow_P(Long64_t min, Long64_t max) {coincidenceTimeWindowMin_P=min; coincidenceTimeWindowMax_P=max;}
|
||||
void SetAntiCoincidenceTimeWindowMin(Long64_t min) {antiCoincidenceTimeWindowMin=min;}
|
||||
void SetAntiCoincidenceTimeWindowMax(Long64_t max) {antiCoincidenceTimeWindowMax=max;}
|
||||
Long64_t GetAntiCoincidenceTimeWindowMin() {return antiCoincidenceTimeWindowMin;}
|
||||
Long64_t GetAntiCoincidenceTimeWindowMax() {return antiCoincidenceTimeWindowMax;}
|
||||
void SetTDChistogram(char hName[200],int t0,int t1,int t2,int hNr,char hNameAdd[200]);
|
||||
void FillTDChistogram(Double_t variable, Double_t vaha);
|
||||
void DrawTDChistogram();
|
||||
void FillHitInCounter(Double_t edep, Long64_t timeBin, Long64_t timeBin2, Int_t kEntry, Int_t eveID, Int_t iDet, Int_t detectorID, Int_t eventNum, Int_t& multiCtr);
|
||||
void RemoveHitsInCounter(Long64_t timeBinLimit);
|
||||
// void RewindHitsInCounter(Long64_t timeBinsToRewind);
|
||||
void RewindHitsInCounter();
|
||||
Bool_t IsInCoincidence(Long64_t timeBin, char motherCounter);
|
||||
Bool_t GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t& timeBinOfNextHit, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep);
|
||||
Bool_t CheckForPileupMuons(Long64_t timeBin0);
|
||||
Int_t 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);
|
||||
Int_t GetNextGoodPositronPulsed(Int_t entWanted1, Int_t entWanted2, 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, Int_t& idetFirstMulti, hitInfo*& hitStruct);
|
||||
void myPrintThisCounter(Int_t evtID, Int_t detail=2);
|
||||
// void CheckClockInfo(Long64_t timeBin);
|
||||
Long64_t GetNumberOfMuonCandidates(){return numberOfMuonCandidates;}
|
||||
Long64_t GetNumberOfMuonCandidatesAfterVK(){return numberOfMuonCandidatesAfterVK;}
|
||||
Long64_t GetNumberOfMuonCandidatesAfterVKandDoubleHitRemoval(){return numberOfMuonCandidatesAfterVKandDoubleHitRemoval;}
|
||||
void DumpInfoToDumpFile(Int_t eventNr, Int_t detID, Long64_t tdcBin);
|
||||
void WriteRewindIntoDumpFile();
|
||||
|
||||
private:
|
||||
// static musrCounter* pointerToAnalysis;
|
||||
int counterNr;
|
||||
char counterName[200];
|
||||
char counterType;
|
||||
double couterEThreshold;
|
||||
Bool_t keepBelowThresholdHits; // JSL: for pulsed mode overlap
|
||||
Long64_t counterTimeShift;
|
||||
typedef std::map<int,musrCounter*> counterMapType;
|
||||
counterMapType koincidenceCounterMap;
|
||||
counterMapType vetoCounterMap;
|
||||
char TDC_histoName[200];
|
||||
int TDC_t0, TDC_t1, TDC_t2, TDC_histoNrAdd;
|
||||
char TDC_histoNameAdd[200];
|
||||
TH1D* histTDC;
|
||||
Long64_t antiCoincidenceTimeWindowMin, coincidenceTimeWindowMin_M, coincidenceTimeWindowMin_P;
|
||||
Long64_t antiCoincidenceTimeWindowMax, coincidenceTimeWindowMax_M, coincidenceTimeWindowMax_P;
|
||||
Long64_t maxCoincidenceTimeWindow;
|
||||
// typedef std::map<Long64_t,Int_t> hitMap_TYPE; // Long64_t = timeBin, Int_t=eventID
|
||||
typedef std::map<Long64_t,hitInfo*> hitMap_TYPE; // Long64_t = timeBin, hitInfo = eventID and det_i
|
||||
hitMap_TYPE hitMap;
|
||||
// std::list<Double_t> timeOfHitsList;
|
||||
// for pulsed double hit processing
|
||||
double discriminatorLastVolts;
|
||||
Long64_t discriminatorLastTime;
|
||||
hitMap_TYPE::iterator discriminatorIterator;
|
||||
Double_t discriminatorRecoveryTime; // in TDC bins!
|
||||
|
||||
Int_t doubleHitN;
|
||||
Long64_t numberOfMuonCandidates;
|
||||
Long64_t numberOfMuonCandidatesAfterVK;
|
||||
Long64_t numberOfMuonCandidatesAfterVKandDoubleHitRemoval;
|
||||
|
||||
public:
|
||||
static Bool_t bool_ignoreUnperfectMuons;
|
||||
static Bool_t bool_ignoreUnperfectPositrons;
|
||||
static Bool_t bool_WriteDataToDumpFile;
|
||||
// static ofstream dumpFile;
|
||||
// static Long64_t previousClock;
|
||||
// static Long64_t CLOCK_INTERVAL;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -49,7 +49,7 @@ void musrTH::FillTH1D(Double_t vaha, Bool_t* cond){
|
||||
for (Int_t i=0; i<musrAnalysis::nrConditions; i++) {
|
||||
if (bool_rotating_reference_frame) {
|
||||
// Double_t var = *variableToBeFilled_X;
|
||||
Double_t waha = vaha*exp((*variableToBeFilled_X)/2.19703)*cos(2*musrAnalysis::pi*rot_ref_frequency*(*variableToBeFilled_X)+rot_ref_phase);
|
||||
Double_t waha = vaha*exp((*variableToBeFilled_X)/2.19703)*cos(2*pi*rot_ref_frequency*(*variableToBeFilled_X)+rot_ref_phase);
|
||||
// std::cout<<"rot_ref_frequency="<<rot_ref_frequency<<std::endl;
|
||||
if (cond[i]) histArray1D[i]->Fill(*variableToBeFilled_X,waha);
|
||||
}
|
||||
@ -225,7 +225,7 @@ void musrTH::ListHistograms() {
|
||||
//==============================================================================================
|
||||
void musrTH::FitHistogramsIfRequired(Double_t omega) {
|
||||
if (funct==NULL) return;
|
||||
if (bool_rotating_reference_frame) omega = fabs(omega) - 2*musrAnalysis::pi*fabs(rot_ref_frequency);
|
||||
if (bool_rotating_reference_frame) omega = fabs(omega) - 2*pi*fabs(rot_ref_frequency);
|
||||
std::cout<<"============================================================================================================"<<std::endl;
|
||||
std::cout<<"Fitting \""<<funct->GetName()<<"\", funct_xMin="<<funct_xMin<<" funct_xMax="<<funct_xMax<<" omega="<<omega<<std::endl;
|
||||
if (strcmp(funct->GetName(),"funct1")==0) {funct->FixParameter(0,omega);}
|
||||
|
Reference in New Issue
Block a user