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:
@@ -1,6 +1,7 @@
|
||||
//#include <iostream>
|
||||
#include "musrCounter.hh"
|
||||
#include "TCanvas.h"
|
||||
#include "musrAnalysis.hh"
|
||||
|
||||
typedef std::map<int,int> debugEventMapType;
|
||||
debugEventMapType debugEventMap;
|
||||
@@ -8,6 +9,10 @@ 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......
|
||||
|
||||
@@ -68,7 +73,7 @@ void musrCounter::DrawTDChistogram() {
|
||||
}
|
||||
|
||||
//================================================================
|
||||
void musrCounter::FillHitInCounter(Double_t edep, Long64_t timeBin, Long64_t timeBin2, Int_t kEntry, Int_t eveID, Int_t iDet, Int_t detectorID){
|
||||
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;
|
||||
@@ -77,6 +82,11 @@ void musrCounter::FillHitInCounter(Double_t edep, Long64_t timeBin, Long64_t tim
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,55 +109,46 @@ void musrCounter::RemoveHitsInCounter(Long64_t timeBinLimit) {
|
||||
}
|
||||
|
||||
//================================================================
|
||||
void musrCounter::RewindHitsInCounter(Long64_t timeBinsToRewind) {
|
||||
//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) {
|
||||
// std::cout<<"musrCounter::RewindHitsInCounter: "<<std::endl;
|
||||
Long64_t tempBinT = it->first;
|
||||
// int tempEvnr= it->second;
|
||||
// hitMap_TMP.insert( std::pair<Long64_t,int>(tempBinT-timeBinsToRewind,tempEvnr) );
|
||||
hitInfo* tempEvnr= it->second;
|
||||
tempEvnr->RewindTimeBin2(timeBinsToRewind);
|
||||
hitMap_TMP.insert( std::pair<Long64_t,hitInfo*>(tempBinT-timeBinsToRewind,tempEvnr) );
|
||||
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, Bool_t ignoreHitsAtBinZero, Long64_t timeBinMinimum, Long64_t timeBinMaximum){
|
||||
Bool_t musrCounter::IsInCoincidence(Long64_t timeBin, char motherCounter){
|
||||
// timeBin ... time bin, at which the coincidence is searched
|
||||
// counterTimeShiftOfRequestingCounter ... time shift (in bin units) of the counter, for which the coincidence is searched
|
||||
// ignoreHitsAtBinZero ... if "true", hits at timeBin will be ignored (needed for searching of coincidence of M counter
|
||||
// with other M counters or P counters with other P counters)
|
||||
// "false" should be used for coincidence detectors and vetos.
|
||||
|
||||
if (hitMap.empty()) return false;
|
||||
// Long64_t timeBinToTest = timeBin;
|
||||
Long64_t timeBinMin;
|
||||
Long64_t timeBinMax;
|
||||
|
||||
// If timeBinMinimum and timeBinMaximum are not specified, use internal time window of the detector (koincidence or veto detectors).
|
||||
// Otherwise use timeBinMinimum and timeBinMaximum (e.g.coincidence of a positron counter with other positron counters).
|
||||
if (timeBinMinimum!=-123456789) timeBinMin = timeBin + timeBinMinimum; // time window requested through "timeBinMinimum"
|
||||
else if (counterType == 'V') timeBinMin = timeBin + antiCoincidenceTimeWindowMin; // this is veto detector
|
||||
else if (motherCounter=='M') timeBinMin = timeBin + coincidenceTimeWindowMin_M; // this is coinc. detector (or M counter) connected to M
|
||||
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 (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
|
||||
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
|
||||
|
||||
// Long64_t timeBinMin = (timeBinMinimum==-123456789) ? timeBin + coincidenceTimeWindowMin : timeBin + timeBinMinimum;
|
||||
// Long64_t timeBinMax = (timeBinMaximum==-123456789) ? timeBin + coincidenceTimeWindowMax : timeBin + timeBinMaximum;
|
||||
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
|
||||
Long64_t timeBinOfCount_tmp = it->first;
|
||||
if ((timeBinOfCount_tmp >= timeBinMin) && (timeBinOfCount_tmp <= timeBinMax)) {
|
||||
if ((timeBin!=timeBinOfCount_tmp)||(!ignoreHitsAtBinZero)) {
|
||||
return true;
|
||||
}
|
||||
// if ((timeBin!=timeBinOfCount_tmp)||(!ignoreHitsAtBinZero)) {
|
||||
return true;
|
||||
// }
|
||||
}
|
||||
else if (timeBinOfCount_tmp > timeBinMax) return false;
|
||||
}
|
||||
@@ -175,50 +176,55 @@ Bool_t musrCounter::GetNextGoodMuon(Int_t evtID, Long64_t timeBinMin, Long64_t&
|
||||
|
||||
Int_t eventNumber = (it->second)->eventIDnumber;
|
||||
if (eventNumber!=evtID) continue; // This trigger hit does not correspond to the currently processed event
|
||||
// ==> skip it, becuase it was already proceesed or will be processed in future
|
||||
// ==> skip it, because it was already proceesed or will be processed in future
|
||||
numberOfMuonCandidates++;
|
||||
// std::cout<<"*** "<<evtID<<" eventNumber="<<eventNumber<<" canditas="<<numberOfMuonCandidates<<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);
|
||||
goto endOfThisHit;
|
||||
bool_coincidenceConditions = false;
|
||||
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);
|
||||
goto endOfThisHit;
|
||||
bool_coincidenceConditions = false;
|
||||
goto MuonCoincidencesChecked;
|
||||
}
|
||||
}
|
||||
|
||||
MuonCoincidencesChecked:
|
||||
if (!bool_coincidenceConditions) continue; // This hit does not fulfill coincidence and veto criteria
|
||||
numberOfMuonCandidatesAfterVK++;
|
||||
|
||||
if ( CheckForPileupMuons(timeBinOfNextHit) ) {
|
||||
// std::cout<<"CheckForPileupMuons=true"<<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;
|
||||
// timeBinOfNextHit = timeBinOfCount_tmp;
|
||||
return true;
|
||||
|
||||
endOfThisHit:
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//================================================================
|
||||
Bool_t musrCounter::CheckForPileupMuons(Long64_t timeBin0, Int_t kEntry_NN) {
|
||||
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;
|
||||
if (timeBinOfCount_tmp < timeBinMinimum+coincidenceTimeWindowMin_M) continue; // This hit happened too long ago
|
||||
if (timeBinOfCount_tmp > timeBinMinimum+coincidenceTimeWindowMax_M) break; // This hit happened too late
|
||||
if ((timeBinOfCount_tmp == timeBinMinimum)&&( ((it->second)->eventEntry) == kEntry_NN)) continue;
|
||||
// This is the M-counter hit for which we check the pileup -> ignore this hit in this double-hit check.
|
||||
|
||||
// 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) {
|
||||
@@ -244,15 +250,15 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
|
||||
// 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
|
||||
// = 3 ... double hit
|
||||
// Loop over the hits in the counter
|
||||
Int_t positronQuality=0;
|
||||
if (bool_debugingRequired) {if (debugEventMap[evtID]>4) myPrintThisCounter(evtID);}
|
||||
if (hitMap.empty()) return 0;
|
||||
if (counterType!='P') {std::cout<<"\n!!! FATAL ERROR !!! musrCounter::GetNextGoodPositron: not the positron counter! ==> S T O P !!!\n"; exit(1);}
|
||||
for (hitMap_TYPE::iterator it = hitMap.begin(); it != hitMap.end(); ++it) {
|
||||
Int_t eventNumber = (it->second)->eventIDnumber;
|
||||
// Int_t eventNumber = (it->second)->eventIDnumber;
|
||||
Long64_t timeBinOfCount_tmp = it->first;
|
||||
if ((timeBinOfCount_tmp <= timeBinMin) || (timeBinOfCount_tmp > timeBinMax)) {
|
||||
if (bool_debugingRequired) {
|
||||
@@ -262,7 +268,7 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
|
||||
}
|
||||
|
||||
// Hit candidate was found. Now check its coincidences and vetos
|
||||
positronQuality=1;
|
||||
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); }
|
||||
@@ -272,7 +278,9 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
|
||||
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Coincidence required but not found"<<std::endl;}
|
||||
}
|
||||
if (bool_ignoreUnperfectPositrons) hitMap.erase(it); // no coincidence found ==> remove the candidate.
|
||||
goto endOfThisHit; // no coincidence found ==> skip hit
|
||||
bool_coincidenceConditions = false;
|
||||
goto CoincidencesChecked;
|
||||
// goto endOfThisHit; // no coincidence found ==> skip hit
|
||||
}
|
||||
}
|
||||
for (counterMapType::const_iterator itCounter = vetoCounterMap.begin(); itCounter!=vetoCounterMap.end(); ++itCounter) {
|
||||
@@ -281,10 +289,17 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
|
||||
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Coincidence vith veto detector found"<<std::endl;}
|
||||
}
|
||||
if (bool_ignoreUnperfectPositrons) hitMap.erase(it); // coincidence with veto found ==> remove the candidate.
|
||||
goto endOfThisHit; // coincidence with veto found ==> skip hit
|
||||
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) 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;
|
||||
@@ -294,11 +309,6 @@ Int_t musrCounter::GetNextGoodPositron(Int_t evtID, Long64_t timeBinMin, Long64_
|
||||
if (bool_debugingRequired) {
|
||||
if (debugEventMap[evtID]>3) {std::cout<<"DEBUGEVENT:"<<evtID<<"\"GetNextGoodPositron\": Good positron candidate found in this counter."<<std::endl;}
|
||||
}
|
||||
return 2;
|
||||
|
||||
endOfThisHit:
|
||||
;
|
||||
// continue;
|
||||
}
|
||||
return positronQuality;
|
||||
}
|
||||
@@ -348,3 +358,23 @@ void musrCounter::myPrintThisCounter(Int_t evtID, Int_t detail) {
|
||||
}
|
||||
|
||||
//================================================================
|
||||
//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";
|
||||
}
|
||||
//================================================================
|
||||
void musrCounter::WriteRewindIntoDumpFile() {
|
||||
DumpInfoToDumpFile(-2,1000,0);
|
||||
}
|
||||
//================================================================
|
||||
|
||||
Reference in New Issue
Block a user