29#ifdef HAS_RNTUPLE_SUPPORT
30 , fEnableRNTuples(kFALSE)
36#ifdef QW_ENABLE_MAPFILE
40 TString mapfilename =
"/dev/shm/";
42 mapfilename +=
"/QwMemMapFile.map";
47 QwError <<
"Memory-mapped file " << mapfilename
52 QwMessage <<
"================== RealTime Producer Memory Map File =================" <<
QwLog::endl;
54 QwMessage <<
"======================================================================" <<
QwLog::endl;
60 TString hostname = gSystem -> HostName();
68 rootfilename += Form(
"/%s%s.%s.%d.root",
70 hostname.Data(), pid);
79 if (gSystem->AccessPathName(rootfilename.Data()) == 0) {
80 QwVerbose <<
"Removing existing temporary file before RECREATE: " << rootfilename <<
QwLog::endl;
81 gSystem->Unlink(rootfilename.Data());
87 if (gSystem->AccessPathName(rootfilename.Data()) == 0) {
89 int unlink_result = gSystem->Unlink(rootfilename.Data());
90 if (unlink_result == 0) {
101 fRootFile =
new TFile(rootfilename.Data(),
"RECREATE",
"myfile1");
103 QwError <<
"ROOT file " << rootfilename
111 TString run_condition_name = Form(
"condition_%s", run_label.Data());
112 TList *run_cond_list = (TList*)
fRootFile -> FindObjectAny(run_condition_name);
113 if (not run_cond_list) {
151 TString rootfilename =
fRootFile->GetName();
169 err = remove( rootfilename.Data() );
183 std::map< const std::string, std::vector<QwRootTree*> >::iterator map_iter;
184 std::vector<QwRootTree*>::iterator vec_iter;
186 for (vec_iter = map_iter->second.begin(); vec_iter != map_iter->second.end(); vec_iter++) {
201 "directory of the output ROOT files");
206 "stem of the output ROOT filename");
210 (
"enable-mapfile", po::value<bool>()->default_bool_value(
false),
211 "enable output to memory-mapped file\n(likely requires circular-buffer too)");
213 (
"write-temporary-rootfiles", po::value<bool>()->default_bool_value(
true),
214 "When writing ROOT files, use the PID to create a temporary filename");
218 (
"disable-tree", po::value<std::vector<std::string>>()->composing(),
219 "disable output to tree regex");
221 (
"disable-trees", po::value<bool>()->default_bool_value(
false),
222 "disable output to all trees");
224 (
"disable-histos", po::value<bool>()->default_bool_value(
false),
225 "disable output to all histograms");
229 (
"disable-mps-tree", po::value<bool>()->default_bool_value(
false),
230 "disable helicity window output");
232 (
"disable-pair-tree", po::value<bool>()->default_bool_value(
false),
233 "disable helicity pairs output");
235 (
"disable-hel-tree", po::value<bool>()->default_bool_value(
false),
236 "disable helicity pattern output");
238 (
"disable-burst-tree", po::value<bool>()->default_bool_value(
false),
239 "disable burst tree");
241 (
"disable-slow-tree", po::value<bool>()->default_bool_value(
false),
242 "disable slow control tree");
244#ifdef HAS_RNTUPLE_SUPPORT
247 (
"enable-rntuples", po::value<bool>()->default_bool_value(
false),
248 "enable RNTuple output");
253 (
"num-mps-accepted-events", po::value<int>()->default_value(0),
254 "number of accepted consecutive MPS events");
256 (
"num-mps-discarded-events", po::value<int>()->default_value(0),
257 "number of discarded consecutive MPS events");
259 (
"num-hel-accepted-events", po::value<int>()->default_value(0),
260 "number of accepted consecutive pattern events");
262 (
"num-hel-discarded-events", po::value<int>()->default_value(0),
263 "number of discarded consecutive pattern events");
265 (
"mapfile-update-interval", po::value<int>()->default_value(-1),
266 "Events between a map file update");
269 options.
AddOptions(
"ROOT performance options")
270 (
"autoflush", po::value<int>()->default_value(0),
272 options.
AddOptions(
"ROOT performance options")
273 (
"autosave", po::value<int>()->default_value(300000000),
275 options.
AddOptions(
"ROOT performance options")
276 (
"basket-size", po::value<int>()->default_value(16000),
277 "TTree basket size");
278 options.
AddOptions(
"ROOT performance options")
279 (
"circular-buffer", po::value<int>()->default_value(0),
280 "TTree circular buffer");
281 options.
AddOptions(
"ROOT performance options")
282 (
"compression-algorithm", po::value<int>()->default_value(1),
283 "TFile compression algorithm (1=ZLIB, 2=LZMA, 4=LZ4, 5=ZSTD, default=1 ZLIB)");
284 options.
AddOptions(
"ROOT performance options")
285 (
"compression-level", po::value<int>()->default_value(1),
286 "TFile compression level (default = 1, no compression = 0)");
287 options.
AddOptions(
"ROOT performance options")
288 (
"rntuple-compression-algorithm", po::value<int>()->default_value(4),
289 "RNTuple compression algorithm (1=ZLIB, 2=LZMA, 4=LZ4, 5=ZSTD, default=4 LZ4)");
290 options.
AddOptions(
"ROOT performance options")
291 (
"rntuple-compression-level", po::value<int>()->default_value(0),
292 "RNTuple compression level (0-12, default=0 for maximum performance)");
386 for (
auto& tree : pair.second) {
387 if (tree && tree->GetTree()) {
388 Long64_t entries = tree->GetTree()->GetEntries();
397#ifdef HAS_RNTUPLE_SUPPORT
399 for (
auto& pair : fNTupleByName) {
400 for (
auto& ntuple : pair.second) {
401 if (ntuple && ntuple->fCurrentEvent > 0) {
409 TList* l = d->GetListOfKeys();
412 for(
int i=0; i < l->GetEntries(); ++i) {
413 const char* name = l->At(i)->GetName();
414 TObject* obj = d->FindObjectAny(name);
425 if ( TString(name).Contains(
"parameter_file") ) {
429 if ( TString(name).Contains(
"mapfile") ) {
432 if ( TString(name).Contains(
"_condition") ) {
436 if ( TString(name).Contains(
"slow") ) {
441 if (obj->IsA()->InheritsFrom(
"TDirectory" )) {
442 if (this->
HasAnyFilled( (TDirectory*)obj ))
return true;
445 if (obj->IsA()->InheritsFrom(
"TTree" )) {
446 Long64_t entries = ((TTree*) obj)->GetEntries();
447 if ( entries )
return true;
450 if (obj->IsA()->InheritsFrom(
"TH1" )) {
451 Double_t entries = ((TH1*) obj)->GetEntries();
452 if ( entries )
return true;
Int_t WriteObject(const T *obj, const char *name, Option_t *option="", Int_t bufsize=0)
Write any object to the ROOT file (only valid for TFile)