ATLAS Offline Software
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
EnhancedBiasWeightCompAlg Class Reference

Compute Enhanced Bias weights for the events. More...

#include <EnhancedBiasWeightCompAlg.h>

Inheritance diagram for EnhancedBiasWeightCompAlg:
Collaboration diagram for EnhancedBiasWeightCompAlg:

Classes

class  EBChainInfo
 Store necessary information for weight computing for Enhanced Bias chain. More...
 
class  EBResult
 Store result of EB weight calculation. More...
 

Public Member Functions

 EnhancedBiasWeightCompAlg (const std::string &name, ISvcLocator *svcLoc)
 
virtual StatusCode initialize () override
 
virtual StatusCode start () override
 
virtual StatusCode execute (const EventContext &context) const override
 
virtual StatusCode stop () override
 
virtual StatusCode sysInitialize () override
 Override sysInitialize. More...
 
virtual bool isClonable () const override
 Specify if the algorithm is clonable. More...
 
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant. More...
 
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm. More...
 
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies. More...
 
virtual bool filterPassed (const EventContext &ctx) const
 
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

EBResult calculateEBWeight (const std::vector< EBChainInfo > &EBChains) const
 Calculate EB result based on total prescales of chains. More...
 
StatusCode fillTotalPrescaleForChains (const EventContext &context, std::vector< EBChainInfo > &EBChains) const
 Retrieve total prescales (L1 * HLT) for chains into map. More...
 
std::vector< EBChainInfogetPassedEBChains () const
 Get list of Enhanced Bias chains that cound have passed. More...
 
bool checkIfTriggeredByRandomChain (const std::vector< EBChainInfo > &EBChain) const
 Check if any of random chains passed. More...
 
std::vector< std::string > parseItems (const std::string &itemStr)
 Parse list of l1 items. More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

SG::ReadHandleKey< TrigConf::HLTMenum_HLTMenuKey {this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu"}
 
PublicToolHandle< Trig::TrigDecisionToolm_tdt {this, "TrigDecisionTool", "Trig::TrigDecisionTool/TrigDecisionTool", "TrigDecisionTool"}
 
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainerm_finalDecisionKey { this, "FinalDecisionKey", "", "Final stage of all decisions" }
 
SG::ReadCondHandleKey< TrigConf::HLTPrescalesSetm_HLTPrescaleSetInputKey {this, "HLTPrescales", "HLTPrescales", "HLT prescales set"}
 
SG::ReadCondHandleKey< TrigConf::L1PrescalesSetm_L1PrescaleSetInputKey {this, "L1Prescales", "L1Prescales", "L1 prescales set"}
 
Gaudi::Property< std::map< std::string, std::vector< std::string > > > m_chainToHLTSeed {this, "ChainToItemMap", {}, "Map for HLT seeded chains" }
 
std::vector< HLT::Identifierm_EBChainIds
 Available EB chains' IDs from HLT Menu. More...
 
std::map< HLT::Identifier, std::vector< std::string > > m_EBChainIdToItem
 L1 items for EB chains from HLT Menu. More...
 
std::string m_outputFilename ATLAS_THREAD_SAFE
 Name of xml output file. More...
 
tbb::concurrent_vector< std::pair< double, bool > > m_ebWeights ATLAS_THREAD_SAFE
 List of calculated weight + unbiased flag pairs to be saved in xml. More...
 
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. More...
 
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks. More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Compute Enhanced Bias weights for the events.

Definition at line 28 of file EnhancedBiasWeightCompAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ EnhancedBiasWeightCompAlg()

EnhancedBiasWeightCompAlg::EnhancedBiasWeightCompAlg ( const std::string &  name,
ISvcLocator *  svcLoc 
)

Definition at line 11 of file EnhancedBiasWeightCompAlg.cxx.

12  : AthReentrantAlgorithm(name, svcLoc) {}

Member Function Documentation

◆ calculateEBWeight()

EnhancedBiasWeightCompAlg::EBResult EnhancedBiasWeightCompAlg::calculateEBWeight ( const std::vector< EBChainInfo > &  EBChains) const
private

Calculate EB result based on total prescales of chains.

Definition at line 152 of file EnhancedBiasWeightCompAlg.cxx.

152  {
153 
154  double weight = 1.;
155 
156  for (const EBChainInfo& chain : EBChains){
157  if (chain.getIsDisabled()){
158  ATH_MSG_DEBUG("Chain " << chain.getName() << " disabled");
159  continue;
160  }
161  ATH_MSG_DEBUG("Chain " << chain.getName() << " total prescale " << chain.getTotalPrescale());
162  weight *= 1. - ( 1. / chain.getTotalPrescale() );
163  }
164 
165  weight = (std::fabs(1.0 - weight) < 1e-10) ? 0. : (1. / (1. - weight));
166 
167  // Check if the event was triggered by EB noalg random chain
168  bool isUnbiased = checkIfTriggeredByRandomChain(EBChains);
169 
170  return {double(weight), isUnbiased};
171 }

◆ cardinality()

unsigned int AthReentrantAlgorithm::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Override this to return 0 for reentrant algorithms.

Definition at line 55 of file AthReentrantAlgorithm.cxx.

56 {
57  return 0;
58 }

◆ checkIfTriggeredByRandomChain()

bool EnhancedBiasWeightCompAlg::checkIfTriggeredByRandomChain ( const std::vector< EBChainInfo > &  EBChain) const
private

Check if any of random chains passed.

Definition at line 210 of file EnhancedBiasWeightCompAlg.cxx.

210  {
211 
212  return std::find_if (EBChains.begin(), EBChains.end(),
213  [](const EBChainInfo& chain) -> bool { return chain.getIsRandom(); }) != EBChains.end();
214 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ execute()

StatusCode EnhancedBiasWeightCompAlg::execute ( const EventContext &  context) const
overridevirtual

Definition at line 80 of file EnhancedBiasWeightCompAlg.cxx.

80  {
81 
82  // Retrieve information about EB chains that could have passed
83  std::vector<EBChainInfo> EBChains = getPassedEBChains();
84 
85  ATH_MSG_DEBUG("Number of eb chains that passed int this event: " << EBChains.size());
86 
87  // None of EB chains passed the algorithm
88  if (EBChains.empty()) {
89  ATH_MSG_DEBUG("Empty event!");
90  return StatusCode::SUCCESS;
91  }
92 
93  // Retrieve L1 and HLT prescales
94  ATH_CHECK( fillTotalPrescaleForChains(context, EBChains) );
95 
96  // Calculate EB weight
97  EBResult result = calculateEBWeight(EBChains);
98 
99  // Save output values: EBWeight and EBUnbiased to xml file
100  // Create filename (run number necessary)
101  if ( context.evt() == 0 ){
102  std::stringstream filename;
103  filename << "EnhancedBiasWeights_" << context.eventID().run_number() << ".xml";
104  m_outputFilename = filename.str();
105  ATH_MSG_INFO("The output file name is " << m_outputFilename);
106  }
107 
108  // Save to containers to be saved to xml
109  auto resultPair = std::pair<double, bool>(result.weight, result.isUnbiased);
110  auto newPair = std::find(m_ebWeights.begin(), m_ebWeights.end(), resultPair);
111  if (newPair == m_ebWeights.end()){
112  newPair = m_ebWeights.push_back(resultPair);
113  ATH_MSG_DEBUG("New weight value: " << result.weight << " with id " << (m_ebWeights.size()-1));
114  }
115  m_eventToWeight[context.eventID().event_number()] = std::distance(m_ebWeights.begin(), newPair);
116 
117  ATH_MSG_DEBUG("EnhacedBias EBWeight: " << result.weight << " EnhacedBias isUnbiased: " << (bool) result.isUnbiased );
118 
119  return StatusCode::SUCCESS;
120 }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthReentrantAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 79 of file AthReentrantAlgorithm.cxx.

80 {
81  // If we didn't find any symlinks to add, just return the collection
82  // from the base class. Otherwise, return the extended collection.
83  if (!m_extendedExtraObjects.empty()) {
85  }
86  return Algorithm::extraOutputDeps();
87 }

◆ fillTotalPrescaleForChains()

StatusCode EnhancedBiasWeightCompAlg::fillTotalPrescaleForChains ( const EventContext &  context,
std::vector< EBChainInfo > &  EBChains 
) const
private

Retrieve total prescales (L1 * HLT) for chains into map.

Definition at line 123 of file EnhancedBiasWeightCompAlg.cxx.

123  {
124 
126  ATH_CHECK( HLTPrescalesSet.isValid() );
127 
129  ATH_CHECK( L1PrescalesSet.isValid() );
130 
131  for (EBChainInfo& chain : EBChains) {
132  if ( not HLTPrescalesSet->prescale(chain.getId()).enabled ){
133  chain.setTotalPrescale(-1);
134  continue;
135  }
136 
137  double HLTPrescale = HLTPrescalesSet->prescale(chain.getId()).prescale;
138  double L1Prescale = 1.0;
139  if (!chain.getIsNoPS()) {
140  for (const std::string& item : m_EBChainIdToItem.at(chain.getId())){
141  L1Prescale *= L1PrescalesSet->prescale(item).prescale;
142  }
143  }
144 
145  chain.setTotalPrescale(HLTPrescale * L1Prescale);
146  }
147 
148  return StatusCode::SUCCESS;
149 }

◆ filterPassed()

virtual bool AthReentrantAlgorithm::filterPassed ( const EventContext &  ctx) const
inlinevirtualinherited

Definition at line 135 of file AthReentrantAlgorithm.h.

135  {
136  return execState( ctx ).filterPassed();
137  }

◆ getPassedEBChains()

std::vector< EnhancedBiasWeightCompAlg::EBChainInfo > EnhancedBiasWeightCompAlg::getPassedEBChains ( ) const
private

Get list of Enhanced Bias chains that cound have passed.

Definition at line 174 of file EnhancedBiasWeightCompAlg.cxx.

174  {
175 
176  std::vector<EBChainInfo> passedEBChains;
177 
178  for (const HLT::Identifier& chainId : m_EBChainIds) {
179  std::string chainName = HLT::Identifier(chainId).name();
180 
181  bool ebChainIsSeeded = false;
182  // For chains with HLT seed discrimintaion check if one of the seeds could pass
183  if ((chainName.find("_eb_") != std::string::npos) && (!m_chainToHLTSeed.empty())){
184  for (const std::string& l1Item : m_chainToHLTSeed.value().at(chainName)) {
185  if (m_tdt->isPassedBits(l1Item) & TrigDefs::L1_isPassedBeforePrescale) {
186  ebChainIsSeeded = true;
187  break;
188  }
189  }
190  } else if (chainName.find("L1RD3") != std::string::npos){
191  // For the random items, we need to look at HLT decision
192  ebChainIsSeeded = m_tdt->isPassed(chainName);
193  } else {
194  for (const std::string& l1Item : m_EBChainIdToItem.at(chainId)) {
195  if (m_tdt->isPassedBits(l1Item) & TrigDefs::L1_isPassedBeforePrescale) {
196  ebChainIsSeeded = true;
197  break;
198  }
199  }
200  }
201  if (ebChainIsSeeded) {
202  passedEBChains.push_back(EBChainInfo(HLT::Identifier(chainId)));
203  }
204  }
205 
206  return passedEBChains;
207 }

◆ initialize()

StatusCode EnhancedBiasWeightCompAlg::initialize ( )
overridevirtual

Definition at line 14 of file EnhancedBiasWeightCompAlg.cxx.

14  {
15 
17  if (!m_finalDecisionKey.empty()) {
18  ATH_CHECK( m_finalDecisionKey.initialize() );
19  }
20 
23 
24  ATH_CHECK( m_tdt.retrieve() );
25 
26  return StatusCode::SUCCESS;
27 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

bool AthReentrantAlgorithm::isClonable ( ) const
overridevirtualinherited

◆ msg() [1/2]

MsgStream& AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Gaudi::Algorithm >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ parseItems()

std::vector< std::string > EnhancedBiasWeightCompAlg::parseItems ( const std::string &  itemStr)
private

Parse list of l1 items.

Definition at line 216 of file EnhancedBiasWeightCompAlg.cxx.

216  {
217 
218  std::vector<std::string> items;
219 
220  std::stringstream itemStream (itemStr);
221  std::string item;
222 
223  while (std::getline(itemStream, item, ',')) {
224  items.push_back(item);
225  }
226 
227  return items;
228 }

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ setFilterPassed()

virtual void AthReentrantAlgorithm::setFilterPassed ( bool  state,
const EventContext &  ctx 
) const
inlinevirtualinherited

Definition at line 139 of file AthReentrantAlgorithm.h.

139  {
140  execState( ctx ).setFilterPassed( state );
141  }

◆ start()

StatusCode EnhancedBiasWeightCompAlg::start ( )
overridevirtual

Definition at line 30 of file EnhancedBiasWeightCompAlg.cxx.

30  {
31 
33  ATH_CHECK( hltMenuHandle.isValid() );
34 
35  // Save ids of EB chains - that contain "_eb_"
36  m_EBChainIds = std::vector<HLT::Identifier>();
37  m_EBChainIds = std::vector<HLT::Identifier>();
38  for (const TrigConf::Chain& chain : *hltMenuHandle){
39  if (chain.name() == "HLT_noalg_eb_L1All") continue; // this is a special chain
40  std::vector<std::string> streams = chain.streams();
41  if (std::find(streams.begin(), streams.end(), "EnhancedBias") != streams.end()){
42  auto chainId = HLT::Identifier(chain.name());
43  m_EBChainIds.push_back(chainId);
44  m_EBChainIdToItem[chainId] = parseItems(chain.l1item());
45  }
46  }
47 
48  return StatusCode::SUCCESS;
49 }

◆ stop()

StatusCode EnhancedBiasWeightCompAlg::stop ( )
overridevirtual

Definition at line 51 of file EnhancedBiasWeightCompAlg.cxx.

51  {
52 
53  // Save weights and events mapping to xml
54  if (!m_outputFilename.empty()){
55  std::ofstream outputStream;
56  outputStream.open(m_outputFilename);
57  outputStream << "<?xml version=\"1.0\" encoding=\"us-ascii\"?>" << std::endl;
58  outputStream << "<run>" << std::endl;
59  outputStream << "<weights>" << std::endl;
60 
61  for (size_t i = 0; i < m_ebWeights.size(); ++i){
62  outputStream << "<weight id=\"" << i << "\" value=\"" << m_ebWeights[i].first << "\" unbiased=\"" << m_ebWeights[i].second << "\"/>" << std::endl;
63  }
64 
65  outputStream << "</weights>" << std::endl;
66  outputStream << "<events>" << std::endl;
67 
68  for (const auto& event : m_eventToWeight){
69  outputStream << "<e n=\"" << event.first << "\" w=\"" << event.second << "\"/>" << std::endl;
70  }
71 
72  outputStream << "</events>" << std::endl;
73  outputStream << "</run>" << std::endl;
74  outputStream.close();
75  }
76 
77  return StatusCode::SUCCESS;
78 }

◆ sysExecute()

StatusCode AthReentrantAlgorithm::sysExecute ( const EventContext &  ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 67 of file AthReentrantAlgorithm.cxx.

68 {
69  return Gaudi::Algorithm::sysExecute (ctx);
70 }

◆ sysInitialize()

StatusCode AthReentrantAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in InputMakerBase, and HypoBase.

Definition at line 96 of file AthReentrantAlgorithm.cxx.

96  {
98 
99  if (sc.isFailure()) {
100  return sc;
101  }
102 
103  ServiceHandle<ICondSvc> cs("CondSvc",name());
104  for (auto h : outputHandles()) {
105  if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
106  // do this inside the loop so we don't create the CondSvc until needed
107  if ( cs.retrieve().isFailure() ) {
108  ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
109  return StatusCode::SUCCESS;
110  }
111  if (cs->regHandle(this,*h).isFailure()) {
112  sc = StatusCode::FAILURE;
113  ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
114  << " with CondSvc");
115  }
116  }
117  }
118  return sc;
119 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/3]

std::string m_outputFilename EnhancedBiasWeightCompAlg::ATLAS_THREAD_SAFE
mutableprivate

Name of xml output file.

Definition at line 105 of file EnhancedBiasWeightCompAlg.h.

◆ ATLAS_THREAD_SAFE [2/3]

tbb::concurrent_vector<std::pair<double, bool> > m_ebWeights EnhancedBiasWeightCompAlg::ATLAS_THREAD_SAFE
mutableprivate

List of calculated weight + unbiased flag pairs to be saved in xml.

Definition at line 108 of file EnhancedBiasWeightCompAlg.h.

◆ ATLAS_THREAD_SAFE [3/3]

tbb::concurrent_unordered_map<int, double> m_eventToWeight EnhancedBiasWeightCompAlg::ATLAS_THREAD_SAFE
mutableprivate

Map of event number to index in m_ebWeights vector to be saved in xml.

Definition at line 111 of file EnhancedBiasWeightCompAlg.h.

◆ m_chainToHLTSeed

Gaudi::Property<std::map<std::string, std::vector<std::string> > > EnhancedBiasWeightCompAlg::m_chainToHLTSeed {this, "ChainToItemMap", {}, "Map for HLT seeded chains" }
private

Definition at line 81 of file EnhancedBiasWeightCompAlg.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_EBChainIds

std::vector<HLT::Identifier> EnhancedBiasWeightCompAlg::m_EBChainIds
private

Available EB chains' IDs from HLT Menu.

Definition at line 99 of file EnhancedBiasWeightCompAlg.h.

◆ m_EBChainIdToItem

std::map<HLT::Identifier, std::vector<std::string> > EnhancedBiasWeightCompAlg::m_EBChainIdToItem
private

L1 items for EB chains from HLT Menu.

Definition at line 102 of file EnhancedBiasWeightCompAlg.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthReentrantAlgorithm::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 153 of file AthReentrantAlgorithm.h.

◆ m_finalDecisionKey

SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> EnhancedBiasWeightCompAlg::m_finalDecisionKey { this, "FinalDecisionKey", "", "Final stage of all decisions" }
private

Definition at line 76 of file EnhancedBiasWeightCompAlg.h.

◆ m_HLTMenuKey

SG::ReadHandleKey<TrigConf::HLTMenu> EnhancedBiasWeightCompAlg::m_HLTMenuKey {this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu"}
private

Definition at line 74 of file EnhancedBiasWeightCompAlg.h.

◆ m_HLTPrescaleSetInputKey

SG::ReadCondHandleKey<TrigConf::HLTPrescalesSet> EnhancedBiasWeightCompAlg::m_HLTPrescaleSetInputKey {this, "HLTPrescales", "HLTPrescales", "HLT prescales set"}
private

Definition at line 78 of file EnhancedBiasWeightCompAlg.h.

◆ m_L1PrescaleSetInputKey

SG::ReadCondHandleKey<TrigConf::L1PrescalesSet> EnhancedBiasWeightCompAlg::m_L1PrescaleSetInputKey {this, "L1Prescales", "L1Prescales", "L1 prescales set"}
private

Definition at line 79 of file EnhancedBiasWeightCompAlg.h.

◆ m_tdt

PublicToolHandle<Trig::TrigDecisionTool> EnhancedBiasWeightCompAlg::m_tdt {this, "TrigDecisionTool", "Trig::TrigDecisionTool/TrigDecisionTool", "TrigDecisionTool"}
private

Definition at line 75 of file EnhancedBiasWeightCompAlg.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
get_generator_info.result
result
Definition: get_generator_info.py:21
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
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
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
EnhancedBiasWeightCompAlg::m_EBChainIds
std::vector< HLT::Identifier > m_EBChainIds
Available EB chains' IDs from HLT Menu.
Definition: EnhancedBiasWeightCompAlg.h:99
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
python.outputTest_v2.streams
streams
Definition: outputTest_v2.py:55
EnhancedBiasWeightCompAlg::m_HLTMenuKey
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
Definition: EnhancedBiasWeightCompAlg.h:74
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
AthCommonDataStore::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition: AthCommonDataStore.h:380
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
RunGeantinoStepRecordingITk.outputStream
outputStream
Definition: RunGeantinoStepRecordingITk.py:126
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
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
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:27
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
AthCommonDataStore
Definition: AthCommonDataStore.h:52
AthReentrantAlgorithm::AthReentrantAlgorithm
AthReentrantAlgorithm()
Default constructor:
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
EnhancedBiasWeightCompAlg::m_chainToHLTSeed
Gaudi::Property< std::map< std::string, std::vector< std::string > > > m_chainToHLTSeed
Definition: EnhancedBiasWeightCompAlg.h:81
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
EnhancedBiasWeightCompAlg::m_L1PrescaleSetInputKey
SG::ReadCondHandleKey< TrigConf::L1PrescalesSet > m_L1PrescaleSetInputKey
Definition: EnhancedBiasWeightCompAlg.h:79
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
AthReentrantAlgorithm::m_extendedExtraObjects
DataObjIDColl m_extendedExtraObjects
Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
Definition: AthReentrantAlgorithm.h:153
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AthReentrantAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Override sysInitialize.
Definition: AthReentrantAlgorithm.cxx:96
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
item
Definition: ItemListSvc.h:43
EnhancedBiasWeightCompAlg::m_tdt
PublicToolHandle< Trig::TrigDecisionTool > m_tdt
Definition: EnhancedBiasWeightCompAlg.h:75
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
HLT::Identifier::name
std::string name() const
reports human redable name if it is enabled or, empty string
Definition: HLTIdentifier.cxx:14
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
EnhancedBiasWeightCompAlg::m_HLTPrescaleSetInputKey
SG::ReadCondHandleKey< TrigConf::HLTPrescalesSet > m_HLTPrescaleSetInputKey
Definition: EnhancedBiasWeightCompAlg.h:78
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
TrigConf::Chain
HLT chain configuration.
Definition: TrigConfData/TrigConfData/HLTChain.h:18
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
EnhancedBiasWeightCompAlg::m_finalDecisionKey
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_finalDecisionKey
Definition: EnhancedBiasWeightCompAlg.h:76
fitman.k
k
Definition: fitman.py:528
ServiceHandle< ICondSvc >