From 90807030f1f3c83ad3681bae95d395b84a00bc41 Mon Sep 17 00:00:00 2001 From: nemu Date: Mon, 2 Nov 2009 08:40:47 +0000 Subject: [PATCH] started with the next step of encapsulation, will take a while --- src/classes/PMsr2Data.cpp | 2 +- src/classes/PMsrHandler.cpp | 35 +++------ src/classes/PMusr.cpp | 129 +++++++++++++++++++++++++++++++- src/classes/PMusrCanvas.cpp | 28 +++---- src/classes/PRunAsymmetry.cpp | 22 +++--- src/classes/PRunDataHandler.cpp | 20 ++--- src/classes/PRunNonMusr.cpp | 4 +- src/classes/PRunSingleHisto.cpp | 36 ++++----- src/include/PMsrHandler.h | 2 +- src/include/PMusr.h | 79 +++++++++++-------- src/include/PRunBase.h | 2 +- src/include/PRunDataHandler.h | 2 +- src/musrfit.cpp | 4 +- src/musrt0.cpp | 20 ++--- src/musrview.cpp | 2 +- 15 files changed, 251 insertions(+), 136 deletions(-) diff --git a/src/classes/PMsr2Data.cpp b/src/classes/PMsr2Data.cpp index ba2982fa..25c9a65b 100644 --- a/src/classes/PMsr2Data.cpp +++ b/src/classes/PMsr2Data.cpp @@ -412,7 +412,7 @@ void PMsr2Data::WriteOutput(const string &outfile, bool db, bool withHeader) con if (fDataHandler) { PMsrRunList *msrRunList(fMsrHandler->GetMsrRunList()); - PRawRunData *rawRunData(fDataHandler->GetRunData((*msrRunList)[0].fRunName[0])); + PRawRunData *rawRunData(fDataHandler->GetRunData((*msrRunList)[0].GetRunName()->Data())); switch (rawRunData->GetNoOfTemperatures()) { case 1: diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 06d0273b..78b867ed 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -90,17 +90,6 @@ PMsrHandler::~PMsrHandler() fParam.clear(); fTheory.clear(); fFunctions.clear(); - for (UInt_t i=0; iData() << " "; str = fRuns[runNo].fBeamline[0]; str.ToUpper(); fout << str.Data() << " "; @@ -514,7 +503,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) fout << str.Data() << " (name beamline institute data-file-format)" << endl; } else if (sstr.BeginsWith("ADDRUN")) { addRunNo++; - fout << "ADDRUN " << fRuns[runNo].fRunName[addRunNo].Data() << " "; + fout << "ADDRUN " << fRuns[runNo].GetRunName(addRunNo)->Data() << " "; str = fRuns[runNo].fBeamline[addRunNo]; str.ToUpper(); fout << str.Data() << " "; @@ -1422,7 +1411,7 @@ Bool_t PMsrHandler::HandleFunctionsEntry(PMsrLines &lines) Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) { PMsrLines::iterator iter; - PMsrRunStructure param; + PMsrRunBlock param; Bool_t first = true; // first run line tag Bool_t error = false; @@ -1430,12 +1419,6 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) TObjArray *tokens = 0; TObjString *ostr = 0; - // init some stuff - param.fXYDataIndex[0] = -1; - param.fXYDataIndex[1] = -1; - param.fXYDataLabel[0] = TString(""); - param.fXYDataLabel[1] = TString(""); - iter = lines.begin(); while ((iter != lines.end()) && !error) { // tokenize line @@ -1451,19 +1434,18 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) if (!first) { // not the first run in the list fRuns.push_back(param); + param.CleanUp(); } else { first = false; } - InitRunParameterStructure(param); - // get run name, beamline, institute, and file-format if (tokens->GetEntries() < 5) { error = true; } else { // run name ostr = dynamic_cast(tokens->At(1)); - param.fRunName.push_back(ostr->GetString()); + param.AppendRunName(ostr->GetString()); // beamline ostr = dynamic_cast(tokens->At(2)); param.fBeamline.push_back(ostr->GetString()); @@ -1484,7 +1466,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) } else { // run name ostr = dynamic_cast(tokens->At(1)); - param.fRunName.push_back(ostr->GetString()); + param.AppendRunName(ostr->GetString()); // beamline ostr = dynamic_cast(tokens->At(2)); param.fBeamline.push_back(ostr->GetString()); @@ -1882,6 +1864,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) cerr << endl << "RUN block syntax is too complex to print it here. Please check the manual."; } else { // save last run found fRuns.push_back(param); + param.CleanUp(); } // check if for fittypes: single histo, asymmetry, RRF any background info is given @@ -1900,7 +1883,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) found = false; } if (!found) { - cerr << endl << ">> PMsrHandler::HandleRunEntry: **ERROR** for run " << fRuns[i].fRunName[0].Data() << ", forward " << fRuns[i].fForwardHistoNo; + cerr << endl << ">> PMsrHandler::HandleRunEntry: **ERROR** for run " << fRuns[i].GetRunName()->Data() << ", forward " << fRuns[i].fForwardHistoNo; cerr << endl << " no background information found!"; cerr << endl << " Either of the tags 'backgr.fit', 'backgr.fix', 'background'"; cerr << endl << " with data is needed."; @@ -1921,6 +1904,7 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) * * \param param */ +/* void PMsrHandler::InitRunParameterStructure(PMsrRunStructure ¶m) { param.fRunName.clear(); @@ -1956,6 +1940,7 @@ void PMsrHandler::InitRunParameterStructure(PMsrRunStructure ¶m) for (Int_t i=0; i<2; i++) param.fXYDataLabel[i] = ""; } +*/ //-------------------------------------------------------------------------- // FilterNumber (private) diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index 43197eac..4557c3ad 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -451,5 +451,132 @@ void PRawRunData::AddDataBin(const UInt_t histoNo, const UInt_t bin, const Doubl //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// implementation PMsrRunStructure +// implementation PMsrRunBlock //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +//-------------------------------------------------------------------------- +// PMsrRunBlock +//-------------------------------------------------------------------------- +/** + *

Constructor + */ +PMsrRunBlock::PMsrRunBlock() +{ + fFitType = -1; // undefined fit type + fAlphaParamNo = -1; // undefined alpha parameter number + fBetaParamNo = -1; // undefined beta parameter number + fNormParamNo = -1; // undefined norm parameter number + fBkgFitParamNo = -1; // undefined background parameter number + fPhaseParamNo = -1; // undefined phase parameter number + fLifetimeParamNo = -1; // undefined lifetime parameter number + fLifetimeCorrection = true; // lifetime correction == true by default (used in single histogram musrview) + fForwardHistoNo = -1; // undefined forward histogram number + fBackwardHistoNo = -1; // undefined backward histogram number + fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range + fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range + fPacking = -1; // undefined packing + fRRFFreq = PMUSR_UNDEFINED; // undefined RRF frequency + fRRFPacking = -1; // undefined RRF packing + fAlpha2ParamNo = -1; // undefined alpha2 parameter number + fBeta2ParamNo = -1; // undefined beta2 parameter number + fRightHistoNo = -1; // undefined right histogram number + fLeftHistoNo = -1; // undefined left histogram number + fXYDataIndex[0] = -1; // undefined x data index (NonMusr) + fXYDataIndex[1] = -1; // undefined y data index (NonMusr) + fXYDataLabel[0] = TString("??"); // undefined x data label (NonMusr) + fXYDataLabel[1] = TString("??"); // undefined y data label (NonMusr) +} + +//-------------------------------------------------------------------------- +// ~PMsrRunBlock +//-------------------------------------------------------------------------- +/** + *

Destructor + */ +PMsrRunBlock::~PMsrRunBlock() +{ + fRunName.clear(); + fBeamline.clear(); + fInstitute.clear(); + fFileFormat.clear(); + fMap.clear(); + fBkgFix.clear(); + fBkgRange.clear(); + fDataRange.clear(); + fT0.clear(); +} + +//-------------------------------------------------------------------------- +// CleanUp +//-------------------------------------------------------------------------- +/** + *

Clean up data structure. + */ +void PMsrRunBlock::CleanUp() +{ + fFitType = -1; // undefined fit type + fAlphaParamNo = -1; // undefined alpha parameter number + fBetaParamNo = -1; // undefined beta parameter number + fNormParamNo = -1; // undefined norm parameter number + fBkgFitParamNo = -1; // undefined background parameter number + fPhaseParamNo = -1; // undefined phase parameter number + fLifetimeParamNo = -1; // undefined lifetime parameter number + fLifetimeCorrection = true; // lifetime correction == true by default (used in single histogram musrview) + fForwardHistoNo = -1; // undefined forward histogram number + fBackwardHistoNo = -1; // undefined backward histogram number + fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range + fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range + fPacking = -1; // undefined packing + fRRFFreq = PMUSR_UNDEFINED; // undefined RRF frequency + fRRFPacking = -1; // undefined RRF packing + fAlpha2ParamNo = -1; // undefined alpha2 parameter number + fBeta2ParamNo = -1; // undefined beta2 parameter number + fRightHistoNo = -1; // undefined right histogram number + fLeftHistoNo = -1; // undefined left histogram number + fXYDataIndex[0] = -1; // undefined x data index (NonMusr) + fXYDataIndex[1] = -1; // undefined y data index (NonMusr) + fXYDataLabel[0] = TString("??"); // undefined x data label (NonMusr) + fXYDataLabel[1] = TString("??"); // undefined y data label (NonMusr) + + fRunName.clear(); + fBeamline.clear(); + fInstitute.clear(); + fFileFormat.clear(); + fMap.clear(); + fBkgFix.clear(); + fBkgRange.clear(); + fDataRange.clear(); + fT0.clear(); +} + +//-------------------------------------------------------------------------- +// GetRunName +//-------------------------------------------------------------------------- +/** + *

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

set run name at position i + * + * \param i index of the run name to be set + */ +void PMsrRunBlock::SetRunName(TString &str, UInt_t i) +{ + if (i>fRunName.size()) + fRunName.resize(i+1); + + fRunName[i] = str; +} diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 720821eb..5fbf1f72 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -529,10 +529,10 @@ void PMusrCanvas::UpdateInfoPad() for (UInt_t i=0; i 1) - tstr = "++" + runs[runNo].fRunName[0] + TString(","); // run_name + if (runs[runNo].GetRunNames().size() > 1) + tstr = "++" + *(runs[runNo].GetRunName()) + TString(","); // run_name else - tstr = runs[runNo].fRunName[0] + TString(","); // run_name + tstr = *(runs[runNo].GetRunName()) + TString(","); // run_name // histo info (depending on the fittype if (runs[runNo].fFitType == MSR_FITTYPE_SINGLE_HISTO) { tstr += TString("h:"); @@ -546,7 +546,7 @@ void PMusrCanvas::UpdateInfoPad() tstr += TString(","); } // temperature if present - ddvec = fRunList->GetTemp(runs[runNo].fRunName[0]); + ddvec = fRunList->GetTemp(*(runs[runNo].GetRunName())); if (ddvec.empty()) { tstr += TString("T="); tstr += TString("??,"); @@ -564,7 +564,7 @@ void PMusrCanvas::UpdateInfoPad() } // field if present tstr += TString("B="); - dval = fRunList->GetField(runs[runNo].fRunName[0]); + dval = fRunList->GetField(*(runs[runNo].GetRunName())); if (dval == PMUSR_UNDEFINED) { tstr += TString("??,"); } else { @@ -573,7 +573,7 @@ void PMusrCanvas::UpdateInfoPad() } // energy if present tstr += TString("E="); - dval = fRunList->GetEnergy(runs[runNo].fRunName[0]); + dval = fRunList->GetEnergy(*(runs[runNo].GetRunName())); //cout << endl << ">> dval = " << dval << " (Engery)"; if (dval == PMUSR_UNDEFINED) { tstr += TString("??,"); @@ -582,7 +582,7 @@ void PMusrCanvas::UpdateInfoPad() tstr += TString(sval) + TString("keV,"); } // setup if present - tstr += fRunList->GetSetup(runs[runNo].fRunName[0]); + tstr += fRunList->GetSetup(*(runs[runNo].GetRunName())); // add entry fInfoPad->AddEntry(fData[i].data, tstr.Data(), "p"); } @@ -1390,7 +1390,7 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data) // dataHisto ------------------------------------------------------------- // create histo specific infos - name = fMsrHandler->GetMsrRunList()->at(runNo).fRunName[0] + "_DataRunNo"; + name = *(fMsrHandler->GetMsrRunList()->at(runNo).GetRunName()) + "_DataRunNo"; name += (Int_t)runNo; name += "_"; name += fPlotNumber; @@ -1472,7 +1472,7 @@ void PMusrCanvas::HandleDataSet(UInt_t plotNo, UInt_t runNo, PRunData *data) // theoHisto ------------------------------------------------------------- // create histo specific infos - name = fMsrHandler->GetMsrRunList()->at(runNo).fRunName[0] + "_TheoRunNo"; + name = *(fMsrHandler->GetMsrRunList()->at(runNo).GetRunName()) + "_TheoRunNo"; name += (Int_t)runNo; name += "_"; name += fPlotNumber; @@ -2413,8 +2413,8 @@ void PMusrCanvas::PlotData() PMsrRunList runs = *fMsrHandler->GetMsrRunList(); PMsrPlotStructure plotInfo = fMsrHandler->GetMsrPlotList()->at(fPlotNumber); UInt_t runNo = (UInt_t)plotInfo.fRuns[0].Re()-1; - TString xAxisTitle = fRunList->GetXAxisTitle(runs[runNo].fRunName[0], runNo); - TString yAxisTitle = fRunList->GetYAxisTitle(runs[runNo].fRunName[0], runNo); + TString xAxisTitle = fRunList->GetXAxisTitle(*(runs[runNo].GetRunName()), runNo); + TString yAxisTitle = fRunList->GetYAxisTitle(*(runs[runNo].GetRunName()), runNo); if (fNonMusrData.size() > 0) { // check if fMultiGraphData needs to be created, and if yes add all data and theory @@ -2472,8 +2472,8 @@ void PMusrCanvas::PlotData() PStringVector legendLabel; for (UInt_t i=0; iGetXAxisTitle(runs[runNo].fRunName[0], runNo); - yAxisTitle = fRunList->GetYAxisTitle(runs[runNo].fRunName[0], runNo); + xAxisTitle = fRunList->GetXAxisTitle(*(runs[runNo].GetRunName()), runNo); + yAxisTitle = fRunList->GetYAxisTitle(*(runs[runNo].GetRunName()), runNo); legendLabel.push_back(xAxisTitle + " vs. " + yAxisTitle); } for (UInt_t i=0; iGetMsrRunList(); PMsrPlotStructure plotInfo = fMsrHandler->GetMsrPlotList()->at(fPlotNumber); UInt_t runNo = (UInt_t)plotInfo.fRuns[0].Re()-1; - TString xAxisTitle = fRunList->GetXAxisTitle(runs[runNo].fRunName[0], runNo); + TString xAxisTitle = fRunList->GetXAxisTitle(*(runs[runNo].GetRunName()), runNo); // if fMultiGraphDiff is not present create it and add the diff data if (!fMultiGraphDiff) { diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index a844aff0..9f851844 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -283,9 +283,9 @@ Bool_t PRunAsymmetry::PrepareData() // get forward/backward histo from PRunDataHandler object ------------------------ // get the correct run - PRawRunData *runData = fRawData->GetRunData(fRunInfo->fRunName[0]); + PRawRunData *runData = fRawData->GetRunData(*(fRunInfo->GetRunName())); if (!runData) { // run not found - cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->fRunName[0].Data() << "!"; + cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; cerr << endl; return false; } @@ -358,13 +358,13 @@ Bool_t PRunAsymmetry::PrepareData() // check if addrun's are present, and if yes add data // check if there are runs to be added to the current one - if (fRunInfo->fRunName.size() > 1) { // runs to be added present + if (fRunInfo->GetRunNames().size() > 1) { // runs to be added present PRawRunData *addRunData; - for (UInt_t i=1; ifRunName.size(); i++) { + for (UInt_t i=1; iGetRunNames().size(); i++) { // get run to be added to the main one - addRunData = fRawData->GetRunData(fRunInfo->fRunName[i]); + addRunData = fRawData->GetRunData(*(fRunInfo->GetRunName(i))); if (addRunData == 0) { // couldn't get run - cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->fRunName[i].Data() << "!"; + cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; cerr << endl; return false; } @@ -380,7 +380,7 @@ Bool_t PRunAsymmetry::PrepareData() t0Add[0] = addRunData->GetT0(fRunInfo->fForwardHistoNo-1); // forward t0 t0Add[1] = addRunData->GetT0(fRunInfo->fBackwardHistoNo-1); // backward t0 } else { // t0's are neither in the run data nor in the msr-file -> not acceptable! - cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** NO t0's found, neither in the addrun (" << fRunInfo->fRunName[i].Data() << ") data nor in the msr-file!"; + cerr << endl << "PRunAsymmetry::PrepareData(): **ERROR** NO t0's found, neither in the addrun (" << fRunInfo->GetRunName(i)->Data() << ") data nor in the msr-file!"; cerr << endl; return false; } @@ -391,9 +391,9 @@ Bool_t PRunAsymmetry::PrepareData() t0Add[1] = fRunInfo->fT0[2*i+1]; } else { cerr << endl << "PRunAsymmetry::PrepareData(): **WARNING** NO t0's found, neither in the addrun data ("; - cerr << fRunInfo->fRunName[i].Data(); + cerr << fRunInfo->GetRunName(i)->Data(); cerr << "), nor in the msr-file! Will try to use the T0 of the run data ("; - cerr << fRunInfo->fRunName[i].Data(); + cerr << fRunInfo->GetRunName(i)->Data(); cerr << ") without any warranty!"; t0Add[0] = fRunInfo->fT0[0]; t0Add[1] = fRunInfo->fT0[1]; @@ -405,7 +405,7 @@ Bool_t PRunAsymmetry::PrepareData() cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[2*i]; cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fForwardHistoNo-1); cerr << endl << " This is quite a deviation! Is this done intentionally??"; - cerr << endl << " addrun: " << fRunInfo->fRunName[i].Data(); + cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data(); cerr << endl; } if (fabs(t0Add[1]-addRunData->GetT0(fRunInfo->fBackwardHistoNo-1))>5.0) { // given in bins!! @@ -413,7 +413,7 @@ Bool_t PRunAsymmetry::PrepareData() cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[2*i+1]; cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fBackwardHistoNo-1); cerr << endl << " This is quite a deviation! Is this done intentionally??"; - cerr << endl << " addrun: " << fRunInfo->fRunName[i].Data(); + cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data(); cerr << endl; } } diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index ef1ee153..ebab60f0 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -144,10 +144,10 @@ Bool_t PRunDataHandler::ReadFile() } for (UInt_t i=0; isize(); i++) { - for (UInt_t j=0; jat(i).fRunName.size(); j++) { - fRunName = runList->at(i).fRunName[j]; + for (UInt_t j=0; jat(i).GetRunNames().size(); j++) { + fRunName = *(runList->at(i).GetRunName(j)); // check is file is already read - if (FileAlreadyRead(runList->at(i).fRunName[j])) + if (FileAlreadyRead(*(runList->at(i).GetRunName(j)))) continue; // check if file actually exists if (!FileExistsCheck(runList->at(i), j)) @@ -210,7 +210,7 @@ Bool_t PRunDataHandler::FileAlreadyRead(TString runName) * * return: true if data file exists, otherwise false. */ -Bool_t PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t idx) +Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) { Bool_t success = true; @@ -270,7 +270,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t } // check if the file is in the local directory - str = runInfo.fRunName[idx] + TString(".") + ext; + str = *(runInfo.GetRunName(idx)) + TString(".") + ext; if (gSystem->AccessPathName(str.Data())!=true) { // found in the local dir pathName = str; } @@ -278,7 +278,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t // check if the file is found in the if (pathName.CompareTo("???") == 0) { // not found in local directory search str = *fMsrInfo->GetMsrFileDirectoryPath(); - str += runInfo.fRunName[idx] + TString(".") + ext; + str += *(runInfo.GetRunName(idx)) + TString(".") + ext; if (gSystem->AccessPathName(str.Data())!=true) { // found pathName = str; } @@ -287,7 +287,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t // check if the file is found in the directory given in the startup file if (pathName.CompareTo("???") == 0) { // not found in local directory search for (UInt_t i=0; iAccessPathName(str.Data())!=true) { // found pathName = str; break; @@ -304,7 +304,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t TObjString *ostr; for (Int_t i=0; iGetEntries(); i++) { ostr = dynamic_cast(tokens->At(i)); - str = ostr->GetString() + TString("/") + runInfo.fRunName[idx] + TString(".") + ext; + str = ostr->GetString() + TString("/") + *(runInfo.GetRunName(idx)) + TString(".") + ext; if (gSystem->AccessPathName(str.Data())!=true) { // found pathName = str; break; @@ -329,7 +329,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t runInfo.fInstitute[idx] + TString("/") + runInfo.fBeamline[idx] + TString("/") + dt + TString("/") + - runInfo.fRunName[idx] + TString(".") + ext; + *(runInfo.GetRunName(idx)) + TString(".") + ext; if (gSystem->AccessPathName(str.Data())!=true) { // found pathName = str; break; @@ -339,7 +339,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t // no proper path name found if (pathName.CompareTo("???") == 0) { - cerr << endl << "**ERROR** Couldn't find '" << runInfo.fRunName[idx] << "' in any standard path."; + cerr << endl << "**ERROR** Couldn't find '" << runInfo.GetRunName(idx)->Data() << "' in any standard path."; cerr << endl << " standard search pathes are:"; cerr << endl << " 1. the local directory"; cerr << endl << " 2. the data directory given in the startup XML file"; diff --git a/src/classes/PRunNonMusr.cpp b/src/classes/PRunNonMusr.cpp index 1c31f3e3..ad872907 100644 --- a/src/classes/PRunNonMusr.cpp +++ b/src/classes/PRunNonMusr.cpp @@ -63,7 +63,7 @@ PRunNonMusr::PRunNonMusr() : PRunBase() PRunNonMusr::PRunNonMusr(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag) : PRunBase(msrInfo, rawData, runNo, tag) { // get the proper run - fRawRunData = fRawData->GetRunData(fRunInfo->fRunName[0]); + fRawRunData = fRawData->GetRunData(*(fRunInfo->GetRunName())); if (!fRawRunData) { // couldn't get run cerr << endl << "PRunNonMusr::PRunNonMusr(): **ERROR** Couldn't get raw run data!"; cerr << endl; @@ -158,7 +158,7 @@ Bool_t PRunNonMusr::PrepareData() //cout << endl << "in PRunNonMusr::PrepareData(): will feed fFitData"; - if (fRunInfo->fRunName.size() > 1) { // ADDRUN present which is not supported for NonMusr + if (fRunInfo->GetRunNames().size() > 1) { // ADDRUN present which is not supported for NonMusr cerr << endl << ">> PRunNonMusr::PrepareData(): **WARNING** ADDRUN NOT SUPPORTED FOR THIS FIT TYPE, WILL IGNORE IT." << endl; } diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index 68e4a242..0e1896b2 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -147,16 +147,6 @@ Double_t PRunSingleHisto::CalcChiSquare(const std::vector& par) } } -/* -static Int_t firstTime = 0; -if (firstTime < 4) { -firstTime++; -cout << endl << "size=" << fData.GetValue()->size() << ", fDataTimeStart=" << fData.GetDataTimeStart() << ", fDataTimeStep=" << fData.GetDataTimeStep() << ", fFitStartTime=" << fFitStartTime << ", fFitStopTime=" << fFitStopTime; -cout << endl << "chisq=" << chisq*fRunInfo->fPacking; -cout << endl << "----"; -} -*/ - return chisq; } @@ -309,9 +299,9 @@ Bool_t PRunSingleHisto::PrepareData() Bool_t success = true; // get the proper run - PRawRunData* runData = fRawData->GetRunData(fRunInfo->fRunName[0]); + PRawRunData* runData = fRawData->GetRunData(*(fRunInfo->GetRunName())); if (!runData) { // couldn't get run - cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->fRunName[0].Data() << "!"; + cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** Couldn't get run " << fRunInfo->GetRunName()->Data() << "!"; cerr << endl; return false; } @@ -337,7 +327,7 @@ Bool_t PRunSingleHisto::PrepareData() fT0s.push_back(runData->GetT0(fRunInfo->fForwardHistoNo-1)); } else { // t0's are neither in the run data nor in the msr-file -> not acceptable! cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the run data nor in the msr-file!"; - cerr << endl << " run: " << fRunInfo->fRunName[0].Data(); + cerr << endl << " run: " << fRunInfo->GetRunName()->Data(); cerr << endl; return false; } @@ -365,14 +355,14 @@ Bool_t PRunSingleHisto::PrepareData() } // check if there are runs to be added to the current one - if (fRunInfo->fRunName.size() > 1) { // runs to be added present + if (fRunInfo->GetRunNames().size() > 1) { // runs to be added present PRawRunData *addRunData; - for (UInt_t i=1; ifRunName.size(); i++) { + for (UInt_t i=1; iGetRunNames().size(); i++) { // get run to be added to the main one - addRunData = fRawData->GetRunData(fRunInfo->fRunName[i]); + addRunData = fRawData->GetRunData(*(fRunInfo->GetRunName(i))); if (addRunData == 0) { // couldn't get run - cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->fRunName[i].Data() << "!"; + cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** Couldn't get addrun " << fRunInfo->GetRunName(i)->Data() << "!"; cerr << endl; return false; } @@ -388,7 +378,7 @@ Bool_t PRunSingleHisto::PrepareData() t0Add = addRunData->GetT0(fRunInfo->fForwardHistoNo-1); } else { // t0's are neither in the run data nor in the msr-file -> not acceptable! cerr << endl << "PRunSingleHisto::PrepareData(): **ERROR** NO t0's found, neither in the addrun data nor in the msr-file!"; - cerr << endl << " addrun: " << fRunInfo->fRunName[i].Data(); + cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data(); cerr << endl; return false; } @@ -401,7 +391,7 @@ Bool_t PRunSingleHisto::PrepareData() cerr << endl << " t0 from the msr-file is " << fRunInfo->fT0[i]; cerr << endl << " t0 from the data file is " << addRunData->GetT0(fRunInfo->fForwardHistoNo-1); cerr << endl << " This is quite a deviation! Is this done intentionally??"; - cerr << endl << " addrun: " << fRunInfo->fRunName[i].Data(); + cerr << endl << " addrun: " << fRunInfo->GetRunName(i)->Data(); cerr << endl; } } @@ -409,9 +399,9 @@ Bool_t PRunSingleHisto::PrepareData() t0Add = fRunInfo->fT0[i]; } else { cerr << endl << "PRunSingleHisto::PrepareData(): **WARNING** NO t0's found, neither in the addrun data ("; - cerr << fRunInfo->fRunName[i].Data(); + cerr << fRunInfo->GetRunName(i)->Data(); cerr << "), nor in the msr-file! Will try to use the T0 of the run data ("; - cerr << fRunInfo->fRunName[i].Data(); + cerr << fRunInfo->GetRunName(i)->Data(); cerr << ") without any warranty!"; cerr << endl; t0Add = fRunInfo->fT0[0]; @@ -910,7 +900,7 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo) } // get the proper run - PRawRunData* runData = fRawData->GetRunData(fRunInfo->fRunName[0]); + PRawRunData* runData = fRawData->GetRunData(*(fRunInfo->GetRunName())); // check if start is within histogram bounds if ((start < 0) || (start >= runData->GetDataBin(histoNo)->size())) { @@ -941,7 +931,7 @@ Bool_t PRunSingleHisto::EstimateBkg(UInt_t histoNo) fBackground = bkg / (fTimeResolution * 1e3); // keep background (per 1 nsec) for chisq, max.log.likelihood, fTimeResolution us->ns - cout << endl << ">> fRunInfo->fRunName=" << fRunInfo->fRunName[0].Data() << ", histNo=" << histoNo << ", fBackground=" << fBackground; + cout << endl << ">> fRunInfo->fRunName=" << fRunInfo->GetRunName()->Data() << ", histNo=" << histoNo << ", fBackground=" << fBackground; return true; } diff --git a/src/include/PMsrHandler.h b/src/include/PMsrHandler.h index c03d94c0..3e2aedd6 100644 --- a/src/include/PMsrHandler.h +++ b/src/include/PMsrHandler.h @@ -129,7 +129,7 @@ class PMsrHandler virtual void FillParameterInUse(PMsrLines &theory, PMsrLines &funcs, PMsrLines &run); - virtual void InitRunParameterStructure(PMsrRunStructure ¶m); +// virtual void InitRunParameterStructure(PMsrRunStructure ¶m); virtual void InitFourierParameterStructure(PMsrFourierStructure &fourier); virtual Bool_t FilterNumber(TString str, const Char_t *filter, Int_t offset, Int_t &no); diff --git a/src/include/PMusr.h b/src/include/PMusr.h index b34a429d..e7e52bff 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -354,46 +354,59 @@ typedef vector PMsrParamList; //------------------------------------------------------------- /** - *

Holds the information of a single plot block + *

Holds the information of a single run block * */ -typedef struct { - PStringVector fRunName; ///< name of the run file - PStringVector fBeamline; ///< e.g. mue4, mue1, pim3, emu, m15, ... (former: run type) - PStringVector fInstitute; ///< e.g. psi, ral, triumf (former: run format) - PStringVector fFileFormat; ///< e.g. root, nexus, psi-bin, mud, ascii, db - Int_t fFitType; ///< fit type: 0=single histo fit, 2=asymmetry fit, 4=asymmetry in RRF, 8=non muSR - Int_t fAlphaParamNo; ///< alpha parameter number (fit type 2, 4) - Int_t fBetaParamNo; ///< beta parameter number (fit type 2, 4) - Int_t fNormParamNo; ///< N0 parameter number (fit type 0) - Int_t fBkgFitParamNo; ///< background fit parameter number (fit type 0) - Int_t fPhaseParamNo; ///< ??? NEEDED ??? NEEDS TO BE CHECKED !!! - Int_t fLifetimeParamNo; ///< muon lifetime parameter number (fit type 0) - 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 - Int_t fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4) - Int_t 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) - 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, ... - Double_t fFitRange[2]; ///< fit range in (us) - Int_t fPacking; ///< packing/rebinning - Double_t fRRFFreq; ///< rotating reference frequency (fit type 4) - Int_t fRRFPacking; ///< rotating reference packing (fit type 4) - Int_t fAlpha2ParamNo; ///< rotating reference alpha2 (fit type 4) - Int_t fBeta2ParamNo; ///< rotating reference beta2 (fit type 4) - Int_t fRightHistoNo; ///< rotating reference right histogram number (fit type 4) - Int_t fLeftHistoNo; ///< rotating reference left histogram number (fit type 4) - Int_t fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8) - TString fXYDataLabel[2]; ///< used to get the indices via labels when using db-files (fit type 8) -} PMsrRunStructure; +class PMsrRunBlock { + public: + PMsrRunBlock(); + virtual ~PMsrRunBlock(); + virtual void CleanUp(); + + virtual PStringVector GetRunNames() { return fRunName; } + virtual TString* GetRunName(UInt_t i=0); + + virtual void AppendRunName(TString str) { fRunName.push_back(str); } + virtual void SetRunName(TString &str, UInt_t i); + + PStringVector fBeamline; ///< e.g. mue4, mue1, pim3, emu, m15, ... (former: run type) + PStringVector fInstitute; ///< e.g. psi, ral, triumf (former: run format) + PStringVector fFileFormat; ///< e.g. root, nexus, psi-bin, mud, ascii, db + Int_t fFitType; ///< fit type: 0=single histo fit, 2=asymmetry fit, 4=asymmetry in RRF, 8=non muSR + Int_t fAlphaParamNo; ///< alpha parameter number (fit type 2, 4) + Int_t fBetaParamNo; ///< beta parameter number (fit type 2, 4) + Int_t fNormParamNo; ///< N0 parameter number (fit type 0) + Int_t fBkgFitParamNo; ///< background fit parameter number (fit type 0) + Int_t fPhaseParamNo; ///< ??? NEEDED ??? NEEDS TO BE CHECKED !!! + Int_t fLifetimeParamNo; ///< muon lifetime parameter number (fit type 0) + 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 + Int_t fForwardHistoNo; ///< forward histogram number (fit type 0, 2, 4) + Int_t 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) + 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, ... + Double_t fFitRange[2]; ///< fit range in (us) + Int_t fPacking; ///< packing/rebinning + Double_t fRRFFreq; ///< rotating reference frequency (fit type 4) + Int_t fRRFPacking; ///< rotating reference packing (fit type 4) + Int_t fAlpha2ParamNo; ///< rotating reference alpha2 (fit type 4) + Int_t fBeta2ParamNo; ///< rotating reference beta2 (fit type 4) + Int_t fRightHistoNo; ///< rotating reference right histogram number (fit type 4) + Int_t fLeftHistoNo; ///< rotating reference left histogram number (fit type 4) + Int_t fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8) + TString fXYDataLabel[2]; ///< used to get the indices via labels when using db-files (fit type 8) + + private: + PStringVector fRunName; ///< name of the run file +}; //------------------------------------------------------------- /** *

typedef to make to code more readable: list of runs with its parameters. */ -typedef vector PMsrRunList; +typedef vector PMsrRunList; //------------------------------------------------------------- /** diff --git a/src/include/PRunBase.h b/src/include/PRunBase.h index 15af45ee..78780964 100644 --- a/src/include/PRunBase.h +++ b/src/include/PRunBase.h @@ -70,7 +70,7 @@ class PRunBase Int_t fRunNo; ///< number of the run within the msr file PMsrHandler *fMsrInfo; ///< msr-file handler - PMsrRunStructure *fRunInfo; ///< run info used to filter out needed infos for the run + PMsrRunBlock *fRunInfo; ///< run info used to filter out needed infos for the run PRunDataHandler *fRawData; ///< holds the raw run data PIntVector fParamNo; ///< vector of parameter numbers for the specifc run diff --git a/src/include/PRunDataHandler.h b/src/include/PRunDataHandler.h index 6da0d09d..7ceba2bf 100644 --- a/src/include/PRunDataHandler.h +++ b/src/include/PRunDataHandler.h @@ -61,7 +61,7 @@ class PRunDataHandler virtual Bool_t ReadFile(); virtual Bool_t FileAlreadyRead(TString runName); - virtual Bool_t FileExistsCheck(PMsrRunStructure &runInfo, const UInt_t idx); + virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx); virtual Bool_t ReadRootFile(Bool_t notPostPileup); virtual Bool_t ReadNexusFile(); virtual Bool_t ReadWkmFile(); diff --git a/src/musrfit.cpp b/src/musrfit.cpp index 3e14e4fd..e479b82c 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -457,7 +457,7 @@ int main(int argc, char *argv[]) // if present, replace the run title of the with the run title of the FIRST run in the run block of the msr-file if (title_from_data_file) { PMsrRunList *rl = msrHandler->GetMsrRunList(); - PRawRunData *rrd = dataHandler->GetRunData(rl->at(0).fRunName[0]); + PRawRunData *rrd = dataHandler->GetRunData(*(rl->at(0).GetRunName())); if (rrd->GetRunTitle()->Length() > 0) msrHandler->SetMsrTitle(*rrd->GetRunTitle()); } @@ -471,7 +471,7 @@ int main(int argc, char *argv[]) success = runListCollection->Add(i, kFit); if (!success) { cout << endl << "**ERROR** Couldn't handle run no " << i << " "; - cout << (*msrHandler->GetMsrRunList())[i].fRunName[0].Data(); + cout << (*msrHandler->GetMsrRunList())[i].GetRunName()->Data(); break; } } diff --git a/src/musrt0.cpp b/src/musrt0.cpp index b33f642a..a76b0b3b 100644 --- a/src/musrt0.cpp +++ b/src/musrt0.cpp @@ -245,40 +245,40 @@ int main(int argc, char *argv[]) for (unsigned int i=0; isize(); i++) { switch (runList->at(i).fFitType) { case MSR_FITTYPE_SINGLE_HISTO: - for (unsigned int j=0; jat(i).fRunName.size(); j++) { // necessary in case of ADDRUN - if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(runList->at(i).fRunName[j]), i, runList->at(i).fForwardHistoNo, 0, j)) { + for (unsigned int j=0; jat(i).GetRunNames().size(); j++) { // necessary in case of ADDRUN + if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fForwardHistoNo, 0, j)) { musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler); exit(0); } } break; case MSR_FITTYPE_ASYM: - for (unsigned int j=0; jat(i).fRunName.size(); j++) { // necessary in case of ADDRUN - if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(runList->at(i).fRunName[j]), i, runList->at(i).fForwardHistoNo, 0, j)) { + for (unsigned int j=0; jat(i).GetRunNames().size(); j++) { // necessary in case of ADDRUN + if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fForwardHistoNo, 0, j)) { musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler); exit(0); } - if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(runList->at(i).fRunName[j]), i, runList->at(i).fBackwardHistoNo, 1, j)) { + if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fBackwardHistoNo, 1, j)) { musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler); exit(0); } } break; case MSR_FITTYPE_ASYM_RRF: - for (unsigned int j=0; jat(i).fRunName.size(); j++) { // necessary in case of ADDRUN - if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(runList->at(i).fRunName[j]), i, runList->at(i).fForwardHistoNo, 0, j)) { + for (unsigned int j=0; jat(i).GetRunNames().size(); j++) { // necessary in case of ADDRUN + if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fForwardHistoNo, 0, j)) { musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler); exit(0); } - if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(runList->at(i).fRunName[j]), i, runList->at(i).fBackwardHistoNo, 1, j)) { + if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fBackwardHistoNo, 1, j)) { musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler); exit(0); } - if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(runList->at(i).fRunName[j]), i, runList->at(i).fRightHistoNo, 2, j)) { + if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fRightHistoNo, 2, j)) { musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler); exit(0); } - if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(runList->at(i).fRunName[j]), i, runList->at(i).fLeftHistoNo, 3, j)) { + if (!musrt0_item(app, msrHandler, dataHandler->GetRunData(*(runList->at(i).GetRunName(j))), i, runList->at(i).fLeftHistoNo, 3, j)) { musrt0_cleanup(saxParser, startupHandler, msrHandler, dataHandler); exit(0); } diff --git a/src/musrview.cpp b/src/musrview.cpp index 2bc167be..9358a93b 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -239,7 +239,7 @@ cout << endl; success = runListCollection->Add(i, kView); if (!success) { cout << endl << "**ERROR** Couldn't handle run no " << i << " "; - cout << (*msrHandler->GetMsrRunList())[i].fRunName[0].Data(); + cout << (*msrHandler->GetMsrRunList())[i].GetRunName()->Data(); break; } }