ATLAS Offline Software
ImportData.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // contact: jmaurer@cern.ch
6 
7 #ifndef TRIGGLOBALEFFICIENCYCORRECTION_IMPORTDATA_H
8 #define TRIGGLOBALEFFICIENCYCORRECTION_IMPORTDATA_H 1
9 
10 #include <algorithm>
11 #include <array>
12 #include <cctype>
13 #include <functional>
14 #include <map>
15 #include <vector>
16 
19 
20 namespace TrigGlobEffCorr {
21 
23  TT_UNKNOWN = 0x0,
24  TT_X2Y_FLAG = 0x1, // used to distinguish X_2Y from 2X_Y triggers
26  TT_MUON_FLAG = 0x20,
29  TT_SYM = 0x100,
30  TT_HALFSYM = 0x200,
31  TT_ASYM = 0x300,
34  // single lepton triggers
39  // dilepton triggers
40  TT_DILEPTON_FLAG = 0x2000,
52  // trilepton triggers
78  // tetralepton triggers
84 };
85 
86 class ImportData : public asg::AsgMessaging {
88 
89  public:
90  struct TrigDef {
92  std::size_t name;
93  std::array<std::size_t, 4> leg;
94  bool used = false; // auxiliary variable used by
95  // Calculator::Helper::extra() and bindFunction()
96  TrigDef(TriggerType type = TT_UNKNOWN, std::size_t name = 0,
97  std::size_t leg0 = 0, std::size_t leg1 = 0, std::size_t leg2 = 0,
98  std::size_t leg3 = 0)
99  : type(type), name(name), leg{leg0, leg1, leg2, leg3} {}
100  };
101 
102  ImportData();
104  ~ImportData();
105 
106  bool importHierarchies();
107  bool importTriggers();
108  bool importThresholds(
109  const std::map<std::string, std::string>& overridenThresholds = {});
110  bool importPeriods();
111  bool importMapKeys(
112  const std::string& tag,
113  std::map<std::size_t, std::map<std::size_t, int>>& keysPerLeg);
114  // NB: the following function calls all import*() functions except
115  // importMapKeys()
116  bool importAll(
117  const std::map<std::string, std::string>& overridenThresholds = {});
118 
119  bool getPeriodBoundaries(const std::string& period,
120  std::pair<unsigned, unsigned>& boundaries);
122  const std::map<std::string, std::string>& triggerCombination,
123  const std::string& version,
124  std::map<std::string, std::string>& legsPerKey,
126  const std::map<std::size_t, TrigDef>& getTriggerDefs() const {
127  return m_triggerDefs;
128  }
129  const std::map<std::size_t, float>& getTriggerThresholds() const {
130  return m_triggerThresholds;
131  }
132  const std::map<std::string, std::pair<unsigned, unsigned>>& getDataPeriods()
133  const {
134  return m_dataPeriods;
135  }
136  const std::vector<Hierarchy>& getHierarchyMeta() const {
137  return m_hierarchyMeta;
138  }
139  const std::vector<std::size_t>& getHierarchyData() const {
140  return m_hierarchyData;
141  }
142  const std::map<std::size_t, std::string>& getDictionary() const {
143  return m_dictionary;
144  }
146  bool& success);
147  static xAOD::Type::ObjectType associatedLeptonFlavour(const std::string& leg,
148  bool& success);
149  std::vector<TrigDef> parseTriggerString(const std::string& triggerString,
150  bool& success);
153  std::vector<ImportData::TrigDef>& triggers);
154 
155  protected:
156  bool readDataFile(const char* filename, std::vector<std::string>& contents);
157  void setNonMixed3LType(TrigDef& def, TriggerType flavourFlag);
158 
160  std::map<std::size_t, std::string>& m_dictionary;
161  std::hash<std::string>& m_hasher;
162 
163  std::map<std::size_t, TrigDef> m_triggerDefs;
164  std::map<std::size_t, float> m_triggerThresholds;
165  std::map<std::string, std::pair<unsigned, unsigned>> m_dataPeriods;
166  std::vector<Hierarchy> m_hierarchyMeta;
167  std::vector<std::size_t> m_hierarchyData;
168 };
169 
170 inline std::string removeWhitespaces(const std::string& s) {
171  std::string t(s);
172  t.erase(std::remove_if(t.begin(), t.end(),
173  [](char c) { return std::isspace(c); }),
174  t.end());
175  return t;
176 }
177 
178 } // namespace TrigGlobEffCorr
179 
180 #endif
TrigGlobEffCorr::TT_E_MU
@ TT_E_MU
Definition: ImportData.h:47
TrigGlobEffCorr::TT_3G_ASYM
@ TT_3G_ASYM
Definition: ImportData.h:69
used
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:224
TrigGlobEffCorr::ImportData::m_triggerDefs
std::map< std::size_t, TrigDef > m_triggerDefs
Definition: ImportData.h:163
TrigGlobEffCorr::TT_2MU_SYM
@ TT_2MU_SYM
Definition: ImportData.h:45
TrigGlobEffCorr::TT_3E_HALFSYM
@ TT_3E_HALFSYM
Definition: ImportData.h:58
TrigGlobEffCorr::TT_HALFSYM
@ TT_HALFSYM
Definition: ImportData.h:30
TrigGlobEffCorr::TT_2E_MU_SYM
@ TT_2E_MU_SYM
Definition: ImportData.h:63
TrigGlobEffCorr::TT_2G_ASYM
@ TT_2G_ASYM
Definition: ImportData.h:49
TrigGlobEffCorr::TT_SINGLE_MU
@ TT_SINGLE_MU
Definition: ImportData.h:37
TrigGlobEffCorr::TT_ASYM
@ TT_ASYM
Definition: ImportData.h:31
ObjectType
ObjectType
Definition: BaseObject.h:11
TrigGlobEffCorr::ImportData::m_dictionary
std::map< std::size_t, std::string > & m_dictionary
Definition: ImportData.h:160
TrigGlobEffCorr::ImportData::adaptTriggerListForTriggerMatching
bool adaptTriggerListForTriggerMatching(std::vector< ImportData::TrigDef > &triggers)
Definition: ImportData.cxx:729
TrigGlobEffCorr::ImportData::getPeriodBoundaries
bool getPeriodBoundaries(const std::string &period, std::pair< unsigned, unsigned > &boundaries)
Definition: ImportData.cxx:482
TrigGlobEffCorr
the template specializations below must be enclosed in this namespace
Definition: Calculator.cxx:1596
TrigGlobEffCorr::ImportData::~ImportData
~ImportData()
Definition: ImportData.cxx:34
TrigGlobEffCorr::ImportData::getHierarchyMeta
const std::vector< Hierarchy > & getHierarchyMeta() const
Definition: ImportData.h:136
TrigGlobEffCorr::TT_DILEPTON_ASYM
@ TT_DILEPTON_ASYM
Definition: ImportData.h:42
TrigGlobEffCorr::TT_2E_ASYM
@ TT_2E_ASYM
Definition: ImportData.h:44
TrigGlobEffCorr::TT_SINGLELEPTON_FLAG
@ TT_SINGLELEPTON_FLAG
Definition: ImportData.h:35
TrigGlobEffCorr::TT_E_2MU_SYM
@ TT_E_2MU_SYM
Definition: ImportData.h:64
InDetConditions::Hierarchy
Hierarchy
Definition: InDetHierarchy.h:14
TrigGlobalEfficiencyCorrectionTool.h
TrigGlobEffCorr::TT_SINGLE_E
@ TT_SINGLE_E
Definition: ImportData.h:36
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
python.TrigTLAMonitorAlgorithm.triggers
triggers
Definition: TrigTLAMonitorAlgorithm.py:196
TrigGlobEffCorr::ImportData::m_dataPeriods
std::map< std::string, std::pair< unsigned, unsigned > > m_dataPeriods
Definition: ImportData.h:165
TrigGlobEffCorr::ImportData::importHierarchies
bool importHierarchies()
Definition: ImportData.cxx:342
TrigGlobEffCorr::TT_TETRALEPTON_SYM
@ TT_TETRALEPTON_SYM
Definition: ImportData.h:80
TrigGlobEffCorr::ImportData::importMapKeys
bool importMapKeys(const std::string &tag, std::map< std::size_t, std::map< std::size_t, int >> &keysPerLeg)
Definition: ImportData.cxx:432
TrigGlobEffCorr::TT_MUON_FLAG
@ TT_MUON_FLAG
Definition: ImportData.h:26
TrigGlobEffCorr::TT_E_2MU_ASYM
@ TT_E_2MU_ASYM
Definition: ImportData.h:66
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
TrigGlobEffCorr::TT_SYM
@ TT_SYM
Definition: ImportData.h:29
TrigGlobEffCorr::TT_ELECTRON_FLAG
@ TT_ELECTRON_FLAG
Definition: ImportData.h:25
TrigGlobEffCorr::TT_2MU_G_SYM
@ TT_2MU_G_SYM
Definition: ImportData.h:74
TrigGlobEffCorr::ImportData::parseTriggerString
std::vector< TrigDef > parseTriggerString(const std::string &triggerString, bool &success)
Definition: ImportData.cxx:542
TrigGlobEffCorr::TT_2G_SYM
@ TT_2G_SYM
Definition: ImportData.h:48
AsgMessaging.h
TrigGlobEffCorr::ImportData::m_hierarchyData
std::vector< std::size_t > m_hierarchyData
Definition: ImportData.h:167
TrigGlobEffCorr::TT_2E_SYM
@ TT_2E_SYM
Definition: ImportData.h:43
TrigGlobEffCorr::TT_MU_2G_ASYM
@ TT_MU_2G_ASYM
Definition: ImportData.h:77
TrigGlobEffCorr::TT_X2Y_FLAG
@ TT_X2Y_FLAG
Definition: ImportData.h:24
TrigGlobEffCorr::ImportData::importThresholds
bool importThresholds(const std::map< std::string, std::string > &overridenThresholds={})
Definition: ImportData.cxx:251
TrigGlobEffCorr::ImportData::TrigDef::leg
std::array< std::size_t, 4 > leg
Definition: ImportData.h:93
TrigGlobEffCorr::TT_2E_MU_ASYM
@ TT_2E_MU_ASYM
Definition: ImportData.h:65
TrigGlobEffCorr::ImportData::m_hierarchyMeta
std::vector< Hierarchy > m_hierarchyMeta
Definition: ImportData.h:166
TrigGlobEffCorr::TT_PHOTON_FLAG
@ TT_PHOTON_FLAG
Definition: ImportData.h:27
TrigGlobEffCorr::ImportData::ImportData
ImportData()
the following two variables are owned by this tool and released in the destructor
Definition: ImportData.cxx:18
TrigGlobEffCorr::ImportData::associatedLeptonFlavour
xAOD::Type::ObjectType associatedLeptonFlavour(std::size_t leg, bool &success)
Definition: ImportData.cxx:531
TrigGlobEffCorr::TT_TRILEPTON_ASYM
@ TT_TRILEPTON_ASYM
Definition: ImportData.h:56
TrigGlobEffCorr::ImportData
Definition: ImportData.h:86
TrigGlobEffCorr::TT_3G_SYM
@ TT_3G_SYM
Definition: ImportData.h:67
TrigGlobEffCorr::TT_3MU_ASYM
@ TT_3MU_ASYM
Definition: ImportData.h:62
TrigGlobEffCorr::TT_TRILEPTON_HALFSYM
@ TT_TRILEPTON_HALFSYM
Definition: ImportData.h:55
TrigGlobEffCorr::TT_DILEPTON_SYM
@ TT_DILEPTON_SYM
Definition: ImportData.h:41
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TrigGlobEffCorr::ImportData::getDataPeriods
const std::map< std::string, std::pair< unsigned, unsigned > > & getDataPeriods() const
Definition: ImportData.h:132
compute_lumi.leg
leg
Definition: compute_lumi.py:95
TrigGlobEffCorr::ImportData::importPeriods
bool importPeriods()
Definition: ImportData.cxx:321
TrigGlobEffCorr::TT_4E_SYM
@ TT_4E_SYM
Definition: ImportData.h:81
TrigGlobEffCorr::TT_3E_SYM
@ TT_3E_SYM
Definition: ImportData.h:57
TrigGlobEffCorr::TT_TETRALEPTON_FLAG
@ TT_TETRALEPTON_FLAG
Definition: ImportData.h:79
TrigGlobEffCorr::ImportData::getDictionary
const std::map< std::size_t, std::string > & getDictionary() const
Definition: ImportData.h:142
TrigGlobEffCorr::ImportData::getHierarchyData
const std::vector< std::size_t > & getHierarchyData() const
Definition: ImportData.h:139
TrigGlobEffCorr::TT_4G_SYM
@ TT_4G_SYM
Definition: ImportData.h:83
TrigGlobEffCorr::ImportData::m_hasher
std::hash< std::string > & m_hasher
Definition: ImportData.h:161
TrigGlobEffCorr::TT_E_2G_ASYM
@ TT_E_2G_ASYM
Definition: ImportData.h:73
TrigGlobEffCorr::TT_MASK_TYPE
@ TT_MASK_TYPE
Definition: ImportData.h:33
contents
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory, const std::string &pattern, const std::string &path)
Definition: computils.cxx:321
TrigGlobEffCorr::TT_TRILEPTON_FLAG
@ TT_TRILEPTON_FLAG
Definition: ImportData.h:53
TrigGlobEffCorr::ImportData::TrigDef::type
TriggerType type
Definition: ImportData.h:91
TrigGlobEffCorr::ImportData::getParent
TrigGlobalEfficiencyCorrectionTool * getParent()
Definition: ImportData.h:151
TrigGlobEffCorr::TT_2E_G_ASYM
@ TT_2E_G_ASYM
Definition: ImportData.h:72
TrigGlobEffCorr::TriggerType
TriggerType
Definition: ImportData.h:22
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
TrigGlobEffCorr::ImportData::suggestEgammaMapKeys
bool suggestEgammaMapKeys(const std::map< std::string, std::string > &triggerCombination, const std::string &version, std::map< std::string, std::string > &legsPerKey, xAOD::Type::ObjectType type)
Definition: ImportData.cxx:589
TrigGlobalEfficiencyCorrectionTool
Definition: TrigGlobalEfficiencyCorrectionTool.h:37
TrigGlobEffCorr::TT_MASK_SYMMETRY
@ TT_MASK_SYMMETRY
Definition: ImportData.h:32
TrigGlobEffCorr::ImportData::readDataFile
bool readDataFile(const char *filename, std::vector< std::string > &contents)
Definition: ImportData.cxx:47
TrigGlobEffCorr::ImportData::TrigDef
Definition: ImportData.h:90
get_generator_info.version
version
Definition: get_generator_info.py:33
TrigGlobEffCorr::ImportData::m_triggerThresholds
std::map< std::size_t, float > m_triggerThresholds
Definition: ImportData.h:164
TrigGlobEffCorr::TT_MASK_FLAVOUR
@ TT_MASK_FLAVOUR
Definition: ImportData.h:28
TrigGlobEffCorr::TT_UNKNOWN
@ TT_UNKNOWN
Definition: ImportData.h:23
TrigGlobEffCorr::TT_E_2G_SYM
@ TT_E_2G_SYM
Definition: ImportData.h:71
TrigGlobEffCorr::TT_2MU_G_ASYM
@ TT_2MU_G_ASYM
Definition: ImportData.h:76
TrigGlobEffCorr::TT_DILEPTON_FLAG
@ TT_DILEPTON_FLAG
Definition: ImportData.h:40
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
TrigGlobEffCorr::ImportData::importAll
bool importAll(const std::map< std::string, std::string > &overridenThresholds={})
Definition: ImportData.cxx:41
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
TrigGlobEffCorr::ImportData::getTriggerDefs
const std::map< std::size_t, TrigDef > & getTriggerDefs() const
Definition: ImportData.h:126
TrigGlobEffCorr::TT_4MU_SYM
@ TT_4MU_SYM
Definition: ImportData.h:82
TrigGlobEffCorr::ImportData::importTriggers
bool importTriggers()
Definition: ImportData.cxx:99
TrigGlobEffCorr::TT_MU_2G_SYM
@ TT_MU_2G_SYM
Definition: ImportData.h:75
TrigGlobEffCorr::removeWhitespaces
std::string removeWhitespaces(const std::string &s)
Definition: ImportData.h:170
TrigGlobEffCorr::TT_3G_HALFSYM
@ TT_3G_HALFSYM
Definition: ImportData.h:68
TrigGlobEffCorr::TT_2E_G_SYM
@ TT_2E_G_SYM
Definition: ImportData.h:70
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
TrigGlobEffCorr::ImportData::setNonMixed3LType
void setNonMixed3LType(TrigDef &def, TriggerType flavourFlag)
Definition: ImportData.cxx:83
TrigGlobEffCorr::ImportData::m_parent
TrigGlobalEfficiencyCorrectionTool * m_parent
Definition: ImportData.h:159
TrigGlobEffCorr::ImportData::TrigDef::TrigDef
TrigDef(TriggerType type=TT_UNKNOWN, std::size_t name=0, std::size_t leg0=0, std::size_t leg1=0, std::size_t leg2=0, std::size_t leg3=0)
Definition: ImportData.h:96
TrigGlobEffCorr::TT_MU_G
@ TT_MU_G
Definition: ImportData.h:51
python.compressB64.c
def c
Definition: compressB64.py:93
TrigGlobEffCorr::TT_E_G
@ TT_E_G
Definition: ImportData.h:50
TrigGlobEffCorr::TT_3MU_HALFSYM
@ TT_3MU_HALFSYM
Definition: ImportData.h:61
TrigGlobEffCorr::TT_3E_ASYM
@ TT_3E_ASYM
Definition: ImportData.h:59
TrigGlobEffCorr::TT_TRILEPTON_SYM
@ TT_TRILEPTON_SYM
Definition: ImportData.h:54
TrigGlobalEfficiencyCorrectionTool::Hierarchy
Definition: TrigGlobalEfficiencyCorrectionTool.h:96
TrigGlobEffCorr::ImportData::getTriggerThresholds
const std::map< std::size_t, float > & getTriggerThresholds() const
Definition: ImportData.h:129
TrigGlobEffCorr::TT_3MU_SYM
@ TT_3MU_SYM
Definition: ImportData.h:60
TrigGlobEffCorr::TT_SINGLE_G
@ TT_SINGLE_G
Definition: ImportData.h:38
TrigGlobEffCorr::ImportData::TrigDef::name
std::size_t name
Definition: ImportData.h:92
TrigGlobEffCorr::TT_2MU_ASYM
@ TT_2MU_ASYM
Definition: ImportData.h:46