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);
74 fRootFile =
new TFile(rootfilename.Data(),
"RECREATE",
"myfile1");
76 QwError <<
"ROOT file " << rootfilename
84 TString run_condition_name = Form(
"condition_%s", run_label.Data());
85 TList *run_cond_list = (TList*)
fRootFile -> FindObjectAny(run_condition_name);
86 if (not run_cond_list) {
124 TString rootfilename =
fRootFile->GetName();
138 err = remove( rootfilename.Data() );
152 std::map< const std::string, std::vector<QwRootTree*> >::iterator map_iter;
153 std::vector<QwRootTree*>::iterator vec_iter;
155 for (vec_iter = map_iter->second.begin(); vec_iter != map_iter->second.end(); vec_iter++) {
170 "directory of the output ROOT files");
175 "stem of the output ROOT filename");
179 (
"enable-mapfile", po::value<bool>()->default_bool_value(
false),
180 "enable output to memory-mapped file\n(likely requires circular-buffer too)");
182 (
"write-temporary-rootfiles", po::value<bool>()->default_bool_value(
true),
183 "When writing ROOT files, use the PID to create a temporary filename");
187 (
"disable-tree", po::value<std::vector<std::string>>()->composing(),
188 "disable output to tree regex");
190 (
"disable-trees", po::value<bool>()->default_bool_value(
false),
191 "disable output to all trees");
193 (
"disable-histos", po::value<bool>()->default_bool_value(
false),
194 "disable output to all histograms");
198 (
"disable-mps-tree", po::value<bool>()->default_bool_value(
false),
199 "disable helicity window output");
201 (
"disable-pair-tree", po::value<bool>()->default_bool_value(
false),
202 "disable helicity pairs output");
204 (
"disable-hel-tree", po::value<bool>()->default_bool_value(
false),
205 "disable helicity pattern output");
207 (
"disable-burst-tree", po::value<bool>()->default_bool_value(
false),
208 "disable burst tree");
210 (
"disable-slow-tree", po::value<bool>()->default_bool_value(
false),
211 "disable slow control tree");
213#ifdef HAS_RNTUPLE_SUPPORT
216 (
"enable-rntuples", po::value<bool>()->default_bool_value(
false),
217 "enable RNTuple output");
222 (
"num-mps-accepted-events", po::value<int>()->default_value(0),
223 "number of accepted consecutive MPS events");
225 (
"num-mps-discarded-events", po::value<int>()->default_value(0),
226 "number of discarded consecutive MPS events");
228 (
"num-hel-accepted-events", po::value<int>()->default_value(0),
229 "number of accepted consecutive pattern events");
231 (
"num-hel-discarded-events", po::value<int>()->default_value(0),
232 "number of discarded consecutive pattern events");
234 (
"mapfile-update-interval", po::value<int>()->default_value(-1),
235 "Events between a map file update");
238 options.
AddOptions(
"ROOT performance options")
239 (
"autoflush", po::value<int>()->default_value(0),
241 options.
AddOptions(
"ROOT performance options")
242 (
"autosave", po::value<int>()->default_value(300000000),
244 options.
AddOptions(
"ROOT performance options")
245 (
"basket-size", po::value<int>()->default_value(16000),
246 "TTree basket size");
247 options.
AddOptions(
"ROOT performance options")
248 (
"circular-buffer", po::value<int>()->default_value(0),
249 "TTree circular buffer");
250 options.
AddOptions(
"ROOT performance options")
251 (
"compression-algorithm", po::value<int>()->default_value(1),
252 "TFile compression algorithm (default = 1 ZLIB)");
253 options.
AddOptions(
"ROOT performance options")
254 (
"compression-level", po::value<int>()->default_value(1),
255 "TFile compression level (default = 1, no compression = 0)");
347 for (
auto& tree : pair.second) {
348 if (tree && tree->GetTree()) {
349 Long64_t entries = tree->GetTree()->GetEntries();
358#ifdef HAS_RNTUPLE_SUPPORT
360 for (
auto& pair : fNTupleByName) {
361 for (
auto& ntuple : pair.second) {
362 if (ntuple && ntuple->fCurrentEvent > 0) {
370 TList* l = d->GetListOfKeys();
373 for(
int i=0; i < l->GetEntries(); ++i) {
374 const char* name = l->At(i)->GetName();
375 TObject* obj = d->FindObjectAny(name);
386 if ( TString(name).Contains(
"parameter_file") ) {
390 if ( TString(name).Contains(
"mapfile") ) {
393 if ( TString(name).Contains(
"_condition") ) {
397 if ( TString(name).Contains(
"slow") ) {
402 if (obj->IsA()->InheritsFrom(
"TDirectory" )) {
403 if (this->
HasAnyFilled( (TDirectory*)obj ))
return true;
406 if (obj->IsA()->InheritsFrom(
"TTree" )) {
407 Long64_t entries = ((TTree*) obj)->GetEntries();
408 if ( entries )
return true;
411 if (obj->IsA()->InheritsFrom(
"TH1" )) {
412 Double_t entries = ((TH1*) obj)->GetEntries();
413 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)