28.10.2011 Kamil Sedlak
1) musrSimAna significantly rewritten, but still needs to be checked. 2) changed way how some optical photon properties are simulated, + added cross-talk effects (if requested).
This commit is contained in:
@ -100,7 +100,7 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
|
||||
pcoincwin = 40;
|
||||
vcoincwin = 80;
|
||||
muonRateFactor = 1.;
|
||||
rewindTimeBins = 1000000000;
|
||||
// rewindTimeBins = 1000000000;
|
||||
dataWindowMin = -0.2;
|
||||
dataWindowMax = 10.0;
|
||||
pileupWindowMin = -10.5;
|
||||
@ -176,7 +176,9 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
|
||||
}
|
||||
else if (strncmp(tmpString0,"REWINDTIMEBINS=",strlen("REWINDTIMEBINS="))==0) {
|
||||
sscanf(&line[strlen("REWINDTIMEBINS=")],"%d",&tmpivar);
|
||||
rewindTimeBins = tmpivar; std::cout<<" JUHELAK: rewindTimeBins="<<rewindTimeBins<<std::endl;
|
||||
if (tmpivar<0) {rewindTimeBins = Long64_t(tmpivar)* Long64_t(tmpivar);}
|
||||
else {rewindTimeBins = tmpivar;}
|
||||
std::cout<<" JUHELAK: rewindTimeBins="<<rewindTimeBins<<std::endl;
|
||||
}
|
||||
else if (strncmp(tmpString0,"DATAWINDOWMIN=",strlen("DATAWINDOWMIN="))==0) {
|
||||
sscanf(&line[strlen("DATAWINDOWMIN=")],"%g",&tmpfvar);
|
||||
@ -218,6 +220,23 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
|
||||
bool_debugingRequired=true;
|
||||
debugEventMap.insert(std::pair<int,int>(ieventToDebug_tmp,iLevelToDebug_tmp));
|
||||
}
|
||||
else if (strcmp(tmpString0,"WRITE_OUT_DUMP_FILE")==0) {
|
||||
// int clock_channelID_tmp;
|
||||
// int clock_interval_tmp;
|
||||
// sscanf(&line[0],"%*s %s %d %d",tmpString1,&clock_channelID_tmp,&clock_interval_tmp);
|
||||
sscanf(&line[0],"%*s %s",tmpString1);
|
||||
// clock_channelID = clock_channelID_tmp;
|
||||
// clock_interval = clock_interval_tmp;
|
||||
musrCounter::bool_WriteDataToDumpFile = true;
|
||||
// std::cout<<"tmpString1="<<tmpString1<<std::endl;
|
||||
if ((strcmp(tmpString1,"")!=0)&&(strcmp(tmpString1,"Unset")!=0)) musrCounter::dumpFile.open(tmpString1);
|
||||
// musrCounter::dumpFile.open("dumpFile.txt");
|
||||
if (! (musrCounter::dumpFile.is_open()) ) {
|
||||
std::cout<<"Writing data into a DumpFile was requested, but the dump file can not be opened!"<<std::cout;
|
||||
std::cout<<" ===> STOP !!!"<<std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (strcmp(tmpString0,"USE_UNPERFECT_POSITRONS_IN_DOUBLE_HITS")==0) {
|
||||
musrCounter::bool_ignoreUnperfectPositrons = false;
|
||||
}
|
||||
@ -697,11 +716,6 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
|
||||
jj+=strlen(tmpCoinc);
|
||||
int iCoinc=atoi(tmpCoinc);
|
||||
if (iCoinc==987654321) continue;
|
||||
//ckdel 20.9.2010 if ((maxChannels<=tmpChannel)||(maxChannels<=iCoinc)) {
|
||||
//ckdel 20.9.2010 std::cout<<" Channel number ("<<tmpChannel<<") or channel coincidence required ("<<iCoinc
|
||||
//ckdel 20.9.2010 <<") larger than maxChannels ("<<maxChannels<<") ==> S T O P"<<std::endl;
|
||||
//ckdel 20.9.2010 exit(1);
|
||||
//ckdel 20.9.2010 }
|
||||
tmpCoincidenceMultimap.insert(std::pair<int, int>(tmpChannel,iCoinc));
|
||||
// tmpCoincidenceMultimap[tmpChannel][abs(iCoinc)]=iCoinc;
|
||||
} while (jj<endOfCoincidenceArray);
|
||||
@ -766,13 +780,13 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
|
||||
char DetectorType = (it->second)->GetCounterType();
|
||||
if (DetectorType=='M') {
|
||||
(it->second)->SetMaxCoincidenceTimeWindow(pileupWindowBinMin);
|
||||
(it->second)->SetCoincidenceTimeWindow_M(pileupWindowBinMin,pileupWindowBinMax);
|
||||
// (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)->SetCoincidenceTimeWindow_P(dataWindowBinMin,dataWindowBinMax);
|
||||
(it->second)->SetCoincidenceTimeWindowOfAllCoincidenceDetectors('P',-pcoincwin+dataWindowBinMin,-pcoincwin,pcoincwin);
|
||||
(it->second)->SetCoincidenceTimeWindowOfAllVetoDetectors(-pcoincwin+dataWindowBinMin,-vcoincwin,vcoincwin);
|
||||
}
|
||||
@ -835,7 +849,7 @@ void musrAnalysis::CreateHistograms() {
|
||||
hInfo->Fill(1, fieldValue);
|
||||
hInfo->Fill(6, runID);
|
||||
hInfo->Fill(7, hGeantParameters->GetBinContent(7));
|
||||
std::cout<<"musrAnalysis::CreateHistograms(): fieldValue="<<fieldValue<<"T, omega="<<omega<<std::endl;
|
||||
std::cout<<"musrAnalysis::CreateHistograms(): fieldValue="<<fieldValue<<"T, omega="<<omega<<std::endl;
|
||||
}
|
||||
//================================================================
|
||||
|
||||
@ -884,6 +898,9 @@ void musrAnalysis::SaveHistograms(char* runChar, char* v1190FileName) {
|
||||
fHistograms->Close();
|
||||
delete fHistograms;
|
||||
|
||||
if (musrCounter::bool_WriteDataToDumpFile==true) {
|
||||
musrCounter::dumpFile.close();
|
||||
}
|
||||
|
||||
//==============================
|
||||
|
||||
@ -956,7 +973,8 @@ void musrAnalysis::AnalyseEvent(Long64_t iiiEntry) {
|
||||
if (!boolInfinitelyLowMuonRate) RemoveOldHitsFromCounters(currentTimeBin-1); // Remove all hits that can not influence the next event
|
||||
else RemoveOldHitsFromCounters(std::numeric_limits<Long64_t>::max()/2);
|
||||
if (currentTimeBin>rewindTimeBins) { // When the time variables start to be too large, rewind the time info everywhere;
|
||||
RewindAllTimeInfo(rewindTimeBins);
|
||||
// RewindAllTimeInfo(rewindTimeBins);
|
||||
RewindAllTimeInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@ -974,14 +992,23 @@ void musrAnalysis::RemoveOldHitsFromCounters(Long64_t timeBinLimit) {
|
||||
//================================================================
|
||||
|
||||
//void musrAnalysis::RewindAllTimeInfo(Double_t timeToRewind) {
|
||||
void musrAnalysis::RewindAllTimeInfo(Long64_t timeBinsToRewind) {
|
||||
//void musrAnalysis::RewindAllTimeInfo(Long64_t timeBinsToRewind) {
|
||||
void musrAnalysis::RewindAllTimeInfo() {
|
||||
Long64_t timeBinsToRewind = rewindTimeBins;
|
||||
if (musrCounter::bool_WriteDataToDumpFile) {
|
||||
// Long64_t currentTimeBin = Long64_t(currentTime/tdcresolution);
|
||||
// mCounter->CheckClockInfo(currentTimeBin);
|
||||
mCounter->WriteRewindIntoDumpFile();
|
||||
// musrCounter::previousClock -= timeBinsToRewind;
|
||||
}
|
||||
currentTime -= timeBinsToRewind*tdcresolution;
|
||||
nextUnfilledEventTime -= timeBinsToRewind*tdcresolution;
|
||||
numberOfRewinds++;
|
||||
// Loop over all timing information and rewind it by "timeToRewind";
|
||||
// std::cout<<"musrAnalysis::RewindAllTimeInfo()"<<std::endl;
|
||||
for (counterMapType::const_iterator it = allCounterMap.begin(); it!=allCounterMap.end(); ++it) {
|
||||
(*it).second->RewindHitsInCounter(timeBinsToRewind);
|
||||
// (*it).second->RewindHitsInCounter(timeBinsToRewind);
|
||||
(*it).second->RewindHitsInCounter();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1019,7 +1046,8 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) {
|
||||
// std::cout<<" FillHistograms: timeBinOfThePreviouslyProcessedHit = "<<timeBinOfThePreviouslyProcessedHit<<std::endl;
|
||||
// mCounterHitExistsForThisEventID = mCounter->GetNextGoodHitInThisEvent(eventID,timeBinOfThePreviouslyProcessedHit,0,'M',timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM);
|
||||
// mCounterHitExistsForThisEventID = mCounter->GetNextGoodMuon(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM);
|
||||
mCounterHitExistsForThisEventID = MuonCounterHit(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep);
|
||||
// mCounterHitExistsForThisEventID = MuonCounterHit(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep);
|
||||
mCounterHitExistsForThisEventID = mCounter->GetNextGoodMuon(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep);
|
||||
timeBinOfThePreviouslyProcessedHit = timeBin0;
|
||||
|
||||
//___________________________________________________________
|
||||
@ -1225,7 +1253,8 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) {
|
||||
// std::cout<<" FillHistograms: timeBinOfThePreviouslyProcessedHit = "<<timeBinOfThePreviouslyProcessedHit<<std::endl;
|
||||
// mCounterHitExistsForThisEventID = mCounter->GetNextGoodHitInThisEvent(eventID,timeBinOfThePreviouslyProcessedHit,0,'M',timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM);
|
||||
// mCounterHitExistsForThisEventID = mCounter->GetNextGoodMuon(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep,doubleHitM);
|
||||
mCounterHitExistsForThisEventID = MuonCounterHit(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep);
|
||||
// mCounterHitExistsForThisEventID = MuonCounterHit(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep);
|
||||
mCounterHitExistsForThisEventID = mCounter->GetNextGoodMuon(eventID,timeBinOfThePreviouslyProcessedHit,timeBin0,kEntry,idetM,idetM_ID,idetM_edep);
|
||||
timeBinOfThePreviouslyProcessedHit = timeBin0;
|
||||
// if (mCounterHitExistsForThisEventID) std::cout<<" YYYYYYYYYYYYYYYYYYY check this : LOOOPING AGAIN"<<std::endl;
|
||||
oncePerEvent=false;
|
||||
@ -1322,37 +1351,14 @@ Double_t musrAnalysis::PreprocessEvent(Long64_t iEn) {
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
Double_t t1 = (globTime+det_time_start[i] )/tdcresolution;
|
||||
Double_t 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]);
|
||||
(*it).second->FillHitInCounter(det_edep[i],timeBin,timeBin2,iEn,eventID,i,det_ID[i],eventID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1363,14 +1369,14 @@ Double_t musrAnalysis::PreprocessEvent(Long64_t iEn) {
|
||||
}
|
||||
|
||||
//================================================================
|
||||
Bool_t musrAnalysis::MuonCounterHit(Int_t evID, Long64_t timeBinMin, Long64_t& timeBin0, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep) {
|
||||
Bool_t mCounterHitCanditateExists = mCounter->GetNextGoodMuon(evID,timeBinMin,timeBin0,kEntry,idet,idetID,idetEdep);
|
||||
if (!mCounterHitCanditateExists) return false;
|
||||
// Check for other muons within the pileup window:
|
||||
if ( mCounter->CheckForPileupMuons(timeBin0,kEntry) ) return false; // This muon candidate is killed due to a double hit rejection.
|
||||
return true;
|
||||
}
|
||||
|
||||
//Bool_t musrAnalysis::MuonCounterHit(Int_t evID, Long64_t timeBinMin, Long64_t& timeBin0, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep) {
|
||||
// Bool_t mCounterHitCanditateExists = mCounter->GetNextGoodMuon(evID,timeBinMin,timeBin0,kEntry,idet,idetID,idetEdep);
|
||||
// if (!mCounterHitCanditateExists) return false;
|
||||
// // Check for other muons within the pileup window:
|
||||
// if ( mCounter->CheckForPileupMuons(timeBin0,kEntry) ) return false; // This muon candidate is killed due to a double hit rejection.
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
//================================================================
|
||||
Bool_t musrAnalysis::PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_t dataBinMax, Long64_t& tBin1, Long64_t& tBin2, Int_t& kEntry, Int_t& idetP, Int_t& idetP_ID, Double_t& idetP_edep) {
|
||||
|
||||
@ -1379,39 +1385,48 @@ Bool_t musrAnalysis::PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_
|
||||
}
|
||||
if (pCounterMap.empty()) return false;
|
||||
|
||||
Bool_t positronHitFound = false;
|
||||
// Bool_t positronHitFound = false;
|
||||
Bool_t goodPositronFound = false;
|
||||
Int_t positronQuality = 0;
|
||||
// std::cout<<"Debug 10------------------------------"<<std::endl;
|
||||
if (musrMode=='D') {
|
||||
// Loop over all positron counters
|
||||
for (counterMapType::const_iterator it = pCounterMap.begin(); it!=pCounterMap.end(); ++it) {
|
||||
// std::cout<<"Debug 20"<<std::endl;
|
||||
Long64_t dataBinMinimum = dataBinMin;
|
||||
do {
|
||||
// std::cout<<"Debug 30"<<std::endl;
|
||||
positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMinimum,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep);
|
||||
// std::cout<<"Debug 40 positronQuality="<<positronQuality<<std::endl;
|
||||
dataBinMinimum=tBin1+1; // If a positron is found, one needs to search again through the remaining hits in this counter.
|
||||
if (positronQuality>0) {
|
||||
// std::cout<<"Debug 50"<<std::endl;
|
||||
if (positronHitFound) { // Positron found now but also previously ==> double hit ==> through away this event.
|
||||
// std::cout<<"Debug 60"<<std::endl;
|
||||
if (bool_debugingRequired) {
|
||||
if (debugEventMap[eventID]>2) {std::cout<<"DEBUGEVENT:"<<eventID
|
||||
<<"\"PositronCounterHit\": Coincidence with other positron candidate in other counter."<<std::endl;}
|
||||
}
|
||||
return false;
|
||||
} // end of "positronHitFound"
|
||||
// std::cout<<"Debug 70"<<std::endl;
|
||||
positronHitFound = true;
|
||||
if (positronQuality>1) goodPositronFound = true;
|
||||
}
|
||||
// std::cout<<"Debug 80"<<std::endl;
|
||||
} while (positronQuality>0);
|
||||
// std::cout<<"Debug 90"<<std::endl;
|
||||
positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep);
|
||||
if (positronQuality==3) return false; // double hit was found in the same counter
|
||||
if (positronQuality==2) {
|
||||
if (goodPositronFound) return false; // double hit was found in a different counter
|
||||
goodPositronFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Long64_t dataBinMinimum = dataBinMin;
|
||||
// do {
|
||||
// // std::cout<<"Debug 30"<<std::endl;
|
||||
// positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMinimum,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep);
|
||||
// // std::cout<<"Debug 40 positronQuality="<<positronQuality<<std::endl;
|
||||
// dataBinMinimum=tBin1+1; // If a positron is found, one needs to search again through the remaining hits in this counter.
|
||||
// if (positronQuality>0) {
|
||||
// // std::cout<<"Debug 50"<<std::endl;
|
||||
// if (positronHitFound) { // Positron found now but also previously ==> double hit ==> through away this event.
|
||||
// // std::cout<<"Debug 60"<<std::endl;
|
||||
// if (bool_debugingRequired) {
|
||||
// if (debugEventMap[eventID]>2) {std::cout<<"DEBUGEVENT:"<<eventID
|
||||
// <<"\"PositronCounterHit\": Coincidence with other positron candidate in other counter."<<std::endl;}
|
||||
// }
|
||||
// return false;
|
||||
// } // end of "positronHitFound"
|
||||
// // std::cout<<"Debug 70"<<std::endl;
|
||||
// positronHitFound = true;
|
||||
// if (positronQuality>1) goodPositronFound = true;
|
||||
// }
|
||||
// // std::cout<<"Debug 80"<<std::endl;
|
||||
// } while (positronQuality>0);
|
||||
// // std::cout<<"Debug 90"<<std::endl;
|
||||
// }
|
||||
// std::cout<<"Debug 100 positronQuality="<<positronQuality<<std::endl;
|
||||
|
||||
if (goodPositronFound) return true;
|
||||
}
|
||||
// std::cout<<"Debug 110"<<std::endl;
|
||||
|
Reference in New Issue
Block a user