diff --git a/src/Makefile.am b/src/Makefile.am index fd52d6e4..6b9fe630 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,12 +2,13 @@ SUBDIRS = external classes -bin_PROGRAMS = musrfit musrview musrt0 musrparam msr2msr +bin_PROGRAMS = musrfit musrview musrt0 musrparam msr2msr msr2data musrfit_SOURCES = musrfit.cpp musrview_SOURCES = musrview.cpp musrt0_SOURCES = musrt0.cpp musrparam_SOURCES = musrparam.cpp msr2msr_SOURCES = msr2msr.cpp +msr2data_SOURCES = msr2data.cpp xmldir = $(bindir) xml_DATA = musrfit_startup.xml diff --git a/src/classes/Makefile.am b/src/classes/Makefile.am index b005cdee..5a2e3544 100644 --- a/src/classes/Makefile.am +++ b/src/classes/Makefile.am @@ -7,6 +7,7 @@ h_sources = \ ../include/PFunctionGrammar.h \ ../include/PFunction.h \ ../include/PFunctionHandler.h \ + ../include/PMsr2Data.h \ ../include/PMsrHandler.h \ ../include/PMusrCanvas.h \ ../include/PMusr.h \ @@ -40,6 +41,7 @@ cpp_sources = \ PFourier.cpp \ PFunction.cpp \ PFunctionHandler.cpp \ + PMsr2Data.cpp \ PMsrHandler.cpp \ PMusrCanvas.cpp \ PMusrT0.cpp \ diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 359351ae..b22b9a69 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -52,7 +52,7 @@ using namespace std; * * \param fileName */ -PMsrHandler::PMsrHandler(char *fileName) : fFileName(fileName) +PMsrHandler::PMsrHandler(const char *fileName) : fFileName(fileName) { // init variables fMsrBlockCounter = 0; diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 857eafeb..29faf392 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -521,6 +521,7 @@ void PMusrCanvas::UpdateInfoPad() // get/set run plot info double dval; + vector< pair > ddvec; char sval[128]; unsigned int runNo; PMsrPlotStructure plotInfo = fMsrHandler->GetMsrPlotList()->at(fPlotNumber); @@ -545,13 +546,21 @@ void PMusrCanvas::UpdateInfoPad() tstr += TString(","); } // temperature if present - tstr += TString("T="); - dval = fRunList->GetTemp(runs[runNo].fRunName[0]); - if (dval == -9.9e99) { + ddvec = fRunList->GetTemp(runs[runNo].fRunName[0]); + if (ddvec.empty()) { + tstr += TString("T="); tstr += TString("??,"); + } else if (ddvec.size() == 1){ + tstr += TString("T="); + sprintf(sval, "%0.2lf", ddvec[0].first); + tstr += TString(sval) + TString("K,"); } else { - sprintf(sval, "%0.2lf", dval); - tstr += TString(sval) + TString("(K),"); + for(unsigned int i(0); iGetEnergy(runs[runNo].fRunName[0]); //cout << endl << ">> dval = " << dval << " (Engery)"; - if (dval == -9.9e99) { + if (dval == -999.0) { tstr += TString("??,"); } else { sprintf(sval, "%0.2lf", dval); - tstr += TString(sval) + TString("(keV),"); + tstr += TString(sval) + TString("keV,"); } // setup if present tstr += fRunList->GetSetup(runs[runNo].fRunName[0]); diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index ee7eebca..b64a1662 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -114,7 +114,7 @@ PRunDataHandler::~PRunDataHandler() * * \param runName */ -PRawRunData* PRunDataHandler::GetRunData(TString runName) +PRawRunData* PRunDataHandler::GetRunData(const TString &runName) { unsigned int i; @@ -394,7 +394,9 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup) runData.fRunTitle = ostr.GetString(); // get temperature - runData.fTemp = runHeader->GetSampleTemperature(); + runData.fTemp.resize(1); + runData.fTemp[0].first = runHeader->GetSampleTemperature(); + runData.fTemp[0].second = runHeader->GetSampleTemperatureError(); // get field runData.fField = runHeader->GetSampleBField(); @@ -403,6 +405,9 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup) runData.fEnergy = runHeader->GetImpEnergy(); //cout << endl << ">> runData.fEnergy = " << runData.fEnergy; + // get moderator HV + runData.fTransport = runHeader->GetModeratorHV(); + // get setup runData.fSetup = runHeader->GetLemSetup().GetString(); @@ -422,6 +427,107 @@ bool PRunDataHandler::ReadRootFile(bool notPostPileup) } } + // read run summary to obtain ring anode HV values + TObjArray *runSummary = dynamic_cast(folder->FindObjectAny("RunSummary")); + + // check if run summary is valid + if (!runSummary) { + cout << endl << "Couldn't obtain run summary info from ROOT file " << fRunPathName.Data() << endl; + // this is not fatal... only RA-HV values are not available + } else { // it follows a (at least) little bit strange extraction of the RA values from Thomas' TObjArray... + //streaming of a ASCII-file would be more easy + TString s, tok; + TObjArrayIter summIter(runSummary); + TObjString *os(dynamic_cast(summIter.Next())); + TObjArray *oa(0); + TObjString *objTok(0); + while(os != 0){ + s = os->GetString(); + // will put four parallel if's since it may be that more than one RA-values are on one line + if(s.Contains("RA-L")){ + if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2) + runData.fRingAnode.resize(2); + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if(!objTok->GetString().CompareTo("RA-L")){ + objTok = dynamic_cast(lineIter.Next()); // "=" + if(objTok != 0 && !objTok->GetString().CompareTo("=")){ + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.fRingAnode[0] = objTok->GetString().Atof(); // fill RA-R value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + } + + if(s.Contains("RA-R")){ + if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2) + runData.fRingAnode.resize(2); + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if(!objTok->GetString().CompareTo("RA-R")){ + objTok = dynamic_cast(lineIter.Next()); // "=" + if(objTok != 0 && !objTok->GetString().CompareTo("=")){ + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.fRingAnode[1] = objTok->GetString().Atof(); // fill RA-R value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + } + + if(s.Contains("RA-T")){ + if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2) + runData.fRingAnode.resize(4); + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if(!objTok->GetString().CompareTo("RA-T")){ + objTok = dynamic_cast(lineIter.Next()); // "=" + if(objTok != 0 && !objTok->GetString().CompareTo("=")){ + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.fRingAnode[2] = objTok->GetString().Atof(); // fill RA-T value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + } + + if(s.Contains("RA-B")){ + if(runData.fRingAnode.empty() || runData.fRingAnode.size() == 2) + runData.fRingAnode.resize(4); + oa = s.Tokenize(" "); + TObjArrayIter lineIter(oa); + objTok = dynamic_cast(lineIter.Next()); + while (objTok != 0){ + if(!objTok->GetString().CompareTo("RA-B")){ + objTok = dynamic_cast(lineIter.Next()); // "=" + if(objTok != 0 && !objTok->GetString().CompareTo("=")){ + objTok = dynamic_cast(lineIter.Next()); // HV value + runData.fRingAnode[3] = objTok->GetString().Atof(); // fill RA-B value into the runData structure + break; + } + } + objTok = dynamic_cast(lineIter.Next()); // next token... + } + } + + os = dynamic_cast(summIter.Next()); // next summary line... + } + } +// for (unsigned int i(0); i 0) line.Resize(idx); idx = line.Index("K"); // remove "K ..." part if (idx > 0) line.Resize(idx); dval = ToDouble(line, ok); - if (ok) - runData.fTemp = dval; + if (ok){ + runData.fTemp.resize(1); + runData.fTemp[0].first = dval; + runData.fTemp[0].second = 0.0; + } + idx = linecp.Index("+/-"); // get the error + linecp.Replace(0, idx+3, 0, 0); + StripWhitespace(linecp); + dval = ToDouble(linecp, ok); + if (ok && !runData.fTemp.empty()){ + runData.fTemp[0].second = dval; + } + } else if (line.Contains("Temp(meas2):")) { + linecp = line; + idx = line.Index(":"); + line.Replace(0, idx+1, 0, 0); // remove 'Temp(meas2):' + StripWhitespace(line); + idx = line.Index("+/-"); // remove "+/- ..." part + if (idx > 0) + line.Resize(idx); + idx = line.Index("K"); // remove "K ..." part + if (idx > 0) + line.Resize(idx); + dval = ToDouble(line, ok); + if (ok){ + runData.fTemp.resize(2); + runData.fTemp[1].first = dval; + runData.fTemp[1].second = 0.0; + } + idx = linecp.Index("+/-"); // get the error + linecp.Replace(0, idx+3, 0, 0); + StripWhitespace(linecp); + dval = ToDouble(linecp, ok); + if (ok && runData.fTemp.size() > 1){ + runData.fTemp[1].second = dval; + } } else if (line.Contains("Groups")) { idx = line.Index(":"); line.Replace(0, idx+1, 0, 0); // remove 'Groups:' @@ -840,15 +985,36 @@ cout << endl; // get run title runData.fRunTitle = TString(psiBin.get_comment().c_str()); // run title // get setup - runData.fSetup = TString(""); + runData.fSetup = TString(psiBin.get_orient().c_str()); + // set LEM specific information to default value since it is not in the file and not used... + runData.fEnergy = -999.0; + runData.fTransport = -999.0; + runData.fRingAnode.clear(); // get field status = sscanf(psiBin.get_field().c_str(), "%lfG", &dval); if (status == 1) runData.fField = dval; // get temperature - status = sscanf(psiBin.get_temp().c_str(), "%lfK", &dval); - if (status == 1) - runData.fTemp = dval; + PDoubleVector tempVec(psiBin.get_temperatures_vector()); + PDoubleVector tempDevVec(psiBin.get_devTemperatures_vector()); + if(tempVec.size() > 1 && tempDevVec.size() > 1 && tempVec[0] && tempVec[1]) { + runData.fTemp.resize(2); + // take only the first two values for now... + //maybe that's not enough - e.g. in older GPD data I saw the "correct values in the second and third entry..." + for (unsigned int i(0); i<2; i++){ + runData.fTemp[i].first = tempVec[i]; + runData.fTemp[i].second = tempDevVec[i]; + } + tempVec.clear(); + tempDevVec.clear(); + } else { + status = sscanf(psiBin.get_temp().c_str(), "%lfK", &dval); + if (status == 1) + runData.fTemp.resize(1); + runData.fTemp[0].first = dval; + runData.fTemp[0].second = 0.0; + } + // get time resolution (ns) runData.fTimeResolution = psiBin.get_binWidth_ns(); // get t0's @@ -1022,7 +1188,9 @@ bool PRunDataHandler::ReadAsciiFile() success = false; break; } - runData.fTemp = workStr.Atof(); + runData.fTemp.resize(1); + runData.fTemp[0].first = workStr.Atof(); + runData.fTemp[0].second = 0.0; } else if (workStr.BeginsWith("energy:", TString::kIgnoreCase)) { workStr = TString(workStr.Data()+workStr.First(":")+2); if (!workStr.IsFloat()) { @@ -1032,6 +1200,8 @@ bool PRunDataHandler::ReadAsciiFile() break; } runData.fEnergy = workStr.Atof(); + runData.fTransport = -999.0; // just to initialize the variables to some "meaningful" value + runData.fRingAnode.clear(); } else { // error cout << endl << "PRunDataHandler::ReadAsciiFile **ERROR** line no " << lineNo << ", illegal header line."; cout << endl; diff --git a/src/classes/PRunListCollection.cpp b/src/classes/PRunListCollection.cpp index 5a4166c8..f925bb9d 100644 --- a/src/classes/PRunListCollection.cpp +++ b/src/classes/PRunListCollection.cpp @@ -42,10 +42,9 @@ * \param msrInfo pointer to the msr info structure * \param data */ -PRunListCollection::PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data) +PRunListCollection::PRunListCollection(PMsrHandler *msrInfo, PRunDataHandler *data) \ + : fMsrInfo(msrInfo), fData(data) { - fMsrInfo = msrInfo; - fData = data; } //-------------------------------------------------------------------------- @@ -135,7 +134,7 @@ bool PRunListCollection::Add(int runNo, EPMusrHandleTag tag) /** *

*/ -double PRunListCollection::GetSingleHistoChisq(const std::vector& par) +double PRunListCollection::GetSingleHistoChisq(const std::vector& par) const { double chisq = 0.0; @@ -151,7 +150,7 @@ double PRunListCollection::GetSingleHistoChisq(const std::vector& par) /** *

*/ -double PRunListCollection::GetAsymmetryChisq(const std::vector& par) +double PRunListCollection::GetAsymmetryChisq(const std::vector& par) const { double chisq = 0.0; @@ -167,7 +166,7 @@ double PRunListCollection::GetAsymmetryChisq(const std::vector& par) /** *

*/ -double PRunListCollection::GetRRFChisq(const std::vector& par) +double PRunListCollection::GetRRFChisq(const std::vector& par) const { double chisq = 0.0; @@ -183,7 +182,7 @@ double PRunListCollection::GetRRFChisq(const std::vector& par) /** *

*/ -double PRunListCollection::GetNonMusrChisq(const std::vector& par) +double PRunListCollection::GetNonMusrChisq(const std::vector& par) const { double chisq = 0.0; @@ -199,7 +198,7 @@ double PRunListCollection::GetNonMusrChisq(const std::vector& par) /** *

*/ -double PRunListCollection::GetSingleHistoMaximumLikelihood(const std::vector& par) +double PRunListCollection::GetSingleHistoMaximumLikelihood(const std::vector& par) const { double mlh = 0.0; @@ -216,7 +215,7 @@ double PRunListCollection::GetSingleHistoMaximumLikelihood(const std::vector Since it is not clear yet how to handle asymmetry fits with max likelihood * the chi square will be used! */ -double PRunListCollection::GetAsymmetryMaximumLikelihood(const std::vector& par) +double PRunListCollection::GetAsymmetryMaximumLikelihood(const std::vector& par) const { double mlh = 0.0; @@ -233,7 +232,7 @@ double PRunListCollection::GetAsymmetryMaximumLikelihood(const std::vector Since it is not clear yet how to handle RRF fits with max likelihood * the chi square will be used! */ -double PRunListCollection::GetRRFMaximumLikelihood(const std::vector& par) +double PRunListCollection::GetRRFMaximumLikelihood(const std::vector& par) const { double mlh = 0.0; @@ -250,7 +249,7 @@ double PRunListCollection::GetRRFMaximumLikelihood(const std::vector& pa *

Since it is not clear yet how to handle non musr fits with max likelihood * the chi square will be used! */ -double PRunListCollection::GetNonMusrMaximumLikelihood(const std::vector& par) +double PRunListCollection::GetNonMusrMaximumLikelihood(const std::vector& par) const { double mlh = 0.0; @@ -266,7 +265,7 @@ double PRunListCollection::GetNonMusrMaximumLikelihood(const std::vector /** *

*/ -unsigned int PRunListCollection::GetTotalNoOfBinsFitted() +unsigned int PRunListCollection::GetTotalNoOfBinsFitted() const { unsigned int counts = 0; @@ -434,7 +433,7 @@ PRunData* PRunListCollection::GetNonMusr(unsigned int index, EDataSwitch tag) * * \param runName */ -double PRunListCollection::GetTemp(TString &runName) +vector< pair > PRunListCollection::GetTemp(const TString &runName) const { return fData->GetRunData(runName)->fTemp; } @@ -447,7 +446,7 @@ double PRunListCollection::GetTemp(TString &runName) * * \param runName */ -double PRunListCollection::GetField(TString &runName) +double PRunListCollection::GetField(const TString &runName) const { return fData->GetRunData(runName)->fField; } @@ -460,7 +459,7 @@ double PRunListCollection::GetField(TString &runName) * * \param runName */ -double PRunListCollection::GetEnergy(TString &runName) +double PRunListCollection::GetEnergy(const TString &runName) const { return fData->GetRunData(runName)->fEnergy; } @@ -473,7 +472,7 @@ double PRunListCollection::GetEnergy(TString &runName) * * \param runName */ -const char* PRunListCollection::GetSetup(TString &runName) +const char* PRunListCollection::GetSetup(const TString &runName) const { return fData->GetRunData(runName)->fSetup.Data(); } @@ -487,7 +486,7 @@ const char* PRunListCollection::GetSetup(TString &runName) * \param runName name of the run file * \param idx msr-file run index */ -const char* PRunListCollection::GetXAxisTitle(TString &runName, const unsigned int idx) +const char* PRunListCollection::GetXAxisTitle(const TString &runName, const unsigned int idx) const { //cout << endl << ">> PRunListCollection::GetXAxisTitle: runName = " << runName.Data() << ", idx = " << idx; //cout << endl << ">> PRunListCollection::GetXAxisTitle: fRunNonMusrList.size() = " << fRunNonMusrList.size(); @@ -521,7 +520,7 @@ const char* PRunListCollection::GetXAxisTitle(TString &runName, const unsigned i * \param runName name of the run file * \param idx msr-file run index */ -const char* PRunListCollection::GetYAxisTitle(TString &runName, const unsigned int idx) +const char* PRunListCollection::GetYAxisTitle(const TString &runName, const unsigned int idx) const { //cout << endl << ">> PRunListCollection::GetYAxisTitle: runName = " << runName.Data() << ", idx = " << idx; //cout << endl; diff --git a/src/include/PMsrHandler.h b/src/include/PMsrHandler.h index 84f71959..76285123 100644 --- a/src/include/PMsrHandler.h +++ b/src/include/PMsrHandler.h @@ -47,7 +47,7 @@ class PMsrHandler { public: - PMsrHandler(char *fileName); + PMsrHandler(const char *fileName); virtual ~PMsrHandler(); virtual int ReadMsrFile(); diff --git a/src/include/PMusr.h b/src/include/PMusr.h index fcbccf7b..5cf0ce5d 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -182,8 +182,11 @@ typedef struct { TString fRunTitle; ///< run title TString fSetup; ///< description of the setup of this run double fField; ///< magnetic field value - double fTemp; ///< temperature during the run +// double fTemp; ///< temperature during the run + vector< pair > fTemp; ///< measured temperatures and standard deviations during the run double fEnergy; ///< implantation energy of the muon + double fTransport; ///< LEM transport settings (Moderator HV) + PDoubleVector fRingAnode; ///< LEM ring anode HVs (L,R[,T,B]) double fTimeResolution; ///< time resolution of the run PIntVector fT0s; ///< vector of t0's of a run vector fDataBin; ///< vector of all histos of a run diff --git a/src/include/PRunDataHandler.h b/src/include/PRunDataHandler.h index 70f8ce1c..0b93b911 100644 --- a/src/include/PRunDataHandler.h +++ b/src/include/PRunDataHandler.h @@ -47,8 +47,8 @@ class PRunDataHandler PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath); virtual ~PRunDataHandler(); - virtual bool IsAllDataAvailable() { return fAllDataAvailable; } - virtual PRawRunData* GetRunData(TString runName); + virtual bool IsAllDataAvailable() const { return fAllDataAvailable; } + virtual PRawRunData* GetRunData(const TString &runName); private: PMsrHandler *fMsrInfo; diff --git a/src/include/PRunListCollection.h b/src/include/PRunListCollection.h index 0ea6f4ed..6b2d65b8 100644 --- a/src/include/PRunListCollection.h +++ b/src/include/PRunListCollection.h @@ -53,34 +53,34 @@ class PRunListCollection virtual bool Add(int runNo, EPMusrHandleTag tag); - virtual double GetSingleHistoChisq(const std::vector& par); - virtual double GetAsymmetryChisq(const std::vector& par); - virtual double GetRRFChisq(const std::vector& par); - virtual double GetNonMusrChisq(const std::vector& par); + virtual double GetSingleHistoChisq(const std::vector& par) const; + virtual double GetAsymmetryChisq(const std::vector& par) const; + virtual double GetRRFChisq(const std::vector& par) const; + virtual double GetNonMusrChisq(const std::vector& par) const; - virtual double GetSingleHistoMaximumLikelihood(const std::vector& par); - virtual double GetAsymmetryMaximumLikelihood(const std::vector& par); - virtual double GetRRFMaximumLikelihood(const std::vector& par); - virtual double GetNonMusrMaximumLikelihood(const std::vector& par); + virtual double GetSingleHistoMaximumLikelihood(const std::vector& par) const; + virtual double GetAsymmetryMaximumLikelihood(const std::vector& par) const; + virtual double GetRRFMaximumLikelihood(const std::vector& par) const; + virtual double GetNonMusrMaximumLikelihood(const std::vector& par) const; - virtual unsigned int GetTotalNoOfBinsFitted(); + virtual unsigned int GetTotalNoOfBinsFitted() const; - virtual unsigned int GetNoOfSingleHisto() { return fRunSingleHistoList.size(); } - virtual unsigned int GetNoOfAsymmetry() { return fRunAsymmetryList.size(); } - virtual unsigned int GetNoOfRRF() { return fRunRRFList.size(); } - virtual unsigned int GetNoOfNonMusr() { return fRunNonMusrList.size(); } + virtual unsigned int GetNoOfSingleHisto() const { return fRunSingleHistoList.size(); } + virtual unsigned int GetNoOfAsymmetry() const { return fRunAsymmetryList.size(); } + virtual unsigned int GetNoOfRRF() const { return fRunRRFList.size(); } + virtual unsigned int GetNoOfNonMusr() const { return fRunNonMusrList.size(); } virtual PRunData* GetSingleHisto(unsigned int index, EDataSwitch tag=kIndex); virtual PRunData* GetAsymmetry(unsigned int index, EDataSwitch tag=kIndex); virtual PRunData* GetRRF(unsigned int index, EDataSwitch tag=kIndex); virtual PRunData* GetNonMusr(unsigned int index, EDataSwitch tag=kIndex); - virtual double GetTemp(TString &runName); - virtual double GetField(TString &runName); - virtual double GetEnergy(TString &runName); - virtual const char* GetSetup(TString &runName); - virtual const char* GetXAxisTitle(TString &runName, const unsigned int idx); - virtual const char* GetYAxisTitle(TString &runName, const unsigned int idx); + virtual vector< pair > GetTemp(const TString &runName) const; + virtual double GetField(const TString &runName) const; + virtual double GetEnergy(const TString &runName) const; + virtual const char* GetSetup(const TString &runName) const; + virtual const char* GetXAxisTitle(const TString &runName, const unsigned int idx) const; + virtual const char* GetYAxisTitle(const TString &runName, const unsigned int idx) const; private: PMsrHandler *fMsrInfo; ///< keeps all msr file info