From 9b95faaabd6a3570ab404d8910f231a587dfca7b Mon Sep 17 00:00:00 2001 From: "P.-A. Loizeau" <p.-a.loizeau@gsi.de> Date: Wed, 22 Jun 2022 15:57:13 +0200 Subject: [PATCH] [MQ] in DigiEventSink, add options to set root file max size and to disable file compression --- MQ/mcbm/CbmDeviceDigiEventSink.cxx | 17 +++++++++++++---- MQ/mcbm/CbmDeviceDigiEventSink.h | 3 +++ MQ/mcbm/runDigiEventSink.cxx | 5 +++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/MQ/mcbm/CbmDeviceDigiEventSink.cxx b/MQ/mcbm/CbmDeviceDigiEventSink.cxx index 16f14e3bef..525bb5fcac 100644 --- a/MQ/mcbm/CbmDeviceDigiEventSink.cxx +++ b/MQ/mcbm/CbmDeviceDigiEventSink.cxx @@ -71,6 +71,8 @@ try { fbBypassConsecutiveTs = fConfig->GetValue<bool>("BypassConsecutiveTs"); fbWriteMissingTs = fConfig->GetValue<bool>("WriteMissingTs"); + fbDisableCompression = fConfig->GetValue<bool>("DisableCompression"); + fiTreeFileMaxSize = fConfig->GetValue<int64_t>("TreeFileMaxSize"); fbFillHistos = fConfig->GetValue<bool>("FillHistos"); fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs"); @@ -119,11 +121,18 @@ try { /// Prepare root output if ("" != fsOutputFileName) { fpRun = new FairRunOnline(); + FairRootFileSink* pSink = new FairRootFileSink(fsOutputFileName); fpFairRootMgr = FairRootManager::Instance(); - fpFairRootMgr->SetSink(new FairRootFileSink(fsOutputFileName)); + fpFairRootMgr->SetSink(pSink); if (nullptr == fpFairRootMgr->GetOutFile()) { throw InitTaskError("Could not open root file"); } // if( nullptr == fpFairRootMgr->GetOutFile() ) + if (fbDisableCompression) { + /// Completely disable the root file compression + pSink->GetRootFile()->SetCompressionLevel(0); + } + /// Set global size limit for all TTree in this process/Root instance + TTree::SetMaxTreeSize(fiTreeFileMaxSize); } // if( "" != fsOutputFileName ) else { throw InitTaskError("Empty output filename!"); @@ -651,9 +660,9 @@ CbmDeviceDigiEventSink::~CbmDeviceDigiEventSink() void CbmDeviceDigiEventSink::Finish() { + LOG(info) << "Performing clean close of the file"; // Clean closure of output to root file - fpFairRootMgr->Write(); - // fpFairRootMgr->GetSource()->Close(); + fpFairRootMgr->Write(); // Broken due to FileMaxSize?!? fpFairRootMgr->CloseSink(); LOG(info) << "File closed after saving " << (fulTsCounter + fulMissedTsCounter) << " TS (" << fulTsCounter << " full ones and " << fulMissedTsCounter << " missed/empty ones)"; @@ -760,7 +769,7 @@ CbmEventTimeslice::CbmEventTimeslice(FairMQParts& parts) inputArchiveEvt >> fvEvents; ++uPartIdx; LOG(info) << "Input event array " << fvEvents.size(); -*/ + */ std::vector<CbmEvent>* pvOutEvents = nullptr; RootSerializer().Deserialize(*parts.At(uPartIdx), pvOutEvents); fvEvents = std::move(*pvOutEvents); diff --git a/MQ/mcbm/CbmDeviceDigiEventSink.h b/MQ/mcbm/CbmDeviceDigiEventSink.h index c39a632be9..6e36b6da6d 100644 --- a/MQ/mcbm/CbmDeviceDigiEventSink.h +++ b/MQ/mcbm/CbmDeviceDigiEventSink.h @@ -85,6 +85,7 @@ private: bool fbStoreFullTs = false; //! If true, store digis vectors with full TS in addition to selected events bool fbBypassConsecutiveTs = false; //! Switch ON/OFF the bypass of the consecutive TS buffer before writing to file bool fbWriteMissingTs = false; //! Switch ON/OFF writing of empty TS to file for the missing ones (if no bypass) + bool fbDisableCompression = false; //! Switch ON/OFF the ROOT file compression bool fbFillHistos = false; //! Switch ON/OFF filling of histograms bool fbInitDone = false; //! Keep track of whether the Init was already fully completed bool fbFinishDone = false; //! Keep track of whether the Finish was already called @@ -97,6 +98,8 @@ private: std::string fsChannelNameDataInput = "events"; std::string fsChannelNameCommands = "commands"; std::string fsChannelNameHistosInput = "histogram-in"; + /// Output file/tree management + int64_t fiTreeFileMaxSize = 10000000000LL; //! Default value: ~10 GB /// Histograms management uint32_t fuPublishFreqTs = 100; double_t fdMinPublishTime = 0.5; diff --git a/MQ/mcbm/runDigiEventSink.cxx b/MQ/mcbm/runDigiEventSink.cxx index 2f75778476..94c750ce57 100644 --- a/MQ/mcbm/runDigiEventSink.cxx +++ b/MQ/mcbm/runDigiEventSink.cxx @@ -26,6 +26,11 @@ void addCustomOptions(bpo::options_description& options) options.add_options()("WriteMissingTs", bpo::value<bool>()->default_value(false), "Write empty TS to file for the missing ones if true (irrelevant if bypass ON)"); + options.add_options()("DisableCompression", bpo::value<bool>()->default_value(false), + "Disable the root file compression if true"); + options.add_options()("TreeFileMaxSize", bpo::value<int64_t>()->default_value(10000000000LL), + "Set the maximum output tree size (~file size) in bytes"); + options.add_options()("FillHistos", bpo::value<bool>()->default_value(false), "Fill histograms and send them to histo server if true"); -- GitLab