From 2e6e5ecb97442a3965df4d6b567c1ac5285181e2 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Wed, 30 Aug 2023 14:09:19 +0200 Subject: [PATCH 1/7] added the flame instrument. --- src/dump_header.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dump_header.cpp b/src/dump_header.cpp index 960c6a65..8f193074 100644 --- a/src/dump_header.cpp +++ b/src/dump_header.cpp @@ -99,7 +99,7 @@ void dump_header_syntax() std::cout << std::endl << " -s, --summary : this option is used for LE-uSR data sets only. It will, additionally"; std::cout << std::endl << " to the header information, print the summary file content."; std::cout << std::endl << " -i, --instrument : where is the requested instrument:"; - std::cout << std::endl << " lem (default) | gps | ltf | dolly | gpd | hifi."; + std::cout << std::endl << " lem (default) | gps | ltf | dolly | gpd | hifi | flame."; std::cout << std::endl << " -c, --counts : will show detector counts as well."; std::cout << std::endl << " -h, --help : will show this help"; std::cout << std::endl << " -v, --version : will show the current version."; @@ -883,7 +883,8 @@ int main(int argc, char *argv[]) return 1; } if (strcmp(argv[i+1], "lem") && strcmp(argv[i+1], "gps") && strcmp(argv[i+1], "ltf") && - strcmp(argv[i+1], "dolly") && strcmp(argv[i+1], "gpd") && strcmp(argv[i+1], "hifi")) { + strcmp(argv[i+1], "dolly") && strcmp(argv[i+1], "gpd") && strcmp(argv[i+1], "hifi") && + strcmp(argv[i+1], "flame")) { std::cerr << std::endl << "**ERROR** found --instrument with unkown instrument name: '" << argv[i+1] << "'!" << std::endl; dump_header_syntax(); return 1; From 22178f786927581c0dab65096df2f0a752055919 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Wed, 30 Aug 2023 15:05:56 +0200 Subject: [PATCH 2/7] improved search run, allowing to look for a specific file format in case the run is saved in multiple different file formats. --- src/classes/PFindRun.cpp | 27 +++++++++++++++++++++++++-- src/dump_header.cpp | 3 ++- src/include/PFindRun.h | 3 ++- 3 files changed, 29 insertions(+), 4 deletions(-) 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); From 1f32698b5f94a65eaa616a5c6ee9fd559bc72add Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Wed, 30 Aug 2023 15:41:34 +0200 Subject: [PATCH 3/7] try to improve the reload issue of musrT0 called via musredit - Issue #61 on bitbucket. --- src/musredit_qt5/musredit/PTextEdit.cpp | 6 +++++- src/musredit_qt6/musredit/PTextEdit.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/musredit_qt5/musredit/PTextEdit.cpp b/src/musredit_qt5/musredit/PTextEdit.cpp index d768f531..e242fb0a 100644 --- a/src/musredit_qt5/musredit/PTextEdit.cpp +++ b/src/musredit_qt5/musredit/PTextEdit.cpp @@ -2649,6 +2649,10 @@ void PTextEdit::musrT0() #endif proc->setProcessEnvironment(env); proc->setWorkingDirectory(workDir); + + connect(proc, QOverload::of(&QProcess::finished), + [=](int exitCode, QProcess::ExitStatus exitStatus){ fileReload(); }); + proc->start(cmd, arg); if (!proc->waitForStarted()) { // error handling @@ -2658,7 +2662,7 @@ void PTextEdit::musrT0() msg, tr("Quit") ); return; - } + } } //---------------------------------------------------------------------------------------------------- diff --git a/src/musredit_qt6/musredit/PTextEdit.cpp b/src/musredit_qt6/musredit/PTextEdit.cpp index c590c7cb..755198fd 100644 --- a/src/musredit_qt6/musredit/PTextEdit.cpp +++ b/src/musredit_qt6/musredit/PTextEdit.cpp @@ -2643,6 +2643,10 @@ void PTextEdit::musrT0() #endif proc->setProcessEnvironment(env); proc->setWorkingDirectory(workDir); + + connect(proc, QOverload::of(&QProcess::finished), + [=](int exitCode, QProcess::ExitStatus exitStatus){ fileReload(); }); + proc->start(cmd, arg); if (!proc->waitForStarted()) { // error handling From 0b3fc43123f313c51612a2028faa24d15011557c Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 31 Aug 2023 07:47:47 +0200 Subject: [PATCH 4/7] handle dump of RunSummary with and without '\n' and/or '\r' properly. --- src/dump_header.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dump_header.cpp b/src/dump_header.cpp index d9c8cdbf..2fdfd9a2 100644 --- a/src/dump_header.cpp +++ b/src/dump_header.cpp @@ -248,6 +248,8 @@ int dump_header_root(const std::string fileName, const bool summary, const bool tstr = static_cast(runSum->At(i)); str = tstr->String(); std::cout << str; + if (!str.Contains("\r") && !str.Contains("\n")) + std::cout << std::endl; } } From 4d1c7c10c8c1bf9599a5c5e54e25c1aabf76c198 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 31 Aug 2023 08:22:37 +0200 Subject: [PATCH 5/7] make sure that exported MusrRoot files have proper stats in the histo objects. --- src/classes/PRunDataHandler.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 59615825..c8c97a7e 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -4647,9 +4647,13 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) str.Form("hDecay%03d", dataSet->GetHistoNo()); length = dataSet->GetData()->size(); histo = new TH1F(str.Data(), str.Data(), length+1, -0.5, static_cast(length)+0.5); + Int_t sum=0, entries=0; for (UInt_t j=0; jSetBinContent(j+1, dataSet->GetData()->at(j)); + entries = dataSet->GetData()->at(j); + histo->SetBinContent(j+1, entries); + sum += entries; } + histo->SetEntries(sum); histos.push_back(histo); } } else { // rebin > 1 @@ -4666,14 +4670,18 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) length = dataSet->GetData()->size(); histo = new TH1F(str.Data(), str.Data(), static_cast(length/fAny2ManyInfo->rebin)+1, -0.5, static_cast(static_cast(length/fAny2ManyInfo->rebin))+0.5); dataCount = 0; + Int_t sum=0, entries=0; for (UInt_t j=0; j 0) && (j % fAny2ManyInfo->rebin == 0)) { dataCount++; histo->SetBinContent(dataCount, dataRebin); dataRebin = 0; } - dataRebin += static_cast(dataSet->GetData()->at(j)); + entries = dataSet->GetData()->at(j); + sum += entries; + dataRebin += static_cast(entries); } + histo->SetEntries(sum); histos.push_back(histo); } } From 1df6643bfaca44624764826986ef8010356ce002 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 31 Aug 2023 10:17:40 +0200 Subject: [PATCH 6/7] more robust handling of positron detector entries. --- src/dump_header.cpp | 46 +++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/dump_header.cpp b/src/dump_header.cpp index 2fdfd9a2..58ccd792 100644 --- a/src/dump_header.cpp +++ b/src/dump_header.cpp @@ -145,6 +145,10 @@ int dump_header_root(const std::string fileName, const bool summary, const bool fileType = DH_LEM_ROOT; } + TMusrRunHeader *header{nullptr}; + bool ok; + Int_t ival; + if (fileType == DH_LEM_ROOT) { // ROOT (LEM) // read header and check if some missing run info need to be fed TLemRunHeader *runHeader = dynamic_cast(folder->FindObjectAny("TLemRunHeader")); @@ -197,7 +201,7 @@ int dump_header_root(const std::string fileName, const bool summary, const bool delete runHeader; } else { // MusrRoot // invoke the MusrRoot header object - TMusrRunHeader *header = new TMusrRunHeader(fileName.c_str(), true); // read quite + header = new TMusrRunHeader(fileName.c_str(), true); // read quite if (header == 0) { std::cerr << std::endl << "**ERROR** Couldn't invoke MusrRoot RunHeader in file:" << fileName; std::cerr << std::endl; @@ -216,8 +220,6 @@ int dump_header_root(const std::string fileName, const bool summary, const bool header->DumpHeader(); if (counts) { - bool ok; - Int_t ival; PIntVector ivec; header->Get("RunInfo/No of Histos", ival, ok); if (ok) @@ -226,8 +228,6 @@ int dump_header_root(const std::string fileName, const bool summary, const bool if (ok) redGreenOffset = ivec; } - - delete header; } // summary as well? @@ -256,27 +256,46 @@ int dump_header_root(const std::string fileName, const bool summary, const bool // detector counts as well? if (counts && (fileType == DH_MUSR_ROOT)) { // dump the detector counts - std::cout << "Detector counts" << std::endl; + std::cout << "Detector counts (all, between fgb and lgb)" << std::endl; f.GetObject("histos", folder); - if (folder != nullptr) { + if ((folder != nullptr) && (header != nullptr)) { char detectorLabel[64]; TH1F *histo{nullptr}; - UInt_t total{0}; + UInt_t total{0}, total_good{0}, ta, tg; + Int_t fgb, lgb; for (UInt_t i=0; iGet(detectorLabel, ival, ok); + if (ok) { + fgb = ival; + } + lgb = -1; + snprintf(detectorLabel, sizeof(detectorLabel), "DetectorInfo/Detector%03d/Last Good Bin", redGreenOffset[i]+j+1); + header->Get(detectorLabel, ival, ok); + if (ok) { + lgb = ival; + } + // get histo info snprintf(detectorLabel, sizeof(detectorLabel), "hDecay%03d", redGreenOffset[i]+j+1); histo = (TH1F*) folder->FindObjectAny(detectorLabel); if (histo != nullptr) { - std::cout << " " << histo->GetTitle() << ":\t " << histo->GetEntries() << std::endl; - total += histo->GetEntries(); + ta = histo->Integral(0, histo->GetNbinsX()+1); + tg = histo->Integral(fgb, lgb); + std::cout << " " << histo->GetTitle() << ":\t " << ta << ", " << tg << std::endl; + total += ta; + total_good += tg; } } if (i % 2 == 0) - std::cout << " total counts of group " << i+1 << ":\t\t\t " << total << std::endl; + std::cout << " total counts of group " << i+1 << ":\t\t\t " << total << ", " << total_good << std::endl; else - std::cout << " total counts of group " << i+1 << ":\t\t\t\t\t " << total << std::endl; + std::cout << " total counts of group " << i+1 << ":\t\t\t\t\t " << total << ", " << total_good << std::endl; } } else { std::cout << "Sorry, no histos folder found" << std::endl; @@ -287,6 +306,9 @@ int dump_header_root(const std::string fileName, const bool summary, const bool f.Close(); + if (header) + delete header; + return 0; } From c6ebaf36753c788219bf0a81ba2f798865671fb0 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 31 Aug 2023 10:30:04 +0200 Subject: [PATCH 7/7] more potential musr-data-file paths added. --- src/classes/PStartupHandler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/classes/PStartupHandler.cpp b/src/classes/PStartupHandler.cpp index 3e00f43d..40c21f58 100644 --- a/src/classes/PStartupHandler.cpp +++ b/src/classes/PStartupHandler.cpp @@ -655,6 +655,7 @@ Bool_t PStartupHandler::WriteDefaultStartupFile() fout << " /afs/psi.ch/project/bulkmusr/data/alc" << std::endl; fout << " /afs/psi.ch/project/bulkmusr/data/hifi" << std::endl; fout << " /afs/psi.ch/project/bulkmusr/data/lem" << std::endl; + fout << " /afs/psi.ch/project/bulkmusr/data/flame" << std::endl; fout << " " << std::endl; fout << " d%yyyy%/pie1/deltat_flc_%rrrr%.bin" << std::endl; fout << " d%yyyy%/pie3/deltat_flc_%rrrr%.bin" << std::endl; @@ -664,8 +665,11 @@ Bool_t PStartupHandler::WriteDefaultStartupFile() fout << " d%yyyy%/pta/deltat_pta_dolly_%rrrr%.bin" << std::endl; fout << " d%yyyy%/tdc/deltat_tdc_dolly_%rrrr%.bin" << std::endl; fout << " d%yyyy%/tdc/root/deltat_tdc_dolly_%rrrr%.root" << std::endl; + fout << " d%yyyy%/tdc/mdu/deltat_tdc_dolly_%rrrr%.mdu" << std::endl; fout << " " << std::endl; - fout << " d%yyyy%/tdc/root/deltat_tdc_flame_%yyyy%_%rrrr%.bin" << std::endl; + fout << " d%yyyy%/tdc/root/deltat_tdc_flame_%yyyy%_%rrrr%.root" << std::endl; + fout << " d%yyyy%/tdc/deltat_tdc_flame_%rrrr%.bin" << std::endl; + fout << " d%yyyy%/tdc/mdu/deltat_tdc_flame_%yyyy%_%rrrr%.mdu" << std::endl; fout << " " << std::endl; fout << " d%yyyy%/deltat_mue1_%rrrr%.bin" << std::endl; fout << " d%yyyy%/deltat_fq_si_%rrrr%.bin" << std::endl; @@ -679,6 +683,7 @@ Bool_t PStartupHandler::WriteDefaultStartupFile() fout << " d%yyyy%/deltat_pta_gpd_%rrrr%.bin" << std::endl; fout << " d%yyyy%/tdc/deltat_tdc_gpd_%rrrr%.bin" << std::endl; fout << " d%yyyy%/tdc/root/deltat_tdc_gpd_%rrrr%.root" << std::endl; + fout << " d%yyyy%/tdc/mdu/deltat_tdc_gpd_%rrrr%.mdu" << std::endl; fout << " " << std::endl; fout << " d%yyyy%/deltat_ccr_%rrrr%.bin" << std::endl; fout << " d%yyyy%/deltat_he3_%rrrr%.bin" << std::endl; @@ -691,6 +696,7 @@ Bool_t PStartupHandler::WriteDefaultStartupFile() fout << " d%yyyy%/deltat_pta_gps_%rrrr%.bin" << std::endl; fout << " d%yyyy%/tdc/deltat_tdc_gps_%rrrr%.bin" << std::endl; fout << " d%yyyy%/tdc/root/deltat_tdc_gps_%yyyy%_%rrrr%.root" << std::endl; + fout << " d%yyyy%/tdc/mdu/deltat_tdc_gps_%yyyy%_%rrrr%.mdu" << std::endl; fout << " " << std::endl; fout << " d%yyyy%/tdc/deltat_hifi_%rrrr%.bin" << std::endl; fout << " d%yyyy%/tdc/tdc_hifi_%yyyy%_%rrrrr%.mdu" << std::endl;