ATLAS Offline Software
EventInfoAttListTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*****************************************************************************
6 Name : EventInfoAttListTool.cxx
7 Author : Jack Cranshaw
8 Created : January 2017
9 Purpose : create a EventInfoAttList - The Tag information associated to the event
10  is built here
11 
12 *****************************************************************************/
13 
14 #include "EventInfoAttListTool.h"
15 
16 #include "CoralBase/AttributeListSpecification.h"
19 
20 
23  ATH_MSG_DEBUG("in initialize()");
24 
25  m_attribListSpec = new coral::AttributeListSpecification();
26  // Note: for any attribute added here, please confirm the corresponding EventInfo member being
27  // retained in DAOD smart slimming:
28  // PhysicsAnalysis/DerivationFramework/DerivationFrameworkCore/python/EventInfoContent.py
29  m_attribListSpec->extend("IsSimulation", "bool");
30  m_attribListSpec->extend("IsCalibration", "bool");
31  m_attribListSpec->extend("IsTestBeam", "bool");
32  m_attribListSpec->extend("McChannel", "unsigned int");
33  m_attribListSpec->extend("RunNumber", "unsigned int");
34  m_attribListSpec->extend("EventNumber", "unsigned long long");
35  m_attribListSpec->extend("LumiBlockN", "unsigned int");
36  m_attribListSpec->extend("ConditionsRun", "unsigned int");
37  m_attribListSpec->extend("EventTime", "unsigned int");
38  m_attribListSpec->extend("EventTimeNanoSec","unsigned int");
39  m_attribListSpec->extend("BunchId", "unsigned int");
40  m_attribListSpec->extend("EventWeight", "float");
41 
42  return AthAlgTool::initialize();
43 }
44 
45 
46 /* Build attribute list from EventInfo object */
47 std::unique_ptr<AthenaAttributeList>
49 {
50  // Create attributeList with appropriate attributes
51  const coral::AttributeListSpecification& specRef = *m_attribListSpec;
52  auto eventTag = std::make_unique<AthenaAttributeList> ( specRef );
53 
54  StatusCode sc = this->eventTag (*eventTag, eventInfo);
55  if (sc.isFailure()) {
56  ATH_MSG_WARNING("Unable to build Tag Fragments for the Event");
57  }
58 
59  ATH_MSG_DEBUG("EventInfoAttListTool - getAttributeList() return success");
60 
61  return eventTag;
62 }
63 
64 
67  const xAOD::EventInfo& eventInfo) const
68 {
69  // Note: for any attribute added here, please confirm the corresponding EventInfo member being
70  // retained in DAOD smart slimming:
71  // PhysicsAnalysis/DerivationFramework/DerivationFrameworkCore/python/EventInfoContent.py
72 
74  bool isSimulation = eventInfo.eventType(xAOD::EventInfo::IS_SIMULATION);
75  bool isTestBeam = eventInfo.eventType(xAOD::EventInfo::IS_TESTBEAM);
76  bool isCalibration = eventInfo.eventType(xAOD::EventInfo::IS_CALIBRATION);
77  eventTag["IsSimulation"] .data<bool>() = isSimulation;
78  eventTag["IsCalibration"].data<bool>() = isCalibration;
79  eventTag["IsTestBeam"] .data<bool>() = isTestBeam;
80 
81  // run number and Event number
82  unsigned int runNumber = eventInfo.runNumber();
83  unsigned int condRunNumber = runNumber;
84  unsigned long long eventNumber = eventInfo.eventNumber();
85  unsigned int lumiBlock = eventInfo.lumiBlock();
86  unsigned int mcChannel = 0;
87  if (isSimulation) mcChannel = eventInfo.mcChannelNumber();
88  eventTag["McChannel"] .data<unsigned int>() = mcChannel;
89  eventTag["RunNumber"] .data<unsigned int>() = runNumber;
90  eventTag["EventNumber"] .data<unsigned long long>() = eventNumber;
91  eventTag["LumiBlockN"] .data<unsigned int>() = lumiBlock;
92  eventTag["ConditionsRun"].data<unsigned int>() = condRunNumber;
93 
94  unsigned long timeStamp = eventInfo.timeStamp();
95  unsigned long timeStampNS = eventInfo.timeStampNSOffset();
96  unsigned long bunchId = eventInfo.bcid();
97  eventTag["EventTime"] .data<unsigned int>() = timeStamp;
98  eventTag["EventTimeNanoSec"].data<unsigned int>() = timeStampNS;
99  eventTag["BunchId"] .data<unsigned int>() = bunchId;
100 
101  // event weight
102  // used for event weighting in monte carlo or just an event count in data
103  float evweight = 1;
104  if (isSimulation) evweight = eventInfo.mcEventWeight();
105  eventTag["EventWeight"].data<float>() = evweight;
106 
107  return StatusCode::SUCCESS;
108 
109 }
110 
111 
114  ATH_MSG_DEBUG("in finalize()");
115  m_attribListSpec->release();
116  m_attribListSpec = nullptr;
117  return AthAlgTool::finalize();
118 }
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
EventInfoAttListTool.h
initialize
void initialize()
Definition: run_EoverP.cxx:894
xAOD::EventInfo_v1::IS_CALIBRATION
@ IS_CALIBRATION
true: calibration, false: physics
Definition: EventInfo_v1.h:155
EventInfoAttListTool::initialize
virtual StatusCode initialize() override
Overriding initialize, finalize and execute.
Definition: EventInfoAttListTool.cxx:22
EventInfoAttListTool::finalize
virtual StatusCode finalize() override
finialize - called once at the end
Definition: EventInfoAttListTool.cxx:113
xAOD::EventInfo_v1::timeStampNSOffset
uint32_t timeStampNSOffset() const
Nanosecond time offset wrt. the time stamp.
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
xAOD::EventInfo_v1::mcChannelNumber
uint32_t mcChannelNumber() const
The MC generator's channel number.
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
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
EventInfoAttListTool::getAttributeListPtr
std::unique_ptr< AthenaAttributeList > getAttributeListPtr(const xAOD::EventInfo &einfo) const
Definition: EventInfoAttListTool.cxx:48
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
AthenaAttributeList.h
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
EventInfo.h
xAOD::timeStamp
setEventNumber timeStamp
Definition: EventInfo_v1.cxx:128
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::EventInfo_v1::timeStamp
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
EventInfoAttListTool::eventTag
StatusCode eventTag(AthenaAttributeList &eventTagCol, const xAOD::EventInfo &eventInfo) const
the various components to build their own fragments of tag
Definition: EventInfoAttListTool.cxx:66
xAOD::EventInfo_v1::mcEventWeight
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
Definition: EventInfo_v1.cxx:203
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:328
xAOD::EventInfo_v1::IS_TESTBEAM
@ IS_TESTBEAM
true: testbeam, false: full detector
Definition: EventInfo_v1.h:153
EventInfoAttListTool::m_attribListSpec
coral::AttributeListSpecification * m_attribListSpec
Definition: EventInfoAttListTool.h:46
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.