From 43ec66ad7c45d7dbace49c304dfff781d94495de Mon Sep 17 00:00:00 2001 From: nemu Date: Fri, 6 Nov 2009 06:16:31 +0000 Subject: [PATCH] added estimate of t0 for the case it is not present, neither in the msr-file nor in the data-file (see MUSR-73). --- src/classes/PMusr.cpp | 19 +++++++++++++ src/classes/PRunAsymmetry.cpp | 30 +++++++++++++------- src/classes/PRunDataHandler.cpp | 50 ++++++++++++++++++++++++++++++++- src/classes/PRunSingleHisto.cpp | 24 +++++++++------- src/include/PMusr.h | 6 +++- 5 files changed, 107 insertions(+), 22 deletions(-) diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index a56eea3f..24aaf4aa 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -211,6 +211,7 @@ PRawRunData::~PRawRunData() fTemp.clear(); fRingAnode.clear(); fT0s.clear(); + fT0Estimated.clear(); fBkgBin.clear(); fGoodDataBin.clear(); for (UInt_t i=0; i Returns an estimated T0 value. + * + * \param idx index of the T0 value whished + */ +const Int_t PRawRunData::GetT0Estimated(const UInt_t idx) +{ + if (idx >= fT0Estimated.size()) { + cerr << endl << "**WARNING** PRawRunData::GetT0Estimated: idx=" << idx << " is out of range (0.." << fT0Estimated.size() << ")."; + cerr << endl; + return -1; + } + return fT0Estimated[idx]; +} + //-------------------------------------------------------------------------- // GetBkgBin //-------------------------------------------------------------------------- diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index a0fd7f0d..c1ebbfbc 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -302,19 +302,24 @@ Bool_t PRunAsymmetry::PrepareData() // check if the t0's are given in the msr-file if (fRunInfo->GetT0Size() == 0) { // t0's are NOT in the msr-file // check if the t0's are in the data file - if (runData->GetT0s().size() != 0) { // t0's in the run data + if (runData->GetT0Size() != 0) { // t0's in the run data // keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no // fForwardHistoNo starts with 1 not with 0 etc. ;-) fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo()-1)); // forward t0 fT0s.push_back(runData->GetT0(fRunInfo->GetBackwardHistoNo()-1)); // backward t0 - } else { // t0's are neither in the run data nor in the msr-file -> not acceptable! - cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** NO t0's found, neither in the run data nor in the msr-file!"; + } else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! + fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo()-1)); + fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo()-1)); + cerr << endl << "PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + cerr << endl << " run: " << fRunInfo->GetRunName()->Data(); + cerr << endl << " will try the estimated one: forward t0 = " << runData->GetT0Estimated(fRunInfo->GetForwardHistoNo()-1); + cerr << endl << " will try the estimated one: backward t0 = " << runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo()-1); + cerr << endl << " NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; cerr << endl; - return false; } } else { // t0's in the msr-file // check if t0's are given in the data file - if (runData->GetT0s().size() != 0) { + if (runData->GetT0Size() != 0) { // compare t0's of the msr-file with the one in the data file if (fabs(fRunInfo->GetT0(0)-runData->GetT0(fRunInfo->GetForwardHistoNo()-1))>5.0) { // given in bins!! cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING**: forward histo"; @@ -374,15 +379,20 @@ Bool_t PRunAsymmetry::PrepareData() // check if the t0's are given in the msr-file if (2*i+1 >= fRunInfo->GetT0Size()) { // t0's are NOT in the msr-file // check if the t0's are in the data file - if (addRunData->GetT0s().size() != 0) { // t0's in the run data + if (addRunData->GetT0Size() != 0) { // t0's in the run data // keep the proper t0's. For asymmetry runs, forward/backward are holding the histo no // fForwardHistoNo starts with 1 not with 0 etc. ;-) t0Add[0] = addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1); // forward t0 t0Add[1] = addRunData->GetT0(fRunInfo->GetBackwardHistoNo()-1); // backward t0 - } else { // t0's are neither in the run data nor in the msr-file -> not acceptable! - cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** NO t0's found, neither in the addrun (" << fRunInfo->GetRunName(i)->Data() << ") data nor in the msr-file!"; + } else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! + t0Add[0] = addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo()-1); + t0Add[1] = addRunData->GetT0Estimated(fRunInfo->GetBackwardHistoNo()-1); + cerr << endl << "PRunAsymmetry::PrepareData(): **WARRNING** NO t0's found, neither in the run data nor in the msr-file!"; + cerr << endl << " addRun: " << fRunInfo->GetRunName()->Data(); + cerr << endl << " will try the estimated one: forward t0 = " << addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo()-1); + cerr << endl << " will try the estimated one: backward t0 = " << addRunData->GetT0Estimated(fRunInfo->GetBackwardHistoNo()-1); + cerr << endl << " NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; cerr << endl; - return false; } } else { // t0's in the msr-file // check if t0's are given in the data file @@ -398,7 +408,7 @@ Bool_t PRunAsymmetry::PrepareData() t0Add[0] = fRunInfo->GetT0(0); t0Add[1] = fRunInfo->GetT0(1); } - if (addRunData->GetT0s().size() != 0) { + if (addRunData->GetT0Size() != 0) { // compare t0's of the msr-file with the one in the data file if (fabs(t0Add[0]-addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1))>5.0) { // given in bins!! cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING**: forward histo"; diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 916a6e6b..b56c2abd 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -570,9 +570,12 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup) cerr << endl; return false; } + // keep maximum of histogram as a T0 estimate + runData.AppendT0Estimated(histo->GetMaximumBin()); // fill data - for (Int_t j=1; jGetNbinsX(); j++) + for (Int_t j=1; jGetNbinsX(); j++) { histoData.push_back(histo->GetBinContent(j)); + } // store them in runData vector runData.AppendDataBin(histoData); // clear histoData for the next histo @@ -587,6 +590,8 @@ Bool_t PRunDataHandler::ReadRootFile(Bool_t notPostPileup) cerr << endl; return false; } + // keep maximum of histogram as a T0 estimate + runData.AppendT0Estimated(histo->GetMaximumBin()); // fill data for (Int_t j=1; jGetNbinsX(); j++) histoData.push_back(histo->GetBinContent(j)); @@ -784,6 +789,16 @@ Bool_t PRunDataHandler::ReadWkmFile() // check if empty line, i.e. new group if (IsWhitespace(instr)) { runData.AppendDataBin(histoData); + // get a T0 estimate + Double_t maxVal = 0.0; + Int_t maxBin = 0; + for (UInt_t i=0; i maxVal) { + maxVal = histoData[i]; + maxBin = i; + } + } + runData.AppendT0Estimated(maxBin); histoData.clear(); group_counter++; } else { @@ -993,6 +1008,16 @@ Bool_t PRunDataHandler::ReadPsiBinFile() } delete[] histo; runData.AppendDataBin(histoData); + // estimate T0 from maximum of the data + Double_t maxVal = 0.0; + Int_t maxBin = 0; + for (UInt_t j=0; j maxVal) { + maxVal = histoData[j]; + maxBin = j; + } + } + runData.AppendT0Estimated(maxBin); histoData.clear(); } @@ -1223,6 +1248,16 @@ Bool_t PRunDataHandler::ReadMudFile() histoData.push_back(pData[j]); } runData.AppendDataBin(histoData); + // estimate T0 from maximum of the data + Double_t maxVal = 0.0; + Int_t maxBin = 0; + for (UInt_t j=0; j maxVal) { + maxVal = histoData[j]; + maxBin = j; + } + } + runData.AppendT0Estimated(maxBin); histoData.clear(); free(pData); @@ -1523,6 +1558,19 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() runData.AppendDataBin(data[i]); } + // estimate T0 from maximum of the data + for (UInt_t i=0; i maxVal) { + maxVal = data[i][j]; + maxBin = j; + } + } + runData.AppendT0Estimated(maxBin); + } + // clean up for (UInt_t i=0; iGetT0Size() == 0) { // t0's are NOT in the msr-file // check if the t0's are in the data file - if (runData->GetT0s().size() != 0) { // t0's in the run data + if (runData->GetT0Size() != 0) { // t0's in the run data // keep the proper t0's. For single histo runs, forward is holding the histo no // fForwardHistoNo starts with 1 not with 0 ;-) fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo()-1)); - } else { // t0's are neither in the run data nor in the msr-file -> not acceptable! - cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the run data nor in the msr-file!"; + } else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! + fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo()-1)); + cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the run data nor in the msr-file!"; cerr << endl << " run: " << fRunInfo->GetRunName()->Data(); + cerr << endl << " will try the estimated one: t0 = " << runData->GetT0Estimated(fRunInfo->GetForwardHistoNo()-1); + cerr << endl << " NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; cerr << endl; - return false; } } else { // t0's in the msr-file // check if t0's are given in the data file - if (runData->GetT0s().size() != 0) { + if (runData->GetT0Size() != 0) { // compare t0's of the msr-file with the one in the data file if (fabs(fRunInfo->GetT0(0)-runData->GetT0(fRunInfo->GetForwardHistoNo()-1))>5.0) { // given in bins!! cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING**:"; @@ -372,19 +374,21 @@ Bool_t PRunSingleHisto::PrepareData() // check if the t0's are given in the msr-file if (i >= fRunInfo->GetT0Size()) { // t0's are NOT in the msr-file // check if the t0's are in the data file - if (addRunData->GetT0s().size() != 0) { // t0's in the run data + if (addRunData->GetT0Size() != 0) { // t0's in the run data // keep the proper t0's. For single histo runs, forward is holding the histo no // fForwardHistoNo starts with 1 not with 0 ;-) t0Add = addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1); - } else { // t0's are neither in the run data nor in the msr-file -> not acceptable! - cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the addrun data nor in the msr-file!"; + } else { // t0's are neither in the run data nor in the msr-file -> will try estimated ones! + t0Add = addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo()-1); + cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the addrun data nor in the msr-file!"; cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data(); + cerr << endl << " will try the estimated one: t0 = " << addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo()-1); + cerr << endl << " NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; cerr << endl; - return false; } } else { // t0's in the msr-file // check if t0's are given in the data file - if (addRunData->GetT0s().size() != 0) { + if (addRunData->GetT0Size() != 0) { // compare t0's of the msr-file with the one in the data file if (fabs(fRunInfo->GetT0(i)-addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1))>5.0) { // given in bins!! cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING**:"; diff --git a/src/include/PMusr.h b/src/include/PMusr.h index 278079ff..b01d4f03 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -263,8 +263,10 @@ class PRawRunData { virtual const PDoubleVector GetRingAnode() { return fRingAnode; } virtual const Double_t GetRingAnode(const UInt_t idx); virtual const Double_t GetTimeResolution() { return fTimeResolution; } - virtual const PIntVector GetT0s() { return fT0s; } + virtual const UInt_t GetT0Size() { return fT0s.size(); } virtual const Int_t GetT0(const UInt_t idx); + virtual const UInt_t GetT0EstimatedSize() { return fT0Estimated.size(); } + virtual const Int_t GetT0Estimated(const UInt_t idx); virtual const PIntPair GetBkgBin(const UInt_t idx); virtual const PIntPair GetGoodDataBin(const UInt_t idx); virtual const UInt_t GetNoOfHistos() { return fDataBin.size(); } @@ -283,6 +285,7 @@ class PRawRunData { virtual void SetRingAnode(const UInt_t idx, const Double_t dval); virtual void SetTimeResolution(const Double_t dval) { fTimeResolution = dval; } virtual void AppendT0(const Int_t ival) { fT0s.push_back(ival); } + virtual void AppendT0Estimated(const Int_t ival) { fT0Estimated.push_back(ival); } virtual void AppendBkgBin(PIntPair pair) { fBkgBin.push_back(pair); } virtual void AppendGoodDataBin(PIntPair pair) { fGoodDataBin.push_back(pair); } virtual void AppendDataBin(PDoubleVector data) { fDataBin.push_back(data); } @@ -302,6 +305,7 @@ class PRawRunData { PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B]) Double_t fTimeResolution; ///< time resolution of the run PIntVector fT0s; ///< vector of t0's of a run + PIntVector fT0Estimated; ///< vector of t0's estimated based on the maximum of the histogram PIntPairVector fBkgBin; ///< background bins (first/last) PIntPairVector fGoodDataBin; ///< data bins (first/last) vector fDataBin; ///< vector of all histos of a run