improved search run, allowing to look for a specific file format in case the run is saved in multiple different file formats.
This commit is contained in:
parent
d948460b0b
commit
d43a0df893
@ -54,8 +54,10 @@ PFindRun::PFindRun(const PStringVector path, const PRunNameTemplateList runNameT
|
|||||||
* @param run
|
* @param run
|
||||||
*/
|
*/
|
||||||
PFindRun::PFindRun(const PStringVector path, const PRunNameTemplateList runNameTemplateList,
|
PFindRun::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,
|
||||||
fPath(path), fRunNameTemplateList(runNameTemplateList), fInstrument(instrument), fYear(year), fRun(run)
|
const TString file_format) :
|
||||||
|
fPath(path), fRunNameTemplateList(runNameTemplateList), fInstrument(instrument),
|
||||||
|
fYear(year), fRun(run), fFileFormat(file_format)
|
||||||
{
|
{
|
||||||
// nothing to be done here
|
// nothing to be done here
|
||||||
}
|
}
|
||||||
@ -130,6 +132,23 @@ TString PFindRun::CreatePathName(const TString path, const TString runNameTempla
|
|||||||
*/
|
*/
|
||||||
Bool_t PFindRun::FoundPathName()
|
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
|
// find instrument name in path list
|
||||||
TString pathName{""};
|
TString pathName{""};
|
||||||
for (Int_t i=0; i<fPath.size(); i++) {
|
for (Int_t i=0; i<fPath.size(); i++) {
|
||||||
@ -137,6 +156,10 @@ Bool_t PFindRun::FoundPathName()
|
|||||||
for (Int_t j=0; j<fRunNameTemplateList.size(); j++) {
|
for (Int_t j=0; j<fRunNameTemplateList.size(); j++) {
|
||||||
if (fRunNameTemplateList[j].instrument == fInstrument) {
|
if (fRunNameTemplateList[j].instrument == fInstrument) {
|
||||||
pathName = CreatePathName(fPath[i], fRunNameTemplateList[j].runNameTemplate);
|
pathName = CreatePathName(fPath[i], fRunNameTemplateList[j].runNameTemplate);
|
||||||
|
if (fFileFormat.Length() != 0) {
|
||||||
|
if (!pathName.Contains(ext, TString::kIgnoreCase))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (boost::filesystem::exists(pathName.Data())) {
|
if (boost::filesystem::exists(pathName.Data())) {
|
||||||
fPathName = pathName;
|
fPathName = pathName;
|
||||||
return true;
|
return true;
|
||||||
|
@ -955,7 +955,8 @@ int main(int argc, char *argv[])
|
|||||||
if (fileName == "") { // only look for runs if the file name is not explicitly given
|
if (fileName == "") { // only look for runs if the file name is not explicitly given
|
||||||
int yy = static_cast<int>(strtod(year.c_str(), static_cast<char**>(nullptr)));
|
int yy = static_cast<int>(strtod(year.c_str(), static_cast<char**>(nullptr)));
|
||||||
int run = static_cast<int>(strtod(runNo.c_str(), static_cast<char**>(nullptr)));
|
int run = static_cast<int>(strtod(runNo.c_str(), static_cast<char**>(nullptr)));
|
||||||
PFindRun findRun(startupHandler->GetDataPathList(), startupHandler->GetRunNameTemplateList(), instrument, yy, run);
|
PFindRun findRun(startupHandler->GetDataPathList(), startupHandler->GetRunNameTemplateList(),
|
||||||
|
instrument, yy, run, fileFormat);
|
||||||
if (findRun.FoundPathName()) {
|
if (findRun.FoundPathName()) {
|
||||||
pathFln = findRun.GetPathName().Data();
|
pathFln = findRun.GetPathName().Data();
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,7 +36,7 @@ class PFindRun {
|
|||||||
public:
|
public:
|
||||||
PFindRun(const PStringVector path, const PRunNameTemplateList runNameTemplateList);
|
PFindRun(const PStringVector path, const PRunNameTemplateList runNameTemplateList);
|
||||||
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();
|
Bool_t FoundPathName();
|
||||||
TString GetPathName() { return fPathName; }
|
TString GetPathName() { return fPathName; }
|
||||||
@ -48,6 +48,7 @@ class PFindRun {
|
|||||||
TString fInstrument{""};
|
TString fInstrument{""};
|
||||||
Int_t fYear{-1};
|
Int_t fYear{-1};
|
||||||
Int_t fRun{-1};
|
Int_t fRun{-1};
|
||||||
|
TString fFileFormat{""};
|
||||||
TString fPathName{""};
|
TString fPathName{""};
|
||||||
|
|
||||||
TString CreatePathName(const TString path, const TString runNameTemplate);
|
TString CreatePathName(const TString path, const TString runNameTemplate);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user