diff --git a/macro/run/run_unpack_online.C b/macro/run/run_unpack_online.C index e52fd82c1b18a58cf79fcc3b5bcbefafe0dfc039..03ed43fcb0a4a160ddebbd3ca475764fcf48310e 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 4411051373384d08fcd61fb7514b165880fa0457..679d9feefd2b2717197cc2a19658c44cb2f1eded 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); } // -------------