From b72ec887839f74db5e7117efa51e85137deafd4f Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Sat, 28 May 2022 14:05:55 +0200 Subject: [PATCH] add search facility for runs via musrfit_startup.xml template entries. --- src/classes/PFindRun.cpp | 149 +++++++++++++++++++++++++++++++++++++++ src/include/PFindRun.h | 56 +++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 src/classes/PFindRun.cpp create mode 100644 src/include/PFindRun.h diff --git a/src/classes/PFindRun.cpp b/src/classes/PFindRun.cpp new file mode 100644 index 00000000..1876c7a1 --- /dev/null +++ b/src/classes/PFindRun.cpp @@ -0,0 +1,149 @@ +/*************************************************************************** + + PFindRun.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007-2022 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include + +#include "PFindRun.h" + +//---------------------------------------------------------------------------- +/** + * @brief PFindRun::PFindRun + * @param runNameTemplateList + */ +PFindRun::PFindRun(const PStringVector path, const PRunNameTemplateList runNameTemplateList) : + fPath(path), fRunNameTemplateList(runNameTemplateList) +{ + // nothing to be done here +} + +//---------------------------------------------------------------------------- +/** + * @brief PFindRun::PFindRun + * + * @param path + * @param runNameTemplateList + * @param instrument + * @param year + * @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) +{ + // nothing to be done here +} + +//---------------------------------------------------------------------------- +/** + * @brief PFindRun::DumpTemplateList + */ +void PFindRun::DumpTemplateList() +{ + std::cout << "debug> instrument: " << fInstrument << std::endl; + std::cout << "debug> year: " << fYear << std::endl; + std::cout << "debug> run: " << fRun << std::endl; + std::cout << "debug> ++++" << std::endl; + std::cout << "debug> run name template list:" << std::endl; + for (UInt_t i=0; i ++++" << std::endl; +} + +//---------------------------------------------------------------------------- +/** + * @brief PFindRun::CreatePathName + * @param path + * @param runNameTemplate + * @return + */ +TString PFindRun::CreatePathName(const TString path, const TString runNameTemplate) +{ + TString pathName{""}; + TString runName = runNameTemplate; + TString yearStr = TString::Format("%d", fYear); + TString yyStr; + if (fYear < 2000) + yyStr = TString::Format("%02d", fYear-1900); + else + yyStr = TString::Format("%02d", fYear-2000); + runName.ReplaceAll("%yyyy%", yearStr); + runName.ReplaceAll("%yy%", yyStr); + + // run handling slightly more complicated, since various number of digits possible + Int_t idx=-1; + TString rr{""}; + for (Int_t i=2; i<10; i++) { + rr ="%"; + for (Int_t j=0; j