From cda0a1ff7f554bb9d76a802c31d3c8988175206f Mon Sep 17 00:00:00 2001 From: Adrian Weber <adrian.a.weber@physik.uni-giessen.de> Date: Tue, 15 Feb 2022 11:42:01 +0100 Subject: [PATCH] sync run_unpack_tsa.C and run_unpack_online.C macros --- macro/run/run_unpack_online.C | 43 ++++++++++++++++++++++++++++++++++- macro/run/run_unpack_tsa.C | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/macro/run/run_unpack_online.C b/macro/run/run_unpack_online.C index e52fd82c1b..03ed43fcb0 100644 --- a/macro/run/run_unpack_online.C +++ b/macro/run/run_unpack_online.C @@ -33,6 +33,7 @@ std::shared_ptr<CbmTrdUnpackMonitor> GetTrdMonitor(std::string treefilename); std::shared_ptr<CbmTrdSpadic> GetTrdSpadic(bool useAvgBaseline = false); std::shared_ptr<CbmStsUnpackMonitor> GetStsMonitor(std::string treefilename, bool bDebugMode = false); +std::shared_ptr<CbmRichUnpackMonitor> GetRichMonitor(std::string treefilename, bool bDebugMode = false); const char* defaultSetupName = "mcbm_beam_2021_07_surveyed"; void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:5556"}, Int_t serverHttpPort = 8080, @@ -98,12 +99,16 @@ void run_unpack_online(std::vector<std::string> publisher = {"tcp://localhost:55 if (1904 < runid) { /// Switch to new unpacking algo starting from first combined cosmics run in 2022 richconfig->SetUnpackerVersion(CbmRichUnpackerVersion::v03); + richconfig->SetMonitor(GetRichMonitor(outfilename, true)); } + + richconfig->DoTotOffsetCorrection(); // correct ToT offset richconfig->SetDebugState(); richconfig->SetDoWriteOutput(); std::string parfilesbasepathRich = Form("%s/macro/beamtime/mcbm2021/", srcDir.Data()); richconfig->SetParFilesBasePath(parfilesbasepathRich); - richconfig->SetSystemTimeOffset(-1200); // [ns] 1 MS and additional correction + richconfig->SetSystemTimeOffset(256000 - 1200); // [ns] 1 MS and additional correction + if (1904 < runid) richconfig->SetSystemTimeOffset(-1200); if (runid == 1588) richconfig->MaskDiRICH(0x7150); } // ------------- @@ -413,6 +418,42 @@ std::shared_ptr<CbmStsUnpackMonitor> GetStsMonitor(std::string treefilename, boo return monitor; } +/** + * @brief Get the Rich Monitor. Extra function to keep default macro part more silent. + * @return std::shared_ptr<CbmRichUnpackMonitor> +*/ +std::shared_ptr<CbmRichUnpackMonitor> GetRichMonitor(std::string treefilename, bool bDebugMode = false) +{ + // ----- Output filename and path ------------------------------------- + std::string outpath = ""; + std::string filename = ""; + auto filenamepos = treefilename.find_last_of("/"); + if (filenamepos != treefilename.npos) { + outpath = treefilename.substr(0, filenamepos); + filename = treefilename.substr(filenamepos++); + } + if (outpath.empty()) outpath = gSystem->GetWorkingDirectory(); + + auto currentdir = gSystem->GetWorkingDirectory(); + + if (!gSystem->cd(outpath.data())) gSystem->MakeDirectory(outpath.data()); + else + gSystem->cd(currentdir.data()); + + std::string outfilename = outpath + filename; + auto filetypepos = outfilename.find(".digi.root"); + if (filetypepos != outfilename.npos) outfilename.replace(filetypepos, 10, ".mon.rich.root"); + else + outfilename += ".mon.rich.root"; + // ------------------------------------------------------------------------ + + auto monitor = std::make_shared<CbmRichUnpackMonitor>(); + monitor->SetHistoFileName(outfilename); + monitor->SetDebugMode(bDebugMode); + + return monitor; +} + void run_unpack_online(std::string publisher = "tcp://localhost:5556", Int_t serverHttpPort = 8080, Int_t serverRefreshRate = 100, std::int32_t nevents = -1, UInt_t runid = 1905, const char* setupName = defaultSetupName, std::string outpath = "data/") diff --git a/macro/run/run_unpack_tsa.C b/macro/run/run_unpack_tsa.C index 4411051373..679d9feefd 100644 --- a/macro/run/run_unpack_tsa.C +++ b/macro/run/run_unpack_tsa.C @@ -120,7 +120,7 @@ void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid std::string parfilesbasepathRich = Form("%s/macro/beamtime/mcbm2021/", srcDir.Data()); richconfig->SetParFilesBasePath(parfilesbasepathRich); richconfig->SetSystemTimeOffset(256000 - 1200); // [ns] 1 MS and additional correction - if (runid > 1904) richconfig->SetSystemTimeOffset(-1200); + if (1904 < runid) richconfig->SetSystemTimeOffset(-1200); if (runid == 1588) richconfig->MaskDiRICH(0x7150); } // ------------- -- GitLab