21.1.2011 Kamil Sedlak

This version contains many changes!
1) Optical photon simulation is now possible - some work still may need to be done
   (e.g. the manual is not updated yet), but it should basically work already now.
2) Changes in the musrSimAna - correction of some bugs (mainly in the coincidence
    of coincidence and veto detectors) and some other improvements
This commit is contained in:
2011-01-21 15:20:22 +00:00
parent dcc8c6119d
commit 4bfcc6aa29
17 changed files with 1266 additions and 169 deletions

View File

@ -75,12 +75,12 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
exit(1);
}
std::cout << "Configuration file \"" << charV1190FileName << "\" was opened."<<std::endl;
char line[1001];
char line[10001];
// Write out the configuration file into the output file:
std::cout << "\n\n....oooOO0OOooo........oooOO0OOooo......Configuration file used for this run....oooOO0OOooo........oooOO0OOooo......"<<std::endl;
while (!feof(fSteeringFile)) {
fgets(line,1000,fSteeringFile);
fgets(line,10000,fSteeringFile);
// if ((line[0]!='#')&&(line[0]!='\n')&&(line[0]!='\r')) // TS: Do not print comments
std::cout << line;
}
@ -120,7 +120,7 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
// }
// }
while (!feof(fSteeringFile)) {
fgets(line,1000,fSteeringFile);
fgets(line,10000,fSteeringFile);
if ((line[0]!='#')&&(line[0]!='\n')&&(line[0]!='\r')&&(line[0]!='$')&&(line[0]!='!')) {
char tmpString0[200]="Unset";
char tmpString1[200]="Unset";
@ -194,6 +194,18 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
sscanf(&line[strlen("MUSRMODE=")],"%s",&tmpString1);
musrMode = tmpString1[0];
}
else if (strcmp(tmpString0,"CLONECHANNEL")==0) {
int ichannel_orig_tmp, ichannel_new_tmp;
sscanf(&line[0],"%*s %d %d",&ichannel_orig_tmp,&ichannel_new_tmp);
bool_clonedChannelsMultimap_NotEmpty = true;
clonedChannelsMultimap.insert(std::pair<int,int>(ichannel_orig_tmp,ichannel_new_tmp));
}
else if (strcmp(tmpString0,"DEBUGEVENT")==0) {
int ieventToDebug_tmp, iLevelToDebug_tmp;
sscanf(&line[0],"%*s %d %d",&ieventToDebug_tmp,&iLevelToDebug_tmp);
bool_debugingRequired=true;
debugEventMap.insert(std::pair<int,int>(ieventToDebug_tmp,iLevelToDebug_tmp));
}
else if (strncmp(tmpString0,"musrTH",strlen("musrTH"))==0) {
// Definition of the histograms - either musrTH1D or musrTH2D
int beginningOfHistoTitle=0, endOfHistoTitle =0;
@ -355,6 +367,18 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
else if (strcmp(conditionNameTMP,"pileupEventCandidate")==0) conditionMap[iConditionTMP]=&pileupEventCandidate;
else if (strcmp(conditionNameTMP,"pileupEvent")==0) conditionMap[iConditionTMP]=&pileupEvent;
else if (strcmp(conditionNameTMP,"goodEvent_det_AND_muonDecayedInSample_gen")==0) conditionMap[iConditionTMP]=&goodEvent_det_AND_muonDecayedInSample_gen;
else if (strcmp(conditionNameTMP,"goodEvent_F_det")==0) conditionMap[iConditionTMP]=&goodEvent_F_det;
else if (strcmp(conditionNameTMP,"goodEvent_B_det")==0) conditionMap[iConditionTMP]=&goodEvent_B_det;
else if (strcmp(conditionNameTMP,"goodEvent_U_det")==0) conditionMap[iConditionTMP]=&goodEvent_U_det;
else if (strcmp(conditionNameTMP,"goodEvent_D_det")==0) conditionMap[iConditionTMP]=&goodEvent_D_det;
else if (strcmp(conditionNameTMP,"goodEvent_L_det")==0) conditionMap[iConditionTMP]=&goodEvent_L_det;
else if (strcmp(conditionNameTMP,"goodEvent_R_det")==0) conditionMap[iConditionTMP]=&goodEvent_R_det;
else if (strcmp(conditionNameTMP,"goodEvent_F_det_AND_pileupEvent")==0) conditionMap[iConditionTMP]=&goodEvent_F_det_AND_pileupEvent;
else if (strcmp(conditionNameTMP,"goodEvent_B_det_AND_pileupEvent")==0) conditionMap[iConditionTMP]=&goodEvent_B_det_AND_pileupEvent;
else if (strcmp(conditionNameTMP,"goodEvent_U_det_AND_pileupEvent")==0) conditionMap[iConditionTMP]=&goodEvent_U_det_AND_pileupEvent;
else if (strcmp(conditionNameTMP,"goodEvent_D_det_AND_pileupEvent")==0) conditionMap[iConditionTMP]=&goodEvent_D_det_AND_pileupEvent;
else if (strcmp(conditionNameTMP,"goodEvent_L_det_AND_pileupEvent")==0) conditionMap[iConditionTMP]=&goodEvent_L_det_AND_pileupEvent;
else if (strcmp(conditionNameTMP,"goodEvent_R_det_AND_pileupEvent")==0) conditionMap[iConditionTMP]=&goodEvent_R_det_AND_pileupEvent;
else {
std::cout<<" !!! ERROR: Condition of the name \""<<conditionNameTMP<<"\" not predefined ==> Add it in the musrAnalysis.cxx S T O P !!!"<<std::endl;
exit(1);
@ -404,6 +428,47 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
nscan = sscanf(pch,"%d %g",&N1,&PHASE_SHIFT);
} while (nscan==2);
}
else if (strcmp(tmpString0,"counterGrouping")==0) {
int nscan; int N1; char NAME[100];
char *pch = line + strlen("counterGrouping");
char counterGroupName[100];
nscan = sscanf(pch,"%s",counterGroupName);
char* pch1 = strstr(pch,counterGroupName)+strlen(counterGroupName);
pch = pch1;
do {
nscan = sscanf(pch,"%d",&N1);
if (strcmp(counterGroupName,"F")==0) F_posCounterList.push_back(N1);
else if (strcmp(counterGroupName,"B")==0) B_posCounterList.push_back(N1);
else if (strcmp(counterGroupName,"U")==0) U_posCounterList.push_back(N1);
else if (strcmp(counterGroupName,"D")==0) D_posCounterList.push_back(N1);
else if (strcmp(counterGroupName,"L")==0) L_posCounterList.push_back(N1);
else if (strcmp(counterGroupName,"R")==0) R_posCounterList.push_back(N1);
else {
std::cout<<"\n\n UNKNOWN COUNTER GROUP REQUIRED !!! =====> S T O P F O R C E D"<<std::endl;
std::cout<<line<<std::endl;
exit(1);
}
std::cout<<"counterGroupName="<<counterGroupName<<" N1="<<N1<<std::endl;
nscan = sscanf(pch,"%s",NAME);
char* pch2 = strstr(pch ,NAME)+strlen(NAME);
pch=pch2;
nscan = sscanf(pch,"%d",&N1);
} while (nscan==1);
}
else if (strcmp(tmpString0,"artificiallyChangeMuDecayTime")==0) {
float min, max, mmmin, mmmax;
sscanf(&line[0],"%*s %g %g %g %g %g %g %g",&min,&max,&mmmin,&mmmax);
bool_muDecayTimeTransformation = true;
muDecayTime_t_min = min;
muDecayTime_t_max = max;
muDecayTime_Transformation_min = mmmin;
muDecayTime_Transformation_max = mmmax;
if ((muDecayTime_t_max <= muDecayTime_t_min) || (muDecayTime_Transformation_max <= muDecayTime_Transformation_min)) {
std::cout<<" ERROR! musrAnalysis: error when setting the \"artificiallyChangeMuDecayTime\" parameters! Min > Max !!!"<<std::endl;
std::cout<<" ==> S T O P "<<std::endl;
exit(1);
}
}
else if (strcmp(tmpString0,"fit")==0) {
char histoName[100]; char functionName[100]; float xMin; float xMax; float p0, p1, p2, p3, p4, p5, p6;
sscanf(&line[0],"%*s %s %s %g %g %g %g %g %g %g",histoName,functionName,&xMin,&xMax,&p0,&p1,&p2,&p3,&p4,&p5,&p6);
@ -453,7 +518,8 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
funct -> SetParameter(1,p1);
}
else if (strcmp(functionName,"rotFrameTime20")==0) {
funct = new TF1("rotFrameTime20","[2]*exp(-x/2.19703)*cos(x*[0]+[1]) ");
// funct = new TF1("rotFrameTime20","[2]*exp(-x/2.19703)*cos(x*[0]+[1]) ");
funct = new TF1("rotFrameTime20","[2]*cos(x*[0]+[1]) ");
funct -> SetParameter(0,p0);
funct -> SetParameter(1,p1);
funct -> SetParameter(2,p2);
@ -574,22 +640,8 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
pileupWindowBinMax = Long64_t(pileupWindowMax/tdcresolution);
dataWindowBinMin = Long64_t( dataWindowMin/tdcresolution);
dataWindowBinMax = Long64_t( dataWindowMax/tdcresolution);
for (counterMapType::const_iterator it = allCounterMap.begin(); it!=allCounterMap.end(); ++it) {
char DetectorType = (it->second)->GetCounterType();
if (DetectorType=='M') {
(it->second)->SetMaxCoincidenceTimeWindow(pileupWindowBinMin);
(it->second)->SetCoincidenceTimeWindow(pileupWindowBinMin,pileupWindowBinMax);
(it->second)->SetCoincidenceTimeWindowOfAllCoincidenceDetectors(-mcoincwin,-mcoincwin,mcoincwin);
}
else if (DetectorType=='P') {
(it->second)->SetMaxCoincidenceTimeWindow(dataWindowBinMin);
(it->second)->SetCoincidenceTimeWindow(dataWindowBinMin,dataWindowBinMax);
(it->second)->SetCoincidenceTimeWindowOfAllCoincidenceDetectors(-pcoincwin,-pcoincwin,pcoincwin);
}
else if (DetectorType=='V') {
(it->second)->SetMaxCoincidenceTimeWindow(-vcoincwin);
(it->second)->SetCoincidenceTimeWindow(-vcoincwin,vcoincwin);
}
int iChanNr = (it->second)->GetCounterNr();
for (std::multimap<int,int>::iterator itCoinc = tmpCoincidenceMultimap.begin(); itCoinc != tmpCoincidenceMultimap.end(); ++itCoinc) {
if ((*itCoinc).first == iChanNr) {
@ -606,6 +658,26 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
}
}
for (counterMapType::const_iterator it = allCounterMap.begin(); it!=allCounterMap.end(); ++it) {
char DetectorType = (it->second)->GetCounterType();
if (DetectorType=='M') {
(it->second)->SetMaxCoincidenceTimeWindow(pileupWindowBinMin);
(it->second)->SetCoincidenceTimeWindow_M(pileupWindowBinMin,pileupWindowBinMax);
(it->second)->SetCoincidenceTimeWindowOfAllCoincidenceDetectors('M',-mcoincwin+pileupWindowBinMin,-mcoincwin,mcoincwin);
(it->second)->SetCoincidenceTimeWindowOfAllVetoDetectors(-mcoincwin+pileupWindowBinMin,-vcoincwin,vcoincwin);
}
else if (DetectorType=='P') {
(it->second)->SetMaxCoincidenceTimeWindow(dataWindowBinMin);
(it->second)->SetCoincidenceTimeWindow_P(dataWindowBinMin,dataWindowBinMax);
(it->second)->SetCoincidenceTimeWindowOfAllCoincidenceDetectors('P',-pcoincwin+dataWindowBinMin,-pcoincwin,pcoincwin);
(it->second)->SetCoincidenceTimeWindowOfAllVetoDetectors(-pcoincwin+dataWindowBinMin,-vcoincwin,vcoincwin);
}
// else if (DetectorType=='V') {
// (it->second)->SetMaxCoincidenceTimeWindow(-vcoincwin);
// (it->second)->SetCoincidenceTimeWindow(-vcoincwin,vcoincwin);
// }
}
// for (int j=0; j<maxChannels; j++) {
// for (multimap<int,int>::iterator itCoinc = tmpCoincidenceMultimap.begin(); itCoinc != tmpCoincidenceMultimap.end(); ++itCoinc) {
// std::cout << " houby [" << (*itCoinc).first << ", " << (*itCoinc).second << "]" << std::endl;
@ -656,7 +728,6 @@ void musrAnalysis::CreateHistograms() {
// omega = 850.62*fieldValue; // value used in Geant ?
omega = 851.610*fieldValue; // value from the fits of the data
hInfo->Fill(1, fieldValue);
hInfo->Fill(6, runID);
hInfo->Fill(7, hGeantParameters->GetBinContent(7));
@ -731,13 +802,19 @@ void musrAnalysis::AnalyseEvent(Long64_t iiiEntry) {
// Loop over several next event and preprocess them (i.e. fill
// them into the lists/maps of the class musrCounter).
if (bool_debugingRequired) {
if (debugEventMap[eventID]>0) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(before \"PreprocessEvent\"_________"<<std::endl;}
}
while (((iiiEntry>lastPreprocessedEntry)||(((nextUnfilledEventTime-currentTime)<safeTimeWindow))&&(!boolInfinitelyLowMuonRate)) && (lastPreprocessedEntry+1<nentries)) {
Double_t deltaT = PreprocessEvent(lastPreprocessedEntry+1);
nextUnfilledEventTime+=deltaT;
};
fChain->GetEntry(iiiEntry); InitialiseEvent();
if (bool_debugingRequired) {
if (debugEventMap[eventID]>2) PrintHitsInAllCounters();
if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(after \"PreprocessEvent\"_________"<<std::endl;}
}
// Loop over all interesting "moments", which are:
// 1) any hit in the muon counter
// 2) any new event (even if nothing was detected in the muon counter)
@ -751,7 +828,14 @@ void musrAnalysis::AnalyseEvent(Long64_t iiiEntry) {
// for (counterMapType::const_iterator it = allCounterMap.begin(); it!=allCounterMap.end(); ++it) {
// (*it).second->myPrintThisCounter(eventID);
// }
if (bool_debugingRequired) {
if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(before \"FillHistograms\"_________"<<std::endl;}
}
FillHistograms(iiiEntry);
if (bool_debugingRequired) {
if (debugEventMap[eventID]>1) {std::cout<<"DEBUGEVENT "<<eventID<<"_________________(after \"FillHistograms\"_________"<<std::endl;}
}
currentTime+=timeToNextEvent*muonRateFactor;
@ -790,6 +874,14 @@ void musrAnalysis::RewindAllTimeInfo(Long64_t timeBinsToRewind) {
//================================================================
void musrAnalysis::PrintHitsInAllCounters() {
std::cout<<"___________________\n";
for (counterMapType::const_iterator it = allCounterMap.begin(); it!=allCounterMap.end(); ++it) {
(*it).second->myPrintThisCounter(eventID,0);
}
}
//================================================================
void musrAnalysis::FillHistograms(Int_t iiiEntry) {
// std::cout<<"musrAnalysis::FillHistograms() event="<<eventID<<" , bool="<<generatedInfo<<","<<detectorInfo<<std::endl;
@ -823,7 +915,10 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) {
// Check whether there was good hit in the Positron counter
// Long64_t dataBinMin = (mCounterHitExistsForThisEventID) ? timeBin0+dataWindowBinMin : timeBinOfThePreviouslyProcessedHit-100000000;
// Long64_t dataBinMax = (mCounterHitExistsForThisEventID) ? timeBin0+dataWindowBinMax : timeBinOfThePreviouslyProcessedHit+100000000;
pileup_eventID = -1001;
pileup_muDecayDetID_double = -1001;
pileup_muDecayPosZ = -1000000000;
pileup_muDecayPosR = -1000000000;
if (mCounterHitExistsForThisEventID) {
numberOfGoodMuons++;
Long64_t dataBinMin = timeBin0+dataWindowBinMin;
@ -833,7 +928,10 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) {
if (pCounterHitExistsForThisEventID && (kEntry>0)&&(posEntry>0)&&(kEntry!=posEntry)) {
// This must be a pileup event (positron counter hit comes from the different event than the muon counter hit)
fChain->GetEntry(posEntry);
pileup_eventID = eventID;
pileup_muDecayDetID_double = muDecayDetID;
pileup_muDecayPosZ = muDecayPosZ;
pileup_muDecayPosR = sqrt(muDecayPosX*muDecayPosX+muDecayPosY*muDecayPosY);
// if (pileup_muDecayDetID_double==-1000) {
// std::cout<<"DEBUG: pileup_muDecayDetID_double==-1000, posEntry="<<posEntry<<", eventID="<<eventID<<", idetP_edep="<<idetP_edep<<", idetP="<<idetP<<", idetP_ID="<<idetP_ID<<std::endl;
// }
@ -875,7 +973,40 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) {
pileupEventCandidate = ((kEntry>0)&&(posEntry>0)&&(kEntry!=posEntry)) ? true:false;
pileupEvent = pileupEventCandidate&&goodEvent_det;
goodEvent_det_AND_muonDecayedInSample_gen = goodEvent_det && muonDecayedInSample_gen;
// if (pileupEvent) std::cout<<"pileupEvent (eventID="<<eventID<<std::endl;
// posCounterList_Iterator = find(F_posCounterList.begin(), F_posCounterList.end(), idetP_ID);
// goodEvent_F_det = posCounterList_Iterator != F_posCounterList.end()
goodEvent_F_det = goodEvent_det && ( (find(F_posCounterList.begin(), F_posCounterList.end(), idetP_ID)) != F_posCounterList.end() );
goodEvent_B_det = goodEvent_det && ( (find(B_posCounterList.begin(), B_posCounterList.end(), idetP_ID)) != B_posCounterList.end() );
goodEvent_U_det = goodEvent_det && ( (find(U_posCounterList.begin(), U_posCounterList.end(), idetP_ID)) != U_posCounterList.end() );
goodEvent_D_det = goodEvent_det && ( (find(D_posCounterList.begin(), D_posCounterList.end(), idetP_ID)) != D_posCounterList.end() );
goodEvent_L_det = goodEvent_det && ( (find(L_posCounterList.begin(), L_posCounterList.end(), idetP_ID)) != L_posCounterList.end() );
goodEvent_R_det = goodEvent_det && ( (find(R_posCounterList.begin(), R_posCounterList.end(), idetP_ID)) != R_posCounterList.end() );
// std::cout<<"goodEvent_F_det="<<goodEvent_F_det<<std::endl;
if (pileupEvent&&goodEvent_F_det) {
std::cout<<" DEBUG: Pileup Event: eventID = "<<eventID<<" pileup_eventID = "<<pileup_eventID<<" det_time10 = "<<det_time10<<std::endl;
// debugEventMap.insert(std::pair<int,int>(eventID,10));
}
goodEvent_F_det_AND_pileupEvent = goodEvent_F_det && pileupEvent;
goodEvent_B_det_AND_pileupEvent = goodEvent_B_det && pileupEvent;
goodEvent_U_det_AND_pileupEvent = goodEvent_U_det && pileupEvent;
goodEvent_D_det_AND_pileupEvent = goodEvent_D_det && pileupEvent;
goodEvent_L_det_AND_pileupEvent = goodEvent_L_det && pileupEvent;
goodEvent_R_det_AND_pileupEvent = goodEvent_R_det && pileupEvent;
// if (bool_debugingRequired && muonTriggered_det) {
// std::cout<<"DEBUG: goodEvent_det: eventID="<<eventID<<std::endl;
// if (goodEvent_det) std::cout<<" ___DETECTED___"<<std::endl;
// MyPrintTree();
// MyPrintConditions();
// }
// if (pileupEvent) {
// std::cout<<"\n NEW: pileupEvent: eventID="<<eventID<<", kEntry="<<kEntry<<", posEntry="<<posEntry<< std::endl;
// std::cout<<"det_time10 = "<<det_time10<<std::endl;
// }
// Fill pileup-variables, but only if positron comes from different muon than the trigger signal
// if (mCounterHitExistsForThisEventID&&pCounterHitExistsForThisEventID)
@ -938,25 +1069,110 @@ void musrAnalysis::InitialiseEvent() {
Double_t musrAnalysis::PreprocessEvent(Long64_t iEn) {
// std::cout<<"musrAnalysis::PreprocessEvent()"<<std::endl;
fChain->GetEntry(iEn); InitialiseEvent();
// Clone some channels into different one, if requested by user
// (This is usefull when e.g. user splits a signal from a veto
// and uses it in two different ways - e.g. once for vetoing
// muons, and second (with a different threshold) for validating
// a positron candidate. This is initiated by the
// keyword "CLONECHANNEL" in the *.v1190 file
if (bool_clonedChannelsMultimap_NotEmpty) {
// std::cout<<"det_n="<<det_n<<std::endl;
Int_t det_n_OLD=det_n;
for (Int_t i=0; i<det_n_OLD; i++) {
// std::cout<<" det_ID["<<i<<"]="<<det_ID[i]<<" edep="<<det_edep[i]<<std::endl;
clonedChannelsMultimapType::const_iterator it = clonedChannelsMultimap.find(det_ID[i]);
// std::cout<<" clonedChannelsMultimap[i]="<<clonedChannelsMultimap[i]<<std::endl;
if (it!=clonedChannelsMultimap.end()) {
int chNumTMP = it->first;
// std::cout<<"DEBUG: chNumTMP="<<chNumTMP<<" ";
std::pair<clonedChannelsMultimapType::const_iterator,clonedChannelsMultimapType::const_iterator> ret = clonedChannelsMultimap.equal_range(chNumTMP);
for (clonedChannelsMultimapType::const_iterator ittt=ret.first; ittt!=ret.second; ++ittt) {
// std::cout << " ittt->second=" << ittt->second;
int chNumNewTMP = ittt->second;
det_ID[det_n] = chNumNewTMP;
det_edep[det_n] = det_edep[i];
det_edep_el[det_n] = det_edep_el[i];
det_edep_pos[det_n] = det_edep_pos[i];
det_edep_gam[det_n] = det_edep_gam[i];
det_edep_mup[det_n] = det_edep_mup[i];
det_nsteps[det_n] = det_nsteps[i];
det_length[det_n] = det_length[i];
det_time_start[det_n] = det_time_start[i];
det_time_end[det_n] = det_time_end[i];
det_x[det_n] = det_x[i];
det_y[det_n] = det_y[i];
det_z[det_n] = det_z[i];
det_kine[det_n] = det_kine[i];
det_VrtxKine[det_n] = det_VrtxKine[i];
det_VrtxX[det_n] = det_VrtxX[i];
det_VrtxY[det_n] = det_VrtxY[i];
det_VrtxZ[det_n] = det_VrtxZ[i];
det_VrtxVolID[det_n] = det_VrtxVolID[i];
det_VrtxProcID[det_n] = det_VrtxProcID[i];
det_VrtxTrackID[det_n] = det_VrtxTrackID[i];
det_VrtxParticleID[det_n]= det_VrtxParticleID[i];
det_VvvKine[det_n] = det_VvvKine[i];
det_VvvX[det_n] = det_VvvX[i];
det_VvvY[det_n] = det_VvvY[i];
det_VvvZ[det_n] = det_VvvZ[i];
det_VvvVolID[det_n] = det_VvvVolID[i];
det_VvvProcID[det_n] = det_VvvProcID[i];
det_VvvTrackID[det_n] = det_VvvTrackID[i];
det_VvvParticleID[det_n] = det_VvvParticleID[i];
det_n++;
}
}
}
}
// std::cout<<"\n musrAnalysis::PreprocessEvent() Filling event "<<eventID<<std::endl;
// MyPrintTree();
Double_t globTime = nextUnfilledEventTime;
for (Int_t i=0; i<det_n; i++) {
// // Int_t detID=det_ID[i];
std::map<int,musrCounter*>::iterator it;
it = allCounterMap.find(det_ID[i]);
if (it==allCounterMap.end()) {
// uncomment std::cout<<"Active detector with det_ID="<<det_ID[i]<<" not found !!!"<<std::endl;
// std::cout<<"Active detector with det_ID="<<det_ID[i]<<" not found !!!"<<std::endl;
}
else {
// Double_t omega = 851.372*fieldNomVal[0];
Double_t dPhaseShift = (omega==0) ? 0:phaseShiftMap[det_ID[i]]/omega;
//cDEL if (det_ID[i]<20) std::cout<<"phaseShift = "<<phaseShiftMap[det_ID[i]]<<" dPhaseShift="<<dPhaseShift<<" tdcresolution="<<tdcresolution<<std::endl;
Long64_t timeBin = Long64_t( (globTime+det_time_start[i] )/tdcresolution );
Long64_t timeBin2 = Long64_t( (globTime+det_time_start[i]+dPhaseShift)/tdcresolution );
//cDEL if (det_ID[i]<20) std::cout<<" timeBin = "<<timeBin<<" ("<<globTime+det_time_start[i]<<")"<<std::endl;
//cDEL if (det_ID[i]<20) std::cout<<" timeBin2 = "<<timeBin2<<" ("<<globTime+det_time_start[i]+dPhaseShift<<")"<<std::endl;
Double_t t1,t2;
if (bool_muDecayTimeTransformation) {
// THIS OPTION WAS SUPOSED TO ALLOW THE USER TO SOMEHOW (IN A TRICKY AND NOT 100% RELIABLE WAY)
// SHIFT THE POSITRON COUNTS TO A RESTRICTED TIME WINDOW, AS IF THE MUON DECAYED IN SOME RESTRICTED
// TIME INTERVAL. THIS, HOWEVER, DOES NOT WORK, IN THE WAY IT IS IMPLEMENTED HERE, BECAUSE THE
// MUON SPIN ROTATION AT REST IS IGNORED HERE - IT WOULD NEED SOME FURTHER WORK TO DO, AND
// BECOMES DIFFICULT TO INTERPRET LATER ==> WORK ON THIS WAS STOPPED.
Double_t diff = muDecayTime_t_max - muDecayTime_t_min;
Double_t ttt1 = det_time_start[i];
if ((ttt1 > muDecayTime_Transformation_min) && (ttt1 < muDecayTime_Transformation_max)) {
if (muDecayTime < muDecayTime_t_min) {
ttt1 = ( Long64_t((muDecayTime_t_min-muDecayTime)/diff)+1) * diff + det_time_start[i];
}
else if (muDecayTime > muDecayTime_t_max) {
ttt1 = ( Long64_t((muDecayTime_t_min-muDecayTime)/diff)) * diff + det_time_start[i];
}
}
t1 = (globTime+ttt1 )/tdcresolution;
t2 = (globTime+ttt1+dPhaseShift)/tdcresolution;
// std::cout<<"DEBUG: det_time_start[i]="<<det_time_start[i]<<" ttt1="<<ttt1<<" t1="<<t1<<" t2="<<t2<<std::endl;
}
else {
t1 = (globTime+det_time_start[i] )/tdcresolution;
t2 = (globTime+det_time_start[i]+dPhaseShift)/tdcresolution;
}
Long64_t timeBin = Long64_t(t1);
Long64_t timeBin2 = Long64_t(t2);
(*it).second->FillHitInCounter(det_edep[i],timeBin,timeBin2,iEn,eventID,i,det_ID[i]);
}
}
@ -969,24 +1185,37 @@ Double_t musrAnalysis::PreprocessEvent(Long64_t iEn) {
//================================================================
Bool_t musrAnalysis::PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_t dataBinMax, Long64_t& tBin1, Long64_t& tBin2, Int_t& kEntry, Int_t& idetP, Int_t& idetP_ID, Double_t& idetP_edep, Bool_t& doubleHit) {
if (bool_debugingRequired) {
if (debugEventMap[eventID]>2) {std::cout<<"DEBUGEVENT:"<<eventID<<"\"PositronCounterHit\": pCounterMap.size()="<<pCounterMap.size()<<std::endl;}
}
if (pCounterMap.empty()) return false;
Bool_t positronHitFound = false;
Bool_t positronHitFound = false;
Bool_t goodPositronFound = false;
if (musrMode=='D') {
// Loop over all positron counters
for (counterMapType::const_iterator it = pCounterMap.begin(); it!=pCounterMap.end(); ++it) {
// std::cout<<" ===POSITRON==="<< pCounterMap.size()<<std::endl;
// Bool_t thereWasHit = (it->second)->GetNextGoodHitInThisEvent(evID,dataBinMin,dataBinMax,'P',tBin1,kEntry,idetP,idetP_ID,idetP_edep,doubleHit);
Bool_t thereWasHit = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep,doubleHit);
// Bool_t thereWasHit = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep,doubleHit);
Int_t positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep,doubleHit);
// std::cout<<"000000000000 tBin1="<<tBin1<<" tBin2="<<tBin2<<std::endl;
if (doubleHit) {return false;} // There were two hits in the same positron counter
if (thereWasHit) {
if (positronHitFound) {doubleHit = true; return false;} // There were two hits in two different positron counters
if (positronQuality>0) {
if (positronHitFound) {
if (bool_debugingRequired) {
if (debugEventMap[eventID]>2) {std::cout<<"DEBUGEVENT:"<<eventID<<"\"PositronCounterHit\": Coincidence with other positron candidate in other counter."<<std::endl;}
}
doubleHit = true;
return false;
} // There were two hits in two different positron counters
positronHitFound = true;
if (positronQuality>1) goodPositronFound = true;
}
}
}
return positronHitFound;
return goodPositronFound;
}
//================================================================

View File

@ -22,6 +22,13 @@
class musrTH;
//#include "musrSimGlobal.hh"
typedef std::map<int,int> debugEventMapType;
extern debugEventMapType debugEventMap;
extern Bool_t bool_debugingRequired;
class musrAnalysis {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
@ -199,7 +206,10 @@ public :
Double_t gen_time10;
Double_t det_time10_MINUS_gen_time10;
Double_t det_time20;
Double_t pileup_eventID;
Double_t pileup_muDecayDetID_double;
Double_t pileup_muDecayPosZ;
Double_t pileup_muDecayPosR;
typedef std::map<int, Bool_t*> conditionMapType;
@ -216,6 +226,18 @@ public :
Bool_t pileupEventCandidate;
Bool_t pileupEvent;
Bool_t goodEvent_det_AND_muonDecayedInSample_gen;
Bool_t goodEvent_F_det;
Bool_t goodEvent_B_det;
Bool_t goodEvent_U_det;
Bool_t goodEvent_D_det;
Bool_t goodEvent_L_det;
Bool_t goodEvent_R_det;
Bool_t goodEvent_F_det_AND_pileupEvent;
Bool_t goodEvent_B_det_AND_pileupEvent;
Bool_t goodEvent_U_det_AND_pileupEvent;
Bool_t goodEvent_D_det_AND_pileupEvent;
Bool_t goodEvent_L_det_AND_pileupEvent;
Bool_t goodEvent_R_det_AND_pileupEvent;
musrAnalysis(TTree *tree=0);
virtual ~musrAnalysis();
@ -234,6 +256,7 @@ public :
virtual void RemoveOldHitsFromCounters(Long64_t timeBinLimit);
// virtual void RewindAllTimeInfo(Double_t timeToRewind);
virtual void RewindAllTimeInfo(Long64_t timeBinsToRewind);
virtual void PrintHitsInAllCounters();
virtual void InitialiseEvent();
virtual Double_t PreprocessEvent(Long64_t iEn);
virtual Bool_t PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_t dataBinMax, Long64_t& tBin1, Long64_t& tBin2, Int_t& kEntry, Int_t& idetP, Int_t& idetP_ID, Double_t& idetP_edep, Bool_t& doubleHit);
@ -247,6 +270,10 @@ public :
TH1D* hGeantParameters;
TH1D* hInfo;
// typedef std::map<int,int> debugEventMapType;
// debugEventMapType debugEventMap;
// Bool_t bool_debugingRequired;
static const Double_t pi=3.14159265358979324;
private:
@ -290,6 +317,8 @@ public :
counterMapType allCounterMap;
Int_t testIVar1;
Double_t omega;
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;
@ -327,6 +356,19 @@ private:
typedef std::multimap<Int_t,Int_t> humanDecayMultimapType;
humanDecayMapType humanDecayMap;
humanDecayMultimapType humanDecayMultimap;
typedef std::multimap<int,int> clonedChannelsMultimapType;
clonedChannelsMultimapType clonedChannelsMultimap;
Bool_t bool_clonedChannelsMultimap_NotEmpty;
// List of group of detectors: F,B,U,D,L,R:
std::list <Int_t> F_posCounterList;
std::list <Int_t> B_posCounterList;
std::list <Int_t> U_posCounterList;
std::list <Int_t> D_posCounterList;
std::list <Int_t> L_posCounterList;
std::list <Int_t> R_posCounterList;
// std::list <Int_t>::iterator posCounterList_Iterator;
};
#endif
@ -399,7 +441,10 @@ musrAnalysis::musrAnalysis(TTree *tree)
variableMap["det_time10"]=&det_time10;
variableMap["gen_time10"]=&gen_time10;
variableMap["det_time10_MINUS_gen_time10"]=&det_time10_MINUS_gen_time10;
variableMap["pileup_eventID"]=&pileup_eventID;
variableMap["pileup_muDecayDetID"]=&pileup_muDecayDetID_double;
variableMap["pileup_muDecayPosZ"]=&pileup_muDecayPosZ;
variableMap["pileup_muDecayPosR"]=&pileup_muDecayPosR;
variableMap["det_time20"]=&det_time20;
testIVar1=0;
@ -407,6 +452,9 @@ musrAnalysis::musrAnalysis(TTree *tree)
motherOfHumanDecayHistograms=NULL;
humanDecayPileupHistograms=NULL;
motherOfHumanDecayPileupHistograms=NULL;
bool_muDecayTimeTransformation = false;
bool_clonedChannelsMultimap_NotEmpty = false;
bool_debugingRequired = false;
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.

View File

@ -2,6 +2,10 @@
#include "musrCounter.hh"
#include "TCanvas.h"
typedef std::map<int,int> 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) {
@ -17,8 +21,12 @@ musrCounter::musrCounter(int CHANNEL_NR, char CHANNEL_NAME[200], char CHANNEL_TY
TDC_t1=0;
TDC_t2=0;
TDC_histoNrAdd=0;
coincidenceTimeWindowMin=0;
coincidenceTimeWindowMax=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;
@ -74,7 +82,7 @@ void musrCounter::RemoveHitsInCounter(Long64_t timeBinLimit) {
// 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<<" hitMap.size()="<<hitMap.size()<<" maxCoincidenceTimeWindow="<<maxCoincidenceTimeWindow<<" bins of tdcresolution."<<std::endl;
// 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;
@ -104,19 +112,31 @@ void musrCounter::RewindHitsInCounter(Long64_t timeBinsToRewind) {
}
//================================================================
Bool_t musrCounter::IsInCoincidence(Long64_t timeBin, Bool_t ignoreHitsAtBinZero, Long64_t timeBinMinimum, Long64_t timeBinMaximum){
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 + counterTimeShift - counterTimeShiftOfRequestingCounter;
Long64_t timeBinToTest = timeBin;
// 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).
Long64_t timeBinMin = (timeBinMinimum==-123456789) ? timeBinToTest + coincidenceTimeWindowMin : timeBinToTest + timeBinMinimum;
Long64_t timeBinMax = (timeBinMaximum==-123456789) ? timeBinToTest + coincidenceTimeWindowMax : timeBinToTest + timeBinMaximum;
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)) {
@ -157,17 +177,14 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t&
// std::cout<<"*** "<<evtID<<" eventNumber="<<eventNumber<<" canditas="<<numberOfMuonCandidates<<std::endl;
// 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
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,counterTimeShift) ) goto endOfThisHit; // coincidence with veto found ==> skip hit
if ( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp) ) goto endOfThisHit; // coincidence with veto found ==> skip hit
if ( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'M') ) goto endOfThisHit; // coincidence with veto found ==> skip hit
}
// Check coincidences with other hits in the M counter
// it is expected that there is only one M counter
// if (this->IsInCoincidence(timeBinOfCount_tmp,counterTimeShift,true) ) { // coincidence with another M-counter hit ==> skip hit
if (this->IsInCoincidence(timeBinOfCount_tmp,true) ) { // coincidence with another M-counter hit ==> skip hit
if (this->IsInCoincidence(timeBinOfCount_tmp,'M',true) ) { // coincidence with another M-counter hit ==> skip hit
doubleHitFound = true;
// std::cout<<"UJGUR double hit found"<<std::endl;
goto endOfThisHit;
@ -187,35 +204,58 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t&
}
//================================================================
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) {
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
if (hitMap.empty()) return false;
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)) continue; // This hit is out of the data interval ==> skip it
if ((timeBinOfCount_tmp <= timeBinMin) || (timeBinOfCount_tmp > timeBinMax)) {
if (bool_debugingRequired) {
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"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
positronQuality=1;
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
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:"<<evtID<<"\"GetNextGoodPositron\": Coincidence required but not found"<<std::endl;}
}
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
if ( (itCounter->second)->IsInCoincidence(timeBinOfCount_tmp,'P') ) {
if (bool_debugingRequired) {
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Coincidence vith veto detector found"<<std::endl;}
}
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 <timeBinMin,timeBinMax>.
// 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
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:"<<evtID<<"\"GetNextGoodPositron\": Coincidence with other positron candidate in the same counter."<<std::endl;}
}
doubleHitFound = true;
// std::cout<<"tttttttttttttttttttt doubleHitN="<<doubleHitN++<<std::endl;
goto endOfThisHit;
@ -227,50 +267,57 @@ Bool_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64
idetEdep = (it->second)->det_edep;
timeBinOfNextGoodHit = timeBinOfCount_tmp;
timeBinOfNextGoodHit_phaseShifted = (it->second) -> timeBin2;
if (bool_debugingRequired) {
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Good positron candidate found in this counter."<<std::endl;}
}
//cDEL std::cout<<"timeBinOfNextGoodHit ="<<timeBinOfNextGoodHit<<" timeBinOfNextGoodHit_phaseShifted = "<<timeBinOfNextGoodHit_phaseShifted<<std::endl;
return true;
return 2;
endOfThisHit:
continue;
;
// continue;
}
return false;
return positronQuality;
}
//================================================================
void musrCounter::SetCoincidenceTimeWindowOfAllCoincidenceDetectors(Long64_t maxCoinc, Long64_t min, Long64_t max) {
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) {
if ( ( ((it->second)->GetMaxCoincidenceTimeWindow()) !=0) &&
( ((it->second)->GetMaxCoincidenceTimeWindow()) !=maxCoinc) ) {
std::cout<<" !!!! ERROR SetCoincidenceTimeWindowOfAllCoincidenceDetectors : coincidenceTimeWindow set multiple times! ==> S T O P !!!"<<std::endl;
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);
}
(it->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 !!!"<<std::endl;
exit(1);
}
(it->second)->SetMaxCoincidenceTimeWindow(maxCoinc);
(it->second)->SetCoincidenceTimeWindow(min,max);
Long64_t maxCoinc_AlreadySet = ((it->second)->GetMaxCoincidenceTimeWindow());
if (maxCoinc < maxCoinc_AlreadySet) (it->second)->SetMaxCoincidenceTimeWindow(maxCoinc);
(it->second)->SetAntiCoincidenceTimeWindow(min,max);
}
}
//================================================================
void musrCounter::myPrintThisCounter(Int_t evtID) {
void musrCounter::myPrintThisCounter(Int_t evtID, Int_t detail) {
Bool_t eventMixing=false;
std::cout<<"musrCounter::myPrintThisCounter: counterNr="<<counterNr<<": ";
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->second)->eventIDnumber<<",";
if (evtID != (it->second)->eventIDnumber) {eventMixing=true;}
}
if (eventMixing) {std::cout<<" Potential event mmmmmmmmixing";}
if (eventMixing) {std::cout<<" Potential event mixing";}
std::cout<<std::endl;
}

View File

@ -18,6 +18,11 @@ public:
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 {
@ -39,19 +44,21 @@ class musrCounter {
}
void SetMaxCoincidenceTimeWindow(Long64_t val) {maxCoincidenceTimeWindow=val;}
Long64_t GetMaxCoincidenceTimeWindow() {return maxCoincidenceTimeWindow;}
void SetCoincidenceTimeWindowOfAllCoincidenceDetectors(Long64_t maxCoinc, Long64_t min, Long64_t max);
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(Long64_t min, Long64_t max) {coincidenceTimeWindowMin=min; coincidenceTimeWindowMax=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 SetAntiCoincidenceTimeWindow(Long64_t min, Long64_t max) {antiCoincidenceTimeWindowMin=min; antiCoincidenceTimeWindowMax=max;}
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);
void RemoveHitsInCounter(Long64_t timeBinLimit);
void RewindHitsInCounter(Long64_t timeBinsToRewind);
Bool_t IsInCoincidence(Long64_t timeBin, Bool_t ignoreHitsAtBinZero=false, Long64_t timeBinMinimum=-123456789, Long64_t timeBinMaximum=-123456789);
Bool_t IsInCoincidence(Long64_t timeBin, char motherCounter, Bool_t ignoreHitsAtBinZero=false, Long64_t timeBinMinimum=-123456789, Long64_t timeBinMaximum=-123456789);
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& doubleHitFound);
Bool_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, Bool_t& doubleHitFound);
void myPrintThisCounter(Int_t evtID);
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, Bool_t& doubleHitFound);
void myPrintThisCounter(Int_t evtID, Int_t detail=2);
Long64_t GetNumberOfMuonCandidates(){return numberOfMuonCandidates;}
@ -69,8 +76,8 @@ class musrCounter {
int TDC_t0, TDC_t1, TDC_t2, TDC_histoNrAdd;
char TDC_histoNameAdd[200];
TH1D* histTDC;
Long64_t coincidenceTimeWindowMin;
Long64_t coincidenceTimeWindowMax;
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

View File

@ -47,7 +47,8 @@ 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;
if (cond[i]) histArray1D[i]->Fill(*variableToBeFilled_X,vaha*cos(2*musrAnalysis::pi*rot_ref_frequency*(*variableToBeFilled_X)+rot_ref_phase));
Double_t waha = vaha*exp((*variableToBeFilled_X)/2.19703)*cos(2*musrAnalysis::pi*rot_ref_frequency*(*variableToBeFilled_X)+rot_ref_phase);
if (cond[i]) histArray1D[i]->Fill(*variableToBeFilled_X,waha);
}
else {
if (cond[i]) histArray1D[i]->Fill(*variableToBeFilled_X,vaha);
@ -223,7 +224,7 @@ void musrTH::FitHistogramsIfRequired(Double_t omega) {
for (Int_t i=0; i<musrAnalysis::nrConditions; i++) {
// std::cout<<"fitted histogram pointer="<<histArray1D[i]<<std::endl;
histArray1D[i]->Fit(funct,"","",funct_xMin,funct_xMax);
histArray1D[i]->Fit(funct,"WW","",funct_xMin,funct_xMax);
// histArray1D[i]->Fit(funct,"LL","",funct_xMin,funct_xMax);
}
// if (strcmp(funct->GetName(),"simpleExpoPLUSconst")==0) {