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