|
ATLAS Offline Software
|
Tool to calculate data-driven rates using EnhancedBias datasets.
More...
#include <EnhancedBiasWeighter.h>
|
| EnhancedBiasWeighter (const std::string &name) |
|
virtual StatusCode | initialize () override |
| Initialize is required by AsgTool base class. More...
|
|
virtual StatusCode | finalize () override |
|
virtual StatusCode | addBranches () const override |
| Decorate the AOD with EnhancedBias weighting quantities such that no CVMFS or DB access is required on subsequent passes through the dAOD to perform rates. More...
|
|
virtual double | getEBWeight (const xAOD::EventInfo *eventInfo) const override |
|
virtual double | getEBWeight (const EventContext &context) const override |
|
virtual double | getEBLiveTime (const xAOD::EventInfo *eventInfo) const override |
|
virtual double | getEBLiveTime (const EventContext &context) const override |
|
virtual double | getLBLength (const xAOD::EventInfo *eventInfo) const override |
|
virtual double | getLBLength (const EventContext &context) const override |
|
virtual double | getLBLumi (const xAOD::EventInfo *eventInfo) const override |
|
virtual double | getLBLumi (const EventContext &context) const override |
|
virtual double | getAverageLumi () const override |
|
virtual double | getAverageMu () const override |
|
virtual double | getDeadtime (const int lumiblock=-1) const override |
|
virtual uint32_t | getPairedBunches () const override |
|
virtual StatusCode | getDistanceIntoTrain (const xAOD::EventInfo *eventInfo, uint32_t &distance) const override |
|
virtual uint32_t | getRunNumber () const override |
|
virtual bool | isUnbiasedEvent (const xAOD::EventInfo *eventInfo) const override |
|
virtual bool | isGoodLB (const xAOD::EventInfo *eventInfo) const override |
|
virtual bool | isGoodLB (const EventContext &context) const override |
|
virtual bool | isMC () const override |
|
virtual std::unordered_map< std::string, ChainDetail > | parsePrescaleXML (const std::string &prescaleXML) const override |
| Parse a presscale XML and return a ordered summary of its content To make most use of the XML parsing available already in this class. More...
|
|
virtual const std::vector< int32_t > & | getBunchGroups () const override |
|
virtual void | print () const |
| Print the state of the tool. More...
|
|
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 | sysInitialize () override |
| Perform system initialization for an algorithm. 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 |
|
|
SG::ReadCondHandleKey< BunchCrossingCondData > | m_bunchCrossingKey {this, "BunchCrossingKey", "BunchCrossingData", "Key BunchCrossing CDO" } |
| Tool to get distance into bunch train. More...
|
|
Gaudi::Property< uint32_t > | m_runNumber {this, "RunNumber", 0, "Run we're processing (if data), needed at initialize to locate and read in extra configuration."} |
|
Gaudi::Property< bool > | m_errorOnMissingEBWeights {this, "ErrorOnMissingEBWeights", false, "If true, Throws error if EB weights are missing."} |
|
Gaudi::Property< bool > | m_enforceEBGRL {this, "EnforceEBGRL", true, "Each Enhanced Bias run has a 'good run list' style veto on some LB. If this flag is true, events in these LB get weight 0"} |
|
Gaudi::Property< bool > | m_useBunchCrossingData {this, "UseBunchCrossingData", true, "BunchCrossing data requires CONDBR2 access. Can be disabled here if this is a problem."} |
|
Gaudi::Property< bool > | m_isMC {this, "IsMC", false, "MC mode? If so we need a cross section and filter efficiency"} |
|
Gaudi::Property< double > | m_mcCrossSection {this, "MCCrossSection", 0.0, "If running over MC. The process cross section in nb (AMI gives thins in nb)"} |
|
Gaudi::Property< double > | m_mcFilterEfficiency {this, "MCFilterEfficiency", 1.0, "If running over MC. The process filter efficiency (0.0-1.0)"} |
|
Gaudi::Property< double > | m_mcKFactor {this, "MCKFactor", 1.0, "If running over MC. The process filter efficiency (0.0-1.0)"} |
|
Gaudi::Property< bool > | m_mcIgnoreGeneratorWeights {this, "MCIgnoreGeneratorWeights", false, "If running over MC. Flag to ignore the generator weight."} |
|
Gaudi::Property< double > | m_inelasticCrossSection {this, "InelasticCrossSection", 8e-26, "Inelastic cross section in units cm^2. Default 80 mb at 13 TeV."} |
|
Gaudi::Property< std::string > | m_weightsDirectory {this, "EBWeightsDirectory", "", "Path to directory with EB XML weights files, if empty they will be read from calibration area"} |
|
double | m_deadtime |
| Online deadtime to correct for in rate prediction. More...
|
|
uint32_t | m_pairedBunches |
| Online number of paired bunches. More...
|
|
double | m_mcModifiedCrossSection |
| Product of xsec, filter & kfactor. More...
|
|
std::unordered_map< uint64_t, int32_t > | m_eventNumberToIdMap |
| Map event number to a weighting ID. More...
|
|
std::unordered_map< uint32_t, float > m_eventLivetime | ATLAS_THREAD_SAFE |
| Cache of per-event livetime as a function of LB [LB -> effective walltime per event]. More...
|
|
std::mutex | m_mutex |
| Protection for above map. More...
|
|
Gaudi::Accumulators::AveragingCounter< double > m_lumiAverage | ATLAS_THREAD_SAFE |
| The average instantaneous lumionosity over all events. More...
|
|
Gaudi::Accumulators::AveragingCounter< double > m_muAverage | ATLAS_THREAD_SAFE |
| The average mu over all events. More...
|
|
std::unordered_map< int32_t, double > | m_idToWeightMap |
| Map a weighting ID to a Enhanced Bias event weight. More...
|
|
std::unordered_map< int32_t, uint8_t > | m_idToUnbiasedMap |
| Map a weighting ID to a flag if this weight is from an unbiased (RD) trigger online. More...
|
|
std::unordered_map< uint32_t, uint32_t > | m_eventsPerLB |
| Map of how many EnhancedBias events were recorded per LB. More...
|
|
std::unordered_map< uint32_t, double > | m_lumiPerLB |
| Map of instantaneous luminosity per LB. More...
|
|
std::unordered_map< uint32_t, uint8_t > | m_goodLB |
| Like a Good Run List flag for EnhancedBias runs. More...
|
|
std::unordered_map< uint32_t, double > | m_deadtimePerLB |
| Map of average deadtime per LB. More...
|
|
std::vector< int32_t > | m_bunches |
| Number of BCIDs in each bunch group. More...
|
|
ReadLumiBlock | m_readLumiBlock |
| Cache lumi block lengths. 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 |
|
Tool to calculate data-driven rates using EnhancedBias datasets.
Definition at line 47 of file EnhancedBiasWeighter.h.
◆ StoreGateSvc_t
◆ EnhancedBiasWeighter()
EnhancedBiasWeighter::EnhancedBiasWeighter |
( |
const std::string & |
name | ) |
|
◆ addBranches()
StatusCode EnhancedBiasWeighter::addBranches |
( |
| ) |
const |
|
overridevirtual |
Decorate the AOD with EnhancedBias weighting quantities such that no CVMFS or DB access is required on subsequent passes through the dAOD to perform rates.
addBranches is required by DerivationFramework::AugmentationTool
Implements DerivationFramework::IAugmentationTool.
Definition at line 717 of file EnhancedBiasWeighter.cxx.
733 decoratorEBWeight(*eventInfo) =
getEBWeight(eventInfo);
735 decoratorLBLumi(*eventInfo) =
getLBLumi(eventInfo);
737 decoratorGoodLBFlag(*eventInfo) =
isGoodLB(eventInfo);
738 decoratorDeadtime(*eventInfo) =
getDeadtime(eventInfo->lumiBlock());
739 decoratorBCIDDistanceFromFront(*eventInfo) =
distance;
741 return StatusCode::SUCCESS;
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation 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.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
253 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation 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.
229 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation 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.
338 return PBASE::declareProperty(
name, property,
doc);
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation 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.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ extraDeps_update_handler()
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
◆ finalize()
StatusCode EnhancedBiasWeighter::finalize |
( |
| ) |
|
|
overridevirtual |
◆ findLocalFile()
std::string EnhancedBiasWeighter::findLocalFile |
( |
const std::string & |
fileName | ) |
const |
|
private |
◆ getAverageLumi()
double EnhancedBiasWeighter::getAverageLumi |
( |
| ) |
const |
|
overridevirtual |
◆ getAverageMu()
double EnhancedBiasWeighter::getAverageMu |
( |
| ) |
const |
|
overridevirtual |
◆ getBunchGroups()
virtual const std::vector<int32_t>& EnhancedBiasWeighter::getBunchGroups |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getDeadtime()
double EnhancedBiasWeighter::getDeadtime |
( |
const int |
lumiblock = -1 | ) |
const |
|
overridevirtual |
- Returns
- the fractional deadtime in the event. Reported as function per LB if value is available else a fixed number There is no deadtime in MC, so for MC this will always return 1. Retrieved from CVMFS XML or fetched from TRIG1 dAOD
Implements IEnhancedBiasWeighter.
Definition at line 678 of file EnhancedBiasWeighter.cxx.
◆ getDistanceIntoTrain()
StatusCode EnhancedBiasWeighter::getDistanceIntoTrain |
( |
const xAOD::EventInfo * |
eventInfo, |
|
|
uint32_t & |
distance |
|
) |
| const |
|
overridevirtual |
- Returns
- How far into the current train this BCID is. Retrieved from the database using the BunchCrossingCondData or fetched from TRIG1 dAOD
Implements IEnhancedBiasWeighter.
Definition at line 694 of file EnhancedBiasWeighter.cxx.
698 const EventContext& context = Gaudi::Hive::currentContext();
700 ATH_CHECK( bunchCrossingTool.isValid() );
701 distance = bunchCrossingTool->distanceFromFront( eventInfo->
bcid(), BunchCrossingCondData::BunchDistanceType::BunchCrossings );
703 return StatusCode::SUCCESS;
◆ getEBLiveTime() [1/2]
double EnhancedBiasWeighter::getEBLiveTime |
( |
const EventContext & |
context | ) |
const |
|
overridevirtual |
Implements IEnhancedBiasWeighter.
Definition at line 509 of file EnhancedBiasWeighter.cxx.
513 ATH_MSG_ERROR(
"Cannot use EventContext based getEBLiveTime with MC. Needs full EventInfo.");
519 std::lock_guard<std::mutex> scopeLock(
m_mutex);
522 const auto inCacheIterator = m_eventLivetime.find(
lumiBlock );
523 if (inCacheIterator != m_eventLivetime.end())
return inCacheIterator->second;
533 const int32_t eventsInThisLB = mapIterator->second;
536 double eventLivetime = 0;
537 if (eventsInThisLB > 0 && fabs(lbLength) > 1
e-10) eventLivetime = (1. /
static_cast<double>(eventsInThisLB)) * lbLength;
539 m_eventLivetime[
lumiBlock] = eventLivetime;
540 return eventLivetime;
◆ getEBLiveTime() [2/2]
- Returns
- The amount of online walltime contributed by this event For data, this is based on the LB length and the number of events in the LB For MC, this is fixed by the sample cross section, the inelastic cross section and the mu of the current event. Retrieved from COOL and CVMFS XML or fetched from TRIG1 dAOD
Implements IEnhancedBiasWeighter.
Definition at line 467 of file EnhancedBiasWeighter.cxx.
477 ATH_MSG_DEBUG(
"MC livetime debug: probOfProcess:" << probOfProcess <<
" probOfBunchCrossing:" << probOfBunchCrossing <<
" bunchCrossingRate:" << bunchCrossingRate <<
" time:" << (1. / (probOfBunchCrossing * bunchCrossingRate)));
478 return 1. / (probOfBunchCrossing * bunchCrossingRate);
483 std::lock_guard<std::mutex> scopeLock(
m_mutex);
486 const auto inCacheIterator = m_eventLivetime.find(
lumiBlock );
487 if (inCacheIterator != m_eventLivetime.end())
return inCacheIterator->second;
497 const int32_t eventsInThisLB = mapIterator->second;
500 double eventLivetime = 0;
501 if (eventsInThisLB > 0 && fabs(lbLength) > 1
e-10) eventLivetime = (1. /
static_cast<double>(eventsInThisLB)) * lbLength;
503 m_eventLivetime[
lumiBlock] = eventLivetime;
504 return eventLivetime;
◆ getEBWeight() [1/2]
double EnhancedBiasWeighter::getEBWeight |
( |
const EventContext & |
context | ) |
const |
|
overridevirtual |
Definition at line 425 of file EnhancedBiasWeighter.cxx.
436 ATH_MSG_ERROR(
"Cannot use EventContext based getEBWeight with MC. Needs full EventInfo.");
444 ATH_MSG_ERROR(
"Couldn't find enhanced bias weight for event with ID " << ebID);
447 return mapIterator->second;
◆ getEBWeight() [2/2]
- Returns
- The effective number of events this one event represents from online, given EnhancedBias online prescales. For MC, this is the generator weight Retrieved from CVMFS XML, EventInfo (MC) or fetched from TRIG1 dAOD
Definition at line 391 of file EnhancedBiasWeighter.cxx.
416 ATH_MSG_ERROR(
"Couldn't find enhanced bias weight for event with ID " << ebID);
419 return mapIterator->second;
◆ getEventEBID() [1/2]
int32_t EnhancedBiasWeighter::getEventEBID |
( |
const EventContext & |
context | ) |
const |
|
private |
Definition at line 372 of file EnhancedBiasWeighter.cxx.
378 return mapIterator->second;
381 const int32_t eventNumber32 =
static_cast<int32_t
>(
eventNumber);
384 return mapIterator32->second;
◆ getEventEBID() [2/2]
- Returns
- Internal mapping of an event number to a weight ID. Retrieved from CVMFS XML or fetched from TRIG1 dAOD
Definition at line 353 of file EnhancedBiasWeighter.cxx.
359 return mapIterator->second;
362 const int32_t eventNumber32 =
static_cast<int32_t
>(
eventNumber);
365 return mapIterator32->second;
◆ getKey()
Get the (hashed) key of an object that is in the event store.
This is a bit of a special one. StoreGateSvc
and xAOD::TEvent
both provide ways for getting the SG::sgkey_t
key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.
In order to allow tools to efficiently perform this operation, they can use this helper function.
- See also
- asg::AsgTool::getName
- Parameters
-
ptr | The bare pointer to the object that the event store should know about |
- Returns
- The hashed key of the object in the store. If not found, an invalid (zero) key.
Definition at line 119 of file AsgTool.cxx.
121 #ifdef XAOD_STANDALONE
127 return (
proxy ==
nullptr ? 0 :
proxy->sgkey() );
128 #endif // XAOD_STANDALONE
◆ getLBLength() [1/2]
double EnhancedBiasWeighter::getLBLength |
( |
const EventContext & |
context | ) |
const |
|
overridevirtual |
◆ getLBLength() [2/2]
◆ getLBLumi() [1/2]
double EnhancedBiasWeighter::getLBLumi |
( |
const EventContext & |
context | ) |
const |
|
overridevirtual |
◆ getLBLumi() [2/2]
- Returns
- the instantaneous luminosity for the current event in units of cm-2s-1. For data, based on the current LB For MC, based on the event mu Retrieved from CVMFS XML or fetched from TRIG1 dAOD
Implements IEnhancedBiasWeighter.
Definition at line 638 of file EnhancedBiasWeighter.cxx.
653 return mapIterator->second;
◆ getName()
const std::string & asg::AsgTool::getName |
( |
const void * |
ptr | ) |
const |
|
inherited |
Get the name of an object that is / should be in the event store.
This is a bit of a special one. StoreGateSvc
and xAOD::TEvent
both provide ways for getting the std::string
name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.
In order to allow tools to efficiently perform this operation, they can use this helper function.
- See also
- asg::AsgTool::getKey
- Parameters
-
ptr | The bare pointer to the object that the event store should know about |
- Returns
- The string name of the object in the store. If not found, an empty string.
Definition at line 106 of file AsgTool.cxx.
108 #ifdef XAOD_STANDALONE
114 static const std::string
dummy =
"";
116 #endif // XAOD_STANDALONE
◆ getPairedBunches()
uint32_t EnhancedBiasWeighter::getPairedBunches |
( |
| ) |
const |
|
overridevirtual |
- Returns
- The number of colliding bunches in the Enhanced Bias run being used. For MC this will return the number of bunches which corresponds to a full-ring. Retrieved from CVMFS XML or fetched from TRIG1 dAOD
Implements IEnhancedBiasWeighter.
Definition at line 689 of file EnhancedBiasWeighter.cxx.
◆ getProperty()
template<class T >
const T* asg::AsgTool::getProperty |
( |
const std::string & |
name | ) |
const |
|
inherited |
Get one of the tool's properties.
◆ getRunNumber()
uint32_t EnhancedBiasWeighter::getRunNumber |
( |
| ) |
const |
|
overridevirtual |
◆ initialize()
StatusCode EnhancedBiasWeighter::initialize |
( |
| ) |
|
|
overridevirtual |
Initialize is required by AsgTool base class.
Check if we're MC or data, and if data check if we're to load the weighting info or read it from the input file
Reimplemented from asg::AsgTool.
Definition at line 36 of file EnhancedBiasWeighter.cxx.
44 ATH_MSG_FATAL(
"For MC rates, a cross section and filter efficiency must be supplied.");
45 return StatusCode::FAILURE;
56 ATH_MSG_FATAL(
"calculateWeightingData is TRUE, but the RunNumber property has not been set. This must be set such that we can read in the correct data.");
57 return StatusCode::FAILURE;
59 ATH_MSG_INFO (
"calculateWeightingData is TRUE. This job will read in EnhancedBias weighting data from CVMFS and COOL.");
66 return StatusCode::SUCCESS;
◆ inputHandles()
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.
◆ interfaceID() [1/2]
static const InterfaceID& DerivationFramework::IAugmentationTool::interfaceID |
( |
| ) |
|
|
inlinestaticinherited |
AlgTool interface methods.
Definition at line 31 of file IAugmentationTool.h.
31 {
return IID_IAugmentationTool; }
◆ interfaceID() [2/2]
static const InterfaceID& DerivationFramework::IAugmentationTool::interfaceID |
( |
| ) |
|
|
inlinestaticinherited |
AlgTool interface methods.
Definition at line 31 of file IAugmentationTool.h.
31 {
return IID_IAugmentationTool; }
◆ isGoodLB() [1/2]
bool EnhancedBiasWeighter::isGoodLB |
( |
const EventContext & |
context | ) |
const |
|
overridevirtual |
◆ isGoodLB() [2/2]
- Returns
- If the current lumi block should be used for rates or vetoed due to online deadtime Not a concern for MC Retrieved from CVMFS XML or fetched from TRIG1 dAOD
Implements IEnhancedBiasWeighter.
Definition at line 590 of file EnhancedBiasWeighter.cxx.
601 if (mapIterator ==
m_goodLB.end() ) {
605 return static_cast<bool>(mapIterator->second);
◆ isMC()
bool EnhancedBiasWeighter::isMC |
( |
| ) |
const |
|
overridevirtual |
◆ isUnbiasedEvent()
- Returns
- If the current event was selected online by a fully unbiased trigger for MC we cannot play such games and return True so that every trigger is queried. the user is expected to know that a j0 trigger running on a ttbar MC is going to underestimate the rate of the j0 trigger running on MinBias. Retrieved from CVMFS XML or fetched from TRIG1 dAOD
Implements IEnhancedBiasWeighter.
Definition at line 571 of file EnhancedBiasWeighter.cxx.
582 ATH_MSG_ERROR(
"Couldn't find isUnbiased information for event with ID " << ebID);
585 return mapIterator->second;
◆ loadLumi()
StatusCode EnhancedBiasWeighter::loadLumi |
( |
| ) |
|
|
private |
Read into memory this EnhancedBias run's XML.
Definition at line 146 of file EnhancedBiasWeighter.cxx.
151 ATH_MSG_FATAL(
"Unable to load this runs luminosity values from COOL.");
152 return StatusCode::FAILURE;
167 std::unique_ptr<TXMLEngine>
xml(
new TXMLEngine());
168 const XMLDocPointer_t xmlDoc =
xml->ParseFile( runFile.c_str() );
170 if (xmlDoc ==
nullptr) {
172 return StatusCode::FAILURE;
175 const XMLNodePointer_t mainNode =
xml->DocGetRootElement(xmlDoc);
176 if (
xml->GetNodeName(mainNode) != std::string(
"trigger") ) {
177 ATH_MSG_ERROR (
"Canot parse XML. Expected 'trigger' node, got " <<
xml->GetNodeName(mainNode));
178 return StatusCode::FAILURE;
180 XMLNodePointer_t listNode =
xml->GetChild( mainNode );
182 while ( listNode != 0 ) {
183 const std::string listName =
xml->GetNodeName(listNode);
185 if (listName ==
"lb_list") {
187 XMLNodePointer_t
node =
xml->GetChild( listNode );
189 if (
xml->GetNodeName(
node) != std::string(
"lb") ) {
191 return StatusCode::FAILURE;
196 const std::string
flag =
xml->HasAttr(
node,
"flag") ?
xml->GetAttr(
node,
"flag") :
"";
202 if (
xml->HasAttr(
node,
"deadtime")) {
210 }
else if (listName ==
"lumivalues") {
212 XMLNodePointer_t
node =
xml->GetChild( listNode );
214 if (
xml->GetNodeName(
node) == std::string(
"deadtime") ) {
220 }
else if (listName ==
"bunchgroups") {
222 XMLNodePointer_t
node =
xml->GetChild( listNode );
225 if (
xml->GetNodeName(
node) == std::string(
"bunchgroup") &&
xml->HasAttr(
node,
"name") &&
226 (std::string(
xml->GetAttr(
node,
"name")) ==
"Paired" || std::string(
xml->GetAttr(
node,
"name")) ==
"Filled")) {
232 }
else if (listName ==
"filters") {
234 ATH_MSG_DEBUG(
"Found filters section of enhanced bias XML. Unused by this application.");
238 ATH_MSG_INFO(
"Encountered unknown element in enhanced bias XML: " << listName <<
" ignoring it.");
242 listNode =
xml->GetNext(listNode);
246 return StatusCode::SUCCESS;
◆ loadWeights()
StatusCode EnhancedBiasWeighter::loadWeights |
( |
| ) |
|
|
private |
Read into memory from XML event weights for this EnhancedBias run.
Definition at line 75 of file EnhancedBiasWeighter.cxx.
85 if (weightingFile ==
"") {
90 std::unique_ptr<TXMLEngine>
xml(
new TXMLEngine() );
91 XMLDocPointer_t xmlDoc =
xml->ParseFile( weightingFile.c_str() );
93 if (xmlDoc ==
nullptr) {
95 return StatusCode::FAILURE;
99 const XMLNodePointer_t mainNode =
xml->DocGetRootElement(xmlDoc);
100 if (
xml->GetNodeName(mainNode) != std::string(
"run") ) {
101 ATH_MSG_ERROR (
"Canot parse XML. Expected 'run' node, got " <<
xml->GetNodeName(mainNode));
102 return StatusCode::FAILURE;
104 const XMLNodePointer_t weightsNode =
xml->GetChild( mainNode );
105 const XMLNodePointer_t eventsNode =
xml->GetNext( weightsNode );
107 XMLNodePointer_t weightNode =
xml->GetChild( weightsNode );
108 XMLNodePointer_t eventNode =
xml->GetChild( eventsNode );
110 while ( weightNode != 0 ) {
111 if (
xml->GetNodeName(weightNode) != std::string(
"weight") ) {
112 ATH_MSG_ERROR (
"Canot parse XML. Expected 'weight' node, got " <<
xml->GetNodeName(weightNode));
113 return StatusCode::FAILURE;
116 const int32_t
id =
std::atoi(
xml->GetAttr(weightNode,
"id") );
118 int32_t unbiased = 0;
119 if (
xml->HasAttr(weightNode,
"unbiased") ==
true ) {
120 unbiased =
std::atoi(
xml->GetAttr(weightNode,
"unbiased"));
126 weightNode =
xml->GetNext(weightNode);
129 while ( eventNode != 0 ) {
130 if (
xml->GetNodeName(eventNode) != std::string(
"e") ) {
131 ATH_MSG_ERROR (
"Canot parse XML. Expected 'e' (event) node, got " <<
xml->GetNodeName(eventNode));
132 return StatusCode::FAILURE;
135 const int32_t eventWeightID = std::stoi(
xml->GetAttr(eventNode,
"w") );
139 eventNode =
xml->GetNext(eventNode);
143 return StatusCode::SUCCESS;
◆ msg() [1/2]
◆ msg() [2/2]
◆ msg_level_name()
const std::string & asg::AsgTool::msg_level_name |
( |
| ) |
const |
|
inherited |
A deprecated function for getting the message level's name.
Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:
MSG::name( msg().level() )
This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.
- Returns
- The string name of the current minimum message level that's printed
Definition at line 101 of file AsgTool.cxx.
◆ msgLvl()
◆ outputHandles()
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.
◆ parsePrescaleXML()
std::unordered_map< std::string, ChainDetail > EnhancedBiasWeighter::parsePrescaleXML |
( |
const std::string & |
prescaleXML | ) |
const |
|
overridevirtual |
Parse a presscale XML and return a ordered summary of its content To make most use of the XML parsing available already in this class.
- Parameters
-
prescaleXML | File name of a prescales file as generated by the RuleBook |
- Returns
- Set of L1 or HLT chain names mapped to their desired prescale
Implements IEnhancedBiasWeighter.
Definition at line 249 of file EnhancedBiasWeighter.cxx.
250 std::unordered_map<std::string, ChainDetail>
result;
254 ATH_MSG_ERROR (
"Could not retrieve " << prescaleXML <<
", place it somewhere PathResolver can find it (such as the current directory).");
258 std::unique_ptr<TXMLEngine>
xml(
new TXMLEngine());
259 const XMLDocPointer_t xmlDoc =
xml->ParseFile( xmlFile.c_str() );
261 if (xmlDoc ==
nullptr) {
262 ATH_MSG_WARNING (
"Could not parse " << prescaleXML <<
", please check that it is valid XML.");
267 XMLNodePointer_t mainNode =
xml->DocGetRootElement(xmlDoc);
268 if (
xml->GetNodeName(mainNode) != std::string(
"trigger") ) {
269 ATH_MSG_ERROR (
"Canot parse XML. Expected 'trigger' node, got " <<
xml->GetNodeName(mainNode));
272 XMLNodePointer_t listNode =
xml->GetChild( mainNode );
275 while ( listNode !=
nullptr) {
276 const std::string listName =
xml->GetNodeName(listNode);
281 if (listName !=
"level") {
282 listNode =
xml->GetNext(listNode);
286 XMLNodePointer_t sigNode =
xml->GetChild( listNode );
287 while( sigNode !=
nullptr) {
288 if (
xml->GetNodeName(sigNode) != std::string(
"signature")) {
289 sigNode =
xml->GetNext(sigNode);
293 XMLNodePointer_t sigDetailsNode =
xml->GetChild( sigNode );
295 while( sigDetailsNode !=
nullptr) {
297 if (
xml->GetNodeContent(sigDetailsNode) ==
nullptr) {
298 sigDetailsNode =
xml->GetNext(sigDetailsNode);
302 const std::string
detail =
xml->GetNodeName(sigDetailsNode);
303 if (
detail ==
"sig_name") {
306 }
else if (
detail ==
"sig_counter") {
308 }
else if (
detail ==
"prescale" ||
detail ==
"chain_prescale") {
310 }
else if (
detail ==
"lower_chain_name") {
312 std::string lower =
xml->GetNodeContent(sigDetailsNode);
313 while (lower.find(
" ") != std::string::npos) lower.replace( lower.find(
" "), 1,
"");
315 }
else if (
detail ==
"evts_passed") {
317 }
else if (
detail ==
"evts_passed_weighted") {
318 result[
chainName].m_eventsPassedWeighted = std::stod(
xml->GetNodeContent(sigDetailsNode) );
319 }
else if (
detail ==
"rate") {
321 }
else if (
detail ==
"rate_err") {
323 }
else if (
detail ==
"passthrough") {
324 result[
chainName].m_passthroughPrescale = std::stod(
xml->GetNodeContent(sigDetailsNode) );
325 }
else if (
detail ==
"rerun_prescale") {
327 }
else if (
detail ==
"express_prescale") {
328 result[
chainName].m_expressPrescale = std::stod(
xml->GetNodeContent(sigDetailsNode) );
329 }
else if (
detail ==
"efficiency") {
331 }
else if (
detail ==
"efficiency_err") {
333 }
else if (
detail ==
"prescaled_efficiency") {
334 result[
chainName].m_prescaledEfficiency = std::stod(
xml->GetNodeContent(sigDetailsNode) );
335 }
else if (
detail ==
"prescaled_efficiency_error") {
336 result[
chainName].m_prescaledEfficiencyErr = std::stod(
xml->GetNodeContent(sigDetailsNode) );
337 }
else if (
detail ==
"comment") {
340 ATH_MSG_DEBUG(
"Input prescales XML contains additional data which cannot be parsed at present:" <<
detail);
343 sigDetailsNode =
xml->GetNext(sigDetailsNode);
345 sigNode =
xml->GetNext(sigNode);
347 listNode =
xml->GetNext(listNode);
◆ print()
void asg::AsgTool::print |
( |
| ) |
const |
|
virtualinherited |
Print the state of the tool.
Implements asg::IAsgTool.
Reimplemented in JetRecTool, JetFinder, JetModifiedMassDrop, JetFromPseudojet, JetReclusterer, JetReclusteringTool, JetTruthLabelingTool, JetPileupLabelingTool, HI::HIPileupTool, JetDumper, JetBottomUpSoftDrop, JetRecursiveSoftDrop, JetSoftDrop, JetConstituentsRetriever, JetSubStructureMomentToolsBase, JetSplitter, JetToolRunner, JetPruner, JetPseudojetRetriever, JetTrimmer, AsgHelloTool, and KtDeltaRTool.
Definition at line 131 of file AsgTool.cxx.
◆ renounce()
◆ renounceArray()
◆ sysInitialize()
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ trackAverages() [1/2]
StatusCode EnhancedBiasWeighter::trackAverages |
( |
const EventContext & |
context | ) |
const |
|
private |
◆ trackAverages() [2/2]
Internal function to keep track of the mean instantaneous lumi & mean pileup of the EB/MC sample being processed.
Definition at line 460 of file EnhancedBiasWeighter.cxx.
464 return StatusCode::SUCCESS;
◆ updateVHKA()
◆ ATLAS_THREAD_SAFE [1/3]
std::unordered_map<uint32_t, float> m_eventLivetime EnhancedBiasWeighter::ATLAS_THREAD_SAFE |
|
mutableprivate |
Cache of per-event livetime as a function of LB [LB -> effective walltime per event].
Definition at line 205 of file EnhancedBiasWeighter.h.
◆ ATLAS_THREAD_SAFE [2/3]
Gaudi::Accumulators::AveragingCounter<double> m_lumiAverage EnhancedBiasWeighter::ATLAS_THREAD_SAFE |
|
mutableprivate |
◆ ATLAS_THREAD_SAFE [3/3]
Gaudi::Accumulators::AveragingCounter<double> m_muAverage EnhancedBiasWeighter::ATLAS_THREAD_SAFE |
|
mutableprivate |
◆ FULL_RING
constexpr static uint32_t EnhancedBiasWeighter::FULL_RING = 2738 |
|
staticconstexpr |
◆ LHC_FREQUENCY
constexpr static double EnhancedBiasWeighter::LHC_FREQUENCY = 11245.5 |
|
staticconstexpr |
◆ m_bunchCrossingKey
◆ m_bunches
std::vector<int32_t> EnhancedBiasWeighter::m_bunches |
|
private |
◆ m_deadtime
double EnhancedBiasWeighter::m_deadtime |
|
private |
Online deadtime to correct for in rate prediction.
Currently a constant for the EB period
Definition at line 200 of file EnhancedBiasWeighter.h.
◆ m_deadtimePerLB
std::unordered_map<uint32_t, double> EnhancedBiasWeighter::m_deadtimePerLB |
|
private |
◆ m_detStore
◆ m_enforceEBGRL
Gaudi::Property<bool> EnhancedBiasWeighter::m_enforceEBGRL {this, "EnforceEBGRL", true, "Each Enhanced Bias run has a 'good run list' style veto on some LB. If this flag is true, events in these LB get weight 0"} |
|
private |
◆ m_errorOnMissingEBWeights
Gaudi::Property<bool> EnhancedBiasWeighter::m_errorOnMissingEBWeights {this, "ErrorOnMissingEBWeights", false, "If true, Throws error if EB weights are missing."} |
|
private |
◆ m_eventNumberToIdMap
std::unordered_map<uint64_t, int32_t> EnhancedBiasWeighter::m_eventNumberToIdMap |
|
private |
◆ m_eventsPerLB
std::unordered_map<uint32_t, uint32_t> EnhancedBiasWeighter::m_eventsPerLB |
|
private |
◆ m_evtStore
◆ m_goodLB
std::unordered_map<uint32_t, uint8_t> EnhancedBiasWeighter::m_goodLB |
|
private |
◆ m_idToUnbiasedMap
std::unordered_map<int32_t, uint8_t> EnhancedBiasWeighter::m_idToUnbiasedMap |
|
private |
Map a weighting ID to a flag if this weight is from an unbiased (RD) trigger online.
Definition at line 211 of file EnhancedBiasWeighter.h.
◆ m_idToWeightMap
std::unordered_map<int32_t, double> EnhancedBiasWeighter::m_idToWeightMap |
|
private |
◆ m_inelasticCrossSection
Gaudi::Property<double> EnhancedBiasWeighter::m_inelasticCrossSection {this, "InelasticCrossSection", 8e-26, "Inelastic cross section in units cm^2. Default 80 mb at 13 TeV."} |
|
private |
◆ m_isMC
Gaudi::Property<bool> EnhancedBiasWeighter::m_isMC {this, "IsMC", false, "MC mode? If so we need a cross section and filter efficiency"} |
|
private |
◆ m_lumiPerLB
std::unordered_map<uint32_t, double> EnhancedBiasWeighter::m_lumiPerLB |
|
private |
◆ m_mcCrossSection
Gaudi::Property<double> EnhancedBiasWeighter::m_mcCrossSection {this, "MCCrossSection", 0.0, "If running over MC. The process cross section in nb (AMI gives thins in nb)"} |
|
private |
◆ m_mcFilterEfficiency
Gaudi::Property<double> EnhancedBiasWeighter::m_mcFilterEfficiency {this, "MCFilterEfficiency", 1.0, "If running over MC. The process filter efficiency (0.0-1.0)"} |
|
private |
◆ m_mcIgnoreGeneratorWeights
Gaudi::Property<bool> EnhancedBiasWeighter::m_mcIgnoreGeneratorWeights {this, "MCIgnoreGeneratorWeights", false, "If running over MC. Flag to ignore the generator weight."} |
|
private |
◆ m_mcKFactor
Gaudi::Property<double> EnhancedBiasWeighter::m_mcKFactor {this, "MCKFactor", 1.0, "If running over MC. The process filter efficiency (0.0-1.0)"} |
|
private |
◆ m_mcModifiedCrossSection
double EnhancedBiasWeighter::m_mcModifiedCrossSection |
|
private |
◆ m_mutex
std::mutex EnhancedBiasWeighter::m_mutex |
|
mutableprivate |
◆ m_pairedBunches
uint32_t EnhancedBiasWeighter::m_pairedBunches |
|
private |
◆ m_readLumiBlock
◆ m_runNumber
Gaudi::Property<uint32_t> EnhancedBiasWeighter::m_runNumber {this, "RunNumber", 0, "Run we're processing (if data), needed at initialize to locate and read in extra configuration."} |
|
private |
◆ m_useBunchCrossingData
Gaudi::Property<bool> EnhancedBiasWeighter::m_useBunchCrossingData {this, "UseBunchCrossingData", true, "BunchCrossing data requires CONDBR2 access. Can be disabled here if this is a problem."} |
|
private |
◆ m_varHandleArraysDeclared
◆ m_vhka
◆ m_weightsDirectory
Gaudi::Property<std::string> EnhancedBiasWeighter::m_weightsDirectory {this, "EBWeightsDirectory", "", "Path to directory with EB XML weights files, if empty they will be read from calibration area"} |
|
private |
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
virtual double getEBLiveTime(const xAOD::EventInfo *eventInfo) const override
Gaudi::Property< double > m_mcCrossSection
Gaudi::Property< uint32_t > m_runNumber
uint64_t eventNumber() const
The current event's event number.
virtual StatusCode getDistanceIntoTrain(const xAOD::EventInfo *eventInfo, uint32_t &distance) const override
const std::vector< float > & mcEventWeights() const
The weights of all the MC events used in the simulation.
uint32_t m_pairedBunches
Online number of paired bunches.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Gaudi::Property< bool > m_isMC
StatusCode trackAverages(const xAOD::EventInfo *eventInfo) const
Internal function to keep track of the mean instantaneous lumi & mean pileup of the EB/MC sample bein...
virtual double getLBLumi(const xAOD::EventInfo *eventInfo) const override
Gaudi::Property< bool > m_mcIgnoreGeneratorWeights
std::unordered_map< int32_t, uint8_t > m_idToUnbiasedMap
Map a weighting ID to a flag if this weight is from an unbiased (RD) trigger online.
std::unordered_map< uint32_t, double > m_deadtimePerLB
Map of average deadtime per LB.
std::unordered_map< uint32_t, uint32_t > m_eventsPerLB
Map of how many EnhancedBias events were recorded per LB.
int32_t getEventEBID(const xAOD::EventInfo *eventInfo) const
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
virtual double getDeadtime(const int lumiblock=-1) const override
float getLumiBlockLength(uint32_t lb, MsgStream &msg) const
@ u
Enums for curvilinear frames.
virtual void setOwner(IDataHandleHolder *o)=0
Gaudi::Property< double > m_inelasticCrossSection
Gaudi::Property< bool > m_enforceEBGRL
Gaudi::Property< std::string > m_weightsDirectory
std::string findLocalFile(const std::string &fileName) const
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
std::vector< int32_t > m_bunches
Number of BCIDs in each bunch group.
virtual bool isGoodLB(const xAOD::EventInfo *eventInfo) const override
Helper class to provide type-safe access to aux data.
ReadLumiBlock m_readLumiBlock
Cache lumi block lengths.
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
uint32_t lumiBlock() const
The current event's luminosity block number.
Gaudi::Property< bool > m_useBunchCrossingData
constexpr static uint32_t FULL_RING
Number of bunches in a full ring.
double atof(std::string_view str)
Converts a string into a double / float.
bool updateLumiBlocks(uint32_t run, MsgStream &msg)
Load information for.
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
SG::ReadCondHandleKey< BunchCrossingCondData > m_bunchCrossingKey
Tool to get distance into bunch train.
std::unordered_map< uint64_t, int32_t > m_eventNumberToIdMap
Map event number to a weighting ID.
virtual double getEBWeight(const xAOD::EventInfo *eventInfo) const override
Gaudi::Property< double > m_mcFilterEfficiency
constexpr static double LHC_FREQUENCY
Gaudi::Property< bool > m_errorOnMissingEBWeights
StatusCode initialize(bool used=true)
std::unordered_map< uint32_t, uint8_t > m_goodLB
Like a Good Run List flag for EnhancedBias runs.
std::mutex m_mutex
Protection for above map.
Class describing the basic event information.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
virtual bool isUnbiasedEvent(const xAOD::EventInfo *eventInfo) const override
std::string PathResolverFindDataFile(const std::string &logical_file_name)
StatusCode loadWeights()
Read into memory from XML event weights for this EnhancedBias run.
std::unordered_map< int32_t, double > m_idToWeightMap
Map a weighting ID to a Enhanced Bias event weight.
double m_deadtime
Online deadtime to correct for in rate prediction.
#define ATH_MSG_WARNING(x)
double m_mcModifiedCrossSection
Product of xsec, filter & kfactor.
std::unordered_map< uint32_t, double > m_lumiPerLB
Map of instantaneous luminosity per LB.
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Gaudi::Property< double > m_mcKFactor
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
uint32_t bcid() const
The bunch crossing ID of the event.
StatusCode loadLumi()
Read into memory this EnhancedBias run's XML.
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Structure to encompass the data stored in a prescales XML generated by the RuleBook.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.