ATLAS Offline Software
EnhancedBiasWeightCompAlg.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 #ifndef TRIG_ENHANCEDBIASWEIGHTCOMPALG_H
6 #define TRIG_ENHANCEDBIASWEIGHTCOMPALG_H
7 
10 #include "TrigConfData/HLTMenu.h"
15 
16 #include <vector>
17 #include <string>
18 
19 #include <tbb/concurrent_hash_map.h>
20 #include <tbb/concurrent_unordered_map.h>
21 #include <tbb/concurrent_vector.h>
22 
29  public:
30 
31  EnhancedBiasWeightCompAlg(const std::string& name, ISvcLocator* svcLoc);
32 
33  virtual StatusCode initialize() override;
34  virtual StatusCode start() override;
35  virtual StatusCode execute(const EventContext& context) const override;
36  virtual StatusCode stop() override;
37 
38  private:
44  class EBChainInfo {
45  public:
47 
48  std::string getName() const {return m_id.name();}
50  double getTotalPrescale() const {return m_totalPrescale;}
51  bool getIsRandom() const {return (getName().find("HLT_noalg_L1RD") != std::string::npos);}
52  bool getIsNoPS() const {return (getName().find("noPS") != std::string::npos);}
53  bool getIsDisabled() const {return (m_totalPrescale <= 0);}
54 
55  void setTotalPrescale(const double& prescale) {m_totalPrescale = prescale;}
56 
57  private:
60 
63  };
64 
69  struct EBResult {
70  double weight {1.0};
72  };
73 
74  SG::ReadHandleKey<TrigConf::HLTMenu> m_HLTMenuKey{this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu"};
75  PublicToolHandle<Trig::TrigDecisionTool> m_tdt{this, "TrigDecisionTool", "Trig::TrigDecisionTool/TrigDecisionTool", "TrigDecisionTool"};
76  SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> m_finalDecisionKey{ this, "FinalDecisionKey", "", "Final stage of all decisions" };
77 
78  SG::ReadCondHandleKey<TrigConf::HLTPrescalesSet> m_HLTPrescaleSetInputKey {this, "HLTPrescales", "HLTPrescales", "HLT prescales set"};
79  SG::ReadCondHandleKey<TrigConf::L1PrescalesSet> m_L1PrescaleSetInputKey {this, "L1Prescales", "L1Prescales", "L1 prescales set"};
80 
81  Gaudi::Property<std::map<std::string, std::vector<std::string>>> m_chainToHLTSeed {this, "ChainToItemMap", {}, "Map for HLT seeded chains" };
82 
84  EBResult calculateEBWeight(const std::vector<EBChainInfo>& EBChains) const;
85 
87  StatusCode fillTotalPrescaleForChains(const EventContext& context, std::vector<EBChainInfo>& EBChains) const;
88 
90  std::vector<EBChainInfo> getPassedEBChains() const;
91 
93  bool checkIfTriggeredByRandomChain(const std::vector<EBChainInfo>& EBChain) const;
94 
96  std::vector<std::string> parseItems(const std::string& itemStr);
97 
99  std::vector<HLT::Identifier> m_EBChainIds;
100 
102  std::map<HLT::Identifier, std::vector<std::string>> m_EBChainIdToItem;
103 
105  mutable std::string m_outputFilename ATLAS_THREAD_SAFE;
106 
108  mutable tbb::concurrent_vector<std::pair<double, bool>> m_ebWeights ATLAS_THREAD_SAFE;
109 
111  mutable tbb::concurrent_unordered_map<int, double> m_eventToWeight ATLAS_THREAD_SAFE;
112 
113 };
114 
115 #endif //TRIG_ENHANCEDBIASWEIGHTCOMPALG_H
HLTPrescalesSet.h
EnhancedBiasWeightCompAlg::EBChainInfo::getName
std::string getName() const
Definition: EnhancedBiasWeightCompAlg.h:48
EnhancedBiasWeightCompAlg::EBChainInfo::EBChainInfo
EBChainInfo(const HLT::Identifier &id)
Definition: EnhancedBiasWeightCompAlg.h:46
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
EnhancedBiasWeightCompAlg::getPassedEBChains
std::vector< EBChainInfo > getPassedEBChains() const
Get list of Enhanced Bias chains that cound have passed.
Definition: EnhancedBiasWeightCompAlg.cxx:174
EnhancedBiasWeightCompAlg::parseItems
std::vector< std::string > parseItems(const std::string &itemStr)
Parse list of l1 items.
Definition: EnhancedBiasWeightCompAlg.cxx:216
EnhancedBiasWeightCompAlg::m_EBChainIds
std::vector< HLT::Identifier > m_EBChainIds
Available EB chains' IDs from HLT Menu.
Definition: EnhancedBiasWeightCompAlg.h:99
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
EnhancedBiasWeightCompAlg::m_EBChainIdToItem
std::map< HLT::Identifier, std::vector< std::string > > m_EBChainIdToItem
L1 items for EB chains from HLT Menu.
Definition: EnhancedBiasWeightCompAlg.h:102
EnhancedBiasWeightCompAlg::m_HLTMenuKey
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
Definition: EnhancedBiasWeightCompAlg.h:74
EnhancedBiasWeightCompAlg::EBChainInfo::getIsRandom
bool getIsRandom() const
Definition: EnhancedBiasWeightCompAlg.h:51
EnhancedBiasWeightCompAlg::start
virtual StatusCode start() override
Definition: EnhancedBiasWeightCompAlg.cxx:30
TrigDecisionTool.h
L1PrescalesSet.h
SG::ReadHandleKey< TrigConf::HLTMenu >
EnhancedBiasWeightCompAlg::checkIfTriggeredByRandomChain
bool checkIfTriggeredByRandomChain(const std::vector< EBChainInfo > &EBChain) const
Check if any of random chains passed.
Definition: EnhancedBiasWeightCompAlg.cxx:210
EnhancedBiasWeightCompAlg::fillTotalPrescaleForChains
StatusCode fillTotalPrescaleForChains(const EventContext &context, std::vector< EBChainInfo > &EBChains) const
Retrieve total prescales (L1 * HLT) for chains into map.
Definition: EnhancedBiasWeightCompAlg.cxx:123
EnhancedBiasWeightCompAlg::calculateEBWeight
EBResult calculateEBWeight(const std::vector< EBChainInfo > &EBChains) const
Calculate EB result based on total prescales of chains.
Definition: EnhancedBiasWeightCompAlg.cxx:152
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
EnhancedBiasWeightCompAlg
Compute Enhanced Bias weights for the events.
Definition: EnhancedBiasWeightCompAlg.h:28
TrigCompositeUtils.h
EnhancedBiasWeightCompAlg::EBChainInfo::m_id
HLT::Identifier m_id
HLTID of the chain.
Definition: EnhancedBiasWeightCompAlg.h:59
EnhancedBiasWeightCompAlg::ATLAS_THREAD_SAFE
tbb::concurrent_unordered_map< int, double > m_eventToWeight ATLAS_THREAD_SAFE
Map of event number to index in m_ebWeights vector to be saved in xml.
Definition: EnhancedBiasWeightCompAlg.h:111
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EnhancedBiasWeightCompAlg::m_chainToHLTSeed
Gaudi::Property< std::map< std::string, std::vector< std::string > > > m_chainToHLTSeed
Definition: EnhancedBiasWeightCompAlg.h:81
EnhancedBiasWeightCompAlg::ATLAS_THREAD_SAFE
tbb::concurrent_vector< std::pair< double, bool > > m_ebWeights ATLAS_THREAD_SAFE
List of calculated weight + unbiased flag pairs to be saved in xml.
Definition: EnhancedBiasWeightCompAlg.h:108
EnhancedBiasWeightCompAlg::EBChainInfo::setTotalPrescale
void setTotalPrescale(const double &prescale)
Definition: EnhancedBiasWeightCompAlg.h:55
EnhancedBiasWeightCompAlg::EBResult
Store result of EB weight calculation.
Definition: EnhancedBiasWeightCompAlg.h:69
EnhancedBiasWeightCompAlg::ATLAS_THREAD_SAFE
std::string m_outputFilename ATLAS_THREAD_SAFE
Name of xml output file.
Definition: EnhancedBiasWeightCompAlg.h:105
EnhancedBiasWeightCompAlg::m_L1PrescaleSetInputKey
SG::ReadCondHandleKey< TrigConf::L1PrescalesSet > m_L1PrescaleSetInputKey
Definition: EnhancedBiasWeightCompAlg.h:79
EnhancedBiasWeightCompAlg::EBChainInfo::m_totalPrescale
double m_totalPrescale
Value of total prescale L1 * HLT.
Definition: EnhancedBiasWeightCompAlg.h:62
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
EnhancedBiasWeightCompAlg::EBChainInfo::getTotalPrescale
double getTotalPrescale() const
Definition: EnhancedBiasWeightCompAlg.h:50
TrigCompositeContainer.h
EnhancedBiasWeightCompAlg::EBResult::weight
double weight
Definition: EnhancedBiasWeightCompAlg.h:70
EnhancedBiasWeightCompAlg::EBResult::isUnbiased
uint8_t isUnbiased
Definition: EnhancedBiasWeightCompAlg.h:71
AthReentrantAlgorithm.h
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
EnhancedBiasWeightCompAlg::EBChainInfo
Store necessary information for weight computing for Enhanced Bias chain.
Definition: EnhancedBiasWeightCompAlg.h:44
EnhancedBiasWeightCompAlg::EBChainInfo::getId
TrigCompositeUtils::DecisionID getId() const
Definition: EnhancedBiasWeightCompAlg.h:49
EnhancedBiasWeightCompAlg::m_tdt
PublicToolHandle< Trig::TrigDecisionTool > m_tdt
Definition: EnhancedBiasWeightCompAlg.h:75
SG::ReadCondHandleKey< TrigConf::HLTPrescalesSet >
EnhancedBiasWeightCompAlg::stop
virtual StatusCode stop() override
Definition: EnhancedBiasWeightCompAlg.cxx:51
EnhancedBiasWeightCompAlg::initialize
virtual StatusCode initialize() override
Definition: EnhancedBiasWeightCompAlg.cxx:14
EnhancedBiasWeightCompAlg::EBChainInfo::getIsDisabled
bool getIsDisabled() const
Definition: EnhancedBiasWeightCompAlg.h:53
HLT::Identifier::name
std::string name() const
reports human redable name if it is enabled or, empty string
Definition: HLTIdentifier.cxx:14
EnhancedBiasWeightCompAlg::EBChainInfo::getIsNoPS
bool getIsNoPS() const
Definition: EnhancedBiasWeightCompAlg.h:52
HLTMenu.h
EnhancedBiasWeightCompAlg::m_HLTPrescaleSetInputKey
SG::ReadCondHandleKey< TrigConf::HLTPrescalesSet > m_HLTPrescaleSetInputKey
Definition: EnhancedBiasWeightCompAlg.h:78
EnhancedBiasWeightCompAlg::m_finalDecisionKey
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_finalDecisionKey
Definition: EnhancedBiasWeightCompAlg.h:76
EnhancedBiasWeightCompAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: EnhancedBiasWeightCompAlg.cxx:80
EnhancedBiasWeightCompAlg::EnhancedBiasWeightCompAlg
EnhancedBiasWeightCompAlg(const std::string &name, ISvcLocator *svcLoc)
Definition: EnhancedBiasWeightCompAlg.cxx:11