ATLAS Offline Software
MuonTriggerSFConfGenerator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 // Script for generating configuration files for MuonTriggerSFFilesTest script. Configuration files are generated so that they correspond to given scale factors file.
6 
7 #include <string>
8 #include <map>
9 #include <fstream>
10 #include <set>
11 
12 #include <TFile.h>
13 #include <TError.h>
14 #include <TH2.h>
15 #include <TKey.h>
16 
17 int main(int argc, char* argv[]) {
18 
19  const char* APP_NAME = argv[0];
20 
21  if (argc < 3) {
22  Error(APP_NAME, "No scale factors or configuration file name received!");
23  Error(APP_NAME, " Usage: %s [configuration file name] [scale factors file name]", APP_NAME);
24  return 1;
25  }
26 
27  std::ofstream confFileStream(argv[1], std::ofstream::out);
28 
29  TFile* file = TFile::Open(argv[2]);
30  if (!file) {
31  Error(APP_NAME, " Unable to load scale factors file");
32  return 1;
33  }
34 
35  std::string quality = "Medium"; // HighPt, Tight, Loose, LowPt may also be used here
36  TDirectory* qualityDirectory = file->GetDirectory(quality.c_str());
37  if (!qualityDirectory) {
38  Error("MuonTriggerSFConfGenerator", " Directory for quality %s is missing", quality.c_str());
39  return 1;
40  }
41  TKey* periodKey;
42  TIter nextPeriod(qualityDirectory->GetListOfKeys());
43  while ((periodKey = (TKey*)nextPeriod())) {
44  std::string period = periodKey->GetName();
45  TDirectory* periodDirectory = qualityDirectory->GetDirectory(period.c_str());
46  confFileStream << period << ": ";
47 
48  TKey* triggerKey;
49  TIter nextTrigger(periodDirectory->GetListOfKeys());
50  bool isFirst = true;
51  while ((triggerKey = (TKey*)nextTrigger())) {
52  if (isFirst) isFirst = false;
53  else confFileStream << ", ";
54  std::string trigger = triggerKey->GetName();
55  confFileStream << triggerKey->GetName();
56  }
57  confFileStream << ";\n";
58  }
59  file->Close();
60  delete file;
61  confFileStream.close();
62 
63  return 0;
64 }
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:225
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
main
int main(int argc, char *argv[])
Definition: MuonTriggerSFConfGenerator.cxx:17
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
APP_NAME
#define APP_NAME
Definition: BoostedXbbTag.cxx:23
file
TFile * file
Definition: tile_monitor.h:29
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16