diff --git a/src/classes/PFindRun.cpp b/src/classes/PFindRun.cpp index 64e361b6..0a490fbe 100644 --- a/src/classes/PFindRun.cpp +++ b/src/classes/PFindRun.cpp @@ -54,8 +54,10 @@ PFindRun::PFindRun(const PStringVector path, const PRunNameTemplateList runNameT * @param run */ PFindRun::PFindRun(const PStringVector path, const PRunNameTemplateList runNameTemplateList, - const TString &instrument, const UInt_t year, const UInt_t run) : - fPath(path), fRunNameTemplateList(runNameTemplateList), fInstrument(instrument), fYear(year), fRun(run) + const TString &instrument, const UInt_t year, const UInt_t run, + const TString file_format) : + fPath(path), fRunNameTemplateList(runNameTemplateList), fInstrument(instrument), + fYear(year), fRun(run), fFileFormat(file_format) { // nothing to be done here } @@ -130,6 +132,23 @@ TString PFindRun::CreatePathName(const TString path, const TString runNameTempla */ Bool_t PFindRun::FoundPathName() { + // if file format is given, get proper extension + TString ext(""); + if (fFileFormat.Length() != 0) { + if (!fFileFormat.CompareTo("MusrRoot") || !fFileFormat.CompareTo("ROOT")) + ext = ".root"; + else if (!fFileFormat.CompareTo("NeXus")) + ext = ".nxs"; + else if (!fFileFormat.CompareTo("PSI-BIN")) + ext = ".bin"; + else if (!fFileFormat.CompareTo("PSI-MDU")) + ext = ".mdu"; + else if (!fFileFormat.CompareTo("MUD")) + ext = ".mud"; + else if (!fFileFormat.CompareTo("WKM")) + ext = ".wkm"; + } + // find instrument name in path list TString pathName{""}; for (Int_t i=0; i(strtod(year.c_str(), static_cast(nullptr))); int run = static_cast(strtod(runNo.c_str(), static_cast(nullptr))); - PFindRun findRun(startupHandler->GetDataPathList(), startupHandler->GetRunNameTemplateList(), instrument, yy, run); + PFindRun findRun(startupHandler->GetDataPathList(), startupHandler->GetRunNameTemplateList(), + instrument, yy, run, fileFormat); if (findRun.FoundPathName()) { pathFln = findRun.GetPathName().Data(); } else { diff --git a/src/include/PFindRun.h b/src/include/PFindRun.h index 3f88dc7a..acff4867 100644 --- a/src/include/PFindRun.h +++ b/src/include/PFindRun.h @@ -36,7 +36,7 @@ class PFindRun { public: PFindRun(const PStringVector path, const PRunNameTemplateList runNameTemplateList); PFindRun(const PStringVector path, const PRunNameTemplateList runNameTemplateList, - const TString &instrument, const UInt_t year, const UInt_t run); + const TString &instrument, const UInt_t year, const UInt_t run, const TString file_format=""); Bool_t FoundPathName(); TString GetPathName() { return fPathName; } @@ -48,6 +48,7 @@ class PFindRun { TString fInstrument{""}; Int_t fYear{-1}; Int_t fRun{-1}; + TString fFileFormat{""}; TString fPathName{""}; TString CreatePathName(const TString path, const TString runNameTemplate);