From f2bd5b124f6717d419f75a765f158cf06527174a Mon Sep 17 00:00:00 2001 From: nemu Date: Mon, 8 Feb 2010 14:01:41 +0000 Subject: [PATCH] first implementation of histogram grouping. Probably still some more testing needed. --- src/classes/PMsrHandler.cpp | 431 ++++++++++++--- src/classes/PMusr.cpp | 507 +++++++++++++----- src/classes/PRunAsymmetry.cpp | 400 ++++++++------ src/classes/PRunSingleHisto.cpp | 281 ++++++---- src/include/PMsrHandler.h | 2 + src/include/PMusr.h | 81 +-- .../t0NotEqFirstGoodData.C | 37 +- 7 files changed, 1200 insertions(+), 539 deletions(-) diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index b9c0ed65..dba7967b 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -275,6 +275,17 @@ Int_t PMsrHandler::ReadMsrFile() if (!CheckFuncs()) result = PMUSR_MSR_SYNTAX_ERROR; + // check that if histogram grouping is present that it makes any sense + if (result == PMUSR_SUCCESS) + if (!CheckHistoGrouping()) + result = PMUSR_MSR_SYNTAX_ERROR; + + // check that if addrun is present that the given parameter make any sense + if (result == PMUSR_SUCCESS) + if (!CheckAddRunParameters()) + result = PMUSR_MSR_SYNTAX_ERROR; + + // clean up fit_parameter.clear(); theory.clear(); @@ -285,19 +296,6 @@ Int_t PMsrHandler::ReadMsrFile() plot.clear(); statistic.clear(); -/* -cout << endl << ">> FOURIER Block:"; -cout << endl << ">> Fourier Block Present : " << fFourier.fFourierBlockPresent; -cout << endl << ">> Fourier Units : " << fFourier.fUnits; -cout << endl << ">> Fourier Power : " << fFourier.fFourierPower; -cout << endl << ">> Apodization : " << fFourier.fApodization; -cout << endl << ">> Plot Tag : " << fFourier.fPlotTag; -cout << endl << ">> Phase : " << fFourier.fPhase; -cout << endl << ">> Range for Freq. Corrections : " << fFourier.fRangeForPhaseCorrection[0] << ", " << fFourier.fRangeForPhaseCorrection[1]; -cout << endl << ">> Plot Range : " << fFourier.fPlotRange[0] << ", " << fFourier.fPlotRange[1]; -cout << endl; -*/ - return result; } @@ -335,6 +333,11 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) dataTagMissing.push_back(true); } + // add some counters needed in connection to addruns + Int_t addForwardHistoNoCounter = 0; + Int_t addBackwardHistoNoCounter = 0; + Int_t addT0Counter = 0; + ifstream fin; ofstream fout; @@ -417,6 +420,11 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) } else if (str.BeginsWith("RUN")) { // RUN block tag tag = MSR_TAG_RUN; runNo++; + + // reset addrun helper counters + addForwardHistoNoCounter = 0; + addBackwardHistoNoCounter = 0; + addT0Counter = 0; } else if (str.BeginsWith("COMMANDS")) { // COMMANDS block tag tag = MSR_TAG_COMMANDS; fout << str.Data() << endl; @@ -620,10 +628,6 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) fout.width(16); fout << left << "backgr.fit"; fout << fRuns[runNo].GetBkgFitParamNo() << endl; - } else if (sstr.BeginsWith("rphase")) { - fout.width(16); - fout << left << "rphase"; - fout << fRuns[runNo].GetPhaseParamNo() << endl; } else if (sstr.BeginsWith("lifetime ")) { fout.width(16); fout << left << "lifetime"; @@ -645,38 +649,96 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) } fout << endl; } else if (sstr.BeginsWith("forward")) { - fout.width(16); - fout << left << "forward"; - fout << fRuns[runNo].GetForwardHistoNo() << endl; + if (fRuns[runNo].GetForwardHistoNoSize() == 0) { + cerr << endl << ">> PMsrHandler::WriteMsrLogFile: **WARNING** 'forward' tag without any data found!"; + cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; + } else { + fout.width(16); + fout << left << "forward"; + for (UInt_t i=0; i> PMsrHandler::WriteMsrLogFile: **WARNING** 'addforward' tag without any data found!"; + cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; + } else if (addForwardHistoNoCounter >= fRuns[runNo].GetAddForwardHistoNoSize(addForwardHistoNoCounter)) { + cerr << endl << ">> PMsrHandler::WriteMsrLogFile: **WARNING** More 'addforward' tags present than addforward data!"; + cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; + } else { + fout.width(16); + fout << left << "addforward"; + for (Int_t i=0; i> PMsrHandler::WriteMsrLogFile: **WARNING** 'backward' tag without any data found!"; + cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; + } else { + fout.width(16); + fout << left << "backward"; + for (UInt_t i=0; i> PMsrHandler::WriteMsrLogFile: **WARNING** 'addbackward' tag without any data found!"; + cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; + } else if (addBackwardHistoNoCounter >= fRuns[runNo].GetAddBackwardHistoNoSize(addBackwardHistoNoCounter)) { + cerr << endl << ">> PMsrHandler::WriteMsrLogFile: **WARNING** More 'addbackward' tags present than addbackward data!"; + cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; + } else { + fout.width(16); + fout << left << "addbackward"; + for (Int_t i=0; i 0) { + fout.width(8); + fout << left << fRuns[runNo].GetBkgRange(j)+1; // +1 since internally the data start at 0 + } } fout << endl; } else if (sstr.BeginsWith("data")) { dataTagMissing[runNo] = false; fout.width(16); fout << left << "data"; - for (UInt_t j=0; j 0) { + fout.width(8); + fout << left << fRuns[runNo].GetDataRange(j)+1; // +1 since internally the data start at 0 + } } fout << endl; } else if (sstr.BeginsWith("t0")) { @@ -688,6 +750,20 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) fout << left << fRuns[runNo].GetT0(j)+1; // +1 since internally the data start at 0 } fout << endl; + } else if (sstr.BeginsWith("addt0")) { + if (fRuns[runNo].GetAddT0Size(addT0Counter) <=0) { + cerr << endl << ">> PMsrHandler::WriteMsrLogFile: **WARNING** 'addt0' tag without any data found!"; + cerr << endl << ">> Something is VERY fishy, please check your msr-file carfully." << endl; + } else { + fout.width(16); + fout << left << "addt0"; + for (Int_t j=0; j 0) { + if (fRuns[runNo].GetBkgRange(0) >= 0) { fout.width(16); fout << left << "background"; - for (UInt_t j=0; j 0) { + if (fRuns[runNo].GetDataRange(0) >= 0) { fout.width(16); fout << left << "data"; - for (UInt_t j=0; j(tokens->At(1)); - param.AppendRunName(ostr->GetString()); + str = ostr->GetString(); + param.SetRunName(str); // beamline ostr = dynamic_cast(tokens->At(2)); - param.AppendBeamline(ostr->GetString()); + str = ostr->GetString(); + param.SetBeamline(str); // institute ostr = dynamic_cast(tokens->At(3)); - param.AppendInstitute(ostr->GetString()); + str = ostr->GetString(); + param.SetInstitute(str); // data file format ostr = dynamic_cast(tokens->At(4)); - param.AppendFileFormat(ostr->GetString()); + str = ostr->GetString(); + param.SetFileFormat(str); } + + // reset addrun helper counters + addForwardHistoNoCounter = 0; + addBackwardHistoNoCounter = 0; + addT0Counter = 0; } // ADDRUN line --------------------------------------------- @@ -1572,16 +1662,20 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) } else { // run name ostr = dynamic_cast(tokens->At(1)); - param.AppendRunName(ostr->GetString()); + str = ostr->GetString(); + param.SetRunName(str); // beamline ostr = dynamic_cast(tokens->At(2)); - param.AppendBeamline(ostr->GetString()); + str = ostr->GetString(); + param.SetBeamline(str); // institute ostr = dynamic_cast(tokens->At(3)); - param.AppendInstitute(ostr->GetString()); + str = ostr->GetString(); + param.SetInstitute(str); // data file format ostr = dynamic_cast(tokens->At(4)); - param.AppendFileFormat(ostr->GetString()); + str = ostr->GetString(); + param.SetFileFormat(str); } } @@ -1622,9 +1716,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(1)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetAlphaParamNo(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetAlphaParamNo(ival); else error = true; } else { @@ -1644,9 +1738,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(1)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetBetaParamNo(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetBetaParamNo(ival); else error = true; } else { @@ -1690,9 +1784,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(1)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetBkgFitParamNo(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetBkgFitParamNo(ival); else error = true; } else { @@ -1712,9 +1806,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(1)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetLifetimeParamNo(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetLifetimeParamNo(ival); else error = true; } else { @@ -1740,9 +1834,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval >= 0) - param.AppendMap(dval); + ival = str.Atoi(); + if (ival >= 0) + param.SetMap(ival); else error = true; } else { @@ -1771,9 +1865,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetForwardHistoNo(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetForwardHistoNo(ival); else error = true; } else { @@ -1783,6 +1877,32 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) } } + // addforward --------------------------------------------- + if (iter->fLine.BeginsWith("addforward", TString::kIgnoreCase)) { + + runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following + + if (tokens->GetEntries() < 2) { + error = true; + } else { + for (Int_t i=1; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + str = ostr->GetString(); + if (str.IsDigit()) { + ival = str.Atoi(); + if (ival > 0) + param.SetAddForwardHistoNo(ival, addForwardHistoNoCounter, i-1); + else + error = true; + } else { + error = true; + } + } + } + + addForwardHistoNoCounter++; + } + // backward ----------------------------------------------- if (iter->fLine.BeginsWith("backward", TString::kIgnoreCase)) { @@ -1795,9 +1915,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetBackwardHistoNo(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetBackwardHistoNo(ival); else error = true; } else { @@ -1807,6 +1927,32 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) } } + // addbackward --------------------------------------------- + if (iter->fLine.BeginsWith("addbackward", TString::kIgnoreCase)) { + + runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following + + if (tokens->GetEntries() < 2) { + error = true; + } else { + for (Int_t i=1; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + str = ostr->GetString(); + if (str.IsDigit()) { + ival = str.Atoi(); + if (ival > 0) + param.SetAddBackwardHistoNo(ival, addBackwardHistoNoCounter, i-1); + else + error = true; + } else { + error = true; + } + } + } + + addBackwardHistoNoCounter++; + } + // backgr.fix ---------------------------------------------- if (iter->fLine.BeginsWith("backgr.fix", TString::kIgnoreCase)) { @@ -1819,7 +1965,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); if (str.IsFloat()) - param.AppendBkgFix(str.Atof()); + param.SetBkgFix(str.Atof()); else error = true; } @@ -1838,9 +1984,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.AppendBkgRange(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetBkgRange(ival, i-1); else error = true; } else { @@ -1862,9 +2008,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.AppendDataRange(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetDataRange(ival, i-1); else error = true; } else { @@ -1886,9 +2032,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(i)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.AppendT0(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetT0(ival); else error = true; } else { @@ -1898,6 +2044,32 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) } } + // addt0 ----------------------------------------------------- + if (iter->fLine.BeginsWith("addt0", TString::kIgnoreCase)) { + + runLinePresent = false; // this is needed to make sure that a run line is present before and ADDRUN is following + + if (tokens->GetEntries() < 2) { + error = true; + } else { + for (Int_t i=1; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + str = ostr->GetString(); + if (str.IsDigit()) { + ival = str.Atoi(); + if (ival > 0) + param.SetAddT0(ival, addT0Counter, i-1); + else + error = true; + } else { + error = true; + } + } + } + + addT0Counter++; + } + // fit ----------------------------------------------------- if (iter->fLine.BeginsWith("fit ", TString::kIgnoreCase)) { @@ -1928,9 +2100,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(1)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetPacking(dval); + ival = str.Atoi(); + if (ival > 0) + param.SetPacking(ival); else error = true; } else { @@ -1954,9 +2126,9 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) ostr = dynamic_cast(tokens->At(2)); str = ostr->GetString(); if (str.IsDigit()) { - dval = str.Atoi(); - if (dval > 0) - param.SetYDataIndex(dval); // y-index + ival = str.Atoi(); + if (ival > 0) + param.SetYDataIndex(ival); // y-index else error = true; } else { @@ -3117,7 +3289,7 @@ void PMsrHandler::FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLi if (str.Contains("alpha") || str.Contains("beta") || str.Contains("alpha2") || str.Contains("beta2") || str.Contains("norm") || str.Contains("backgr.fit") || - str.Contains("rphase") || str.Contains("lifetime ")) { + str.Contains("lifetime ")) { // tokenize string tokens = str.Tokenize(" \t"); if (!tokens) @@ -3548,4 +3720,95 @@ Bool_t PMsrHandler::CheckFuncs() return result; } +//-------------------------------------------------------------------------- +// CheckHistoGrouping (private) +//-------------------------------------------------------------------------- +/** + *

Checks if histogram grouping makes any sense. + */ +Bool_t PMsrHandler::CheckHistoGrouping() +{ + Bool_t result = true; + + for (UInt_t i=0; i> PMsrHandler::CheckHistoGrouping: **ERROR** # of forward histos != # of backward histos."; + cerr << endl << ">> Run #" << i+1; + cerr << endl; + result = false; + break; + } + } + } + + return result; +} + +//-------------------------------------------------------------------------- +// CheckAddRunParameters (private) +//-------------------------------------------------------------------------- +/** + *

Check if addrun is present that given parameters make any sense. + */ +Bool_t PMsrHandler::CheckAddRunParameters() +{ + Bool_t result = true; + + for (UInt_t i=0; i 1) { + // checks concerning forward <-> backward, addforward <-> addbackward + if (fRuns[i].GetAddForwardHistoNoEntries() != 0) { // addforward given, make some consistency checks + if (fRuns[i].GetRunNameSize()-1 != fRuns[i].GetAddForwardHistoNoEntries()) { + cerr << endl << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addruns != # of addforwards found."; + cerr << endl << ">> Run #" << i+1; + cerr << endl; + result = false; + break; + } + if (fRuns[i].GetFitType() == MSR_FITTYPE_ASYM) { + if (fRuns[i].GetAddForwardHistoNoEntries() != fRuns[i].GetAddBackwardHistoNoEntries()) { + cerr << endl << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addforward entries != # of addbackward entries."; + cerr << endl << ">> Run #" << i+1; + cerr << endl; + result = false; + break; + } + } + for (UInt_t j=0; j(fRuns[i].GetForwardHistoNoSize())) { + cerr << endl << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addforward histos != # of forward histos."; + cerr << endl << ">> Run #" << i+1; + cerr << endl; + result = false; + break; + } + } + } + + // check concerning the addt0 tags + if (fRuns[i].GetAddT0Entries() != 0) { + if (fRuns[i].GetAddT0Entries() != fRuns[i].GetRunNameSize()-1) { + cerr << endl << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addt0 != # of addruns."; + cerr << endl << ">> Run #" << i+1; + cerr << endl; + result = false; + break; + } + } + } else { // no addrun present, check if addforward, addbackward, ... is present (which doesn't make any sense) + if ((fRuns[i].GetAddForwardHistoNoEntries() != 0) || (fRuns[i].GetAddBackwardHistoNoEntries() != 0) || + (fRuns[i].GetAddT0Entries() != 0)) { + cerr << endl << ">> PMsrHandler::CheckAddRunParameters: **WARNING** found one of the following tags in Run #" << i+1 << ":"; + cerr << endl << ">> addforward, addbackward, or addt0"; + cerr << endl << ">> this doesn't make any sense if there no addrun present."; + cerr << endl << ">> Will ignore these entires for this run!"; + cerr << endl; + } + } + } + + return result; +} + // end --------------------------------------------------------------------- diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index 0113375a..bf3af33d 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -80,14 +80,14 @@ PRunData::~PRunData() /** *

Sets a value of the theory vector * - * \param i index of the theory vector + * \param idx index of the theory vector */ -void PRunData::SetTheoryValue(UInt_t i, Double_t dval) +void PRunData::SetTheoryValue(UInt_t idx, Double_t dval) { - if (i > fTheory.size()) - fTheory.resize(i+1); + if (idx > fTheory.size()) + fTheory.resize(idx+1); - fTheory[i] = dval; + fTheory[idx] = dval; } //-------------------------------------------------------------------------- @@ -528,6 +528,12 @@ PMsrRunBlock::PMsrRunBlock() fPhaseParamNo = -1; // undefined phase parameter number fLifetimeParamNo = -1; // undefined lifetime parameter number fLifetimeCorrection = false; // lifetime correction == false by default (used in single histogram musrview) + for (UInt_t i=0; i<2; i++) + fBkgFix[i] = PMUSR_UNDEFINED; + for (UInt_t i=0; i<4; i++) { + fBkgRange[i] = -1; // undefined start background range + fDataRange[i] = -1; // undefined start data range + } fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range fPacking = -1; // undefined packing @@ -552,9 +558,6 @@ PMsrRunBlock::~PMsrRunBlock() fForwardHistoNo.clear(); fBackwardHistoNo.clear(); fMap.clear(); - fBkgFix.clear(); - fBkgRange.clear(); - fDataRange.clear(); fT0.clear(); } @@ -574,6 +577,12 @@ void PMsrRunBlock::CleanUp() fPhaseParamNo = -1; // undefined phase parameter number fLifetimeParamNo = -1; // undefined lifetime parameter number fLifetimeCorrection = true; // lifetime correction == true by default (used in single histogram musrview) + fBkgFix[0] = PMUSR_UNDEFINED; // undefined fixed background for forward + fBkgFix[1] = PMUSR_UNDEFINED; // undefined fixed background for backward + for (UInt_t i=0; i<4; i++) { + fBkgRange[i] = -1; // undefined background range + fDataRange[i] = -1; // undefined data range + } fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range fPacking = -1; // undefined packing @@ -587,166 +596,196 @@ void PMsrRunBlock::CleanUp() fInstitute.clear(); fFileFormat.clear(); fForwardHistoNo.clear(); + for (UInt_t i=0; i get run name at position i + *

get run name at position idx * - * \param i index of the run name to be returned + * \param idx index of the run name to be returned */ -TString* PMsrRunBlock::GetRunName(UInt_t i) +TString* PMsrRunBlock::GetRunName(UInt_t idx) { - if (i>fRunName.size()) + if (idx>fRunName.size()) return 0; - return &fRunName[i]; + return &fRunName[idx]; } //-------------------------------------------------------------------------- // SetRunName //-------------------------------------------------------------------------- /** - *

set run name at position i + *

set run name at position idx * - * \param i index of the run name to be set + * \param str run name string + * \param idx index of the run name to be set. If idx == -1 append run name */ -void PMsrRunBlock::SetRunName(TString &str, UInt_t i) +void PMsrRunBlock::SetRunName(TString &str, Int_t idx) { - if (i >= fRunName.size()) - fRunName.resize(i+1); + if (idx == -1) { + fRunName.push_back(str); + return; + } - fRunName[i] = str; + if (idx >= static_cast(fRunName.size())) + fRunName.resize(idx+1); + + fRunName[idx] = str; } //-------------------------------------------------------------------------- // GetBeamline //-------------------------------------------------------------------------- /** - *

get beamline name at position i + *

get beamline name at position idx * - * \param i index of the beamline to be returned + * \param idx index of the beamline to be returned */ -TString* PMsrRunBlock::GetBeamline(UInt_t i) +TString* PMsrRunBlock::GetBeamline(UInt_t idx) { - if (i>fBeamline.size()) + if (idx>fBeamline.size()) return 0; - return &fBeamline[i]; + return &fBeamline[idx]; } //-------------------------------------------------------------------------- // SetBeamline //-------------------------------------------------------------------------- /** - *

set beamline name at position i + *

set beamline name at position idx * - * \param i index of the beamline name to be set + * \param str beamline name string + * \param idx index of the beamline name to be set. If idx == -1, append beamline */ -void PMsrRunBlock::SetBeamline(TString &str, UInt_t i) +void PMsrRunBlock::SetBeamline(TString &str, Int_t idx) { - if (i >= fBeamline.size()) - fBeamline.resize(i+1); + if (idx == -1) { + fBeamline.push_back(str); + return; + } - fBeamline[i] = str; + if (idx >= static_cast(fBeamline.size())) + fBeamline.resize(idx+1); + + fBeamline[idx] = str; } //-------------------------------------------------------------------------- // GetInstitute //-------------------------------------------------------------------------- /** - *

get institute name at position i + *

get institute name at position idx * - * \param i index of the institute to be returned + * \param idx index of the institute to be returned */ -TString* PMsrRunBlock::GetInstitute(UInt_t i) +TString* PMsrRunBlock::GetInstitute(UInt_t idx) { - if (i>fInstitute.size()) + if (idx>fInstitute.size()) return 0; - return &fInstitute[i]; + return &fInstitute[idx]; } //-------------------------------------------------------------------------- // SetInstitute //-------------------------------------------------------------------------- /** - *

set institute name at position i + *

set institute name at position idx * - * \param i index of the run name to be set + * \param str institute name string + * \param idx index of the run name to be set. If idx == -1, append institute name */ -void PMsrRunBlock::SetInstitute(TString &str, UInt_t i) +void PMsrRunBlock::SetInstitute(TString &str, Int_t idx) { - if (i >= fInstitute.size()) - fInstitute.resize(i+1); + if (idx == -1) { + fInstitute.push_back(str); + return; + } - fInstitute[i] = str; + if (idx >= static_cast(fInstitute.size())) + fInstitute.resize(idx+1); + + fInstitute[idx] = str; } //-------------------------------------------------------------------------- // GetFileFormat //-------------------------------------------------------------------------- /** - *

get file format name at position i + *

get file format name at position idx * - * \param i index of the file format to be returned + * \param idx index of the file format to be returned */ -TString* PMsrRunBlock::GetFileFormat(UInt_t i) +TString* PMsrRunBlock::GetFileFormat(UInt_t idx) { - if (i>fFileFormat.size()) + if (idx>fFileFormat.size()) return 0; - return &fFileFormat[i]; + return &fFileFormat[idx]; } //-------------------------------------------------------------------------- // SetFileFormat //-------------------------------------------------------------------------- /** - *

set file format name at position i + *

set file format name at position idx * - * \param i index of the file format name to be set + * \param str file format string + * \param idx index of the file format name to be set. If idx == -1, append file format */ -void PMsrRunBlock::SetFileFormat(TString &str, UInt_t i) +void PMsrRunBlock::SetFileFormat(TString &str, Int_t idx) { - if (i >= fFileFormat.size()) - fFileFormat.resize(i+1); + if (idx == -1) { + fFileFormat.push_back(str); + return; + } - fFileFormat[i] = str; + if (idx >= static_cast(fFileFormat.size())) + fFileFormat.resize(idx+1); + + fFileFormat[idx] = str; } //-------------------------------------------------------------------------- // GetForwardHistoNo //-------------------------------------------------------------------------- /** - *

get forward histogram value at position i + *

get forward histogram value at position idx * - * \param i index of the forward histogram value to be returned + * \param idx index of the forward histogram value to be returned */ -Int_t PMsrRunBlock::GetForwardHistoNo(UInt_t i) +Int_t PMsrRunBlock::GetForwardHistoNo(UInt_t idx) { if (fForwardHistoNo.empty()) return -1; - if (i>fForwardHistoNo.size()) + if (idx>fForwardHistoNo.size()) return -1; - return fForwardHistoNo[i]; + return fForwardHistoNo[idx]; } //-------------------------------------------------------------------------- // SetForwardHistoNo //-------------------------------------------------------------------------- /** - *

set forward histogram value at position pos + *

set forward histogram value at index idx * * \param histoNo histogram value * \param idx index whithin the fForwardHistoNo vector where to set the value. @@ -763,23 +802,89 @@ void PMsrRunBlock::SetForwardHistoNo(Int_t histoNo, Int_t idx) } } +//-------------------------------------------------------------------------- +// GetAddForwardHistoNoSize +//-------------------------------------------------------------------------- +/** + *

get forward histo number size of the addrun at index addRunIdx + * + * \param addRunIdx index of the addrun + */ +Int_t PMsrRunBlock::GetAddForwardHistoNoSize(UInt_t addRunIdx) +{ + if (fAddForwardHistoNo.empty()) + return -1; + + if (addRunIdx > fAddForwardHistoNo.size()) + return -1; + + return fAddForwardHistoNo[addRunIdx].size(); +} + +//-------------------------------------------------------------------------- +// GetAddForwardHistoNo +//-------------------------------------------------------------------------- +/** + *

get forward histo number of the addrun (index addRunIdx) at index histoIdx + * + * \param addRunIdx index of the addrun + * \param histoIdx index of the add forward histo number value + */ +Int_t PMsrRunBlock::GetAddForwardHistoNo(UInt_t addRunIdx, UInt_t histoIdx) +{ + if (fAddForwardHistoNo.empty()) + return -1; + + if (addRunIdx > fAddForwardHistoNo.size()) + return -1; + + if (fAddForwardHistoNo[addRunIdx].empty()) + return -1; + + if (histoIdx > fAddForwardHistoNo[addRunIdx].size()) + return -1; + + return fAddForwardHistoNo[addRunIdx][histoIdx]; +} + +//-------------------------------------------------------------------------- +// SetAddForwardHistoNo +//-------------------------------------------------------------------------- +/** + *

set add forward histogram value at index idx + * + * \param histoNo histogram value + * \param addRunIdx addrun index + * \param histoNoIdx index whithin the fAddForwardHistoNo vector where to set the value. + */ +void PMsrRunBlock::SetAddForwardHistoNo(Int_t histoNo, UInt_t addRunIdx, UInt_t histoNoIdx) +{ + if (addRunIdx >= fAddForwardHistoNo.size()) + fAddForwardHistoNo.resize(addRunIdx+1); + + if (histoNoIdx >= fAddForwardHistoNo[addRunIdx].size()) + fAddForwardHistoNo[addRunIdx].resize(histoNoIdx+1); + + fAddForwardHistoNo[addRunIdx][histoNoIdx] = histoNo; +} + //-------------------------------------------------------------------------- // GetBackwardHistoNo //-------------------------------------------------------------------------- /** - *

get backward histogram value at position i + *

get backward histogram value at position idx * - * \param i index of the map value to be returned + * \param idx index of the map value to be returned */ -Int_t PMsrRunBlock::GetBackwardHistoNo(UInt_t i) +Int_t PMsrRunBlock::GetBackwardHistoNo(UInt_t idx) { if (fBackwardHistoNo.empty()) return -1; - if (i>fBackwardHistoNo.size()) + if (idx>fBackwardHistoNo.size()) return -1; - return fBackwardHistoNo[i]; + return fBackwardHistoNo[idx]; } //-------------------------------------------------------------------------- @@ -803,33 +908,105 @@ void PMsrRunBlock::SetBackwardHistoNo(Int_t histoNo, Int_t idx) } } +//-------------------------------------------------------------------------- +// GetAddBackwardHistoNoSize +//-------------------------------------------------------------------------- +/** + *

get backward histo number size of the addrun at index addRunIdx + * + * \param addRunIdx index of the addrun + */ +Int_t PMsrRunBlock::GetAddBackwardHistoNoSize(UInt_t addRunIdx) +{ + if (fAddBackwardHistoNo.empty()) + return -1; + + if (addRunIdx > fAddBackwardHistoNo.size()) + return -1; + + return fAddBackwardHistoNo[addRunIdx].size(); +} + +//-------------------------------------------------------------------------- +// GetAddBackwardHistoNo +//-------------------------------------------------------------------------- +/** + *

get backward histo number of the addrun (index addRunIdx) at index histoIdx + * + * \param addRunIdx index of the addrun + * \param histoIdx index of the add backward histo number value + */ +Int_t PMsrRunBlock::GetAddBackwardHistoNo(UInt_t addRunIdx, UInt_t histoIdx) +{ + if (fAddBackwardHistoNo.empty()) + return -1; + + if (addRunIdx > fAddBackwardHistoNo.size()) + return -1; + + if (fAddBackwardHistoNo[addRunIdx].empty()) + return -1; + + if (histoIdx > fAddBackwardHistoNo[addRunIdx].size()) + return -1; + + return fAddBackwardHistoNo[addRunIdx][histoIdx]; +} + +//-------------------------------------------------------------------------- +// SetAddBackwardHistoNo +//-------------------------------------------------------------------------- +/** + *

set add backward histogram value of the addrun at index histoNoIdx + * + * \param histoNo histogram value + * \param addRunIdx addrun index + * \param histoNoIdx index whithin the fAddBackwardHistoNo vector where to set the value. + */ +void PMsrRunBlock::SetAddBackwardHistoNo(Int_t histoNo, UInt_t addRunIdx, UInt_t histoNoIdx) +{ + if (addRunIdx >= fAddBackwardHistoNo.size()) + fAddBackwardHistoNo.resize(addRunIdx+1); + + if (histoNoIdx >= fAddBackwardHistoNo[addRunIdx].size()) + fAddBackwardHistoNo[addRunIdx].resize(histoNoIdx+1); + + fAddBackwardHistoNo[addRunIdx][histoNoIdx] = histoNo; +} + //-------------------------------------------------------------------------- // GetMap //-------------------------------------------------------------------------- /** - *

get map value at position i + *

get map value at position idx * - * \param i index of the map value to be returned + * \param idx index of the map value to be returned */ -Int_t PMsrRunBlock::GetMap(UInt_t i) +Int_t PMsrRunBlock::GetMap(UInt_t idx) { - if (i>fMap.size()) + if (idx>fMap.size()) return -1; - return fMap[i]; + return fMap[idx]; } //-------------------------------------------------------------------------- // SetMap //-------------------------------------------------------------------------- /** - *

set map value at position i + *

set map value at position idx * - * \param i index of the map value to be set + * \param mapVal map value + * \param idx index of the map value to be set. If idx == -1, append map value. */ -void PMsrRunBlock::SetMap(Int_t mapVal, UInt_t idx) +void PMsrRunBlock::SetMap(Int_t mapVal, Int_t idx) { - if (idx >= fMap.size()) + if (idx == -1) { + fMap.push_back(mapVal); + return; + } + + if (idx >= static_cast(fMap.size())) fMap.resize(idx+1); fMap[idx] = mapVal; @@ -839,30 +1016,34 @@ void PMsrRunBlock::SetMap(Int_t mapVal, UInt_t idx) // GetBkgFix //-------------------------------------------------------------------------- /** - *

get background fixed value at position i + *

get background fixed value at position idx * - * \param i index of the background fixed value to be returned + * \param idx index of the background fixed value to be returned */ -Double_t PMsrRunBlock::GetBkgFix(UInt_t i) +Double_t PMsrRunBlock::GetBkgFix(UInt_t idx) { - if (i>fBkgFix.size()) + if (idx >= 2) return PMUSR_UNDEFINED; - return fBkgFix[i]; + return fBkgFix[idx]; } //-------------------------------------------------------------------------- // SetBkgFix //-------------------------------------------------------------------------- /** - *

set background fixed value at position i + *

set background fixed value at position idx * - * \param i index of the background fixed value to be set + * \param dval fixed background value + * \param idx index of the background fixed value to be set. */ -void PMsrRunBlock::SetBkgFix(Double_t dval, UInt_t idx) +void PMsrRunBlock::SetBkgFix(Double_t dval, Int_t idx) { - if (idx >= fBkgFix.size()) - fBkgFix.resize(idx+1); + if (idx >= 2) { + cerr << endl << "PMsrRunBlock::SetBkgFix: **WARNING** idx=" << idx << ", only idx=0,1 are sensible."; + cerr << endl; + return; + } fBkgFix[idx] = dval; } @@ -871,64 +1052,73 @@ void PMsrRunBlock::SetBkgFix(Double_t dval, UInt_t idx) // GetBkgRange //-------------------------------------------------------------------------- /** - *

get background range at position i + *

get background range at position idx * - * \param i index of the background range to be returned + * \param idx index of the background range to be returned */ -Int_t PMsrRunBlock::GetBkgRange(UInt_t i) +Int_t PMsrRunBlock::GetBkgRange(UInt_t idx) { - if (i >= fBkgRange.size()) { + if (idx >= 4) { return -1; } - return fBkgRange[i]-1; // -1 because the counting of the data vector starts at 0! + return fBkgRange[idx]-1; // -1 because the counting of the data vector starts at 0! } //-------------------------------------------------------------------------- // SetBkgRange //-------------------------------------------------------------------------- /** - *

set background range element at position i + *

set background range element at position idx * - * \param i index of the background range element to be returned + * \param ival background bin value + * \param idx index of the background range element to be set. If idx==-1, append value. */ -void PMsrRunBlock::SetBkgRange(Int_t ival, UInt_t idx) +void PMsrRunBlock::SetBkgRange(Int_t ival, Int_t idx) { - if (idx >= fBkgRange.size()) - fBkgRange.resize(idx+1); + if (idx >= 4) { + cerr << endl << "PMsrRunBlock::SetBkgRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible."; + cerr << endl; + return; + } fBkgRange[idx] = ival; } + //-------------------------------------------------------------------------- // GetDataRange //-------------------------------------------------------------------------- /** - *

get data range at position i + *

get data range at position idx * - * \param i index of the data range to be returned + * \param idx index of the data range to be returned */ -Int_t PMsrRunBlock::GetDataRange(UInt_t i) +Int_t PMsrRunBlock::GetDataRange(UInt_t idx) { - if (i >= fDataRange.size()) { + if (idx >= 4) { return -1; } - return fDataRange[i]-1; // -1 because the counting of the data vector starts at 0! + return fDataRange[idx]-1; // -1 because the counting of the data vector starts at 0! } //-------------------------------------------------------------------------- // SetDataRange //-------------------------------------------------------------------------- /** - *

set data range element at position i + *

set data range element at position idx * - * \param i index of the data range element to be returned + * \param ival data range element + * \param idx index of the data range element to be set. If idx==-1, append value */ -void PMsrRunBlock::SetDataRange(Int_t ival, UInt_t idx) +void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx) { - if (idx >= fDataRange.size()) - fDataRange.resize(idx+1); + if (idx >= 4) { + cerr << endl << "PMsrRunBlock::SetDataRange: **WARNING** idx=" << idx << ", only idx=0..3 are sensible."; + cerr << endl; + return; + } fDataRange[idx] = ival; } @@ -937,61 +1127,134 @@ void PMsrRunBlock::SetDataRange(Int_t ival, UInt_t idx) // GetT0 //-------------------------------------------------------------------------- /** - *

get T0 value at position i + *

get T0 value at position idx * - * \param i index of the T0 value to be returned + * \param idx index of the T0 value to be returned */ -Int_t PMsrRunBlock::GetT0(UInt_t i) +Int_t PMsrRunBlock::GetT0(UInt_t idx) { - if (i>fT0.size()) + if (idx>fT0.size()) return -1; - return fT0[i]-1; // -1 because the counting of the data vector starts at 0! + return fT0[idx]-1; // -1 because the counting of the data vector starts at 0! } //-------------------------------------------------------------------------- // SetT0 //-------------------------------------------------------------------------- /** - *

set T0 value at position i + *

set T0 value at position idx * - * \param i index of the T0 value to be set + * \param ival t0 value + * \param idx index of the T0 value to be set. If idx==-1, append value */ -void PMsrRunBlock::SetT0(Int_t ival, UInt_t idx) +void PMsrRunBlock::SetT0(Int_t ival, Int_t idx) { - if (idx >= fT0.size()) + if (idx == -1) { + fT0.push_back(ival); + return; + } + + if (idx >= static_cast(fT0.size())) fT0.resize(idx+1); fT0[idx] = ival; } +//-------------------------------------------------------------------------- +// GetAddT0Size +//-------------------------------------------------------------------------- +/** + *

get add T0 size of the addrun at index addRunIdx + * + * \param addRunIdx index of the addrun + */ +Int_t PMsrRunBlock::GetAddT0Size(UInt_t addRunIdx) +{ + if (fAddT0.empty()) + return -1; + + if (addRunIdx > fAddT0.size()) + return -1; + + return fAddT0[addRunIdx].size(); +} + +//-------------------------------------------------------------------------- +// GetAddT0 +//-------------------------------------------------------------------------- +/** + *

get add T0 of the addrun (index addRunIdx) at index histoIdx + * + * \param addRunIdx index of the addrun + * \param histoIdx index of the add backward histo number value + */ +Int_t PMsrRunBlock::GetAddT0(UInt_t addRunIdx, UInt_t histoIdx) +{ + if (fAddT0.empty()) + return -1; + + if (addRunIdx > fAddT0.size()) + return -1; + + if (fAddT0[addRunIdx].empty()) + return -1; + + if (histoIdx > fAddT0[addRunIdx].size()) + return -1; + + return fAddT0[addRunIdx][histoIdx]-1; // -1 because the counting of the data vector starts at 0! +} + +//-------------------------------------------------------------------------- +// SetAddT0 +//-------------------------------------------------------------------------- +/** + *

set add t0 value of the addrun at index histoNoIdx + * + * \param ival t0 value + * \param addRunIdx addrun index + * \param histoNoIdx index whithin the fAddT0 vector where to set the value. + */ +void PMsrRunBlock::SetAddT0(Int_t ival, UInt_t addRunIdx, UInt_t histoNoIdx) +{ + if (addRunIdx >= fAddT0.size()) + fAddT0.resize(addRunIdx+1); + + if (histoNoIdx >= fAddT0[addRunIdx].size()) + fAddT0[addRunIdx].resize(histoNoIdx+1); + + fAddT0[addRunIdx][histoNoIdx] = ival; + +} + //-------------------------------------------------------------------------- // GetFitRange //-------------------------------------------------------------------------- /** - *

get fit range value at position i + *

get fit range value at position idx * - * \param i index of the fit range value to be returned + * \param idx index of the fit range value to be returned */ -Double_t PMsrRunBlock::GetFitRange(UInt_t i) +Double_t PMsrRunBlock::GetFitRange(UInt_t idx) { - if (i>2) + if (idx >= 2) return PMUSR_UNDEFINED; - return fFitRange[i]; + return fFitRange[idx]; } //-------------------------------------------------------------------------- // SetFitRange //-------------------------------------------------------------------------- /** - *

set fit range value at position i + *

set fit range value at position idx * - * \param i index of the fit range value to be set + * \param idx index of the fit range value to be set */ void PMsrRunBlock::SetFitRange(Double_t dval, UInt_t idx) { - if (idx>=2) + if (idx >= 2) return; fFitRange[idx] = dval; diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index 3fc5ddbb..0043bc3c 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -67,15 +67,15 @@ PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UIn // check if alpha is given if (fRunInfo->GetAlphaParamNo() == -1) { // no alpha given - cerr << endl << "PRunAsymmetry::PRunAsymmetry(): **ERROR** no alpha parameter given! This is needed for an asymmetry fit!"; + cerr << endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** no alpha parameter given! This is needed for an asymmetry fit!"; cerr << endl; fValid = false; return; } // check if alpha parameter is within proper bounds if ((fRunInfo->GetAlphaParamNo() < 0) || (fRunInfo->GetAlphaParamNo() > (Int_t)param->size())) { - cerr << endl << "PRunAsymmetry::PRunAsymmetry(): **ERROR** alpha parameter no = " << fRunInfo->GetAlphaParamNo(); - cerr << endl << " This is out of bound, since there are only " << param->size() << " parameters."; + cerr << endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** alpha parameter no = " << fRunInfo->GetAlphaParamNo(); + cerr << endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; cerr << endl; fValid = false; return; @@ -92,8 +92,8 @@ PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UIn if (fRunInfo->GetBetaParamNo() == -1) { // no beta given hence assuming beta == 1 betaFixedToOne = true; } else if ((fRunInfo->GetBetaParamNo() < 0) || (fRunInfo->GetBetaParamNo() > (Int_t)param->size())) { // check if beta parameter is within proper bounds - cerr << endl << "PRunAsymmetry::PRunAsymmetry(): **ERROR** beta parameter no = " << fRunInfo->GetBetaParamNo(); - cerr << endl << " This is out of bound, since there are only " << param->size() << " parameters."; + cerr << endl << ">> PRunAsymmetry::PRunAsymmetry(): **ERROR** beta parameter no = " << fRunInfo->GetBetaParamNo(); + cerr << endl << ">> This is out of bound, since there are only " << param->size() << " parameters."; cerr << endl; fValid = false; return; @@ -189,8 +189,6 @@ Double_t PRunAsymmetry::CalcChiSquare(const std::vector& par) } } -//cout << endl << ">> chisq = " << chisq; - return chisq; } @@ -285,7 +283,7 @@ Bool_t PRunAsymmetry::PrepareData() // get the correct run PRawRunData *runData = fRawData->GetRunData(*(fRunInfo->GetRunName())); if (!runData) { // run not found - cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; + cerr << endl << ">> PRunAsymmetry::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; cerr << endl; return false; } @@ -298,6 +296,47 @@ Bool_t PRunAsymmetry::PrepareData() fFitStopTime = fRunInfo->GetFitRange(1); //cout << endl << "start/stop (fit): " << fFitStartTime << ", " << fFitStopTime << endl; + // collect histogram numbers + PUIntVector forwardHistoNo; + PUIntVector backwardHistoNo; + for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { + forwardHistoNo.push_back(fRunInfo->GetForwardHistoNo(i)-1); + + if (runData->GetNoOfHistos() <= forwardHistoNo[i]) { + cerr << endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; + cerr << endl << ">> forwardHistoNo found = " << forwardHistoNo[i]+1 << ", but there are only " << runData->GetNoOfHistos() << " runs!?!?"; + cerr << endl << ">> Will quit :-("; + cerr << endl; + // clean up + forwardHistoNo.clear(); + backwardHistoNo.clear(); + return false; + } + } + for (UInt_t i=0; iGetBackwardHistoNoSize(); i++) { + backwardHistoNo.push_back(fRunInfo->GetBackwardHistoNo(i)-1); + + if (runData->GetNoOfHistos() <= backwardHistoNo[i]) { + cerr << endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; + cerr << endl << ">> backwardHistoNo found = " << backwardHistoNo[i]+1 << ", but there are only " << runData->GetNoOfHistos() << " runs!?!?"; + cerr << endl << ">> Will quit :-("; + cerr << endl; + // clean up + forwardHistoNo.clear(); + backwardHistoNo.clear(); + return false; + } + } + if (forwardHistoNo.size() != backwardHistoNo.size()) { + cerr << endl << ">> PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; + cerr << endl << ">> # of forward histograms different from # of backward histograms."; + cerr << endl << ">> Will quit :-("; + cerr << endl; + // clean up + forwardHistoNo.clear(); + backwardHistoNo.clear(); + return false; + } // check if the t0's are given in the msr-file if (fRunInfo->GetT0Size() == 0) { // t0's are NOT in the msr-file @@ -305,77 +344,77 @@ Bool_t PRunAsymmetry::PrepareData() 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 + for (UInt_t i=0; iGetT0(fRunInfo->GetForwardHistoNo(i)-1)); // forward t0 + fT0s.push_back(runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1)); // backward t0 + } } 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; + for (UInt_t i=0; iGetT0Estimated(fRunInfo->GetForwardHistoNo(i)-1)); + fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(i)-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(i)-1)+1; + cerr << endl << ">> will try the estimated one: backward t0 = " << runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(i)-1)+1; + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; + } } } else { // t0's in the msr-file - // check if t0's are given in the data file - 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"; - cerr << endl << " t0 from the msr-file is " << fRunInfo->GetT0(0); - cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo()-1); - cerr << endl << " This is quite a deviation! Is this done intentionally??"; - cerr << endl; - } - if (fabs(fRunInfo->GetT0(1)-runData->GetT0(fRunInfo->GetBackwardHistoNo()-1))>5.0) { // given in bins!! - cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING**: backward histo"; - cerr << endl << " t0 from the msr-file is " << fRunInfo->GetT0(1); - cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->GetBackwardHistoNo()-1); - cerr << endl << " This is quite a deviation! Is this done intentionally??"; - cerr << endl; + for (UInt_t i=0; iGetT0Size() <= 2*i) || (fRunInfo->GetT0Size() <= 2*i+1)) { // t0 for i not present in the msr-file, i.e. #t0's != #forward histos + if (static_cast(runData->GetT0Size()) > fRunInfo->GetForwardHistoNo(i)-1) { // t0 for i present in the data file + fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1)); + } else { // t0 is neither in the run data nor in the msr-file -> will try estimated ones! + fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-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(i)-1)+1; + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; + } + if (static_cast(runData->GetT0Size()) > fRunInfo->GetBackwardHistoNo(i)-1) { // t0 for i present in the data file + fT0s.push_back(runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1)); + } else { // t0 is neither in the run data nor in the msr-file -> will try estimated ones! + fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(i)-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->GetBackwardHistoNo(i)-1)+1; + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; + } + } else { // # of t0's in the msr-file == # of histos in forward + fT0s.push_back(fRunInfo->GetT0(2*i)); // forward t0 + fT0s.push_back(fRunInfo->GetT0(2*i+1)); // backward t0 + + // check if t0's are given in the data file + if (runData->GetT0Size() != 0) { + // compare t0's of the msr-file with the one in the data file + if (fabs(fRunInfo->GetT0(2*i)-runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1))>5.0) { + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING**: forward histo #" << i+1; + cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetT0(2*i)+1; + cerr << endl << ">> t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1)+1; + cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; + cerr << endl; + } + if (fabs(fRunInfo->GetT0(2*i+1)-runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1))>5.0) { // given in bins!! + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING**: backward histo #" << i+1; + cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetT0(2*i+1)+1; + cerr << endl << ">> t0 from the data file is " << runData->GetT0(fRunInfo->GetBackwardHistoNo(i)-1)+1; + cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; + cerr << endl; + } + } } } - fT0s.push_back(fRunInfo->GetT0(0)); // forward t0 - fT0s.push_back(fRunInfo->GetT0(1)); // backward t0 - } - - // first check if forward/backward given in the msr-file are valid - if (fRunInfo->GetForwardHistoNo() <= 0) { - cerr << endl << "PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; - cerr << endl << " forward histoNo found = " << fRunInfo->GetForwardHistoNo() << ". Only histoNo > 0 are allowed."; - cerr << endl << " Will quit :-("; - cerr << endl; - return false; - } - if (fRunInfo->GetBackwardHistoNo() <= 0) { - cerr << endl << "PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; - cerr << endl << " backward histoNo found = " << fRunInfo->GetBackwardHistoNo() << ". Only histoNo > 0 are allowed."; - cerr << endl << " Will quit :-("; - cerr << endl; - return false; - } - - // check if post pile up data shall be used - UInt_t histoNo[2]; // forward/backward - histoNo[0] = fRunInfo->GetForwardHistoNo()-1; - histoNo[1] = fRunInfo->GetBackwardHistoNo()-1; - // first check if forward/backward given in the msr-file are valid - if ((runData->GetNoOfHistos() < histoNo[0]+1) || - (runData->GetNoOfHistos() < histoNo[1]+1)) { - cerr << endl << "PRunAsymmetry::PrepareData(): **PANIC ERROR**:"; - cerr << endl << " forward/backward histo no found = " << histoNo[0]+1; - cerr << ", " << histoNo[1]+1 << ", but there are only " << runData->GetNoOfHistos() << " histo sets!?!?"; - cerr << endl << " Will quit :-("; - cerr << endl; - return false; } // get raw forward/backward histo data - fForward.resize(runData->GetDataBin(histoNo[0])->size()); - fBackward.resize(runData->GetDataBin(histoNo[0])->size()); - fForward = *runData->GetDataBin(histoNo[0]); - fBackward = *runData->GetDataBin(histoNo[1]); + fForward.resize(runData->GetDataBin(forwardHistoNo[0])->size()); + fBackward.resize(runData->GetDataBin(backwardHistoNo[0])->size()); + fForward = *runData->GetDataBin(forwardHistoNo[0]); + fBackward = *runData->GetDataBin(backwardHistoNo[0]); // check if addrun's are present, and if yes add data // check if there are runs to be added to the current one @@ -385,89 +424,123 @@ Bool_t PRunAsymmetry::PrepareData() // get run to be added to the main one addRunData = fRawData->GetRunData(*(fRunInfo->GetRunName(i))); if (addRunData == 0) { // couldn't get run - cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + cerr << endl << ">> PRunAsymmetry::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; cerr << endl; return false; } // get T0's of the to be added run - Int_t t0Add[2] = {0, 0}; + PUIntVector t0Add; // 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 + if (i >= fRunInfo->GetAddT0Entries()) { // t0's are NOT in the msr-file // check if the t0's are in the data file 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 + for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { + t0Add.push_back(addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1)); // forward t0 + t0Add.push_back(addRunData->GetT0(fRunInfo->GetBackwardHistoNo(j)-1)); // backward t0 + } } 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; - } - } else { // t0's in the msr-file - // check if t0's are given in the data file - if (2*i+1 < fRunInfo->GetT0Size()) { - t0Add[0] = fRunInfo->GetT0(2*i); - t0Add[1] = fRunInfo->GetT0(2*i+1); - } else { - cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING** NO t0's found, neither in the addrun data ("; - cerr << fRunInfo->GetRunName(i)->Data(); - cerr << "), nor in the msr-file! Will try to use the T0 of the run data ("; - cerr << fRunInfo->GetRunName(i)->Data(); - cerr << ") without any warranty!"; - t0Add[0] = fRunInfo->GetT0(0); - t0Add[1] = fRunInfo->GetT0(1); - } - 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"; - cerr << endl << " t0 from the msr-file is " << fRunInfo->GetT0(2*i); - cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1); - cerr << endl << " This is quite a deviation! Is this done intentionally??"; - cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data(); + for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { + t0Add.push_back(addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo(j)-1)); + t0Add.push_back(addRunData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(j)-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(j)-1)+1; + cerr << endl << ">> will try the estimated one: backward t0 = " << addRunData->GetT0Estimated(fRunInfo->GetBackwardHistoNo(j)-1)+1; + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; cerr << endl; } - if (fabs(t0Add[1]-addRunData->GetT0(fRunInfo->GetBackwardHistoNo()-1))>5.0) { // given in bins!! - cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING**: backward histo"; - cerr << endl << " t0 from the msr-file is " << fRunInfo->GetT0(2*i+1); - cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->GetBackwardHistoNo()-1); - cerr << endl << " This is quite a deviation! Is this done intentionally??"; - cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data(); + } + } else { // t0's in the msr-file + for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { + // check if t0's are given in the data file + if (addRunData->GetT0Size() != 0) { + // compare t0's of the msr-file with the one in the data file + if (fabs(fRunInfo->GetAddT0(i,2*j)-addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1))>5.0) { // given in bins!! + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING**:"; + cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetAddT0(i,2*j)+1; // +1 since vector starts at 0 + cerr << endl << ">> t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1)+1; // +1 since vector starts at 0 + cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; + cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); + cerr << endl; + } + if (fabs(fRunInfo->GetAddT0(i,2*j+1)-addRunData->GetT0(fRunInfo->GetBackwardHistoNo(j)-1))>5.0) { // given in bins!! + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING**:"; + cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetAddT0(i,2*j+1)+1; // +1 since vector starts at 0 + cerr << endl << ">> t0 from the data file is " << addRunData->GetT0(fRunInfo->GetBackwardHistoNo(j)-1)+1; // +1 since vector starts at 0 + cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; + cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); + cerr << endl; + } + } + if (i < fRunInfo->GetAddT0Entries()) { + t0Add.push_back(fRunInfo->GetAddT0(i,2*j)); + t0Add.push_back(fRunInfo->GetAddT0(i,2*j+1)); + } else { + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the addrun data ("; + cerr << fRunInfo->GetRunName(i)->Data(); + cerr << "), nor in the msr-file! Will try to use the T0 of the run data ("; + cerr << fRunInfo->GetRunName(i)->Data(); + cerr << ") without any warranty!"; cerr << endl; + t0Add.push_back(fRunInfo->GetT0(2*j)); + t0Add.push_back(fRunInfo->GetT0(2*j+1)); } } } // add forward run - UInt_t addRunSize = addRunData->GetDataBin(histoNo[0])->size(); - for (UInt_t j=0; jGetDataBin(histoNo[0])->size(); j++) { - // make sure that the index stays in the proper range - if ((j-t0Add[0]+fT0s[0] >= 0) && (j-t0Add[0]+fT0s[0] < addRunSize)) { - fForward[j] += addRunData->GetDataBin(histoNo[0])->at(j-t0Add[0]+fT0s[0]); + UInt_t addRunSize; + for (UInt_t k=0; kGetDataBin(forwardHistoNo[k])->size(); + for (UInt_t j=0; jGetDataBin(forwardHistoNo[k])->size(); j++) { + // make sure that the index stays in the proper range + if ((j-t0Add[2*k]+fT0s[2*k] >= 0) && (j-t0Add[2*k]+fT0s[2*k] < addRunSize)) { + fForward[j] += addRunData->GetDataBin(forwardHistoNo[k])->at(j-t0Add[2*k]+fT0s[2*k]); + } } } // add backward run - addRunSize = addRunData->GetDataBin(histoNo[1])->size(); - for (UInt_t j=0; jGetDataBin(histoNo[1])->size(); j++) { - // make sure that the index stays in the proper range - if ((j-t0Add[1]+fT0s[1] >= 0) && (j-t0Add[1]+fT0s[1] < addRunSize)) { - fBackward[j] += addRunData->GetDataBin(histoNo[1])->at(j-t0Add[1]+fT0s[1]); + for (UInt_t k=0; kGetDataBin(backwardHistoNo[k])->size(); + for (UInt_t j=0; jGetDataBin(backwardHistoNo[k])->size(); j++) { + // make sure that the index stays in the proper range + if ((j-t0Add[2*k+1]+fT0s[2*k+1] >= 0) && (j-t0Add[2*k+1]+fT0s[2*k+1] < addRunSize)) { + fBackward[j] += addRunData->GetDataBin(backwardHistoNo[k])->at(j-t0Add[2*k+1]+fT0s[2*k+1]); + } } } + + // clean up + t0Add.clear(); + } + } + + // group histograms, add all the forward histograms to the one with forwardHistoNo[0] + for (UInt_t i=1; iGetDataBin(forwardHistoNo[i])->size(); j++) { + // make sure that the index stays within proper range + if ((j-fT0s[0]+fT0s[2*i] >= 0) && (j-fT0s[0]+fT0s[2*i] < runData->GetDataBin(forwardHistoNo[i])->size())) { + fForward[j] += runData->GetDataBin(forwardHistoNo[i])->at(j-fT0s[0]+fT0s[2*i]); + } + } + } + // group histograms, add all the backward histograms to the one with backwardHistoNo[0] + for (UInt_t i=1; iGetDataBin(backwardHistoNo[i])->size(); j++) { + // make sure that the index stays within proper range + if ((j-fT0s[1]+fT0s[2*i+1] >= 0) && (j-fT0s[1]+fT0s[2*i+1] < runData->GetDataBin(backwardHistoNo[i])->size())) { + fBackward[j] += runData->GetDataBin(backwardHistoNo[i])->at(j-fT0s[1]+fT0s[2*i+1]); + } } } // subtract background from histogramms ------------------------------------------ - if (fRunInfo->GetBkgFixSize() == 0) { // no fixed background given - if (fRunInfo->GetBkgRangeSize() != 0) { + if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given + if (fRunInfo->GetBkgRange(0) >= 0) { if (!SubtractEstimatedBkg()) return false; } else { // no background given to do the job, try to estimate it @@ -475,11 +548,11 @@ Bool_t PRunAsymmetry::PrepareData() fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); fRunInfo->SetBkgRange(static_cast(fT0s[1]*0.1), 2); fRunInfo->SetBkgRange(static_cast(fT0s[1]*0.6), 3); - cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << "Will try the following:"; - cerr << endl << "forward: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << "backward: bkg start = " << fRunInfo->GetBkgRange(2) << ", bkg end = " << fRunInfo->GetBkgRange(3); - cerr << endl << "NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; + cerr << endl << ">> Will try the following:"; + cerr << endl << ">> forward: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + cerr << endl << ">> backward: bkg start = " << fRunInfo->GetBkgRange(2) << ", bkg end = " << fRunInfo->GetBkgRange(3); + cerr << endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; cerr << endl; if (!SubtractEstimatedBkg()) return false; @@ -490,6 +563,7 @@ Bool_t PRunAsymmetry::PrepareData() } // everything looks fine, hence fill data set + UInt_t histoNo[2] = {forwardHistoNo[0], backwardHistoNo[0]}; Bool_t status; switch(fHandleTag) { case kFit: @@ -506,6 +580,10 @@ Bool_t PRunAsymmetry::PrepareData() break; } + // clean up + forwardHistoNo.clear(); + backwardHistoNo.clear(); + return status; } @@ -594,18 +672,18 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() // check if start is within histogram bounds if ((start[0] < 0) || (start[0] >= fForward.size()) || (start[1] < 0) || (start[1] >= fBackward.size())) { - cerr << endl << "PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << " histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; - cerr << endl << " background start (f/b) = (" << start[0] << "/" << start[1] << ")."; + cerr << endl << ">> PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; + cerr << endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; + cerr << endl << ">> background start (f/b) = (" << start[0] << "/" << start[1] << ")."; return false; } // check if end is within histogram bounds if ((end[0] < 0) || (end[0] >= fForward.size()) || (end[1] < 0) || (end[1] >= fBackward.size())) { - cerr << endl << "PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << " histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; - cerr << endl << " background end (f/b) = (" << end[0] << "/" << end[1] << ")."; + cerr << endl << ">> PRunAsymmetry::SubtractEstimatedBkg(): **ERROR** background bin values out of bound!"; + cerr << endl << ">> histo lengths (f/b) = (" << fForward.size() << "/" << fBackward.size() << ")."; + cerr << endl << ">> background end (f/b) = (" << end[0] << "/" << end[1] << ")."; return false; } @@ -660,26 +738,26 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2]) // check if data range has been provided, and if not try to estimate them if (start[0] < 0) { start[0] = (Int_t)t0[0]+5; - cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING** data range (forward) was not provided, will try data range start = t0+5 = " << start[0] << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** data range (forward) was not provided, will try data range start = t0+5 = " << start[0] << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } if (start[1] < 0) { start[1] = (Int_t)t0[1]+5; - cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING** data range (backward) was not provided, will try data range start = t0+5 = " << start[1] << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** data range (backward) was not provided, will try data range start = t0+5 = " << start[1] << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } if (end[0] < 0) { end[0] = runData->GetDataBin(histoNo[0])->size(); - cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING** data range (forward) was not provided, will try data range end = " << end[0] << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** data range (forward) was not provided, will try data range end = " << end[0] << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } if (end[1] < 0) { end[1] = runData->GetDataBin(histoNo[1])->size(); - cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING** data range (backward) was not provided, will try data range end = " << end[1] << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunAsymmetry::PrepareData(): **WARNING** data range (backward) was not provided, will try data range end = " << end[1] << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } // check if start, end, and t0 make any sense @@ -692,19 +770,19 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2]) } // 2nd check if start is within proper bounds if ((start[i] < 0) || (start[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds if ((end[i] < 0) || (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; } // 4th check if t0 is within proper bounds if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareFitData(): **ERROR** t0 data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareFitData(): **ERROR** t0 data bin doesn't make any sense!"; cerr << endl; return false; } @@ -842,13 +920,13 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) // check if data range has been provided, and if not try to estimate them if (fRunInfo->GetDataRange(0) < 0) { start[0] = ((Int_t)t0[0]+5) - (((Int_t)t0[0]+5)/packing)*packing; - cerr << endl << "PRunAsymmetry::PrepareViewData(): **WARNING** data range (forward) was not provided, will try data range start = " << start[0] << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** data range (forward) was not provided, will try data range start = " << start[0] << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } else if (fRunInfo->GetDataRange(2) < 0) { start[1] = ((Int_t)t0[1]+5) - (((Int_t)t0[1]+5)/packing)*packing; - cerr << endl << "PRunAsymmetry::PrepareViewData(): **WARNING** data range (backward) was not provided, will try data range start = " << start[1] << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **WARNING** data range (backward) was not provided, will try data range start = " << start[1] << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } else { Int_t val = fRunInfo->GetDataRange(0)-packing*(fRunInfo->GetDataRange(0)/packing); @@ -879,19 +957,19 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) } // 2nd check if start is within proper bounds if ((start[i] < 0) || (start[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds if ((end[i] < 0) || (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; } // 4th check if t0 is within proper bounds if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareViewData(): **ERROR** t0 data bin doesn't make any sense!"; cerr << endl; return false; } @@ -1094,13 +1172,13 @@ Bool_t PRunAsymmetry::PrepareRRFViewData(PRawRunData* runData, UInt_t histoNo[2] // check if data range has been provided, and if not try to estimate them if (fRunInfo->GetDataRange(0) < 0) { start[0] = static_cast(t0[0])+5; - cerr << endl << "PRunAsymmetry::PrepareRRFViewData(): **WARNING** data range (forward) was not provided, will try data range start = " << start[0] << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **WARNING** data range (forward) was not provided, will try data range start = " << start[0] << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } else if (fRunInfo->GetDataRange(2) < 0) { start[1] = static_cast(t0[1])+5; - cerr << endl << "PRunAsymmetry::PrepareRRFViewData(): **WARNING** data range (backward) was not provided, will try data range start = " << start[1] << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **WARNING** data range (backward) was not provided, will try data range start = " << start[1] << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } else { Int_t val = fRunInfo->GetDataRange(0)-packing*(fRunInfo->GetDataRange(0)/packing); @@ -1131,19 +1209,19 @@ Bool_t PRunAsymmetry::PrepareRRFViewData(PRawRunData* runData, UInt_t histoNo[2] } // 2nd check if start is within proper bounds if ((start[i] < 0) || (start[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareRRFViewData(): **ERROR** start data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds if ((end[i] < 0) || (end[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareRRFViewData(): **ERROR** end data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; } // 4th check if t0 is within proper bounds if ((t0[i] < 0) || (t0[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { - cerr << endl << "PRunAsymmetry::PrepareRRFViewData(): **ERROR** t0 data bin doesn't make any sense!"; + cerr << endl << ">> PRunAsymmetry::PrepareRRFViewData(): **ERROR** t0 data bin doesn't make any sense!"; cerr << endl; return false; } diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index 7594fb67..fcad8923 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -61,8 +61,8 @@ PRunSingleHisto::PRunSingleHisto() : PRunBase() PRunSingleHisto::PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag) : PRunBase(msrInfo, rawData, runNo, tag) { if (!PrepareData()) { - cerr << endl << "**SEVERE ERROR**: PRunSingleHisto::PRunSingleHisto: Couldn't prepare data for fitting!"; - cerr << endl << " This is very bad :-(, will quit ..."; + cerr << endl << ">> PRunSingleHisto::PRunSingleHisto: **SEVERE ERROR**: Couldn't prepare data for fitting!"; + cerr << endl << ">> This is very bad :-(, will quit ..."; cerr << endl; fValid = false; } @@ -120,7 +120,7 @@ Double_t PRunSingleHisto::CalcChiSquare(const std::vector& par) // get background Double_t bkg; if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted - if (fRunInfo->GetBkgFixSize() == 0) { // no fixed background given (background interval) + if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given (background interval) bkg = fBackground; } else { // fixed bkg given bkg = fRunInfo->GetBkgFix(0); @@ -184,7 +184,7 @@ Double_t PRunSingleHisto::CalcMaxLikelihood(const std::vector& par) // get background Double_t bkg; if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted - if (fRunInfo->GetBkgFixSize() == 0) { // no fixed background given (background interval) + if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given (background interval) bkg = fBackground; } else { // fixed bkg given bkg = fRunInfo->GetBkgFix(0); @@ -258,7 +258,7 @@ void PRunSingleHisto::CalcTheory() // get background Double_t bkg; if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted - if (fRunInfo->GetBkgFixSize() == 0) { // no fixed background given (background interval) + if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given (background interval) bkg = fBackground; } else { // fixed bkg given bkg = fRunInfo->GetBkgFix(0); @@ -301,28 +301,24 @@ Bool_t PRunSingleHisto::PrepareData() // get the proper run PRawRunData* runData = fRawData->GetRunData(*fRunInfo->GetRunName()); if (!runData) { // couldn't get run - cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; cerr << endl; return false; } - // check if post pile up data shall be used - if (fRunInfo->GetForwardHistoNo() <= 0) { - cerr << endl << "PRunSingleHisto::PrepareData(): **PANIC ERROR**:"; - cerr << endl << " histoNo found = " << fRunInfo->GetForwardHistoNo() << ". Only histoNo > 0 are allowed."; - cerr << endl << " Will quit :-("; - cerr << endl; - return false; - } + // collect histogram numbers + PUIntVector histoNo; + for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { + histoNo.push_back(fRunInfo->GetForwardHistoNo(i)-1); - UInt_t histoNo = fRunInfo->GetForwardHistoNo()-1; - - if (runData->GetNoOfHistos() <= histoNo) { - cerr << endl << "PRunSingleHisto::PrepareData(): **PANIC ERROR**:"; - cerr << endl << " histoNo found = " << histoNo+1 << ", but there are only " << runData->GetNoOfHistos() << " runs!?!?"; - cerr << endl << " Will quit :-("; - cerr << endl; - return false; + if (runData->GetNoOfHistos() <= histoNo[i]) { + cerr << endl << ">> PRunSingleHisto::PrepareData(): **PANIC ERROR**:"; + cerr << endl << ">> histoNo found = " << histoNo[i]+1 << ", but there are only " << runData->GetNoOfHistos() << " runs!?!?"; + cerr << endl << ">> Will quit :-("; + cerr << endl; + histoNo.clear(); + return false; + } } // check if the t0's are given in the msr-file @@ -331,36 +327,56 @@ Bool_t PRunSingleHisto::PrepareData() 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)); + for (UInt_t i=0; iGetForwardHistoNoSize(); i++) + fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1)); } 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; - } - } else { // t0's in the msr-file - // check if t0's are given in the data file - 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**:"; - cerr << endl << " t0 from the msr-file is " << fRunInfo->GetT0(0); - cerr << endl << " t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo()-1); - cerr << endl << " This is quite a deviation! Is this done intentionally??"; + for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { + fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-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(i)-1)+1; + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; cerr << endl; } } - fT0s.push_back(fRunInfo->GetT0(0)); + } else { // t0's in the msr-file + for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { + // check if enough t0's are given in the msr-file, if not try to get the rest from the data file + if (fRunInfo->GetT0Size() <= i) { // t0 for i not present in the msr-file, i.e. #t0's != #forward histos + if (runData->GetT0Size() > fRunInfo->GetForwardHistoNo(i)-1) { // t0 for i present in the data file + fT0s.push_back(runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1)); + } else { // t0 is neither in the run data nor in the msr-file -> will try estimated ones! + fT0s.push_back(runData->GetT0Estimated(fRunInfo->GetForwardHistoNo(i)-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(i)-1)+1; + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; + cerr << endl; + } + } else { // # of t0's in the msr-file == # of histos in forward + fT0s.push_back(fRunInfo->GetT0(i)); + // check if t0's are given in the data file + if (runData->GetT0Size() != 0) { + // compare t0's of the msr-file with the one in the data file + if (fabs(fRunInfo->GetT0(i)-runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1))>5.0) { // given in bins!! + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING**:"; + cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetT0(i)+1; + cerr << endl << ">> t0 from the data file is " << runData->GetT0(fRunInfo->GetForwardHistoNo(i)-1)+1; + cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; + cerr << endl; + } + } + } + } } // check if t0 is within proper bounds - Int_t t0 = fT0s[0]; - if ((t0 < 0) || (t0 > (Int_t)runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** t0 data bin doesn't make any sense!"; - cerr << endl; - return false; + for (UInt_t i=0; iGetForwardHistoNoSize(); i++) { + if ((fT0s[i] < 0) || (fT0s[i] > (Int_t)runData->GetDataBin(histoNo[i])->size())) { + cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** t0 data bin doesn't make any sense!"; + cerr << endl; + return false; + } } // check if there are runs to be added to the current one @@ -371,61 +387,81 @@ Bool_t PRunSingleHisto::PrepareData() // get run to be added to the main one addRunData = fRawData->GetRunData(*fRunInfo->GetRunName(i)); if (addRunData == 0) { // couldn't get run - cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; cerr << endl; return false; } // get T0's of the to be added run - Int_t t0Add; + PUIntVector t0Add; // check if the t0's are given in the msr-file - if (i >= fRunInfo->GetT0Size()) { // t0's are NOT in the msr-file + if (i >= fRunInfo->GetAddT0Entries()) { // t0's are NOT in the msr-file // check if the t0's are in the data file 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); + for (UInt_t j=0; jGetForwardHistoNoSize(); j++) + t0Add.push_back(addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1)); } 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; - } - } else { // t0's in the msr-file - // check if t0's are given in the data file - 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**:"; - cerr << endl << " t0 from the msr-file is " << fRunInfo->GetT0(i); - cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo()-1); - cerr << endl << " This is quite a deviation! Is this done intentionally??"; - cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data(); + for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { + t0Add.push_back(addRunData->GetT0Estimated(fRunInfo->GetForwardHistoNo(j)-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(j)-1)+1; + cerr << endl << ">> NO WARRANTY THAT THIS OK!! For instance for LEM this is almost for sure rubbish!"; cerr << endl; } } - if (i < fRunInfo->GetT0Size()) { - t0Add = fRunInfo->GetT0(i); - } else { - cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the addrun data ("; - cerr << fRunInfo->GetRunName(i)->Data(); - cerr << "), nor in the msr-file! Will try to use the T0 of the run data ("; - cerr << fRunInfo->GetRunName(i)->Data(); - cerr << ") without any warranty!"; - cerr << endl; - t0Add = fRunInfo->GetT0(0); + } else { // t0's in the msr-file + for (UInt_t j=0; jGetForwardHistoNoSize(); j++) { + // check if t0's are given in the data file + if (addRunData->GetT0Size() != 0) { + // compare t0's of the msr-file with the one in the data file + if (fabs(fRunInfo->GetAddT0(i,j)-addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1))>5.0) { // given in bins!! + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING**:"; + cerr << endl << ">> t0 from the msr-file is " << fRunInfo->GetAddT0(i,j)+1; // +1 since vector starts at 0 + cerr << endl << ">> t0 from the data file is " << addRunData->GetT0(fRunInfo->GetForwardHistoNo(j)-1)+1; // +1 since vector starts at 0 + cerr << endl << ">> This is quite a deviation! Is this done intentionally??"; + cerr << endl << ">> addrun: " << fRunInfo->GetRunName(i)->Data(); + cerr << endl; + } + } + if (i < fRunInfo->GetAddT0Entries()) { + t0Add.push_back(fRunInfo->GetAddT0(i,j)); + } else { + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the addrun data ("; + cerr << fRunInfo->GetRunName(i)->Data(); + cerr << "), nor in the msr-file! Will try to use the T0 of the run data ("; + cerr << fRunInfo->GetRunName(i)->Data(); + cerr << ") without any warranty!"; + cerr << endl; + t0Add.push_back(fRunInfo->GetT0(j)); + } } } - // add run - for (UInt_t j=0; jGetDataBin(histoNo)->size(); j++) { - // make sure that the index stays in the proper range - if ((j-t0Add+t0 >= 0) && (j-t0Add+t0 < addRunData->GetDataBin(histoNo)->size())) { - runData->AddDataBin(histoNo, j, addRunData->GetDataBin(histoNo)->at(j-t0Add+t0)); + // add runs + for (UInt_t k=0; kGetForwardHistoNoSize(); k++) { + for (UInt_t j=0; jGetDataBin(histoNo[k])->size(); j++) { + // make sure that the index stays within proper range + if ((j-t0Add[k]+fT0s[k] >= 0) && (j-t0Add[k]+fT0s[k] < addRunData->GetDataBin(histoNo[k])->size())) { + runData->AddDataBin(histoNo[k], j, addRunData->GetDataBin(histoNo[k])->at(j-t0Add[k]+fT0s[k])); + } } } + + // clean up + t0Add.clear(); + } + } + + // group histograms, add all the forward histograms to the one with histoNo[0] + for (UInt_t i=1; iGetForwardHistoNoSize(); i++) { + for (UInt_t j=0; jGetDataBin(histoNo[0])->size(); j++) { + // make sure that the index stays within proper range + if ((j-fT0s[0]+fT0s[i] >= 0) && (j-fT0s[0]+fT0s[i] < runData->GetDataBin(histoNo[i])->size())) { + runData->AddDataBin(histoNo[0], j, runData->GetDataBin(histoNo[i])->at(j-fT0s[0]+fT0s[i])); + } } } @@ -433,14 +469,17 @@ Bool_t PRunSingleHisto::PrepareData() fTimeResolution = runData->GetTimeResolution()/1.0e3; if (fHandleTag == kFit) - success = PrepareFitData(runData, histoNo); + success = PrepareFitData(runData, histoNo[0]); else if ((fHandleTag == kView) && !fRunInfo->IsLifetimeCorrected()) - success = PrepareRawViewData(runData, histoNo); + success = PrepareRawViewData(runData, histoNo[0]); else if ((fHandleTag == kView) && fRunInfo->IsLifetimeCorrected()) - success = PrepareViewData(runData, histoNo); + success = PrepareViewData(runData, histoNo[0]); else success = false; + // cleanup + histoNo.clear(); + return success; } @@ -469,14 +508,14 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN // check if data range has been provided, and if not try to estimate them if (start < 0) { start = fT0s[0]+5; - cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = t0+5 = " << start << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = t0+5 = " << start << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } if (end < 0) { end = runData->GetDataBin(histoNo)->size(); - cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range end = " << end << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range end = " << end << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } @@ -489,13 +528,13 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN } // 2nd check if start is within proper bounds if ((start < 0) || (start > (Int_t)runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; + cerr << endl << ">> PRunSingleHisto::PrepareFitData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds if ((end < 0) || (end > (Int_t)runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; + cerr << endl << ">> PRunSingleHisto::PrepareFitData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; } @@ -503,20 +542,24 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN // check how the background shall be handled if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg shall **NOT** be fitted // subtract background from histogramms ------------------------------------------ - if (fRunInfo->GetBkgFixSize() == 0) { // no fixed background given - if (fRunInfo->GetBkgRangeSize() != 0) { + if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given + if (fRunInfo->GetBkgRange(0) >= 0) { if (!EstimateBkg(histoNo)) return false; } else { // no background given to do the job, try estimate fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.1), 0); fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); - cerr << endl << "PRunSingleHisto::PrepareFitData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << "Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << "NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + cerr << endl << ">> PRunSingleHisto::PrepareFitData(): **WARNING** Neither fix background nor background bins are given!"; + cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + cerr << endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; cerr << endl; if (!EstimateBkg(histoNo)) return false; } + } else { // fixed background given + for (UInt_t i=0; iGetDataBin(histoNo)->size(); i++) { + runData->AddDataBin(histoNo, i, -fRunInfo->GetBkgFix(0)); + } } } @@ -593,8 +636,8 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi if (start < 0) { start = (fT0s[0]+5) - ((fT0s[0]+5)/packing)*packing; end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing; - cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } // check if start, end, and t0 make any sense @@ -606,13 +649,13 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi } // 2nd check if start is within proper bounds if ((start < 0) || (start > (Int_t)runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; + cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds if ((end < 0) || (end > (Int_t)runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; + cerr << endl << ">> PRunSingleHisto::PrepareRawViewData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; } @@ -688,16 +731,16 @@ cout << endl << ">> data start time = " << fData.GetDataTimeStart(); // get background Double_t bkg; if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted - if (fRunInfo->GetBkgFixSize() == 0) { // no fixed background given (background interval) - if (fRunInfo->GetBkgRangeSize() != 0) { // background range given + if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given (background interval) + if (fRunInfo->GetBkgRange(0) >= 0) { // background range given if (!EstimateBkg(histoNo)) return false; } else { // no background given to do the job, try estimate fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.1), 0); fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); - cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << "Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << "NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; + cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + cerr << endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; cerr << endl; if (!EstimateBkg(histoNo)) return false; @@ -781,8 +824,8 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo if (start < 0) { start = (fT0s[0]+5) - ((fT0s[0]+5)/packing)*packing; end = start + ((runData->GetDataBin(histoNo)->size()-start)/packing)*packing; - cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << "."; - cerr << endl << "NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** data range was not provided, will try data range start = " << start << "."; + cerr << endl << ">> NO WARRANTY THAT THIS DOES MAKE ANY SENSE."; cerr << endl; } @@ -795,13 +838,13 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo } // 2nd check if start is within proper bounds if ((start < 0) || (start > (Int_t)runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; + cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **ERROR** start data bin doesn't make any sense!"; cerr << endl; return false; } // 3rd check if end is within proper bounds if ((end < 0) || (end > (Int_t)runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; + cerr << endl << ">> PRunSingleHisto::PrepareViewData(): **ERROR** end data bin doesn't make any sense!"; cerr << endl; return false; } @@ -837,16 +880,16 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo // get background Double_t bkg; if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg not fitted - if (fRunInfo->GetBkgFixSize() == 0) { // no fixed background given (background interval) - if (fRunInfo->GetBkgRangeSize() != 0) { // background range given + if (fRunInfo->GetBkgFix(0) == PMUSR_UNDEFINED) { // no fixed background given (background interval) + if (fRunInfo->GetBkgRange(0) >= 0) { // background range given if (!EstimateBkg(histoNo)) return false; } else { // no background given to do the job, try estimate fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.1), 0); fRunInfo->SetBkgRange(static_cast(fT0s[0]*0.6), 1); - cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; - cerr << endl << "Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); - cerr << endl << "NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; + cerr << endl << ">> PRunSingleHisto::PrepareData(): **WARNING** Neither fix background nor background bins are given!"; + cerr << endl << ">> Will try the following: bkg start = " << fRunInfo->GetBkgRange(0) << ", bkg end = " << fRunInfo->GetBkgRange(1); + cerr << endl << ">> NO WARRANTY THAT THIS MAKES ANY SENSE! Better check ..."; cerr << endl; if (!EstimateBkg(histoNo)) return false; @@ -1058,18 +1101,18 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo) // check if start is within histogram bounds if ((start < 0) || (start >= runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << " histo lengths = " << runData->GetDataBin(histoNo)->size(); - cerr << endl << " background start = " << start; + cerr << endl << ">> PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; + cerr << endl << ">> histo lengths = " << runData->GetDataBin(histoNo)->size(); + cerr << endl << ">> background start = " << start; cerr << endl; return false; } // check if end is within histogram bounds if ((end < 0) || (end >= runData->GetDataBin(histoNo)->size())) { - cerr << endl << "PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; - cerr << endl << " histo lengths = " << runData->GetDataBin(histoNo)->size(); - cerr << endl << " background end = " << end; + cerr << endl << ">> PRunSingleHisto::EstimatBkg(): **ERROR** background bin values out of bound!"; + cerr << endl << ">> histo lengths = " << runData->GetDataBin(histoNo)->size(); + cerr << endl << ">> background end = " << end; cerr << endl; return false; } diff --git a/src/include/PMsrHandler.h b/src/include/PMsrHandler.h index fc089194..81e83b53 100644 --- a/src/include/PMsrHandler.h +++ b/src/include/PMsrHandler.h @@ -96,6 +96,8 @@ class PMsrHandler virtual Bool_t CheckUniquenessOfParamNames(UInt_t &parX, UInt_t &parY); virtual Bool_t CheckMaps(); virtual Bool_t CheckFuncs(); + virtual Bool_t CheckHistoGrouping(); + virtual Bool_t CheckAddRunParameters(); private: TString fFileName; ///< file name of the msr-file diff --git a/src/include/PMusr.h b/src/include/PMusr.h index 2679c785..06486389 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -129,6 +129,12 @@ using namespace std; */ typedef vector PBoolVector; +//------------------------------------------------------------- +/** + *

typedef to make to code more readable. + */ +typedef vector PUIntVector; + //------------------------------------------------------------- /** *

typedef to make to code more readable. @@ -384,13 +390,13 @@ class PMsrRunBlock { virtual void CleanUp(); virtual UInt_t GetRunNameSize() { return fRunName.size(); } - virtual TString *GetRunName(UInt_t i=0); + virtual TString *GetRunName(UInt_t idx=0); virtual UInt_t GetBeamlineSize() { return fBeamline.size(); } - virtual TString *GetBeamline(UInt_t i=0); + virtual TString *GetBeamline(UInt_t idx=0); virtual UInt_t GetInstituteSize() { return fInstitute.size(); } - virtual TString *GetInstitute(UInt_t i=0); + virtual TString *GetInstitute(UInt_t idx=0); virtual UInt_t GetFileFormatSize() { return fFileFormat.size(); } - virtual TString *GetFileFormat(UInt_t i=0); + virtual TString *GetFileFormat(UInt_t idx=0); virtual Int_t GetFitType() { return fFitType; } virtual Int_t GetAlphaParamNo() { return fAlphaParamNo; } virtual Int_t GetBetaParamNo() { return fBetaParamNo; } @@ -401,31 +407,35 @@ class PMsrRunBlock { virtual Bool_t IsLifetimeCorrected() { return fLifetimeCorrection; } virtual PIntVector* GetMap() { return &fMap; } virtual Int_t GetMap(UInt_t idx); - virtual Int_t GetForwardHistoNo(UInt_t i=0); - virtual Int_t GetBackwardHistoNo(UInt_t i=0); - virtual UInt_t GetBkgFixSize() { return fBkgFix.size(); } - virtual Double_t GetBkgFix(UInt_t i=0); - virtual UInt_t GetBkgRangeSize() { return fBkgRange.size(); } - virtual Int_t GetBkgRange(UInt_t i=0); - virtual UInt_t GetDataRangeSize() { return fDataRange.size(); } - virtual Int_t GetDataRange(UInt_t i=0); + virtual UInt_t GetForwardHistoNoSize() { return fForwardHistoNo.size(); } + virtual Int_t GetForwardHistoNo(UInt_t idx=0); + virtual UInt_t GetAddForwardHistoNoEntries() { return fAddForwardHistoNo.size(); } + virtual Int_t GetAddForwardHistoNoSize(UInt_t addRunIdx); + virtual Int_t GetAddForwardHistoNo(UInt_t addRunIdx, UInt_t histoIdx); + virtual UInt_t GetBackwardHistoNoSize() { return fBackwardHistoNo.size(); } + virtual Int_t GetBackwardHistoNo(UInt_t idx=0); + virtual UInt_t GetAddBackwardHistoNoEntries() { return fAddBackwardHistoNo.size(); } + virtual Int_t GetAddBackwardHistoNoSize(UInt_t addRunIdx); + virtual Int_t GetAddBackwardHistoNo(UInt_t addRunIdx, UInt_t histoIdx); + virtual Double_t GetBkgFix(UInt_t idx); + virtual Int_t GetBkgRange(UInt_t idx); + virtual Int_t GetDataRange(UInt_t idx); virtual UInt_t GetT0Size() { return fT0.size(); } - virtual Int_t GetT0(UInt_t i=0); - virtual Double_t GetFitRange(UInt_t i); + virtual Int_t GetT0(UInt_t idx=0); + virtual UInt_t GetAddT0Entries() { return fAddT0.size(); } + virtual Int_t GetAddT0Size(UInt_t addRunIdx); + virtual Int_t GetAddT0(UInt_t addRunIdx, UInt_t histoIdx); + virtual Double_t GetFitRange(UInt_t idx); virtual Int_t GetPacking() { return fPacking; } virtual Int_t GetXDataIndex() { return fXYDataIndex[0]; } virtual Int_t GetYDataIndex() { return fXYDataIndex[1]; } virtual TString* GetXDataLabel() { return &fXYDataLabel[0]; } virtual TString* GetYDataLabel() { return &fXYDataLabel[1]; } - virtual void AppendRunName(TString str) { fRunName.push_back(str); } - virtual void SetRunName(TString &str, UInt_t i); - virtual void AppendBeamline(TString str) { fBeamline.push_back(str); } - virtual void SetBeamline(TString &str, UInt_t i); - virtual void AppendInstitute(TString str) { fInstitute.push_back(str); } - virtual void SetInstitute(TString &str, UInt_t i); - virtual void AppendFileFormat(TString str) { fFileFormat.push_back(str); } - virtual void SetFileFormat(TString &str, UInt_t i); + virtual void SetRunName(TString &str, Int_t idx=-1); + virtual void SetBeamline(TString &str, Int_t idx=-1); + virtual void SetInstitute(TString &str, Int_t idx=-1); + virtual void SetFileFormat(TString &str, Int_t idx=-1); virtual void SetFitType(Int_t ival) { fFitType = ival; } virtual void SetAlphaParamNo(Int_t ival) { fAlphaParamNo = ival; } virtual void SetBetaParamNo(Int_t ival) { fBetaParamNo = ival; } @@ -434,18 +444,16 @@ class PMsrRunBlock { virtual void SetPhaseParamNo(Int_t ival) { fPhaseParamNo = ival; } virtual void SetLifetimeParamNo(Int_t ival) { fLifetimeParamNo = ival; } virtual void SetLifetimeCorrection(Bool_t bval) { fLifetimeCorrection = bval; } - virtual void AppendMap(Int_t ival) { fMap.push_back(ival); } - virtual void SetMap(Int_t mapVal, UInt_t idx); + virtual void SetMap(Int_t mapVal, Int_t idx=-1); virtual void SetForwardHistoNo(Int_t histoNo, Int_t idx=-1); + virtual void SetAddForwardHistoNo(Int_t histoNo, UInt_t addRunIdx, UInt_t histoNoIdx); virtual void SetBackwardHistoNo(Int_t histoNo, Int_t idx=-1); - virtual void AppendBkgFix(Double_t dval) { fBkgFix.push_back(dval); } - virtual void SetBkgFix(Double_t dval, UInt_t idx); - virtual void AppendBkgRange(Int_t ival) { fBkgRange.push_back(ival); } - virtual void SetBkgRange(Int_t ival, UInt_t idx); - virtual void AppendDataRange(Int_t ival) { fDataRange.push_back(ival); } - virtual void SetDataRange(Int_t ival, UInt_t idx); - virtual void AppendT0(Int_t ival) { fT0.push_back(ival); } - virtual void SetT0(Int_t ival, UInt_t idx); + virtual void SetAddBackwardHistoNo(Int_t histoNo, UInt_t addRunIdx, UInt_t histoNoIdx); + virtual void SetBkgFix(Double_t dval, Int_t idx=-1); + virtual void SetBkgRange(Int_t ival, Int_t idx); + virtual void SetDataRange(Int_t ival, Int_t idx); + virtual void SetT0(Int_t ival, Int_t idx=-1); + virtual void SetAddT0(Int_t ival, UInt_t addRunIdx, UInt_t histoNoIdx); virtual void SetFitRange(Double_t dval, UInt_t idx); virtual void SetPacking(Int_t ival) { fPacking = ival; } virtual void SetXDataIndex(Int_t ival) { fXYDataIndex[0] = ival; } @@ -468,11 +476,14 @@ class PMsrRunBlock { Bool_t fLifetimeCorrection; ///< lifetime correction flag for viewing (fit type 0) PIntVector fMap; ///< map vector needed to switch parameters for different runs within a single theory PIntVector fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4) + vector fAddForwardHistoNo; ///< forward histogram number for addrun's PIntVector fBackwardHistoNo; ///< backward histogram number (fit type 2, 4) - PDoubleVector fBkgFix; ///< fixed background in (1/ns) (fit type 0, 2, 4) - PIntVector fBkgRange; ///< background bin range (fit type 0, 2, 4) - PIntVector fDataRange; ///< data bin range (fit type 0, 2, 4) + vector fAddBackwardHistoNo; ///< backward histogram number for addrun's + Double_t fBkgFix[2]; ///< fixed background in (1/ns) (fit type 0, 2, 4) + Int_t fBkgRange[4]; ///< background bin range (fit type 0, 2, 4) + Int_t fDataRange[4]; ///< data bin range (fit type 0, 2, 4) PIntVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ... + vector fAddT0; ///< t0 bins for addrun's Double_t fFitRange[2]; ///< fit range in (us) Int_t fPacking; ///< packing/rebinning Int_t fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8) diff --git a/src/tests/t0NotEqFirstGoodData/t0NotEqFirstGoodData.C b/src/tests/t0NotEqFirstGoodData/t0NotEqFirstGoodData.C index 270395fc..8ed45621 100644 --- a/src/tests/t0NotEqFirstGoodData/t0NotEqFirstGoodData.C +++ b/src/tests/t0NotEqFirstGoodData/t0NotEqFirstGoodData.C @@ -44,7 +44,7 @@ void t0NotEqFirstGoodData() decayAnaModule = histosFolder->AddFolder("DecayAnaModule", "muSR decay histograms"); // feed run info header - UInt_t runNo = 10113; + UInt_t runNo = 20001; TString tstr; runInfo = gROOT->GetRootFolder()->AddFolder("RunInfo", "LEM RunInfo"); gROOT->GetListOfBrowsables()->Add(runInfo, "RunInfo"); @@ -64,40 +64,41 @@ void t0NotEqFirstGoodData() header->SetSampleBField(-1.0, 0.1); header->SetTimeResolution(0.1953125); header->SetNChannels(66601); - header->SetNHist(4); + header->SetNHist(8); header->SetCuts("none"); header->SetModerator("none"); - Double_t tt0[4] = {3419.0, 3419.0, 3419.0, 3419.0}; + Double_t tt0[8] = {3419.0, 3519.0, 3419.0, 3519.0, 3419.0, 3519.0, 3419.0, 3519.0}; header->SetTimeZero(tt0); runInfo->Add(header); //add header to RunInfo folder // create histos - UInt_t t0[4] = {3419, 3419, 3419, 3419}; - UInt_t n0[4] = {200.0, 205.0, 203.0, 198.0}; - UInt_t bkg[4] = {11.0, 11.0, 5.0, 8.0}; + UInt_t t0[8] = {3419, 3519, 3419, 3519, 3419.0, 3519.0, 3419.0, 3519.0}; + UInt_t n0[8] = {10000.0, 10000.0, 10000.0, 10000.0, 10000.0, 10000.0, 10000.0, 10000.0}; + UInt_t bkg[8] = {11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0}; const Double_t tau = 2197.019; // ns // asymmetry related stuff const Double_t timeResolution = 0.1953125; // ns - Double_t a0[4] = {0.26, 0.26, 0.26, 0.26}; - Double_t a1[4] = {0.0, 0.0, 0.0, 0.0}; - Double_t phase[4] = {0.0*TMath::Pi()/180.0, 90.0*TMath::Pi()/180.0, 180.0*TMath::Pi()/180.0, 270.0*TMath::Pi()/180.0}; + Double_t a0[8] = {0.26, 0.26, 0.26, 0.26, 0.26, 0.26, 0.26, 0.26}; + Double_t a1[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + Double_t phase[8] = {0.0*TMath::Pi()/180.0, 45.0*TMath::Pi()/180.0, 90.0*TMath::Pi()/180.0, 135.0*TMath::Pi()/180.0, + 180.0*TMath::Pi()/180.0, 225.0*TMath::Pi()/180.0, 270.0*TMath::Pi()/180.0, 315.0*TMath::Pi()/180.0,}; const Double_t gamma = 0.00001355; // gamma/(2pi) - Double_t bb0 = 15000.0; // field in Gauss + Double_t bb0 = 200.0; // field in Gauss Double_t bb1 = 400.0; // field in Gauss Double_t sigma0 = 0.05/1000.0; // Gaussian sigma in 1/ns Double_t sigma1 = 0.005/1000.0; // Gaussian sigma in 1/ns - TH1F *histo[8]; + TH1F *histo[16]; char str[128]; - for (UInt_t i=0; i<4; i++) { + for (UInt_t i=0; i<8; i++) { sprintf(str, "hDecay0%d", (Int_t)i); histo[i] = new TH1F(str, str, 66601, -0.5, 66600.5); sprintf(str, "hDecay2%d", (Int_t)i); - histo[i+4] = new TH1F(str, str, 66601, -0.5, 66600.5); + histo[i+8] = new TH1F(str, str, 66601, -0.5, 66600.5); } Double_t time; Double_t dval; - for (UInt_t i=0; i<4; i++) { + for (UInt_t i=0; i<8; i++) { for (UInt_t j=1; j<66601; j++) { if (jSetBinContent(j, bkg[i]); @@ -131,16 +132,16 @@ void t0NotEqFirstGoodData() cerr << endl << "**ERROR** while invoking PAddPoissonNoise" << endl; return; } - for (UInt_t i=0; i<4; i++) { + for (UInt_t i=0; i<8; i++) { addNoise->AddNoise(histo[i]); } - for (UInt_t i=0; i<4; i++) { + for (UInt_t i=0; i<8; i++) { for (UInt_t j=1; jGetEntries(); j++) { - histo[i+4]->SetBinContent(j, histo[i]->GetBinContent(j)); + histo[i+8]->SetBinContent(j, histo[i]->GetBinContent(j)); } } - for (UInt_t i=0; i<8; i++) + for (UInt_t i=0; i<16; i++) decayAnaModule->Add(histo[i]); // write file