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 733 of file ImportData.cxx.

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

519 {
520 // note: 'success' is not set to 'true', only downgraded to 'false' if needed
521 if (leg.length() >= 2 && leg[0] == 'e' && leg[1] >= '1' && leg[1] <= '9')
523 else if (leg.length() >= 3 && leg[0] == 'm' && leg[1] == 'u' &&
524 leg[2] >= '1' && leg[2] <= '9')
525 return xAOD::Type::Muon;
526 else if (leg.length() >= 3 && leg[0] == 'g' && leg[1] >= '1' && leg[1] <= '9')
527 return xAOD::Type::Photon;
528 else if (leg.length() >= 4 && leg[0] == 't' && leg[1] == 'a' &&
529 leg[2] == 'u' && leg[3] >= '1' && leg[3] <= '9')
530 return xAOD::Type::Tau;
531 success = false;
532 return xAOD::Type::Other;
533}
@ 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 535 of file ImportData.cxx.

536 {
537 // note: 'success' is not set to 'true', only downgraded to 'false' if needed
538 auto itr = m_dictionary.find(leg);
539 if (itr != m_dictionary.end()) {
540 return associatedLeptonFlavour(itr->second, success);
541 }
542 success = false;
543 return xAOD::Type::Other;
544}
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 486 of file ImportData.cxx.

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

◆ 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.
static Double_t ss
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 if (year < 2015) {
463 ATH_MSG_ERROR("Malformed line from TrigGlobalEfficiencyCorrection/MapKeys.cfg: " << line);
464 return false;
465 }
466 year = 1 << (year - 2015);
467 std::size_t leg = m_hasher(token);
468 auto& keys = keysPerLeg[leg];
469 while (ss >> token) {
470 std::size_t h = m_hasher(token);
471 auto insertion = keys.emplace(h, year);
472 if (insertion.second)
473 m_dictionary.emplace(h, token);
474 else
475 insertion.first->second |= year;
476 }
477 }
478 if (!keysPerLeg.size()) {
479 ATH_MSG_ERROR("Unable to import the available map keys for the version "
480 << version);
481 return false;
482 }
483 return true;
484}
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(pathvar)
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 546 of file ImportData.cxx.

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

◆ 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 593 of file ImportData.cxx.

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