ATLAS Offline Software
Loading...
Searching...
No Matches
TrigGlobEffCorr::ImportData Class Reference

#include <ImportData.h>

Inheritance diagram for TrigGlobEffCorr::ImportData:
Collaboration diagram for TrigGlobEffCorr::ImportData:

Classes

struct  TrigDef

Public Member Functions

 ImportData ()
 the following two variables are owned by this tool and released in the destructor
 ImportData (TrigGlobalEfficiencyCorrectionTool &parent)
 ~ImportData ()
bool importHierarchies ()
bool importTriggers ()
bool importThresholds (const std::map< std::string, std::string > &overridenThresholds={})
bool importPeriods ()
bool importMapKeys (const std::string &tag, std::map< std::size_t, std::map< std::size_t, int > > &keysPerLeg)
bool importAll (const std::map< std::string, std::string > &overridenThresholds={})
bool getPeriodBoundaries (const std::string &period, std::pair< unsigned, unsigned > &boundaries)
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)
const std::map< std::size_t, TrigDef > & getTriggerDefs () const
const std::map< std::size_t, float > & getTriggerThresholds () const
const std::map< std::string, std::pair< unsigned, unsigned > > & getDataPeriods () const
const std::vector< Hierarchy > & getHierarchyMeta () const
const std::vector< std::size_t > & getHierarchyData () const
const std::map< std::size_t, std::string > & getDictionary () const
xAOD::Type::ObjectType associatedLeptonFlavour (std::size_t leg, bool &success)
std::vector< TrigDefparseTriggerString (const std::string &triggerString, bool &success)
TrigGlobalEfficiencyCorrectionToolgetParent ()
bool adaptTriggerListForTriggerMatching (std::vector< ImportData::TrigDef > &triggers)
void setLevel (MSG::Level lvl)
 Change the current logging level.
Functions providing the same interface as AthMessaging
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.

Static Public Member Functions

static xAOD::Type::ObjectType associatedLeptonFlavour (const std::string &leg, bool &success)

Protected Member Functions

bool readDataFile (const char *filename, std::vector< std::string > &contents)
void setNonMixed3LType (TrigDef &def, TriggerType flavourFlag)

Protected Attributes

TrigGlobalEfficiencyCorrectionToolm_parent
std::map< std::size_t, std::string > & m_dictionary
std::hash< std::string > & m_hasher
std::map< std::size_t, TrigDefm_triggerDefs
std::map< std::size_t, float > m_triggerThresholds
std::map< std::string, std::pair< unsigned, unsigned > > m_dataPeriods
std::vector< Hierarchym_hierarchyMeta
std::vector< std::size_t > m_hierarchyData

Private Types

using Hierarchy = TrigGlobalEfficiencyCorrectionTool::Hierarchy

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Definition at line 86 of file ImportData.h.

Member Typedef Documentation

◆ Hierarchy

Constructor & Destructor Documentation

◆ ImportData() [1/2]

ImportData::ImportData ( )

the following two variables are owned by this tool and released in the destructor

Definition at line 18 of file ImportData.cxx.

19 :
21 asg::AsgMessaging("TrigGlobalEfficiencyCorrectionTool"),
22 m_parent(nullptr),
23 m_dictionary(*new std::map<std::size_t, std::string>),
24 m_hasher(*new std::hash<std::string>) {}
std::hash< std::string > & m_hasher
Definition ImportData.h:161
TrigGlobalEfficiencyCorrectionTool * m_parent
Definition ImportData.h:159
std::map< std::size_t, std::string > & m_dictionary
Definition ImportData.h:160
AsgMessaging(const std::string &name)
Constructor with a name.

◆ ImportData() [2/2]

ImportData::ImportData ( TrigGlobalEfficiencyCorrectionTool & parent)

Definition at line 26 of file ImportData.cxx.

27 : asg::AsgMessaging(&parent),
28 m_parent(&parent),
29 m_dictionary(parent.m_dictionary),
30 m_hasher(parent.m_hasher) {
31 msg().setLevel(parent.msg().level());
32}
MsgStream & msg() const
The standard message stream.

◆ ~ImportData()

ImportData::~ImportData ( )

Definition at line 34 of file ImportData.cxx.

34 {
35 if (!m_parent) {
36 delete &m_dictionary;
37 delete &m_hasher;
38 }
39}

Member Function Documentation

◆ adaptTriggerListForTriggerMatching()

bool ImportData::adaptTriggerListForTriggerMatching ( std::vector< ImportData::TrigDef > & triggers)

This essentially splits OR single lepton triggers into independent items

to prevent duplicates

Definition at line 729 of file ImportData.cxx.

730 {
732 std::set<std::size_t> extraItems;
733 std::vector<ImportData::TrigDef> updatedTriggers;
734 for (auto& trig : triggers) {
735 auto& name = m_dictionary.at(trig.name);
736 std::size_t pos = 0, len = name.find("_OR_");
737 if (len == std::string::npos) {
738 updatedTriggers.emplace_back(trig);
739 continue;
740 }
741 while (true) {
742 std::string item = name.substr(pos, len);
743 auto h = m_hasher(item);
744 auto def = m_triggerDefs.find(h);
745 if (def == m_triggerDefs.end()) {
746 ATH_MSG_ERROR("while listing triggers for trigger matching; trigger \""
747 << item << "\" extracted from \"" << name
748 << "\" is not recognized");
749 return false;
750 }
751 if (extraItems.emplace(h).second)
752 updatedTriggers.emplace_back(def->second);
753 if (len == std::string::npos)
754 break;
755 pos += len + 4;
756 len = name.find("_OR_", pos);
757 if (len != std::string::npos)
758 len -= pos;
759 }
760 }
761 triggers.swap(updatedTriggers);
762 return true;
763}
#define ATH_MSG_ERROR(x)
std::map< std::size_t, TrigDef > m_triggerDefs
Definition ImportData.h:163

◆ associatedLeptonFlavour() [1/2]

xAOD::Type::ObjectType ImportData::associatedLeptonFlavour ( const std::string & leg,
bool & success )
static

Definition at line 514 of file ImportData.cxx.

515 {
516 // note: 'success' is not set to 'true', only downgraded to 'false' if needed
517 if (leg.length() >= 2 && leg[0] == 'e' && leg[1] >= '1' && leg[1] <= '9')
519 else if (leg.length() >= 3 && leg[0] == 'm' && leg[1] == 'u' &&
520 leg[2] >= '1' && leg[2] <= '9')
521 return xAOD::Type::Muon;
522 else if (leg.length() >= 3 && leg[0] == 'g' && leg[1] >= '1' && leg[1] <= '9')
523 return xAOD::Type::Photon;
524 else if (leg.length() >= 4 && leg[0] == 't' && leg[1] == 'a' &&
525 leg[2] == 'u' && leg[3] >= '1' && leg[3] <= '9')
526 return xAOD::Type::Tau;
527 success = false;
528 return xAOD::Type::Other;
529}
@ Photon
The object is a photon.
Definition ObjectType.h:47
@ Other
An object not falling into any of the other categories.
Definition ObjectType.h:34
@ Muon
The object is a muon.
Definition ObjectType.h:48
@ Electron
The object is an electron.
Definition ObjectType.h:46
@ Tau
The object is a tau (jet)
Definition ObjectType.h:49

◆ associatedLeptonFlavour() [2/2]

xAOD::Type::ObjectType ImportData::associatedLeptonFlavour ( std::size_t leg,
bool & success )

Definition at line 531 of file ImportData.cxx.

532 {
533 // note: 'success' is not set to 'true', only downgraded to 'false' if needed
534 auto itr = m_dictionary.find(leg);
535 if (itr != m_dictionary.end()) {
536 return associatedLeptonFlavour(itr->second, success);
537 }
538 success = false;
539 return xAOD::Type::Other;
540}
xAOD::Type::ObjectType associatedLeptonFlavour(std::size_t leg, bool &success)

◆ getDataPeriods()

const std::map< std::string, std::pair< unsigned, unsigned > > & TrigGlobEffCorr::ImportData::getDataPeriods ( ) const
inline

Definition at line 132 of file ImportData.h.

133 {
134 return m_dataPeriods;
135 }
std::map< std::string, std::pair< unsigned, unsigned > > m_dataPeriods
Definition ImportData.h:165

◆ getDictionary()

const std::map< std::size_t, std::string > & TrigGlobEffCorr::ImportData::getDictionary ( ) const
inline

Definition at line 142 of file ImportData.h.

142 {
143 return m_dictionary;
144 }

◆ getHierarchyData()

const std::vector< std::size_t > & TrigGlobEffCorr::ImportData::getHierarchyData ( ) const
inline

Definition at line 139 of file ImportData.h.

139 {
140 return m_hierarchyData;
141 }
std::vector< std::size_t > m_hierarchyData
Definition ImportData.h:167

◆ getHierarchyMeta()

const std::vector< Hierarchy > & TrigGlobEffCorr::ImportData::getHierarchyMeta ( ) const
inline

Definition at line 136 of file ImportData.h.

136 {
137 return m_hierarchyMeta;
138 }
std::vector< Hierarchy > m_hierarchyMeta
Definition ImportData.h:166

◆ getParent()

TrigGlobalEfficiencyCorrectionTool * TrigGlobEffCorr::ImportData::getParent ( )
inline

Definition at line 151 of file ImportData.h.

151{ return m_parent; }

◆ getPeriodBoundaries()

bool ImportData::getPeriodBoundaries ( const std::string & period,
std::pair< unsigned, unsigned > & boundaries )

Definition at line 482 of file ImportData.cxx.

483 {
484 // First possibility: a defined period keyword
485 auto itr = m_dataPeriods.find(period);
486 if (itr != m_dataPeriods.end()) {
487 boundaries = itr->second;
488 return true;
489 }
490 // Otherwise it's a '-'-separated range
491 auto sep = period.find_first_of('-');
492 if (sep != std::string::npos) {
493 std::string kwMin = period.substr(0, sep);
494 std::string kwMax = period.substr(sep + 1);
495 // Second possibility: a range of defined period keywords
496 auto itrMin = m_dataPeriods.find(kwMin);
497 auto itrMax = m_dataPeriods.find(kwMax);
498 if (itrMin != m_dataPeriods.end() && itrMax != m_dataPeriods.end()) {
499 boundaries = std::minmax({itrMin->second.first, itrMax->second.first,
500 itrMin->second.second, itrMax->second.second});
501 return true;
502 }
503 // Third possibility: a range of run numbers
504 try {
505 boundaries = std::minmax(std::stoi(kwMin), std::stoi(kwMax));
506 return true;
507 } catch (...) {
508 }
509 }
510 ATH_MSG_ERROR("Unable to understand the period/range " << period);
511 return false;
512}

◆ getTriggerDefs()

const std::map< std::size_t, TrigDef > & TrigGlobEffCorr::ImportData::getTriggerDefs ( ) const
inline

Definition at line 126 of file ImportData.h.

126 {
127 return m_triggerDefs;
128 }

◆ getTriggerThresholds()

const std::map< std::size_t, float > & TrigGlobEffCorr::ImportData::getTriggerThresholds ( ) const
inline

Definition at line 129 of file ImportData.h.

129 {
130 return m_triggerThresholds;
131 }
std::map< std::size_t, float > m_triggerThresholds
Definition ImportData.h:164

◆ importAll()

bool ImportData::importAll ( const std::map< std::string, std::string > & overridenThresholds = {})

Definition at line 41 of file ImportData.cxx.

42 {
43 return importPeriods() && importThresholds(overridenThresholds) &&
45}
bool importThresholds(const std::map< std::string, std::string > &overridenThresholds={})

◆ importHierarchies()

bool ImportData::importHierarchies ( )

Definition at line 342 of file ImportData.cxx.

342 {
343 if (!m_triggerThresholds.size() && !importThresholds())
344 return false;
345 m_hierarchyMeta.clear();
346 m_hierarchyData.clear();
347 std::vector<std::string> config;
348 if (!readDataFile("TrigGlobalEfficiencyCorrection/Hierarchies.cfg", config))
349 return false;
350 std::stringstream ss;
351 std::string token, unit;
352 std::map<std::size_t, std::vector<std::size_t> > aliases;
353 for (auto& line : config) {
354 bool success = true;
355 ss.clear();
356 ss.str(line);
357 if (line[0] == '[') {
358 auto& meta = *m_hierarchyMeta.emplace(
359 m_hierarchyMeta.end(),
360 Hierarchy{(short)m_hierarchyData.size(), 0, 0.f,
361 std::numeric_limits<float>::max()});
362 if (line[1] == '-' && line[2] == ']')
363 ss.ignore(3);
364 else {
365 char sep = '-';
366 if (line[1] == '>')
367 ss.ignore(2) >> meta.minPt >> unit;
368 else if (line[1] == '<')
369 ss.ignore(2) >> meta.maxPt >> unit;
370 else
371 ss.ignore(1) >> meta.minPt >> sep >> meta.maxPt >> unit;
372 if (!ss || sep != '-' || (unit != "GeV]" && unit != "MeV]")) {
373 ATH_MSG_ERROR("Unable to parse pT restrictions in Hierarchies.cfg");
374 success = false;
375 }
376 if (unit == "GeV]") {
377 meta.minPt *= 1e3f;
378 if (meta.maxPt < std::numeric_limits<float>::max())
379 meta.maxPt *= 1e3f;
380 }
381 }
382 while (ss >> token) {
383 std::size_t h = m_hasher(token);
384 auto itr = aliases.find(h);
385 if (itr == aliases.end()) {
386 if (m_triggerThresholds.find(h) == m_triggerThresholds.end()) {
387 ATH_MSG_ERROR("Unknown trigger leg '"
388 << token << "' found in Hierarchies.cfg");
389 success = false;
390 }
391 m_dictionary.emplace(h, token);
392 m_hierarchyData.push_back(h);
393 } else
394 m_hierarchyData.insert(m_hierarchyData.end(), itr->second.begin(),
395 itr->second.end());
396 if (ss >> token && token != ">")
397 success = false;
398 }
399 meta.nLegs = m_hierarchyData.size() - meta.offset;
400 success = success && meta.nLegs;
401 } else {
402 ss >> token;
403 auto& legs = aliases[m_hasher(token)];
404 if (ss >> token && token == ":=") {
405 legs.clear();
406 while (ss >> token) {
407 std::size_t h = m_hasher(token);
408 m_dictionary.emplace(h, token);
409 legs.push_back(h);
410 if (m_triggerThresholds.find(h) == m_triggerThresholds.end()) {
411 ATH_MSG_ERROR("Unknown trigger leg '"
412 << token << "' found in Hierarchies.cfg");
413 success = false;
414 }
415 if (ss >> token && token != ">")
416 success = false;
417 }
418 success = success && legs.size();
419 } else
420 success = false;
421 }
422 if (!success) {
423 ATH_MSG_ERROR("Failed parsing line from Hierarchies.cfg:\n" << line);
424 m_hierarchyMeta.clear();
425 m_hierarchyData.clear();
426 return false;
427 }
428 }
429 return true;
430}
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
bool readDataFile(const char *filename, std::vector< std::string > &contents)
TrigGlobalEfficiencyCorrectionTool::Hierarchy Hierarchy
Definition ImportData.h:87

◆ importMapKeys()

bool ImportData::importMapKeys ( const std::string & tag,
std::map< std::size_t, std::map< std::size_t, int > > & keysPerLeg )

Definition at line 432 of file ImportData.cxx.

434 {
435 keysPerLeg.clear();
436 std::vector<std::string> config;
437 if (!readDataFile("TrigGlobalEfficiencyCorrection/MapKeys.cfg", config))
438 return false;
439 std::stringstream ss;
440 std::string token;
441 bool reading = false;
442 for (auto& line : config) {
443 std::size_t pos = line.find("[VERSION]");
444 if (pos != std::string::npos) {
445 reading = false;
446 ss.clear();
447 ss.str(TrigGlobEffCorr::removeWhitespaces(line.substr(pos + 9)));
448 while (std::getline(ss, token, ',')) {
449 if (token == version) {
450 reading = true;
451 break;
452 }
453 }
454 continue;
455 }
456 if (!reading)
457 continue;
458 ss.clear();
459 ss.str(line);
460 int year;
461 ss >> year >> token;
462 year = 1 << (year - 2015);
463 std::size_t leg = m_hasher(token);
464 auto& keys = keysPerLeg[leg];
465 while (ss >> token) {
466 std::size_t h = m_hasher(token);
467 auto insertion = keys.emplace(h, year);
468 if (insertion.second)
469 m_dictionary.emplace(h, token);
470 else
471 insertion.first->second |= year;
472 }
473 }
474 if (!keysPerLeg.size()) {
475 ATH_MSG_ERROR("Unable to import the available map keys for the version "
476 << version);
477 return false;
478 }
479 return true;
480}
std::string removeWhitespaces(const std::string &s)
Definition ImportData.h:170

◆ importPeriods()

bool ImportData::importPeriods ( )

Definition at line 321 of file ImportData.cxx.

321 {
322 m_dataPeriods.clear();
323 std::vector<std::string> config;
324 if (!readDataFile("TrigGlobalEfficiencyCorrection/DataPeriods.cfg", config))
325 return false;
326 std::stringstream ss;
327 std::string key;
328 std::pair<unsigned, unsigned> runs;
329 for (auto& line : config) {
330 ss.clear();
331 ss.str(line);
332 ss >> key >> runs.first >> runs.second;
333 if (ss.fail()) {
334 m_dataPeriods.clear();
335 return false;
336 }
337 m_dataPeriods.emplace(key, runs);
338 }
339 return true;
340}

◆ importThresholds()

bool ImportData::importThresholds ( const std::map< std::string, std::string > & overridenThresholds = {})

Override thresholds if requested

Definition at line 251 of file ImportData.cxx.

252 {
253 m_triggerThresholds.clear();
254 std::vector<std::string> config;
255 if (!readDataFile("TrigGlobalEfficiencyCorrection/Thresholds.cfg", config))
256 return false;
257 std::stringstream ss;
258 std::string leg, unit;
259 float pt;
260 bool success = true;
261 for (auto& line : config) {
262 ss.clear();
263 ss.str(line);
264 if (ss >> leg >> pt >> unit) {
265 std::size_t h = m_hasher(leg);
266 m_dictionary.emplace(h, leg);
267 if (unit == "GeV")
268 pt *= 1e3f;
269 else if (unit != "MeV") {
270 ATH_MSG_ERROR("Unable to import pT threshold for leg \""
271 << leg << "\" (missing unit)");
272 success = false;
273 }
275 } else {
276 ATH_MSG_ERROR("Unable to import pT threshold for leg \"" << leg << '"');
277 success = false;
278 }
279 }
280 if (!success) {
281 m_triggerThresholds.clear();
282 return false;
283 }
284
286 bool belowRecommended = false;
287 for (auto& kv : overridenThresholds) {
288 auto itr = m_triggerThresholds.find(m_hasher(kv.first));
289 if (itr != m_triggerThresholds.end()) {
290 float pt = 0.f;
291 try {
292 pt = std::stof(kv.second);
293 } catch (...) {
294 ATH_MSG_ERROR("Unable to convert threshold argument \""
295 << kv.second << "\" to floating-point value");
296 success = false;
297 continue;
298 }
299 if (pt < 1e3f) {
300 ATH_MSG_WARNING("Suspiciously low threshold ("
301 << pt << " MeV) set for trigger leg " << kv.first
302 << ", please make sure you provided the threshold in "
303 "MeV and not in GeV!");
304 }
305 if (pt < itr->second)
306 belowRecommended = true;
307 itr->second = pt;
308 } else {
309 ATH_MSG_ERROR("Can't override threshold for unknown trigger leg "
310 << kv.first);
311 success = false;
312 }
313 }
314 if (belowRecommended) {
316 "Tool configured to use trigger thresholds below those recommended!");
317 }
318 return success;
319}
#define ATH_MSG_WARNING(x)

◆ importTriggers()

bool ImportData::importTriggers ( )

default: assume the leg's name is the same as the full trigger name

Classify trigger and re-arrange legs (if needed) so that all electron legs come before muon legs, and muon legs before photon legs

symmetric tetralepton triggers

single-flavour trilepton triggers

mixed-flavour trilepton triggers

dilepton triggers

single lepton triggers

Definition at line 99 of file ImportData.cxx.

99 {
100 if (!m_triggerThresholds.size() && !importThresholds())
101 return false;
102 m_triggerDefs.clear();
103 std::vector<std::string> config;
104 if (!readDataFile("TrigGlobalEfficiencyCorrection/Triggers.cfg", config))
105 return false;
106 std::stringstream ss;
107 std::string triggerName, token;
108 bool success = true;
109 for (auto& line : config) {
110 ATH_MSG_DEBUG(line);
111 ss.clear();
112 ss.str(line);
113 ss >> triggerName;
114 std::size_t h = m_hasher(triggerName);
115 auto& def = m_triggerDefs[h];
116 def.name = h;
117
118 ss.clear();
119 ss.str(line);
120 ss >> triggerName;
121 m_dictionary[h] = triggerName;
122 ATH_MSG_DEBUG(std::to_string(h) << " " << triggerName);
123
124 bool hasTauLeg{};
125 for (std::size_t& leg : def.leg) {
126 if (!(ss >> token))
127 break;
128 auto flavour = associatedLeptonFlavour(token, success);
129 if (flavour == xAOD::Type::Tau) {
130 // we don't support taus for now
131 leg = 0;
132 hasTauLeg = true;
133 } else {
134 h = m_hasher(token);
135 m_dictionary.emplace(h, token);
136 leg = h;
137 if (m_triggerThresholds.find(h) == m_triggerThresholds.end()) {
138 ATH_MSG_ERROR("Unknown trigger leg '" << token
139 << "' found in Triggers.cfg");
140 success = false;
141 }
142 }
143 }
144 if (!def.leg[0]) {
145 def.leg[0] = h;
147 if (m_triggerThresholds.find(h) == m_triggerThresholds.end()) {
149 "Unknown trigger leg '"
150 << triggerName
151 << "' (inferred from trigger name) found in Triggers.cfg");
152 success = false;
153 }
154 }
155 if (!success)
156 continue;
157
160 def.type = TT_UNKNOWN;
161 // triggers with tau legs should stay unknown
162 if (hasTauLeg) {
163 continue;
164 }
165
166 auto flavour0 = associatedLeptonFlavour(def.leg[0], success);
167 int ne = (flavour0 == xAOD::Type::Electron) * 1;
168 int nm = (flavour0 == xAOD::Type::Muon) * 1;
169 if (def.leg[1]) {
170 auto flavour1 = associatedLeptonFlavour(def.leg[1], success);
171 if (flavour1 == xAOD::Type::Electron) {
172 if (!ne)
173 std::swap(def.leg[0], def.leg[1]);
174 ++ne;
175 } else if (flavour1 == xAOD::Type::Muon) {
176 if (!(ne + nm))
177 std::swap(def.leg[0], def.leg[1]);
178 ++nm;
179 } else if (flavour1 != xAOD::Type::Photon)
180 success = false;
181 if (def.leg[2]) {
182 auto flavour2 = associatedLeptonFlavour(def.leg[2], success);
183 if (flavour2 == xAOD::Type::Electron) {
184 if (!ne)
185 std::swap(def.leg[0], def.leg[2]);
186 else if (ne == 1)
187 std::swap(def.leg[1], def.leg[2]);
188 ++ne;
189 } else if (flavour2 == xAOD::Type::Muon) {
190 if (!(ne + nm))
191 std::swap(def.leg[0], def.leg[2]);
192 else if ((ne + nm) == 1)
193 std::swap(def.leg[1], def.leg[2]);
194 ++nm;
195 } else if (flavour2 != xAOD::Type::Photon)
196 success = false;
197 if (def.leg[3]) {
199 if (std::count(def.leg.cbegin(), def.leg.cend(), def.leg[0]) == 4) {
200 def.type = nm ? TT_4MU_SYM : TT_4E_SYM;
201 } else
202 success = false;
203 } else if (ne + nm == 0 || ne == 3 ||
204 nm == 3)
205 {
207 : nm ? TT_MUON_FLAG
208 : TT_PHOTON_FLAG));
209 } else
210 {
211 bool sym = (def.leg[0] == def.leg[1] || def.leg[1] == def.leg[2]);
212 if (ne == 2)
213 def.type = nm ? (sym ? TT_2E_MU_SYM : TT_2E_MU_ASYM)
214 : (sym ? TT_2E_G_SYM : TT_2E_G_ASYM);
215 else if (nm == 2)
216 def.type = ne ? (sym ? TT_E_2MU_SYM : TT_E_2MU_ASYM)
217 : (sym ? TT_2MU_G_SYM : TT_2MU_G_ASYM);
218 else if (ne + nm == 1)
219 def.type = ne ? (sym ? TT_E_2G_SYM : TT_E_2G_ASYM)
220 : (sym ? TT_MU_2G_SYM : TT_MU_2G_ASYM);
221 else
222 success = false;
223 }
224 } else
225 {
226 if (ne == 2)
227 def.type = (def.leg[0] == def.leg[1]) ? TT_2E_SYM : TT_2E_ASYM;
228 else if (nm == 2)
229 def.type = (def.leg[0] == def.leg[1]) ? TT_2MU_SYM : TT_2MU_ASYM;
230 else if (ne + nm == 0)
231 def.type = (def.leg[0] == def.leg[1]) ? TT_2G_SYM : TT_2G_ASYM;
232 else if (ne == 1 && nm == 1)
233 def.type = TT_E_MU;
234 else if (ne == 1)
235 def.type = TT_E_G;
236 else if (nm == 1)
237 def.type = TT_MU_G;
238 }
239 } else
240 {
241 def.type = ne ? TT_SINGLE_E : nm ? TT_SINGLE_MU : TT_SINGLE_G;
242 }
243 if (!success || def.type == TT_UNKNOWN) {
244 success = false;
245 ATH_MSG_ERROR("Configuration issue for trigger " << triggerName);
246 }
247 }
248 return success;
249}
#define ATH_MSG_DEBUG(x)
if(febId1==febId2)
void setNonMixed3LType(TrigDef &def, TriggerType flavourFlag)
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & asg::AsgMessaging::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 49 of file AsgMessaging.cxx.

49 {
50#ifndef XAOD_STANDALONE
51 return ::AthMessaging::msg();
52#else // not XAOD_STANDALONE
53 return m_msg;
54#endif // not XAOD_STANDALONE
55 }

◆ msg() [2/2]

MsgStream & asg::AsgMessaging::msg ( const MSG::Level lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 57 of file AsgMessaging.cxx.

57 {
58#ifndef XAOD_STANDALONE
59 return ::AthMessaging::msg( lvl );
60#else // not XAOD_STANDALONE
61 m_msg << lvl;
62 return m_msg;
63#endif // not XAOD_STANDALONE
64 }

◆ msgLvl()

bool asg::AsgMessaging::msgLvl ( const MSG::Level lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 41 of file AsgMessaging.cxx.

41 {
42#ifndef XAOD_STANDALONE
43 return ::AthMessaging::msgLvl( lvl );
44#else // not XAOD_STANDALONE
45 return m_msg.msgLevel( lvl );
46#endif // not XAOD_STANDALONE
47 }

◆ parseTriggerString()

std::vector< ImportData::TrigDef > ImportData::parseTriggerString ( const std::string & triggerString,
bool & success )

Replace all || by |

Definition at line 542 of file ImportData.cxx.

543 {
544 std::string s = TrigGlobEffCorr::removeWhitespaces(triggerString);
545 if (s.find("|||") != std::string::npos) {
546 ATH_MSG_ERROR("Invalid format for the trigger combination '"
547 << triggerString << "'");
548 success = false;
549 return {};
550 }
552 while (true) {
553 auto i = s.find("||");
554 if (i == std::string::npos)
555 break;
556 s.replace(i, 1, "");
557 }
558 if (s == "" || s == "|") {
559 ATH_MSG_ERROR("Invalid format for the trigger combination '"
560 << triggerString << "'");
561 success = false;
562 return {};
563 }
564 std::vector<TrigDef> triggers;
565 std::set<std::size_t> hashes;
566 std::stringstream ss(s);
567 while (std::getline(ss, s, '|')) {
568 std::size_t trig = m_hasher(s);
569 ATH_MSG_DEBUG(std::to_string(trig) << " --> " << s);
570 auto itr = m_triggerDefs.find(trig);
571 if (itr == m_triggerDefs.end()) {
572 ATH_MSG_ERROR("Unknown trigger '"
573 << s << "' found while parsing trigger combination");
574 success = false;
575 return {};
576 }
577 if (!hashes.insert(trig).second) {
578 ATH_MSG_ERROR("The trigger '"
579 << s << "' is present more than once in the combination");
580 success = false;
581 return {};
582 }
583 triggers.push_back(itr->second);
584 }
585 success = success && triggers.size();
586 return triggers;
587}

◆ readDataFile()

bool ImportData::readDataFile ( const char * filename,
std::vector< std::string > & contents )
protected

Definition at line 47 of file ImportData.cxx.

48 {
49 contents.clear();
50 bool success = true;
51 auto name = PathResolverFindCalibFile(filename);
52 if (name.length()) {
53 std::ifstream f(name.c_str(), std::ios_base::in);
54 if (f.is_open()) {
55 std::string line;
56 while (f.good()) {
57 if (std::getline(f, line)) {
58 const std::string::size_type i = line.find('#');
59 if (i != std::string::npos)
60 line.resize(i);
61 if (line.length() >= 3)
62 contents.emplace_back(std::move(line));
63 }
64 }
65 if (!f.eof()) {
66 ATH_MSG_ERROR("Issue encountered while reading configuration file "
67 << filename);
68 success = false;
69 }
70 f.close();
71 return true;
72 } else {
73 ATH_MSG_ERROR("Unable to open configuration file " << filename);
74 success = false;
75 }
76 } else {
77 ATH_MSG_ERROR("Unable to find configuration file " << filename);
78 success = false;
79 }
80 return success;
81}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory, const std::string &pattern, const std::string &path)

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setNonMixed3LType()

void ImportData::setNonMixed3LType ( TrigDef & def,
TriggerType flavourFlag )
protected

swap legs so that the last two are identical, for later convenience

Definition at line 83 of file ImportData.cxx.

83 {
84 if (def.leg[0] == def.leg[1] && def.leg[1] == def.leg[2])
85 def.type = static_cast<TriggerType>(TT_TRILEPTON_SYM | flavourFlag);
86 else if (def.leg[0] != def.leg[1] && def.leg[1] != def.leg[2] &&
87 def.leg[0] != def.leg[2])
88 def.type = static_cast<TriggerType>(TT_TRILEPTON_ASYM | flavourFlag);
89 else
90 {
91 if (def.leg[1] != def.leg[0] && def.leg[1] != def.leg[2])
92 std::swap(def.leg[0], def.leg[1]);
93 else if (def.leg[2] != def.leg[0] && def.leg[2] != def.leg[1])
94 std::swap(def.leg[0], def.leg[2]);
95 def.type = static_cast<TriggerType>(TT_TRILEPTON_HALFSYM | flavourFlag);
96 }
97}

◆ suggestEgammaMapKeys()

bool ImportData::suggestEgammaMapKeys ( const std::map< std::string, std::string > & triggerCombination,
const std::string & version,
std::map< std::string, std::string > & legsPerKey,
xAOD::Type::ObjectType type )

If no version is specified, the list of trigger legs is returned

Definition at line 589 of file ImportData.cxx.

592 {
593 legsPerKey.clear();
594 if (!importAll())
595 return false;
596
597 bool success = true;
598 std::map<std::size_t, int> legs;
599
600 for (auto& kv : triggerCombination) {
601 auto itrPeriod = m_dataPeriods.find(kv.first);
602 if (itrPeriod == m_dataPeriods.end()) {
603 ATH_MSG_ERROR("Unknown period " << kv.first);
604 success = false;
605 continue;
606 }
607 int years = 0;
608 for (int k = 0; k < 32; ++k) {
609 auto itr = m_dataPeriods.find(std::to_string(2015 + k));
610 if (itr != m_dataPeriods.end() &&
611 itrPeriod->second.first <= itr->second.second &&
612 itrPeriod->second.second >= itr->second.first) {
613 years |= (1 << k);
614 }
615 }
616 auto triggers = parseTriggerString(kv.second, success);
617 if (!success)
618 continue;
619 for (auto& trig : triggers) {
620 for (std::size_t leg : trig.leg) {
621 if (leg && associatedLeptonFlavour(leg, success) == type) {
622 auto insertion = legs.emplace(leg, years);
623 if (!insertion.second)
624 insertion.first->second |= years;
625 }
626 }
627 }
628 }
629 if (!success)
630 return false;
631
632 if (version != "") {
633 std::map<std::size_t, std::map<std::size_t, int> > allKeys;
634 if (!importMapKeys(version, allKeys))
635 return false;
636 std::map<std::size_t, std::vector<std::size_t> > allLegsPerKey;
637 std::set<std::size_t> legsWithMultipleKeys;
638 bool sameKeyForAllyears = true;
639 while (legs.size()) {
640 allLegsPerKey.clear();
641 for (auto& kvLegs : legs) // loop on remaining legs
642 {
643 std::size_t leg = kvLegs.first;
644 int years = kvLegs.second;
645 auto itrKeys = allKeys.find(leg); // list of keys for that leg
646 if (itrKeys != allKeys.end()) {
647 for (auto& kvKeys : itrKeys->second) // loop on those keys
648 {
649 auto y = (kvKeys.second & years);
650 if ((y == years) ||
651 (!sameKeyForAllyears &&
652 y != 0)) // key must support all years needed for that leg --
653 // until no longer possible
654 {
655 auto insertion = allLegsPerKey.emplace(
656 kvKeys.first, std::vector<std::size_t>{leg});
657 if (!insertion.second)
658 insertion.first->second.push_back(leg);
659 }
660 }
661 } else {
663 "Sorry, no idea what the map key should be for the trigger leg '"
664 << m_dictionary.at(leg) << "', manual configuration is needed");
665 success = false;
666 }
667 }
668 if (!success)
669 break;
670
671 if (!allLegsPerKey.size()) {
672 if (sameKeyForAllyears) {
673 sameKeyForAllyears = false;
674 continue;
675 }
676 success = false;
677 break;
678 }
679
680 using T = decltype(allLegsPerKey)::value_type;
681 auto itrKey = std::max_element(
682 allLegsPerKey.begin(), allLegsPerKey.end(),
683 [](T& x, T& y) { return x.second.size() < y.second.size(); });
684 std::string& strLegs = legsPerKey[m_dictionary.at(itrKey->first)];
685 for (std::size_t leg : itrKey->second) {
686 int& wantedYears = legs.at(leg);
687 int supportedYears = (allKeys.at(leg).at(itrKey->first)) & wantedYears;
688 if (supportedYears != wantedYears || legsWithMultipleKeys.count(leg)) {
689 legsWithMultipleKeys.insert(leg);
690 for (int i = 0; i < 32; ++i) {
691 if (supportedYears & (1u << i)) {
692 if (strLegs.length() && strLegs.back() != ',')
693 strLegs += ',';
694 strLegs +=
695 m_dictionary.at(leg) + "[" + std::to_string(2015 + i) + "]";
696 }
697 }
698 } else {
699 if (strLegs.length() && strLegs.back() != ',')
700 strLegs += ',';
701 strLegs += m_dictionary.at(leg);
702 }
703 if (supportedYears == wantedYears)
704 legs.erase(leg);
705 else
706 wantedYears &= ~supportedYears;
707 }
708 }
709 } else {
711 for (auto& kv : legs) {
712 legsPerKey.emplace(std::to_string(legsPerKey.size()),
713 m_dictionary.at(kv.first));
714 }
715 }
716 for (auto& [key, legs] : legsPerKey) {
717 if (key ==
720 "Some of the requested triggers will result in "
721 "a default scale factor of 1 being returned");
722 }
723 }
724 if (!success)
725 legsPerKey.clear();
726 return success;
727}
#define y
#define x
static std::string toolnameForDefaultScaleFactor()
To be used with the ListOfLegsPerTool property:
std::vector< TrigDef > parseTriggerString(const std::string &triggerString, bool &success)
bool importMapKeys(const std::string &tag, std::map< std::size_t, std::map< std::size_t, int > > &keysPerLeg)
bool importAll(const std::map< std::string, std::string > &overridenThresholds={})
unsigned long long T

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_dataPeriods

std::map<std::string, std::pair<unsigned, unsigned> > TrigGlobEffCorr::ImportData::m_dataPeriods
protected

Definition at line 165 of file ImportData.h.

◆ m_dictionary

std::map<std::size_t, std::string>& TrigGlobEffCorr::ImportData::m_dictionary
protected

Definition at line 160 of file ImportData.h.

◆ m_hasher

std::hash<std::string>& TrigGlobEffCorr::ImportData::m_hasher
protected

Definition at line 161 of file ImportData.h.

◆ m_hierarchyData

std::vector<std::size_t> TrigGlobEffCorr::ImportData::m_hierarchyData
protected

Definition at line 167 of file ImportData.h.

◆ m_hierarchyMeta

std::vector<Hierarchy> TrigGlobEffCorr::ImportData::m_hierarchyMeta
protected

Definition at line 166 of file ImportData.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_parent

TrigGlobalEfficiencyCorrectionTool* TrigGlobEffCorr::ImportData::m_parent
protected

Definition at line 159 of file ImportData.h.

◆ m_triggerDefs

std::map<std::size_t, TrigDef> TrigGlobEffCorr::ImportData::m_triggerDefs
protected

Definition at line 163 of file ImportData.h.

◆ m_triggerThresholds

std::map<std::size_t, float> TrigGlobEffCorr::ImportData::m_triggerThresholds
protected

Definition at line 164 of file ImportData.h.


The documentation for this class was generated from the following files: