Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions | Variables
MonitoringFile.cxx File Reference
#include "DataQualityUtils/MonitoringFile.h"
#include <TDirectory.h>
#include <TEfficiency.h>
#include <TFile.h>
#include <TGraph.h>
#include <TH1.h>
#include <TH2.h>
#include <TIterator.h>
#include <TKey.h>
#include <TObject.h>
#include <TROOT.h>
#include <TSystem.h>
#include <TTree.h>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <exception>
#include <filesystem>
#include <format>
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <vector>
#include "DataQualityInterfaces/HanApp.h"
#include "DataQualityInterfaces/HanUtils.h"
#include "TTreeReader.h"
#include "TTreeReaderArray.h"

Go to the source code of this file.

Functions

 ClassImp (dqutils::MonitoringFile) namespace dqutils
 

Variables

 ATLAS_NO_CHECK_FILE_THREAD_SAFETY
 

Function Documentation

◆ ClassImp()

ClassImp ( dqutils::MonitoringFile  )

Definition at line 41 of file MonitoringFile.cxx.

43  {
44 
45  class dbgPrint {
46 
47  public:
48  dbgPrint(const debugLevel_t setLvl = none) : m_currLvl(setLvl) {};
49  inline void operator()(const debugLevel_t level, const std::string& msg) const {
50  if (level <= m_currLvl)
51  std::cout << msg << std::endl;
52  }
53  void setLvl(const debugLevel_t lvl) { m_currLvl = lvl; }
54  debugLevel_t getLvl() const { return m_currLvl; }
55 
56  private:
57  debugLevel_t m_currLvl;
58  };
59 
60  static dbgPrint s_dbg;
61  static bool s_checkEquality=false;
62 
63  std::optional<std::regex> checkRegEx(const std::string& re) {
64  if (re.empty())
65  return std::nullopt;
66 
67  std::regex reNew(re);
68  try {
69  // this should fail if there are any problems with re!
70  std::string test("Test String");
71  std::regex_match(test, reNew);
72  } catch (std::exception& e) {
73  std::cout << "ERROR: Invalid RegEx string \"" << re << "\"." << std::endl;
74  std::cout << "See http://www.boost.org/doc/libs/1_42_0/libs/regex/doc/html/boost_regex/syntax.html for allowed regular expression syntax" << std::endl;
75  return std::nullopt;
76  }
77  return reNew;
78  }
79 
80  // Internally used data-structures:
81 
82  class histCollection {
83 
84  public:
85  typedef std::map<std::string, std::vector<std::string>> fileLBMap_t;
86  explicit histCollection(TFile* out, bool skipExisting = false) : m_out{out}, m_skipExisting(skipExisting) {};
87  histCollection() = delete;
88 
89  ~histCollection();
90 
91  void addDirectory(TDirectory* dir, const std::string& dirName, const std::string& filename = "");
92  size_t size() { return m_data.size(); };
93  void print();
94  void write(); // Destructive method, will delete internal data after writing
95 
96  void addDirExclusion(const std::optional<std::regex>& dirEx);
97  void addHistExclusion(const std::optional<std::regex>& histEx);
98 
99  unsigned size() const;
100  void clear();
101 
102  fileLBMap_t getFileLBMapAndClear() {
103  m_data.clear();
104  return std::move(m_fileLBMap);
105  }
106 
107  void printTiming();
108 
109  private:
110  class histPerDir_t {
111  public:
112  histPerDir_t(const std::string& nameIn, std::unique_ptr<TObject>&& objIn, TTree* md);
113  histPerDir_t(dqutils::histCollection::histPerDir_t&& other)
114  : name(std::move(other.name)), obj(std::move(other.obj)), metadata(std::move(other.metadata)), mergeMethod(other.mergeMethod) {}
115 
116  std::string name;
117  std::unique_ptr<TObject> obj;
118  std::array<std::string, 3> metadata{"unset","","<default>"};
119  std::clock_t cpuSum = 0;
120  void (*mergeMethod)(TObject* a, const TObject* b) = nullptr;
121  void merge(TObject* other);
122 
123  private:
124  bool fillMD(TTree* mdTree);
125  };
126 
127  struct histDir_t {
128  std::unordered_map<std::string, histPerDir_t> histos;
129  void writeMD(TDirectory* outDir) const;
130  };
131 
132  private:
133  TFile* m_out;
134  bool m_skipExisting;
135  std::unordered_map<std::string, histDir_t> m_data;
136  std::optional<std::regex> m_dirExclusion;
137  std::optional<std::regex> m_histExclusion;
138  fileLBMap_t m_fileLBMap;
139  };
140 
141  void histCollection::clear() {
142  m_data.clear();
143  m_fileLBMap.clear();
144  }
145 
146  void histCollection::printTiming() {
147  std::vector<std::pair<std::string, clock_t>> cpuPerHistVec;
148  for (auto& [dirname, histDir] : m_data) {
149  for (auto& [histname, histo] : histDir.histos) {
150  cpuPerHistVec.emplace_back(dirname + "/" + histname, histo.cpuSum);
151  }
152  }
153  auto ordering = [](std::pair<std::string, clock_t> a, std::pair<std::string, clock_t> b) { return a.second < b.second; };
154  std::sort(cpuPerHistVec.begin(), cpuPerHistVec.end(), ordering);
155  for (const auto& [name, time] : cpuPerHistVec) {
156  const double tSec = double(time) / CLOCKS_PER_SEC;
157  std::cout << std::format("{:<30} : {:10.3f}", name, tSec) << std::endl;
158  }
159  return;
160  }
161 
162  bool histCollection::histPerDir_t::fillMD(TTree * md) {
163  TTreeReader reader(md);
164  TTreeReaderArray<char> i_name(reader, "Name");
165  TTreeReaderArray<char> i_interval(reader, "Interval");
166  TTreeReaderArray<char> i_chain(reader, "TriggerChain");
167  TTreeReaderArray<char> i_merge(reader, "MergeMethod");
168 
169  bool found = false;
170  while (reader.Next()) {
171  const std::string nameStr(static_cast<char*>(i_name.GetAddress()));
172  if (name == nameStr) {
173  metadata = {static_cast<char*>(i_interval.GetAddress()), static_cast<char*>(i_chain.GetAddress()), static_cast<char*>(i_merge.GetAddress())};
174  found = true;
175  break;
176  }
177  }
178  return found;
179  }
180 
182  if (obj && other) {
183  const std::clock_t cpuStart = std::clock();
184  this->mergeMethod(obj.get(), other);
185  cpuSum += std::clock() - cpuStart;
186  }
187  return;
188  }
189 
190  void histCollection::histDir_t::writeMD(TDirectory * out) const {
191 
192  // Check if there is already a metadata-tree. Merge content if necessary
193  std::map<std::string, std::array<std::string, 3>> metadatamap;
194  std::unique_ptr<TTree> oldMD((TTree*)out->Get("metadata"));
195  if (oldMD) {
196  TTreeReader reader(oldMD.get());
197  TTreeReaderArray<char> i_name(reader, "Name");
198  TTreeReaderArray<char> i_interval(reader, "Interval");
199  TTreeReaderArray<char> i_chain(reader, "TriggerChain");
200  TTreeReaderArray<char> i_merge(reader, "MergeMethod");
201 
202  while (reader.Next()) {
203  const std::string name(static_cast<char*>(i_name.GetAddress()));
204  metadatamap[name] = {static_cast<char*>(i_interval.GetAddress()), static_cast<char*>(i_chain.GetAddress()), static_cast<char*>(i_merge.GetAddress())};
205  }
206  }
207 
208  for (const auto& [key, h] : histos) {
209  if (h.metadata[0]!="unset") //Ignore dummy-metadata (eg HLTMon use-case)
210  metadatamap[key] = h.metadata;
211  }
212 
213  if (metadatamap.empty()) return; //Do not write empty metadata tree
214  std::string interval, chain, merge;
215  char histname[1024]; // FIXME, no idea why this works only in this old-fashioned way
216  std::unique_ptr<TTree> mdTree = std::make_unique<TTree>("metadata", "Monitoring Metadata");
217  mdTree->SetDirectory(out);
218 
219  mdTree->Branch("Name", (void*)nullptr, "Name/C");
220  mdTree->Branch("Interval", interval.data(), "Interval/C");
221  mdTree->Branch("TriggerChain", chain.data(), "TriggerChain/C");
222  mdTree->Branch("MergeMethod", merge.data(), "MergeMethod/C");
223 
224  mdTree->SetBranchAddress("Name", histname);
225 
226  for (auto& [key, h] : metadatamap) {
227  strncpy(histname, key.c_str(), 1023);
228  interval = h[0];
229  chain = h[1];
230  merge = h[2];
231  mdTree->Fill();
232  }
233  mdTree->Write(0, TObject::kOverwrite);
234  }
235 
236  histCollection::~histCollection() {}
237 
238  void histCollection::addDirExclusion(const std::optional<std::regex>& dir) {
239  m_dirExclusion = dir;
240  return;
241  }
242 
243  void histCollection::addHistExclusion(const std::optional<std::regex>& dir) {
244  m_histExclusion = dir;
245  return;
246  }
247 
248  unsigned histCollection::size() const {
249  unsigned s = 0;
250  for (const auto& it : m_data) {
251  s += it.second.histos.size();
252  }
253  return s;
254  }
255 
256  void histCollection::print() {
257  for (const auto& it : m_data) {
258  const histDir_t& hd = it.second;
259  std::cout << "Dir: " << it.first << " has " << hd.histos.size() << " histos" << std::endl;
260  for (const auto& it1 : hd.histos)
261  std::cout << "\t" << it1.second.name << std::endl;
262  }
263  return;
264  }
265 
266  template <class HIST>
267  void defaultMerge(TObject * a, const TObject* b) {
268  ((HIST*)a)->Add((HIST*)b);
269  return;
270  }
271 
272  void weightedAverage ATLAS_NOT_THREAD_SAFE(TObject * a, const TObject* b) {
273  TH1* a1 = (dynamic_cast<TH1*>(a));
274  const TH1* b1 = dynamic_cast<const TH1*>(b);
275  if (!b1 || !a1)
276  std::cout << "ERROR in weightedAverageTH1: Object not of type TH1" << std::endl;
277  else {
278  if (b1->GetEntries()==0) return;
280  }
281  return;
282  }
283 
284  void weightedEff ATLAS_NOT_THREAD_SAFE(TObject * a, const TObject* b) {
285  TH1* a1 = (dynamic_cast<TH1*>(a));
286  const TH1* b1 = (dynamic_cast<const TH1*>(b));
287  if (!b1 || !a1)
288  std::cout << "ERROR in weightedEff: Object not of type TH1" << std::endl;
289  else {
290  if (b1->GetEntries()==0) return;
292  }
293  return;
294  }
295 
296  void mergeRMS ATLAS_NOT_THREAD_SAFE(TObject * a, const TObject* b) {
297  TH1* a1 = (dynamic_cast<TH1*>(a));
298  const TH1* b1 = dynamic_cast<const TH1*>(b);
299  if (!b1 || !a1)
300  std::cout << "ERROR in mergeRMS: Object not of type TH1" << std::endl;
301  else {
302  if (b1->GetEntries()==0) return;
304  }
305  return;
306  }
307 
308  void RMSpercentDeviation ATLAS_NOT_THREAD_SAFE(TObject * a, const TObject* b) {
309  TH1* a1 = (dynamic_cast<TH1*>(a));
310  const TH1* b1 = dynamic_cast<const TH1*>(b);
311  if (!b1 || !a1)
312  std::cout << "ERROR in RMSpercentDeviation: Object not of type TH1" << std::endl;
313  else {
314  if (b1->GetEntries()==0) return;
316  }
317  return;
318  }
319 
320  void perBinEffPerCent ATLAS_NOT_THREAD_SAFE(TObject * a, const TObject* b) {
321  TH1* a1 = (dynamic_cast<TH1*>(a));
322  const TH1* b1 = dynamic_cast<const TH1*>(b);
323  if (!b1 || !a1)
324  std::cout << "ERROR in getBinEffPerCent: Object not of type TH1" << std::endl;
325  else {
326  if (b1->GetEntries()==0) return;
328  }
329  return;
330  }
331 
332  void lowerLB ATLAS_NOT_THREAD_SAFE(TObject * a, const TObject* b) {
333  TH1* a1 = (dynamic_cast<TH1*>(a));
334  const TH1* b1 = dynamic_cast<const TH1*>(b);
335  if (!b1 || !a1)
336  std::cout << "ERROR in lowerLB: Object not of type TH1" << std::endl;
337  else
339  return;
340  }
341 
342  template <class HIST>
343  void identical(TObject * a, const TObject* b) {
344  if (!s_checkEquality)
345  return; //quasi null-operation
346  HIST* a1 = (dynamic_cast<HIST*>(a));
347  const HIST* b1 = dynamic_cast<const HIST*>(b);
349  return;
350  }
351 
352  void merge_rebinned(TObject * a, const TObject* b) {
353  TH1* a1 = (dynamic_cast<TH1*>(a));
354  const TH1* b1 = dynamic_cast<const TH1*>(b);
355  if (!a1 || !b1) {
356  std::cout << "ERROR, in merge_rebinned: Object not of type TH1";
357  return;
358  }
359  TH1* b2 = const_cast<TH1*>(b1);
361  return;
362  }
363 
364  void merge_eventSample(TObject * a, const TObject* b) {
365  TH2* a1 = (dynamic_cast<TH2*>(a));
366  const TH2* b1 = dynamic_cast<const TH2*>(b);
367  if (!a1 || !b1) {
368  std::cout << "ERROR in merge_eventSample: Object not of type TH2" << std::endl;
369  return;
370  }
372  }
373 
374  void merge_TEfficency(TObject * a, const TObject* b) {
375  TEfficiency* a1 = dynamic_cast<TEfficiency*>(a);
376  const TEfficiency* b1 = dynamic_cast<const TEfficiency*>(b);
377  TEfficiency* b2 = const_cast<TEfficiency*>(b1);
378  if (!a1 || !b1) {
379  std::cout << "ERROR in merge_TEfficiency: Object not of type TEfficiency" << std::endl;
380  return;
381  }
382  TList listE;
383  listE.Add(b2);
384  a1->Merge(&listE);
385  listE.Clear();
386  }
387 
388  void merge_TTree(TObject * a, const TObject* b) {
389  TTree* a1 = dynamic_cast<TTree*>(a);
390  const TTree* b1 = dynamic_cast<const TTree*>(b);
391  TTree* b2 = const_cast<TTree*>(b1);
392  TList listT;
393  listT.Add(b2);
394  a1->Merge(&listT);
395  listT.Clear();
396  }
397 
398  histCollection::histPerDir_t::histPerDir_t(const std::string& nameIn, std::unique_ptr<TObject>&& objIn, TTree* mdTree)
399  : name(nameIn), obj(std::move(objIn)), mergeMethod(nullptr) {
400  // Some sanity checks:
401  if (!obj) {
402  std::cout << "ERROR while adding " << nameIn << ": Histogram pointer is NULL" << std::endl;
403  return;
404  }
405 
406  if (mdTree) {
407  fillMD(mdTree);
408  }
409  else {
410  s_dbg(VERBOSE,"No matadata found for " + name +", use defaults");
411  }
412  const std::string& howToMerge = metadata[2];
413  s_dbg(VERBOSE, "Name: " + name + " mergeMethod=" + howToMerge);
414 
415  TH1* th1 = dynamic_cast<TH1*>(obj.get());
416  TH2* th2 = dynamic_cast<TH2*>(obj.get());
417  TEfficiency* teff = dynamic_cast<TEfficiency*>(obj.get());
418  if (th1) {
419  th1->SetDirectory(nullptr); // Get ownership of this hist
420  if (howToMerge == "<default>") {
421  if (th2) {
422  mergeMethod = &defaultMerge<TH2>;
423  } else { //TH1 case
424  mergeMethod = &defaultMerge<TH1>;
425  }
426  }
427  else if (howToMerge == "weightedAverage" || howToMerge=="weightedAverage2D")
428  mergeMethod = &weightedAverage;
429  else if (howToMerge == "weightedEff")
430  mergeMethod = &weightedEff;
431  else if (howToMerge == "mergeRMS")
432  mergeMethod = &mergeRMS;
433  else if (howToMerge == "RMSpercentDeviation")
434  mergeMethod = &RMSpercentDeviation;
435  else if (howToMerge == "perBinEffPerCent")
436  mergeMethod = &perBinEffPerCent;
437  else if (howToMerge == "lowerLB")
438  mergeMethod = &lowerLB;
439  else if (howToMerge == "identical")
440  if (th2) {
441  mergeMethod = &identical<TH2>;
442  } else { //TH1 case
443  mergeMethod = &identical<TH1>;
444  }
445  else if ((howToMerge == "mergeRebinned") || (howToMerge == "merge"))
446  mergeMethod = &merge_rebinned;
447  else {
448  std::cout << "ERROR: Unknown merging method (" << howToMerge << ") for object of type TH1 named " << nameIn << std::endl;
449  obj.reset(nullptr);
450  }
451  } // end if TH1
452  else if (teff) {
453  teff->SetDirectory(nullptr);
454  if (howToMerge == "<default>")
455  mergeMethod = &merge_TEfficency;
456  else
457  std::cout << "ERROR: Unknown merging method (" << howToMerge << ") for object of type TEfficiency named " << nameIn << std::endl;
458  } // end if TEfficiency
459  else if (nullptr != dynamic_cast<TTree*>(obj.get())) {
460  mergeMethod = &merge_TTree;
461  } else {
462  std::cout << "ERROR Object " << name << " has unkown type" << std::endl;
463  obj.reset(nullptr);
464  }
465  }
466 
467  void histCollection::addDirectory(TDirectory * dir, const std::string& dirName, const std::string& filename) {
468 
469  s_dbg(VERBOSE, "Working on directory " + dirName);
470  if (m_dirExclusion && !std::regex_search(dirName, *m_dirExclusion)) {
471  s_dbg(DEBUG, "Path " + dirName + " is excluded");
472  return;
473  }
474 
475  for (TObject* oKey : *dir->GetListOfKeys()) {
476  TKey* key = static_cast<TKey*>(oKey);
477  const std::string name = key->GetName();
478  const std::string classname = key->GetClassName();
479  if ((classname == "TTree") && (name == "metadata")) {
480  continue;
481  }
482 
483  s_dbg(VERBOSE, "Found name " + name + ", classname=" + classname);
484 
485  const std::string newName = dirName.empty() ? name : dirName + "/" + name;
486  auto itDir = m_data.find(dirName);
487 
488  if (classname.starts_with("TH") || classname.starts_with("TProfile") || classname.starts_with("TEfficiency") || classname == "TTree") {
489  if (m_histExclusion && !std::regex_search(name, *m_histExclusion)) {
490  s_dbg(DEBUG, "Histogram with name " + name + " is excluded");
491  continue;
492  }
493 
494  // arrive here if we have at least one histogram in this directory
495  if (m_skipExisting) {
496  // Check if this object exists already in the output-file
497  std::unique_ptr<TObject> existingObj(m_out->Get(newName.c_str()));
498  if (existingObj)
499  continue;
500  }
501 
502  std::unique_ptr<TTree> md;
503  if (itDir == m_data.end()) {
504  // Have not seen this dirName yet
505  itDir = m_data.emplace(dirName, histDir_t()).first;
506  s_dbg(VERBOSE, "Registering new directory " + dirName);
507  }
508 
509  // Check if we already have this histogram in the list
510  auto itH = itDir->second.histos.find(name);
511  if (itH == itDir->second.histos.end()) {
512  // New histogram (or Tree):
513  if (!md) {
514  // Metadata tree not yet read in this directory
515  md.reset((TTree*)dir->Get("metadata"));
516  }
517 
518  std::unique_ptr<TObject> obj{key->ReadObj()};
519  TTree* treeObj = dynamic_cast<TTree*>(obj.get());
520  if (treeObj) {
521  TDirectory* outDir = m_out->GetDirectory(dirName.c_str());
522  if (!outDir)
523  outDir = m_out->mkdir(dirName.c_str());
524  // TTree need special treatment ...
525  TDirectory* currentDir = gDirectory;
526  outDir->cd();
527  TTree* cloneTree = treeObj->CloneTree();
528  // this disconnects parent tree
529  obj.reset(cloneTree);
530  currentDir->cd();
531  }
532  histPerDir_t histo(name, std::move(obj), md.get());
533  itH = itDir->second.histos.emplace(name, std::move(histo)).first; //Take owernship of object here!
534  s_dbg(VERBOSE, "Cloning histogram " + name + " in dir " + dirName);
535  } else {
536  // Histogram already known .. merge it
537  std::unique_ptr<TObject> other(key->ReadObj());
538  if (!other) {
539  std::cout << "ERROR, got NULL key";
540  } else {
541  itH->second.merge(other.get()); // Release object in this case
542  s_dbg(VERBOSE, "Merging histogram " + name + " in dir " + dirName);
543  }
544  }
545  } else if (classname.starts_with("TDirectory")) {
546  std::unique_ptr<TObject> obj(key->ReadObj());
547  TDirectory* subdir = dynamic_cast<TDirectory*>(obj.get());
548  if (subdir) {
549  if (filename.empty()) {
550  this->addDirectory(subdir, newName, filename);
551  } else {
552  if (!name.starts_with("lb_") && !name.starts_with("lowStat_LB")) {
553  this->addDirectory(subdir, newName, filename);
554  } else {
555  m_fileLBMap[newName].push_back(filename);
556  }
557  }
558  }
559  } else {
560  std::cout << "Ignored objects '" << name << "' of type " << classname << std::endl;
561  }
562  }
563  return;
564  }
565 
566  void histCollection::write() {
567  unsigned nWritten = 0;
568  unsigned nIgnored = 0;
569  unsigned nDirs = 0;
570  for (auto& it : m_data) {
571  const std::string fulldir = it.first;
572  TDirectory* histDir = m_out->GetDirectory(fulldir.c_str());
573  if (histDir == nullptr) { // Create the directory if it doesn't exist yet
574  histDir = m_out->mkdir(fulldir.c_str());
575  if (histDir == nullptr) {
576  std::cout << "ERROR, failed to create directory " << fulldir << std::endl;
577  break;
578  } else {
579  s_dbg(VERBOSE, "Created directory " + fulldir + " in file " + m_out->GetName());
580  }
581  }
582  m_out->cd(fulldir.c_str());
583  ++nDirs;
584  for (auto& [name, histo] : it.second.histos) {
585  if (histo.obj) {
586  histo.obj->Write();
587  ++nWritten;
588  } else {
589  std::cout << "NOT writing " << name << ". Invalid." << std::endl;
590  ++nIgnored;
591  }
592  } // End loop over histograms in one directory
593  it.second.writeMD(histDir);
594  } // End loop over directories;
595  std::cout << "Wrote " << nWritten << " histograms to " << nDirs << " directories in output file " << m_out->GetName() << std::endl;
596  if (nIgnored)
597  std::cout << " Omitting " << nIgnored << " histograms." << std::endl;
598  }
599 
600  // *********************************************************************
601  // Public Methods
602  // *********************************************************************
603 
604  MonitoringFile::OutputMetadata::OutputMetadata(TTree * metadata) : m_metadata(metadata) {
605  makeBranch("Name", "Name/C");
606  makeBranch("Interval", "Interval/C");
607  makeBranch("TriggerChain", "TriggerChain/C");
608  makeBranch("MergeMethod", "MergeMethod/C");
609  }
610 
611  void MonitoringFile::OutputMetadata::makeBranch(const char* branchName, const char* branchstr) {
612  if (!m_metadata->GetBranch(branchName)) {
613  m_metadata->Branch(branchName, (void*)nullptr, branchstr);
614  }
615  }
616 
617  void MonitoringFile::OutputMetadata::fill(const std::string& theName, const std::string& theInterval, const std::string& theChain,
618  const std::string& theMerge) {
619  std::string name = theName;
620  std::string interval = theInterval;
621  std::string chain = theChain;
622  std::string merge = theMerge;
623  m_metadata->SetBranchAddress("Name", name.data());
624  m_metadata->SetBranchAddress("Interval", interval.data());
625  m_metadata->SetBranchAddress("TriggerChain", chain.data());
626  m_metadata->SetBranchAddress("MergeMethod", merge.data());
627  m_metadata->Fill();
628  }
629 
630  MonitoringFile::MonitoringFile() : m_file(0) {
631  m_fileCompressionLevel = 1;
632  m_doTiming = false;
633  MonitoringFile::clearData();
634  }
635 
636  bool MonitoringFile::setFile(const std::string& fileName) {
637  clearData();
638  m_file = TFile::Open(fileName.c_str());
639  if (m_file != 0)
640  return true;
641  return false;
642  }
643 
644  MonitoringFile::MonitoringFile(const std::string& fileName) : m_file(0) {
645  m_fileCompressionLevel = 1;
646  m_doTiming = false;
647  MonitoringFile::clearData();
648  MonitoringFile::setFile(fileName);
649  }
650 
651  MonitoringFile::~MonitoringFile() {
653 
654  delete m_file;
655  }
656 
657  bool MonitoringFile::setHistogramRegEx(const std::string& re) {
658  m_mergeMatchHistoRE = checkRegEx(re);
659  return m_mergeMatchHistoRE.has_value();
660  }
661 
662  bool MonitoringFile::setDirectoryRegEx(const std::string& re) {
663  m_mergeMatchDirRE = checkRegEx(re);
664  return m_mergeMatchDirRE.has_value();
665  }
666 
667  void MonitoringFile::getAllDirs(DirMap_t & dirmap, TDirectory * dir, const std::string& dirName) {
668  if (dir == 0)
669  return;
670 
671  if (dirName != "") {
672  DirMap_t::value_type dirmapVal(dirName, dir);
673  dirmap.insert(dirmapVal);
674  }
675 
676  TIter next(dir->GetListOfKeys());
677  TKey* key;
678  while ((key = dynamic_cast<TKey*>(next())) != 0) {
679  // don't delete TDirectories
680  TObject* obj = key->ReadObj();
681  TDirectory* subdir = dynamic_cast<TDirectory*>(obj);
682  if (subdir != 0) {
683  std::string subdirName(subdir->GetName());
684  std::string fName("");
685  if (dirName != "") {
686  fName += dirName;
687  fName += '/';
688  }
689  fName += subdirName;
690  getAllDirs(dirmap, subdir, fName);
691  } else {
692  delete obj;
693  }
694  }
695  }
696 
697  TDirectory* MonitoringFile::createDir(DirMap_t & dirmap, TDirectory * dir, const std::string& parent, const std::string& path) {
698  if (dir == 0)
699  return 0;
700 
701  TDirectory* subdir(0);
702  DirMap_t::const_iterator diter;
703  std::string::size_type i = path.find_first_of('/');
704  std::string fName("");
705  if (parent != "") {
706  fName += parent;
707  fName += '/';
708  }
709 
710  if (i != std::string::npos) {
711  std::string dName(path, 0, i);
712  std::string pName(path, i + 1, std::string::npos);
713  fName += dName;
714  if (dName != "") {
715  diter = dirmap.find(fName);
716  if (diter != dirmap.end()) {
717  subdir = diter->second;
718  } else {
719  subdir = dir->mkdir(dName.c_str());
720  DirMap_t::value_type dirmapVal(fName, subdir);
721  dirmap.insert(dirmapVal);
722  }
723  } else {
724  subdir = dir;
725  }
726  return createDir(dirmap, subdir, fName, pName);
727  }
728 
729  fName += path;
730 
731  diter = dirmap.find(fName);
732  if (diter != dirmap.end()) {
733  return diter->second;
734  }
735 
736  subdir = dir->mkdir(path.c_str());
737  DirMap_t::value_type dirmapVal(fName, subdir);
738  dirmap.insert(dirmapVal);
739  return subdir;
740  }
741 
742  TKey* MonitoringFile::getObjKey(TDirectory * dir, const std::string& path) {
743  if (dir == 0)
744  return 0;
745 
746  TKey* key(0);
747 
748  std::string::size_type i = path.find_first_of('/');
749  if (i != std::string::npos) {
750  std::string dName(path, 0, i);
751  std::string pName(path, i + 1, std::string::npos);
752  if (dName != "") {
753  key = dir->FindKey(dName.c_str());
754  if (key != 0) {
755  TDirectory* subDir = dynamic_cast<TDirectory*>(key->ReadObj());
756  if (subDir) {
757  return getObjKey(subDir, pName);
758  } // else fall through
759  }
760  return 0;
761  }
762  return getObjKey(dir, pName);
763  }
764 
765  return dir->FindKey(path.c_str());
766  }
767 
768  void MonitoringFile::fillMetaDataMap(std::map<std::string, dqutils::MonitoringFile::MetaData> & mdMap, TDirectory * dir) {
769  if (dir == 0)
770  return;
771  TTree* md = dynamic_cast<TTree*>(dir->Get("metadata"));
772  if (md == 0)
773  return;
774 
775  TTreeReader reader(md);
776  TTreeReaderArray<char> i_name(reader, "Name");
777  TTreeReaderArray<char> i_interval(reader, "Interval");
778  TTreeReaderArray<char> i_chain(reader, "TriggerChain");
779  TTreeReaderArray<char> i_merge(reader, "MergeMethod");
780 
781  while (reader.Next()) {
782  const std::string nameStr(static_cast<char*>(i_name.GetAddress()));
783  if (mdMap.find(nameStr) == mdMap.end()) {
784  MetaData md(nameStr, static_cast<char*>(i_interval.GetAddress()), static_cast<char*>(i_chain.GetAddress()), static_cast<char*>(i_merge.GetAddress()));
785  std::map<std::string, MetaData>::value_type mdVal(nameStr, md);
786  mdMap.insert(mdVal);
787  }
788  }
789 
790  delete md;
791  }
792 
793  int MonitoringFile::mergeFiles(const std::string& outFileName, const std::vector<std::string>& files) {
794  std::cout << "Writing file: " << outFileName << std::endl;
795  std::cout << "Start merging [" << files.size() << "] histogram files" << std::endl;
797  TH1::AddDirectory(false);
798  if (m_mergeMatchDirRE.has_value() || m_mergeMatchHistoRE.has_value()) {
799  std::cout << " ========== Using regular expressions for selective merging ========== " << std::endl;
800  }
801  if (m_doTiming) {
802  std::cout << "CPU time measurement activated " << std::endl;
803  }
804 
805  const size_t nFiles = files.size();
806 
807  if (nFiles < 1)
808  return -1;
809 
810  if (nFiles == 1) {
811  std::cout << "Got exactly one input file. Will copy input -> output" << std::endl;
812  if (m_mergeMatchDirRE.has_value() || m_mergeMatchHistoRE.has_value()) {
813  std::cout << "regular expressions for selective merging will have no effect!" << std::endl;
814  }
815 
818  std::filesystem::copy_file(inPath, outPath, std::filesystem::copy_options::overwrite_existing);
819  return 0;
820  }
821 
822  std::unique_ptr<TFile> outfile(TFile::Open(outFileName.c_str(), "RECREATE", outFileName.c_str(), m_fileCompressionLevel));
823  if (outfile.get() == 0) {
824  std::cout << " ERROR, cound not open output file " << outFileName << std::endl;
825  return -1;
826  }
827  std::cout << "Opened/created output file " << outFileName << std::endl;
828 
829  histCollection hc(outfile.get());
830  hc.addDirExclusion(m_mergeMatchDirRE);
831  hc.addHistExclusion(m_mergeMatchHistoRE);
832 
833  // Open first input file, mostly to get the run-directory
834  std::unique_ptr<TFile> in1(TFile::Open(files[0].c_str()));
835  if (!in1) {
836  std::cout << "ERROR, could not open input file " << files[0] << std::endl;
837  return -1;
838  }
839  std::cout << "Working on file 1/" << nFiles << ": " << files[0] << std::endl;
840  std::string runDir, runDirFwd;
841  const std::regex runDirPattern("run_[0-9]*");
842  TIter next(in1->GetListOfKeys());
843  TKey* key;
844  while ((key = (TKey*)next())) {
845  const char* name = key->GetName();
846  if (std::regex_match(name, runDirPattern)) {
847  if (runDir.size() > 0) {
848  std::cout << "ERROR More than one run_XXX directory found! Ignoring " << name << std::endl;
849  } else
850  runDir = name;
851  }
852  }
853  if (runDir.empty()) {
854  std::cout << "No run-directory found, start with '/'" << std::endl;
855  runDir="/";
856  runDirFwd="";
857  }
858  else {
859  std::cout << "Found run directory " << runDir << std::endl;
860  runDirFwd=runDir;
861  }
862 
863 
864  TDirectory* dir(dynamic_cast<TDirectory*>(in1->GetDirectory(runDir.c_str())));
865  if (!dir) {
866  std::cout << "ERROR, can't access directory " << runDir;
867  return -1;
868  }
869 
870  hc.addDirectory(dir, runDirFwd, files[0]);
871 
872  // Close first input file
873  in1->Delete("");
874  in1->Close();
875  in1.reset(nullptr);
876 
877  for (size_t i = 1; i < files.size(); ++i) {
878  std::cout << "Working on file " << 1+i << "/" << nFiles << ": " << files[i] << std::endl;
879  std::unique_ptr<TFile> in(TFile::Open(files[i].c_str()));
880  if (!in) {
881  std::cout << "ERROR, could not open input file " << files[i] << std::endl;
882  return -1;
883  }
884  TDirectory* dir(dynamic_cast<TDirectory*>(in->GetDirectory(runDir.c_str())));
885  hc.addDirectory(dir, runDirFwd, files[i]);
886  in->Delete("");
887  in->Close();
888  }
889 
890  std::cout << "Accumulated a total of " << hc.size() << " histograms." << std::endl;
891 
892  std::cout << "Start writing output ..." << std::endl;
893  hc.write();
894 
895  if (m_doTiming) {
896  std::cout << "CPU time for histogram merging: (regular histograms)" << std::endl;
897  hc.printTiming();
898  }
899  const auto lbmap = hc.getFileLBMapAndClear();
900  if (!lbmap.empty()) {
901  std::cout << "Start merging lb_nnn and lowStat_LB directories (" << lbmap.size() << " in total)" << std::endl;
902  histCollection hclb(outfile.get());
903  hc.addDirExclusion(m_mergeMatchDirRE);
904  hc.addHistExclusion(m_mergeMatchHistoRE);
905 
906  for (const auto& [dir, filenames] : lbmap) {
907  std::cout << "Merging/copying directory " << dir << std::endl;
908  for (const std::string& fName : filenames) {
909  std::unique_ptr<TFile> in(TFile::Open(fName.c_str()));
910  if (!in) {
911  std::cout << "ERROR, could not open input file " << fName << std::endl;
912  return -1;
913  }
914  TDirectory* tDir = (dynamic_cast<TDirectory*>(in->Get(dir.c_str())));
915  if (!tDir) {
916  std::cout << "ERROR, failed to get directory " << dir << " from file " << fName << std::endl;
917  } else {
918  hclb.addDirectory(tDir, dir);
919  }
920  in->Delete("");
921  in->Close();
922  }
923  hclb.write();
924  if (m_doTiming) {
925  std::cout << "CPU time for histogram merging: (lumiblock-histograms)" << std::endl;
926  hclb.printTiming();
927  }
928  hclb.clear();
929  }
930  }
931  outfile->Close();
932  return 0;
933  }
934 
935  int MonitoringFile::mergeFiles(const std::string& outFileName, const std::string& listFileName) {
936  typedef std::vector<std::string> FileList_t;
937 
938  const unsigned int nFilesAtOnce = 50;
939 
940  FileList_t allFiles;
941  bool success = setListFromFile(allFiles, listFileName);
942  if (!success) {
943  std::cout << "ERROR Failed ot read list of input files" << std::endl;
944  return -1;
945  }
946 
947  if (allFiles.size() <= nFilesAtOnce) {
949  }
950 
951  FileList_t procFiles, tmpIntermediateFiles;
952 
953  FileList_t::const_iterator filesEnd = allFiles.end();
954  FileList_t::const_iterator fi = allFiles.begin();
955 
956  unsigned int counter = 0;
957  std::string tmpInputFile("");
958  std::string tmpOutputFile("");
959 
960  // new logic: merge intermediately, then merge intermediate files
961  while (fi != filesEnd) {
962 
963  procFiles.push_back(*fi);
964  ++counter;
965  ++fi;
966  if (counter % nFilesAtOnce == 0 || fi == filesEnd) {
967  std::ostringstream nameStream;
968  nameStream << "tmp_merge_" << counter << ".root";
969  tmpOutputFile = nameStream.str();
970  tmpIntermediateFiles.push_back(tmpOutputFile);
971  int stat=mergeFiles(tmpOutputFile, procFiles);
972  if (stat) return stat;
973  procFiles.clear();
974  }
975  }
976 
977  int stat=mergeFiles(outFileName, tmpIntermediateFiles);
978  if (stat) return stat;
979 
980  for (const auto& tmpFile : tmpIntermediateFiles) {
981  std::remove(tmpFile.c_str());
982  }
983  return 0;
984  }
985 
986  void MonitoringFile::printStatistics() {
987  if (m_file == 0) {
988  std::cerr << "MonitoringFile::printStatistics(): "
989  << "No input file is open\n";
990  return;
991  }
992 
993  DirMap_t indirmap;
994 
995  getAllDirs(indirmap, m_file, "");
996 
997  DirMap_t::const_iterator idirend = indirmap.end();
998  for (DirMap_t::const_iterator idir = indirmap.begin(); idir != idirend; ++idir) {
999  std::string idirName = idir->first;
1000 
1001  GatherStatistics stat_shift(idirName);
1002  GatherStatistics stat_all(idirName);
1003 
1004  loopOnHistogramsInMetadata(stat_shift, idir->second);
1005  loopOnHistograms(stat_all, idir->second);
1006 
1007  std::cout.setf(std::ios_base::left, std::ios_base::adjustfield);
1008  std::cout.width(80);
1009  std::cout << idirName << " ";
1010 
1011  std::cout.setf(std::ios_base::right, std::ios_base::adjustfield);
1012  std::cout << " shift: ";
1013  std::cout.width(3);
1014  std::cout << stat_shift.m_nHist1D << " ";
1015  std::cout.width(5);
1016  std::cout << stat_shift.m_nHist1DBins << " ";
1017  std::cout.width(3);
1018  std::cout << stat_shift.m_nHist2D << " ";
1019  std::cout.width(7);
1020  std::cout << stat_shift.m_nHist2DBins << " ";
1021  std::cout.width(3);
1022  std::cout << stat_shift.m_nGraph << " ";
1023  std::cout.width(5);
1024  std::cout << stat_shift.m_nGraphPoints << " ";
1025 
1026  std::cout << " all: ";
1027  std::cout << stat_all.m_nHist1D << " ";
1028  std::cout.width(5);
1029  std::cout << stat_all.m_nHist1DBins << " ";
1030  std::cout.width(3);
1031  std::cout << stat_all.m_nHist2D << " ";
1032  std::cout.width(7);
1033  std::cout << stat_all.m_nHist2DBins << " ";
1034  std::cout.width(3);
1035  std::cout << stat_all.m_nGraph << " ";
1036  std::cout.width(5);
1037  std::cout << stat_all.m_nGraphPoints << "\n";
1038 
1039  std::cout << std::flush;
1040  }
1041  }
1042 
1043  bool MonitoringFile::copyHistograms(const std::string& outFileName, const std::string& dirName) {
1045  // bool useRecursiveDelete = gROOT->MustClean();
1046  // gROOT->SetMustClean(false);
1047 
1048  if (m_file == 0) {
1049  std::cerr << "MonitoringFile::copyHistograms(): "
1050  << "No input file is open\n";
1051  return false;
1052  }
1053 
1054  DirMap_t indirmap;
1055  DirMap_t reducedmap;
1056  DirMap_t outdirmap;
1057 
1058  if (dirName != "all") {
1059  TKey* dkey = getObjKey(m_file, dirName);
1060  if (dkey == 0) {
1061  std::cerr << "MonitoringFile::copyHistograms(): "
1062  << "Directory \'" << dirName << "\' not found in input file\n";
1063  return false;
1064  }
1065 
1066  TDirectory* fromDir = dynamic_cast<TDirectory*>(dkey->ReadObj());
1067 
1068  DirMap_t::value_type dirmapVal(dirName, fromDir);
1069  indirmap.insert(dirmapVal);
1070  } else {
1071  std::cout << "Building list of all TDirectories in file...\n" << std::flush;
1072  getAllDirs(indirmap, m_file, "");
1073  }
1074 
1075  DirMap_t::const_iterator idirend = indirmap.end();
1076  for (DirMap_t::const_iterator idir = indirmap.begin(); idir != idirend; ++idir) {
1077 
1078  std::string idirName = idir->first;
1079  std::cout << "Checking " << idirName << "\n" << std::flush;
1080  // std::string::size_type j = idirName.find( "L1Calo/1_PPr_EmFADCTiming" );
1081  // if( j != std::string::npos ) {
1082  // std::cerr << "Skipping directory \"" << idirName << "\"\n";
1083  // std::cerr << std::flush;
1084  // continue;
1085  // }
1086 
1087  if (!dirHasHistogramsInMetadata(idir->second)) {
1088  continue;
1089  }
1090 
1091  reducedmap.insert(*idir);
1092  }
1093 
1094  std::unique_ptr<TFile> outfile(TFile::Open(outFileName.c_str(), "RECREATE", outFileName.c_str(), m_fileCompressionLevel));
1095  if (outfile.get() == 0) {
1096  std::cerr << "MonitoringFile::copyHistograms(): "
1097  << "Output file not opened\n";
1098  return false;
1099  }
1100 
1101  idirend = reducedmap.end();
1102  for (DirMap_t::const_iterator idir = reducedmap.begin(); idir != idirend; ++idir) {
1103 
1104  std::string idirName = idir->first;
1105  std::cout << "Processing " << idirName << "\n" << std::flush;
1106 
1107  TDirectory* toDir = createDir(outdirmap, outfile.get(), "", idirName);
1108  if (toDir == 0) {
1109  std::cerr << "MonitoringFile::copyHistograms(): "
1110  << "Directory \'" << idirName << "\' not created in output file\n";
1111  return false;
1112  }
1113 
1114  CopyHistogram copyFcn(toDir, idirName);
1115 
1116  loopOnHistogramsInMetadata(copyFcn, idir->second);
1117  }
1118 
1119  outfile->Write();
1120  outfile->Close();
1121 
1122  // gROOT->SetMustClean(useRecursiveDelete);
1123  return true;
1124  }
1125 
1126  std::string MonitoringFile::getHanResults(const std::string& hanResultsDir, const std::string& input, const std::string& hcfg,
1127  const std::string& hcfg_lowStat, const std::string& hcfg_medStat) {
1128  // DisableMustClean disabled;
1129 
1130  std::cout << "\nUsing han configurations:\n"
1131  << " entire run: " << hcfg << "\n"
1132  << " low stat interval: " << hcfg_lowStat << "\n"
1133  << " medium stat interval: " << hcfg_medStat << "\n\n"
1134  << std::flush;
1135 
1136  TFile* infile = TFile::Open(input.c_str());
1137  if (infile == 0) {
1138  std::cerr << "MonitoringFile::getHanResults(): "
1139  << "Cannot open input file \"" << input << "\"\n";
1140  return "";
1141  }
1142 
1143  std::vector<std::string> run_dirs;
1144  std::vector<std::string> lowStat_dirs;
1145  std::vector<std::string> medStat_dirs;
1146 
1147  TIter next_run(infile->GetListOfKeys());
1148  TKey* key_run(0);
1149  while ((key_run = dynamic_cast<TKey*>(next_run())) != 0) {
1150  TObject* obj_run = key_run->ReadObj();
1151  TDirectory* tdir_run = dynamic_cast<TDirectory*>(obj_run);
1152  if (tdir_run != 0) {
1153  std::string tdir_run_name(tdir_run->GetName());
1154  if (tdir_run_name.find("run") != std::string::npos) {
1155  run_dirs.push_back(tdir_run_name);
1156  TIter next_minutes(tdir_run->GetListOfKeys());
1157  TKey* key_minutes(0);
1158  while ((key_minutes = dynamic_cast<TKey*>(next_minutes())) != 0) {
1159  TObject* obj_minutes = key_minutes->ReadObj();
1160  TDirectory* tdir_minutes = dynamic_cast<TDirectory*>(obj_minutes);
1161  if (tdir_minutes != 0) {
1162  std::string tdir_minutes_name(tdir_minutes->GetName());
1163  if (tdir_minutes_name.find("lowStat") != std::string::npos) {
1164  lowStat_dirs.push_back(tdir_run_name + '/' + tdir_minutes_name);
1165  } else if (tdir_minutes_name.find("medStat") != std::string::npos) {
1166  medStat_dirs.push_back(tdir_run_name + '/' + tdir_minutes_name);
1167  }
1168  }
1169  delete obj_minutes;
1170  }
1171  }
1172  }
1173  delete obj_run;
1174  }
1175 
1176  delete infile;
1177 
1178  dqi::HanApp han;
1179 
1180  std::string fileList = " ";
1181  std::vector<std::string>::const_iterator dirs_end;
1182  std::vector<std::string>::const_iterator dir;
1183 
1184  dirs_end = run_dirs.end();
1185  for (dir = run_dirs.begin(); dir != dirs_end; ++dir) {
1186  const std::string& tdir_run_name = *dir;
1187  std::string han_output_run = hanResultsDir + '/' + tdir_run_name + "_han.root";
1188  std::cout << "Calling han( " << hcfg << ", " << input << ", " << tdir_run_name << ", " << han_output_run << " ):\n" << std::flush;
1189  han.Analyze(hcfg, input, han_output_run, tdir_run_name);
1190  std::cout << "\n";
1191  fileList += han_output_run + " " + tdir_run_name + "\n";
1192  }
1193 
1194  dirs_end = lowStat_dirs.end();
1195  for (dir = lowStat_dirs.begin(); dir != dirs_end; ++dir) {
1196  const std::string& tdir_minutes_path = *dir;
1197 
1198  std::string tdir_minutes_underscore = tdir_minutes_path;
1199  std::string::size_type tdir_minutes_i = tdir_minutes_underscore.find('/');
1200  tdir_minutes_underscore.replace(tdir_minutes_i, 1, "_");
1201 
1202  std::string han_output_lowStat = hanResultsDir + '/' + tdir_minutes_underscore + "_han.root";
1203  std::cout << "Running han, writing to " << han_output_lowStat << ":\n" << std::flush;
1204  han.Analyze(hcfg_lowStat, input, han_output_lowStat, tdir_minutes_path);
1205  std::cout << "\n";
1206  std::string subdirname(tdir_minutes_path, tdir_minutes_i + 1, std::string::npos);
1207  std::string dirname(tdir_minutes_path, 0, tdir_minutes_i);
1208  fileList += han_output_lowStat + " " + subdirname + " " + dirname + " " + subdirname + "\n";
1209  }
1210 
1211  dirs_end = medStat_dirs.end();
1212  for (dir = medStat_dirs.begin(); dir != dirs_end; ++dir) {
1213  const std::string& tdir_minutes_path = *dir;
1214 
1215  std::string tdir_minutes_underscore = tdir_minutes_path;
1216  std::string::size_type tdir_minutes_i = tdir_minutes_underscore.find('/');
1217  tdir_minutes_underscore.replace(tdir_minutes_i, 1, "_");
1218 
1219  std::string han_output_medStat = hanResultsDir + '/' + tdir_minutes_underscore + "_han.root";
1220  std::cout << "Running han, writing to " << han_output_medStat << ":\n" << std::flush;
1221  han.Analyze(hcfg_medStat, input, han_output_medStat, tdir_minutes_path);
1222  std::cout << "\n";
1223  std::string subdirname(tdir_minutes_path, tdir_minutes_i + 1, std::string::npos);
1224  std::string dirname(tdir_minutes_path, 0, tdir_minutes_i);
1225  fileList += han_output_medStat + " " + subdirname + " " + dirname + " " + subdirname + "\n";
1226  }
1227 
1228  return fileList;
1229  }
1230 
1231  void MonitoringFile::printHanConfig() {
1232  if (m_file == 0) {
1233  std::cerr << "MonitoringFile::printHanConfig(): "
1234  << "No input file is open\n";
1235  return;
1236  }
1237 
1238  DirMap_t indirmap;
1239 
1240  getAllDirs(indirmap, m_file, "");
1241 
1242  std::string indent, indent_p, indent_c;
1243  std::string idirName_p;
1244  DirMap_t::const_iterator idirend = indirmap.end();
1245  for (DirMap_t::const_iterator idir = indirmap.begin(); idir != idirend; ++idir) {
1246  std::string idirName = idir->first;
1247  std::string::size_type shortNameIndex = idirName.rfind('/');
1248  std::string shortName = idirName.substr(shortNameIndex + 1, std::string::npos);
1249 
1250  std::string::size_type fsIndex = idirName.find('/');
1251  std::string shortPath;
1252  if (fsIndex != shortNameIndex)
1253  shortPath = idirName.substr(fsIndex + 1, shortNameIndex);
1254  else
1255  shortPath = idirName.substr(fsIndex + 1, std::string::npos);
1256 
1257  std::cout << idirName << "\n";
1258  std::cout << shortPath << ", " << shortName << "\n";
1259  /*
1260  indent = getIndentation(idirName,"");
1261  if(int(indent.size())==in_p){
1262  std::cout << indent << "} \n";
1263  std::cout << indent << "dir " << shortName << " { \n";
1264  std::cout << indent << " output " << idirName << "\n";
1265  std::cout << indent << " hist all_in_dir { \n " << indent << " } \n";
1266  }
1267  else if (int(indent.size()) > in_p){
1268  std::cout << indent << "dir " << shortName << " { \n";
1269  std::cout << indent << " output " << idirName << "\n";
1270  std::cout << indent << " hist all_in_dir { \n " << indent << " } \n";
1271  }
1272  else{
1273  //find common part + number of common '/'
1274  std::string common = FindCommon(idirName,idirName_p);
1275  indent_c = getIndentation(common,"");
1276  int counter = (indent_p.size() - indent_c.size())/2;
1277  for (int i = counter; i>0; i--){
1278  std::string temp = indent_c;
1279  for (int j = 0; j< i; j++){
1280  temp+=" ";
1281  }
1282  std::cout << temp << "} \n" ;
1283  }
1284  std::cout << indent << "} \n";
1285  std::cout << indent << "dir " << shortName << " { \n";
1286  std::cout << indent << " output " << idirName << "\n";
1287  std::cout << indent << " hist all_in_dir { \n " << indent << " } \n";
1288  }
1289  indent_p = indent;
1290  in_p = indent_p.size();
1291  idirName_p = idirName;
1292  */
1293  }
1294  }
1295 
1296  std::string MonitoringFile::getIndentation(const std::string& pathName, const std::string& leadingSpace) {
1297  std::string space = leadingSpace;
1298  std::string::size_type i = pathName.find_first_of('/');
1299  if (i != std::string::npos) {
1300  std::string subPath(pathName, i + 1, std::string::npos);
1301  space += " ";
1302  return getIndentation(subPath, space);
1303  }
1304  return space;
1305  }
1306 
1307  std::string MonitoringFile::FindCommon(const std::string& name1, const std::string& name2) const {
1308  int length = (name1.size() < name2.size()) ? name1.size() : name2.size();
1309  bool found = true;
1310  int count = 0;
1311  while (found == true && count < length) {
1312  if (name1[count] == name2[count]) {
1313  count++;
1314  } else {
1315  found = false;
1316  }
1317  }
1318  return (name1.substr(0, count));
1319  }
1320 
1321  // *********************************************************************
1322  // Protected Methods
1323  // *********************************************************************
1324 
1325  MonitoringFile::CopyHistogram::CopyHistogram(TDirectory * target, const std::string& dirName) : m_target(target), m_dirName(dirName), m_metadata(0) {
1326  m_metadata = new TTree("metadata", "Monitoring Metadata");
1327  m_metadata->SetDirectory(0);
1328  m_metadata->Branch("Name", (void*)nullptr, "Name/C");
1329  m_metadata->Branch("Interval", (void*)nullptr, "Interval/C");
1330  m_metadata->Branch("TriggerChain", (void*)nullptr, "TriggerChain/C");
1331  m_metadata->Branch("MergeMethod", (void*)nullptr, "MergeMethod/C");
1332  }
1333 
1334  MonitoringFile::CopyHistogram::~CopyHistogram() {
1335  m_target->cd();
1336  m_metadata->SetDirectory(m_target);
1337  m_metadata->Write();
1338  delete m_metadata;
1339  }
1340 
1342  m_target->cd();
1343  hist->SetDirectory(m_target);
1344  hist->Write();
1345 
1346  return true;
1347  }
1348 
1349  bool MonitoringFile::CopyHistogram::execute(TGraph * graph) {
1350  m_target->cd();
1351  graph->Write();
1352 
1353  return true;
1354  }
1355 
1356  bool MonitoringFile::CopyHistogram::execute(TEfficiency * eff) {
1357  m_target->cd();
1358  eff->Write();
1359  return true;
1360  }
1361 
1362  void MonitoringFile::CopyHistogram::fillMD(const MetaData& md) {
1363  std::string name(md.name);
1364  std::string interval(md.interval);
1365  std::string chain(md.chain);
1366  std::string merge(md.merge);
1367  m_metadata->SetBranchAddress("Name", name.data());
1368  m_metadata->SetBranchAddress("Interval", interval.data());
1369  m_metadata->SetBranchAddress("TriggerChain", chain.data());
1370  m_metadata->SetBranchAddress("MergeMethod", merge.data());
1371  m_metadata->Fill();
1372  }
1373 
1374  bool MonitoringFile::CopyHistogram::executeMD(TH1 * hist, const MetaData& md) {
1375  m_target->cd();
1376  hist->SetDirectory(m_target);
1377  hist->Write();
1378 
1379  fillMD(md);
1380 
1381  return true;
1382  }
1383 
1384  bool MonitoringFile::CopyHistogram::executeMD(TGraph * graph, const MetaData& md) {
1385  m_target->cd();
1386  graph->Write();
1387 
1388  fillMD(md);
1389 
1390  return true;
1391  }
1392 
1393  bool MonitoringFile::CopyHistogram::executeMD(TEfficiency * eff, const MetaData& md) {
1394  m_target->cd();
1395  eff->Write();
1396  fillMD(md);
1397  return true;
1398  }
1399 
1400  MonitoringFile::GatherStatistics::GatherStatistics(const std::string& dirName)
1401  : m_dirName(dirName), m_nHist1D(0), m_nHist1DBins(0), m_nGraph(0), m_nGraphPoints(0), m_nHist2D(0), m_nHist2DBins(0) {}
1402 
1404  TH2* hist2d = dynamic_cast<TH2*>(hist);
1405  if (hist2d != 0) {
1406  ++m_nHist2D;
1407  m_nHist2DBins += (hist2d->GetNbinsX() * hist2d->GetNbinsY());
1408  return true;
1409  }
1410  ++m_nHist1D;
1411  m_nHist1DBins += hist->GetNbinsX();
1412  return true;
1413  }
1414 
1415  bool MonitoringFile::GatherStatistics::execute(TGraph * graph) {
1416  ++m_nGraph;
1417  m_nGraphPoints += graph->GetMaxSize();
1418  return true;
1419  }
1420 
1421  bool MonitoringFile::GatherStatistics::execute(TEfficiency * eff) {
1422  ++m_nEfficiency;
1423 
1424  TH1* h_total = eff->GetCopyPassedHisto();
1425  TH2* h_total2D = dynamic_cast<TH2*>(h_total);
1426 
1427  if (h_total2D != 0) {
1428  m_nEfficiencyBins += (h_total2D->GetNbinsX() * h_total2D->GetNbinsY());
1429  return true;
1430  } else {
1431  m_nEfficiencyBins += h_total->GetNbinsX();
1432  return true;
1433  }
1434  }
1435 
1436  MonitoringFile::GatherNames::GatherNames() {}
1437 
1439  m_names.push_back(std::string(hist->GetName()));
1440  return true;
1441  }
1442 
1443  bool MonitoringFile::GatherNames::execute(TGraph * graph) {
1444  m_names.push_back(std::string(graph->GetName()));
1445  return true;
1446  }
1447 
1448  bool MonitoringFile::GatherNames::execute(TEfficiency * eff) {
1449  m_names.push_back(std::string(eff->GetName()));
1450  return true;
1451  }
1452 
1453  void MonitoringFile::clearData() {
1455 
1456  delete m_file;
1457  m_file = 0;
1458  m_fileCompressionLevel = 1;
1459  m_doTiming = false;
1460  }
1461 
1462  bool MonitoringFile::dirHasHistogramsInMetadata(TDirectory * dir) {
1463  dir->cd();
1464 
1465  TKey* mdKey = dir->FindKey("metadata");
1466  if (mdKey == 0) {
1467  return false;
1468  }
1469 
1470  TTree* md = dynamic_cast<TTree*>(mdKey->ReadObj());
1471  if (md == 0) {
1472  return false;
1473  }
1474 
1475  int counter = 0;
1476  int nEntries = int(md->GetEntries());
1477 
1478  while (counter < nEntries) {
1479  try {
1480  md->GetEntry(counter);
1481  } catch (const std::exception& e) {
1482  std::cerr << "Exception: \"" << e.what() << "\" in directory \"" << dir->GetName() << "\"\n" << std::flush;
1483  return false;
1484  }
1485 
1486  return true;
1487  ++counter;
1488  }
1489 
1490  return false;
1491  }
1492 
1493  void MonitoringFile::loopOnHistograms(HistogramOperation & fcn, TDirectory * dir) {
1494  TIter next(dir->GetListOfKeys());
1495  TKey* key;
1496  while ((key = dynamic_cast<TKey*>(next())) != 0) {
1497  TObject* obj = key->ReadObj();
1498  TH1* h(0);
1499  TGraph* g(0);
1500  TEfficiency* e(0);
1501  if ((h = dynamic_cast<TH1*>(obj))) {
1502  fcn.execute(h);
1503  } else if ((g = dynamic_cast<TGraph*>(obj))) {
1504  fcn.execute(g);
1505  } else if ((e = dynamic_cast<TEfficiency*>(obj))) {
1506  fcn.execute(e);
1507  }
1508  delete obj;
1509  }
1510  }
1511 
1512  bool MonitoringFile::loopOnHistogramsInMetadata(HistogramOperation & fcn, TDirectory * dir) {
1513  dir->cd();
1514  TKey* mdKey = dir->FindKey("metadata");
1515  if (mdKey == 0) {
1516  return false;
1517  }
1518 
1519  TTree* md = dynamic_cast<TTree*>(mdKey->ReadObj());
1520  if (md == 0) {
1521  return false;
1522  }
1523 
1524  TKey* i_key;
1525 
1526  TTreeReader reader(md);
1527  TTreeReaderArray<char> i_name(reader, "Name");
1528  TTreeReaderArray<char> i_interval(reader, "Interval");
1529  TTreeReaderArray<char> i_chain(reader, "TriggerChain");
1530  TTreeReaderArray<char> i_merge(reader, "MergeMethod");
1531 
1532  while (reader.Next()) {
1533  const std::string nameStr(static_cast<char*>(i_name.GetAddress()));
1534  dir->cd();
1535  i_key = dir->FindKey(static_cast<char*>(i_name.GetAddress()));
1536  if (i_key == 0) {
1537  std::cerr << "MonitoringFile::loopOnHistogramsInMetadata(): "
1538  << "No \'" << nameStr << "\' object found\n";
1539  return false;
1540  }
1541  MetaData md(nameStr, static_cast<char*>(i_interval.GetAddress()), static_cast<char*>(i_chain.GetAddress()), static_cast<char*>(i_merge.GetAddress()));
1542  TObject* obj = i_key->ReadObj();
1543  TH1* h = dynamic_cast<TH1*>(obj);
1544  if (h != 0) {
1545  fcn.executeMD(h, md);
1546  } else {
1547  TGraph* g = dynamic_cast<TGraph*>(obj);
1548  if (g != 0) {
1549  fcn.executeMD(g, md);
1550  }
1551  }
1552  delete obj;
1553  }
1554 
1555  delete md;
1556 
1557  return true;
1558  }
1559 
1560  bool MonitoringFile::setListFromFile(std::vector<std::string> & filelist, const std::string& listFileName) {
1561  using namespace std;
1562 
1563  filelist.clear();
1564 
1565  ifstream listfile(listFileName.c_str());
1566  if (!listfile) {
1567  cerr << "MonitoringFile::setListFromFile(): "
1568  << "cannot read from file: " << listFileName << "\n";
1569  return false;
1570  }
1571 
1572  string line;
1573  char c;
1574  string filename;
1575  while (getline(listfile, line)) {
1576  istringstream linestream(line);
1577  while (linestream.get(c)) {
1578  if (!isspace(c)) {
1579  // ignore comments
1580  if (c == '#') {
1581  break;
1582  }
1583 
1584  linestream.putback(c);
1585  linestream >> filename;
1586  if (!linestream) {
1587  cerr << "MonitoringFile::setListFromFile(): "
1588  << "badly formatted line: " << line << "\n";
1589  break;
1590  }
1591 
1592  filelist.push_back(filename);
1593  }
1594  }
1595  }
1596 
1597  return true;
1598  }
1599 
1600  int MonitoringFile::mergeLBintervals(const std::string& inFilename) {
1601 
1602  std::cout << "Running mergeLBintervals on " << inFilename << std::endl;
1603 
1604  std::unique_ptr<TFile> f(TFile::Open(inFilename.c_str(), "UPDATE"));
1605  if (!f) {
1606  std::cout << "ERROR, could not open file " << inFilename << " for update" << std::endl;
1607  return -1;
1608  }
1609  std::string runDirName;
1610  const std::regex runDirPattern("run_[0-9]*");
1611  TIter next(f->GetListOfKeys());
1612  TKey* key;
1613  while ((key = (TKey*)next())) {
1614  const char* name = key->GetName();
1615  if (std::regex_match(name, runDirPattern)) {
1616  if (runDirName.size() > 0) {
1617  std::cout << "ERROR More than one run_XXX directory found! Ignoring " << name << std::endl;
1618  } else
1619  runDirName = name;
1620  }
1621  break;
1622  }
1623 
1624  TDirectory* runDir = f->GetDirectory(runDirName.c_str());
1625  const auto mapping = buildLBToIntervalMap(runDir);
1626 
1627  if (s_dbg.getLvl() == VERBOSE) {
1628  std::cout << "LB directory mapping:" << std::endl;
1629  for (const auto& i1 : mapping) {
1630  std::cout << i1.first;
1631  for (const auto& i2 : i1.second) {
1632  std::cout << "\t" << i2 << std::endl;
1633  }
1634  }
1635  }
1636 
1637  for (const auto& [outDir, inDIrs] : mapping) {
1638  int stat=mergeLB_processLBinterval(f.get(), inDIrs, outDir);
1639  if (stat) return stat;
1640  }
1641 
1642  f->Close();
1643  f.reset(TFile::Open(inFilename.c_str(), "UPDATE"));
1644  runDir = f->GetDirectory(runDirName.c_str());
1645 
1646  std::cout << "merging lowStat_LB dirs into run-dir" << std::endl;
1647  std::vector<std::string> lowStatDirs;
1648  for (TObject* oKey : *runDir->GetListOfKeys()) {
1649  TKey* key = static_cast<TKey*>(oKey);
1650  const std::string name = key->GetName();
1651  const std::string classname = key->GetClassName();
1652  if (classname.starts_with("TDirectory") and name.starts_with("lowStat_LB")) {
1653  lowStatDirs.push_back(runDirName + "/" + name);
1654  s_dbg(VERBOSE, "Found input: " + runDirName + "/" + name);
1655  }
1656  }
1657 
1658  int stat=mergeLB_processLBinterval(f.get(), lowStatDirs, runDirName);
1659 
1660  f->Close();
1661  return stat;
1662  }
1663 
1664  std::map<std::string, std::vector<std::string>> MonitoringFile::buildLBToIntervalMap(TDirectory * runDir) {
1665 
1666  std::map<std::string, std::vector<std::string>> ranges;
1667 
1668  // No recusion here, everything we care out is run_NNNNN/lb_nnnn (and run_NNNNN/lowStat_nn-mm)
1669  const std::string runDirName = runDir->GetName();
1670  for (TObject* oKey : *runDir->GetListOfKeys()) {
1671  TKey* key = static_cast<TKey*>(oKey);
1672  const std::string name = key->GetName();
1673  const std::string classname = key->GetClassName();
1674  if (!classname.starts_with("TDirectory"))
1675  continue;
1676  if (name.starts_with("lb_")) {
1677  unsigned lumiBlock = 0;
1678  try {
1679  lumiBlock = std::stol(name.substr(3));
1680  } catch (std::invalid_argument& e) {
1681  std::cout << "ERROR, unexpected directory name " << name << ". Can't parse lb number" << std::endl;
1682  std::cout << e.what() << std::endl;
1683  continue;
1684  }
1685  // Copied from Control/AthenaMonitoringKernel/src/HistogramFiller/OfflineHistogramProvider.h
1686  const unsigned lbBase = lumiBlock - (((int64_t)lumiBlock - 1) % 20);
1687  const std::string lbString = runDirName + "/lowStat_LB" + std::to_string(lbBase) + "-" + std::to_string(lbBase + 19);
1688  ranges[lbString].push_back(runDirName + "/" + name);
1689  } // end if lb_NNNN dir
1690  } // end loop over directories under run_NNNNN
1691  return ranges;
1692  }
1693 
1694  int MonitoringFile::mergeLB_processLBinterval(TFile * file, const std::vector<std::string>& inputDirNames, const std::string& outputDirName) {
1695 
1696  TDirectory* outDir = file->GetDirectory(outputDirName.c_str());
1697  if (!outDir) {
1698  outDir = file->mkdir(outputDirName.c_str());
1699  }
1700  if (!outDir) {
1701  std::cout << "ERROR, can't obtain nor create directory " << outputDirName << " in file " << file->GetName() << std::endl;
1702  return -1;
1703  }
1704 
1705  histCollection hc(file, true);
1706  hc.addDirExclusion(m_mergeMatchDirRE);
1707  hc.addHistExclusion(m_mergeMatchHistoRE);
1708 
1709  for (const std::string& inDirName : inputDirNames) {
1710  TDirectory* inDir = file->GetDirectory(inDirName.c_str());
1711  hc.addDirectory(inDir, outputDirName);
1712  }
1713  if (hc.size() == 0) {
1714  std::cout << "mergeLB_processLBinterval: No new objects found for " << outputDirName << std::endl;
1715  } else {
1716  hc.write();
1717  }
1718  return 0;
1719  }
1720 
1721  bool MonitoringFile::CheckHistogram(TFile * f, const char* HistoName) {
1722  std::unique_ptr<TObject> obj(f->Get(HistoName));
1723  if (!obj.get()) {
1724  // std::cerr<<"No such histogram \""<< HistoName << "\"\n";
1725  return false;
1726  } else
1727  return true;
1728  }
1729 
1730  int MonitoringFile::getDebugLevel() {
1731  return s_dbg.getLvl();
1732  }
1733  void MonitoringFile::setDebugLevel(int level) {
1734  s_dbg.setLvl((debugLevel_t)(level));
1735  }
1736  void MonitoringFile::doTiming() {
1737  m_doTiming = true;
1738  }
1739 
1740 
1741  void MonitoringFile::setCheckEquality(bool value) {dqutils::s_checkEquality=value;}
1742  std::atomic<int> MonitoringFile::m_fileCompressionLevel = 1;
1743  bool MonitoringFile::m_doTiming = false;
1744  std::unordered_map<std::string, std::clock_t> MonitoringFile::m_cpuPerHistogram;
1745 
1746  std::string MonitoringFile::getPath(TDirectory * dir) {
1747 
1748  std::string path = dir->GetPath();
1749  if (path.find(':') != std::string::npos)
1750  path = path.substr(path.rfind(':') + 1);
1751 
1752  return path;
1753  }
1754 
1755 } // namespace dqutils

Variable Documentation

◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY

ATLAS_NO_CHECK_FILE_THREAD_SAFETY

Definition at line 39 of file MonitoringFile.cxx.

dqutils::debugLevel_t
debugLevel_t
Definition: MonitoringFile.h:55
histCollection
Definition: LArQuickHistMerge.cxx:50
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
trigbs_pickEvents.ranges
ranges
Definition: trigbs_pickEvents.py:60
fitman.nWritten
int nWritten
Definition: fitman.py:420
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ReadCellNoiseFromCool.name1
name1
Definition: ReadCellNoiseFromCool.py:233
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
run.infile
string infile
Definition: run.py:13
vtune_athena.format
format
Definition: vtune_athena.py:14
FullCPAlgorithmsTest_eljob.flush
flush
Definition: FullCPAlgorithmsTest_eljob.py:194
collListGuids.line
string line
Definition: collListGuids.py:77
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
rootconvert.fName
string fName
Definition: rootconvert.py:5
histCollection::print
void print()
Definition: LArQuickHistMerge.cxx:112
lumiFormat.inPath
string inPath
Definition: lumiFormat.py:68
plotmaker.hist
hist
Definition: plotmaker.py:148
histCollection::histDir_t::histos
std::vector< histPerDir_t > histos
Definition: LArQuickHistMerge.cxx:73
histCollection::write
void write(TFile *out)
Definition: LArQuickHistMerge.cxx:376
skel.it
it
Definition: skel.GENtoEVGEN.py:407
dqutils::MonitoringFile::merge_lowerLB
static void merge_lowerLB(TH1 &a, const TH1 &b)
Definition: MonitoringFile_MergeAlgs.cxx:673
dirname
std::string dirname(std::string name)
Definition: utils.cxx:200
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dqutils::MonitoringFile::merge_Rebinned
static void merge_Rebinned(TH1 &a, TH1 &b)
Definition: MonitoringFile_MergeAlgs.cxx:499
CscCalibQuery.fileList
fileList
Definition: CscCalibQuery.py:330
athena.value
value
Definition: athena.py:124
dqutils::none
@ none
Definition: MonitoringFile.h:55
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
PrintTrkAnaSummary.dirName
dirName
Definition: PrintTrkAnaSummary.py:126
BchCleanup.identical
identical
Definition: BchCleanup.py:304
python.base_data.hcfg
hcfg
Definition: base_data.py:22
defaultMerge
void defaultMerge(TObject *a, const TObject *b)
Definition: LArQuickHistMerge.cxx:134
histCollection::size
size_t size()
Definition: LArQuickHistMerge.cxx:56
histCollection::histCollection
histCollection(bool debug=false)
Definition: LArQuickHistMerge.cxx:54
dqi::DisableMustClean
Definition: HanUtils.h:30
find_tgc_unfilled_channelids.mapping
mapping
Definition: find_tgc_unfilled_channelids.py:17
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
m_file
std::unique_ptr< TFile > m_file
description: this is a custom writer for the old-school drivers that don't use an actual writer
Definition: OutputStreamData.cxx:52
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
python.checkMetadata.metadata
metadata
Definition: checkMetadata.py:175
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
covarianceTool.pathName
pathName
Definition: covarianceTool.py:704
PixelAthClusterMonAlgCfg.histname
histname
Definition: PixelAthClusterMonAlgCfg.py:106
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:37
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:85
DQHistogramMerge.doTiming
bool doTiming
Definition: DQHistogramMerge.py:53
h
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
DetDescrDictionaryDict::it1
std::vector< HWIdentifier >::iterator it1
Definition: DetDescrDictionaryDict.h:17
extractSporadic.h
list h
Definition: extractSporadic.py:97
histCollection::histPerDir_t::obj
TObject * obj
Definition: LArQuickHistMerge.cxx:68
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
getLatestRuns.interval
interval
Definition: getLatestRuns.py:24
generateReferenceFile.files
files
Definition: generateReferenceFile.py:12
calibdata.exception
exception
Definition: calibdata.py:496
file
TFile * file
Definition: tile_monitor.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
histCollection::m_data
std::map< std::string, histDir_t > m_data
Definition: LArQuickHistMerge.cxx:81
hist_file_dump.f
f
Definition: hist_file_dump.py:141
SCT_Monitoring::disabled
@ disabled
Definition: SCT_MonitoringNumbers.h:60
hotSpotInTAG.lowerLB
int lowerLB
Definition: hotSpotInTAG.py:175
index.currentDir
currentDir
Definition: index.py:37
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
skel.allFiles
list allFiles
Definition: skel.GENtoEVGEN.py:763
beamspotman.stat
stat
Definition: beamspotman.py:266
beamspotman.dir
string dir
Definition: beamspotman.py:623
SH::mergeFiles
std::unique_ptr< SampleLocal > mergeFiles(const Sample &sample, const std::string &location, bool overwrite)
merge all the files in the sample into a single file in the given location
Definition: ToolsOther.cxx:73
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
dqutils::MonitoringFile::merge_RMS
static void merge_RMS(TH1 &a, const TH1 &b)
Definition: MonitoringFile_MergeAlgs.cxx:556
dqutils::MonitoringFile::merge_weightedAverage
static void merge_weightedAverage(TH1 &a, const TH1 &b)
Definition: MonitoringFile_MergeAlgs.cxx:301
python.DQWebDisplayMod.getHanResults
def getHanResults(inputFilePath, *args)
Definition: DQWebDisplayMod.py:477
han
Definition: han.py:1
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
MakeNewFileFromOldAndSubstitution.newName
dictionary newName
Definition: ICHEP2016/MakeNewFileFromOldAndSubstitution.py:95
dumpNswErrorDb.outFileName
string outFileName
Definition: dumpNswErrorDb.py:131
checkTriggerxAOD.found
found
Definition: checkTriggerxAOD.py:328
dqi::HanApp
Definition: HanApp.h:21
columnar::operator()
decltype(auto) operator()(ObjectId< OT, CM > id) const noexcept
Definition: ColumnAccessor.h:175
grepfile.filenames
list filenames
Definition: grepfile.py:34
lumiFormat.outPath
string outPath
Definition: lumiFormat.py:64
a
TList * a
Definition: liststreamerinfos.cxx:10
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
copySelective.target
string target
Definition: copySelective.py:37
dqutils::MonitoringFile::merge_identical
static void merge_identical(TH1 &a, const TH1 &b)
Definition: MonitoringFile_MergeAlgs.cxx:722
python.envutil.filelist
filelist
print ("Checking files %s..." % fullfile)
Definition: envutil.py:133
re
const boost::regex re(r_e)
DEBUG
#define DEBUG
Definition: page_access.h:11
python.utility.LHE.merge
def merge(input_file_pattern, output_file)
Merge many input LHE files into a single output file.
Definition: LHE.py:29
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
python.base_data.hanResultsDir
hanResultsDir
Definition: base_data.py:32
DiTauMassTools::MMCFitMethod::shortName
const std::string shortName[MAX]
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:48
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
checkCorrelInHIST.histos
dictionary histos
Definition: checkCorrelInHIST.py:413
dqutils::MonitoringFile::merge_perBinEffPerCent
static void merge_perBinEffPerCent(TH1 &a, const TH1 &b)
Definition: MonitoringFile_MergeAlgs.cxx:133
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
jobOptions.fileName
fileName
Definition: jobOptions.SuperChic_ALP2.py:39
python.envutil.fulldir
fulldir
Definition: envutil.py:153
collisions.reader
reader
read the goodrunslist xml file(s)
Definition: collisions.py:22
python.LumiCalcRecover.subdir
subdir
Definition: LumiCalcRecover.py:25
histCollection::histPerDir_t::name
std::string name
Definition: LArQuickHistMerge.cxx:67
test_pyathena.counter
counter
Definition: test_pyathena.py:15
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
dqBeamSpot.nEntries
int nEntries
Definition: dqBeamSpot.py:73
python.PyAthena.obj
obj
Definition: PyAthena.py:132
dqutils::MonitoringFile::merge_weightedEff
static void merge_weightedEff(TH1 &a, const TH1 &b)
Definition: MonitoringFile_MergeAlgs.cxx:419
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
python.compressB64.c
def c
Definition: compressB64.py:93
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
hist_file_dump.ordering
ordering
Definition: hist_file_dump.py:86
dqutils::MonitoringFile::merge_RMSpercentDeviation
static void merge_RMSpercentDeviation(TH1 &a, const TH1 &b)
Definition: MonitoringFile_MergeAlgs.cxx:613
histCollection::addDirectory
void addDirectory(TDirectory *dir, const std::string &dirName)
Definition: LArQuickHistMerge.cxx:296
histCollection::histPerDir_t::histPerDir_t
histPerDir_t(const std::string &nameIn, TObject *objIn, TTree *md, bool dbg=false)
Definition: LArQuickHistMerge.cxx:226
merge
Definition: merge.py:1
histCollection::histPerDir_t::mergeMethod
void(* mergeMethod)(TObject *a, const TObject *b)
Definition: LArQuickHistMerge.cxx:69
dqutils::MonitoringFile::merge_eventSample
static void merge_eventSample(TH2 &a, const TH2 &b)
Definition: MonitoringFile_MergeAlgs.cxx:520
CscCalibQuery.nFiles
int nFiles
Definition: CscCalibQuery.py:332
dqi::getObjKey
TKey * getObjKey(TDirectory *dir, const std::string &path)
Definition: HanUtils.cxx:36
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37