22.11.2011 Kamil Sedlak
Implemented posibility to write hits from musrSimAna into a "dump file", which can be used later as an input to the analysis of a real PSI data (as in a real experiment).
This commit is contained in:
parent
cac041c03d
commit
35e3d27206
Binary file not shown.
@ -314,6 +314,19 @@ All events should/have to be (?) saved in the Root tree
|
||||
This way the same counter can be used as two independent counters -- e.g.\ once as a veto
|
||||
detector for the M-counter, and simultaneously as a coincidence detector for
|
||||
a P-counter. In both cases the energy threshold and time windows are defined independently.
|
||||
\item{\bf WRITE\_OUT\_DUMP\_FILE \emph{fileNameString} \emph{clockChannel} \emph{randomJitter}}\\
|
||||
If present, this command will create two output files, the so-called ``dump files'':\\
|
||||
{\tt data/TDC\_V1190\_200\_dump\_\emph{fileNameString}.bin} -- file that can be used
|
||||
as an input to the PSI analysis front-end of a real experiment.\\
|
||||
{\tt data/TDC\_V1190\_200\_dump\_\emph{fileNameString}.txt} -- file that contains the same
|
||||
information (hits) as the previous file, however in a human-readable form. The first number in the file
|
||||
stands for the channel number, the second number stands for the time bin in the TDC bin units.\\
|
||||
\emph{clockChannel} ... the channel of the clock signal (typically 15).\\
|
||||
\emph{randomJitter} ... this value is in TDC bins, typically 0 or 8000 (?). If \emph{randomJitter} is smaller then
|
||||
1, then the hits in the dump files will be sorted according to time. If it is larger than 0, then
|
||||
subsequent hits can be unordered in time, but the time difference never exceeds the value of \emph{randomJitter}.
|
||||
This is just a technical thing serving to test the analysis software -- it should not
|
||||
have any effect on the analysis results.
|
||||
\item{\bf musrTH1D \emph{histoName} \emph{histoTitle} \emph{nBins} \emph{min} \emph{max} \emph{variable}
|
||||
[{\tt rotreference} $\nu_{\rm RRF}$ $\phi_{\rm RRF}$]} \\
|
||||
Defines a histogram (or more precisely an array of histograms, where the number of histograms
|
||||
@ -462,6 +475,7 @@ All events should/have to be (?) saved in the Root tree
|
||||
\item[funct4] $=p_3 \exp((- x)/2.19703) \cdot (1+p_2 \cos(p_0 x+p_1)) + p_4$
|
||||
\end{description}
|
||||
|
||||
|
||||
\end{description}
|
||||
%========================================================================================================
|
||||
\section{A real-life example: GPD instrument}
|
||||
|
@ -13,7 +13,7 @@ all: musrRoot
|
||||
%.o:%.cxx
|
||||
$(CPP) -c $(CPPFLAGS) $^
|
||||
|
||||
musrRoot: musrSimAna.o musrAnalysis.o musrCounter.o musrTH.o
|
||||
musrRoot: musrSimAna.o musrAnalysis.o musrCounter.o musrTH.o musrWriteDump.o
|
||||
$(CPP) -o musrSimAna $(LDFLAGS) $^
|
||||
|
||||
clean:
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include <TF1.h>
|
||||
//#include <math.h>
|
||||
|
||||
|
||||
musrWriteDump* musrAnalysis::myWriteDump = NULL;
|
||||
|
||||
void musrAnalysis::Loop(char* runChar, char* v1190FileName, Int_t nrEvents)
|
||||
{
|
||||
// In a ROOT session, you can do:
|
||||
@ -228,21 +231,24 @@ void musrAnalysis::ReadInInputParameters(char* charV1190FileName) {
|
||||
}
|
||||
}
|
||||
else if (strcmp(tmpString0,"WRITE_OUT_DUMP_FILE")==0) {
|
||||
// int clock_channelID_tmp;
|
||||
int clock_channelID;
|
||||
int max_timeBin_jitter;
|
||||
// int clock_interval_tmp;
|
||||
// sscanf(&line[0],"%*s %s %d %d",tmpString1,&clock_channelID_tmp,&clock_interval_tmp);
|
||||
sscanf(&line[0],"%*s %s",tmpString1);
|
||||
sscanf(&line[0],"%*s %s %d %d",tmpString1,&clock_channelID,&max_timeBin_jitter);
|
||||
// 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);
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
// myWriteDump = new musrWriteDump(charV1190FileName,clock_channelID,max_timeBin_jitter);
|
||||
myWriteDump = new musrWriteDump(tmpString1,clock_channelID,max_timeBin_jitter);
|
||||
}
|
||||
else if (strcmp(tmpString0,"USE_UNPERFECT_POSITRONS_IN_DOUBLE_HITS")==0) {
|
||||
musrCounter::bool_ignoreUnperfectPositrons = false;
|
||||
@ -905,8 +911,14 @@ void musrAnalysis::SaveHistograms(char* runChar, char* v1190FileName) {
|
||||
fHistograms->Close();
|
||||
delete fHistograms;
|
||||
|
||||
if (musrCounter::bool_WriteDataToDumpFile==true) {
|
||||
musrCounter::dumpFile.close();
|
||||
// if (musrCounter::bool_WriteDataToDumpFile==true) {
|
||||
// musrCounter::dumpFile.close();
|
||||
// }
|
||||
|
||||
if (musrCounter::bool_WriteDataToDumpFile) {
|
||||
if (myWriteDump!=NULL) {
|
||||
delete myWriteDump;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================
|
||||
@ -1087,9 +1099,12 @@ void musrAnalysis::FillHistograms(Int_t iiiEntry) {
|
||||
numberOfGoodMuons++;
|
||||
Long64_t dataBinMin = timeBin0+dataWindowBinMin;
|
||||
Long64_t dataBinMax = timeBin0+dataWindowBinMax;
|
||||
pCounterHitExistsForThisEventID = PositronCounterHit(eventID,dataBinMin,dataBinMax,timeBin1,timeBin2,posEntry,idetP,idetP_ID,idetP_edep);
|
||||
// Long64_t positronBinMax = timeBin0+pileupWindowBinMax+dataWindowBinMin;
|
||||
Long64_t positronBinMax = dataBinMax-dataWindowBinMin; // note that "dataWindowBinMin" is normally negative, i.e. positronBinMax > dataBinMax !!!
|
||||
pCounterHitExistsForThisEventID = PositronCounterHit(eventID,dataBinMin,dataBinMax,positronBinMax,timeBin1,timeBin2,posEntry,idetP,idetP_ID,idetP_edep);
|
||||
if (debugEventMap[eventID]>2) {
|
||||
if (pCounterHitExistsForThisEventID) {std::cout<<"FillHistograms: GOOD positron candidate found ("<<timeBin1<<")"<<std::endl;}
|
||||
if (pCounterHitExistsForThisEventID) {std::cout<<"FillHistograms: GOOD positron candidate found: timeBin1="<<timeBin1
|
||||
<<", deltat+800="<<timeBin1-timeBin0+800 <<std::endl;}
|
||||
else {std::cout<<"FillHistograms: NO positron candidate found"<<std::endl;}
|
||||
}
|
||||
//cDEL if (pCounterHitExistsForThisEventID) std::cout<<" timeBin1-timeBin2 = "<<timeBin1<<"-"<<timeBin2<<"="<<timeBin1-timeBin2 <<std::endl;
|
||||
@ -1390,7 +1405,7 @@ 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 musrAnalysis::PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_t dataBinMax, Long64_t positronBinMax, Long64_t& tBin1, Long64_t& tBin2, Int_t& kEntry, Int_t& idetP, Int_t& idetP_ID, Double_t& idetP_edep) {
|
||||
|
||||
if (bool_debugingRequired) {
|
||||
if (debugEventMap[eventID]>4) {std::cout<<"PositronCounterHit: pCounterMap.size()="<<pCounterMap.size()<<std::endl;}
|
||||
@ -1404,7 +1419,8 @@ Bool_t musrAnalysis::PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_
|
||||
if (musrMode=='D') {
|
||||
// Loop over all positron counters
|
||||
for (counterMapType::const_iterator it = pCounterMap.begin(); it!=pCounterMap.end(); ++it) {
|
||||
positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep);
|
||||
// positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMin,dataBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep);
|
||||
positronQuality = (it->second)->GetNextGoodPositron(evID,dataBinMin,positronBinMax,tBin1,tBin2,kEntry,idetP,idetP_ID,idetP_edep);
|
||||
if (positronQuality==3) { // double hit was found in the same counter
|
||||
if (debugEventMap[eventID]>3) {std::cout<<"PositronCounterHit: positron candidate killed - double hit in the same counter"<<std::endl;}
|
||||
return false;
|
||||
@ -1419,33 +1435,9 @@ Bool_t musrAnalysis::PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
// if (goodPositronFound) return true;
|
||||
if (goodPositronFound&&(tBin1<dataBinMax)) return true;
|
||||
}
|
||||
// std::cout<<"Debug 110"<<std::endl;
|
||||
return false;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <TH2.h>
|
||||
#include <TVectorD.h>
|
||||
#include "musrCounter.hh"
|
||||
#include "musrWriteDump.hh"
|
||||
//#include "musrTH.hh"
|
||||
#include <math.h>
|
||||
|
||||
@ -300,7 +301,7 @@ public :
|
||||
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);
|
||||
virtual Bool_t PositronCounterHit(Int_t evID, Long64_t dataBinMin, Long64_t dataBinMax, Long64_t positronBinMax, Long64_t& tBin1, Long64_t& tBin2, Int_t& kEntry, Int_t& idetP, Int_t& idetP_ID, Double_t& idetP_edep);
|
||||
// virtual Bool_t MuonCounterHit(Int_t evID, Long64_t timeBinMin, Long64_t& timeBin0, Int_t& kEntry, Int_t& idet, Int_t& idetID, Double_t& idetEdep);
|
||||
void CopySubstring(char* inputChar,int iStart,int iEnd,char* outputChar);
|
||||
void MyPrintTree();
|
||||
@ -318,6 +319,7 @@ public :
|
||||
// Bool_t bool_debugingRequired;
|
||||
|
||||
static const Double_t pi=3.14159265358979324;
|
||||
static musrWriteDump* myWriteDump;
|
||||
|
||||
private:
|
||||
std::string instrument;
|
||||
|
@ -12,7 +12,7 @@ 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;
|
||||
//ofstream musrCounter::dumpFile;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@ -403,7 +403,8 @@ 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";
|
||||
// dumpFile<<eventNr<<"\t"<<detID<<"\t"<<tdcBin<<"\n";
|
||||
musrAnalysis::myWriteDump->send_to_dump(detID,tdcBin,false);
|
||||
}
|
||||
//================================================================
|
||||
void musrCounter::WriteRewindIntoDumpFile() {
|
||||
|
@ -104,7 +104,7 @@ class musrCounter {
|
||||
static Bool_t bool_ignoreUnperfectMuons;
|
||||
static Bool_t bool_ignoreUnperfectPositrons;
|
||||
static Bool_t bool_WriteDataToDumpFile;
|
||||
static ofstream dumpFile;
|
||||
// static ofstream dumpFile;
|
||||
// static Long64_t previousClock;
|
||||
// static Long64_t CLOCK_INTERVAL;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user