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