ATLAS Offline Software
Loading...
Searching...
No Matches
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/*****************************************************************************
6Name : EventInfoAttListTool.cxx
7Author : Jack Cranshaw
8Created : January 2017
9Purpose : create a EventInfoAttList - The Tag information associated to the event
10 is built here
11
12*****************************************************************************/
13
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/* Build attribute list from EventInfo object */
46std::unique_ptr<AthenaAttributeList>
48{
49 // Create attributeList with appropriate attributes
50 const coral::AttributeListSpecification& specRef = *m_attribListSpec;
51 auto eventTag = std::make_unique<AthenaAttributeList> ( specRef );
52
53 StatusCode sc = this->eventTag (*eventTag, eventInfo);
54 if (sc.isFailure()) {
55 ATH_MSG_WARNING("Unable to build Tag Fragments for the Event");
56 }
57
58 ATH_MSG_DEBUG("EventInfoAttListTool - getAttributeList() return success");
59
60 return eventTag;
61}
62
63
66 const xAOD::EventInfo& eventInfo) const
67{
68 // Note: for any attribute added here, please confirm the corresponding EventInfo member being
69 // retained in DAOD smart slimming:
70 // PhysicsAnalysis/DerivationFramework/DerivationFrameworkCore/python/EventInfoContent.py
71
73 bool isSimulation = eventInfo.eventType(xAOD::EventInfo::IS_SIMULATION);
74 bool isTestBeam = eventInfo.eventType(xAOD::EventInfo::IS_TESTBEAM);
75 bool isCalibration = eventInfo.eventType(xAOD::EventInfo::IS_CALIBRATION);
76 eventTag["IsSimulation"] .data<bool>() = isSimulation;
77 eventTag["IsCalibration"].data<bool>() = isCalibration;
78 eventTag["IsTestBeam"] .data<bool>() = isTestBeam;
79
80 // run number and Event number
81 unsigned int runNumber = eventInfo.runNumber();
82 unsigned int condRunNumber = runNumber;
83 unsigned long long eventNumber = eventInfo.eventNumber();
84 unsigned int lumiBlock = eventInfo.lumiBlock();
85 unsigned int mcChannel = 0;
86 if (isSimulation) mcChannel = eventInfo.mcChannelNumber();
87 eventTag["McChannel"] .data<unsigned int>() = mcChannel;
88 eventTag["RunNumber"] .data<unsigned int>() = runNumber;
89 eventTag["EventNumber"] .data<unsigned long long>() = eventNumber;
90 eventTag["LumiBlockN"] .data<unsigned int>() = lumiBlock;
91 eventTag["ConditionsRun"].data<unsigned int>() = condRunNumber;
92
93 unsigned long timeStamp = eventInfo.timeStamp();
94 unsigned long timeStampNS = eventInfo.timeStampNSOffset();
95 unsigned long bunchId = eventInfo.bcid();
96 eventTag["EventTime"] .data<unsigned int>() = timeStamp;
97 eventTag["EventTimeNanoSec"].data<unsigned int>() = timeStampNS;
98 eventTag["BunchId"] .data<unsigned int>() = bunchId;
99
100 // event weight
101 // used for event weighting in monte carlo or just an event count in data
102 float evweight = 1;
103 if (isSimulation) evweight = eventInfo.mcEventWeight();
104 eventTag["EventWeight"].data<float>() = evweight;
105
106 return StatusCode::SUCCESS;
107
108}
109
110
113 ATH_MSG_DEBUG("in finalize()");
114 m_attribListSpec->release();
115 m_attribListSpec = nullptr;
116 return AthAlgTool::finalize();
117}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
An AttributeList represents a logical row of attributes in a metadata table.
An AttributeList represents a logical row of attributes in a metadata table.
coral::AttributeListSpecification * m_attribListSpec
virtual StatusCode initialize() override
Overriding initialize, finalize and execute.
StatusCode eventTag(AthenaAttributeList &eventTagCol, const xAOD::EventInfo &eventInfo) const
the various components to build their own fragments of tag
virtual StatusCode finalize() override
finalize - called once at the end
std::unique_ptr< AthenaAttributeList > getAttributeListPtr(const xAOD::EventInfo &einfo) const
uint32_t lumiBlock() const
The current event's luminosity block number.
bool eventType(EventType type) const
Check for one particular bitmask value.
uint32_t bcid() const
The bunch crossing ID of the event.
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
@ IS_CALIBRATION
true: calibration, false: physics
@ IS_SIMULATION
true: simulation, false: data
@ IS_TESTBEAM
true: testbeam, false: full detector
uint32_t runNumber() const
The current event's run number.
uint32_t mcChannelNumber() const
The MC generator's channel number.
uint32_t timeStampNSOffset() const
Nanosecond time offset wrt. the time stamp.
uint64_t eventNumber() const
The current event's event number.
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
EventInfo_v1 EventInfo
Definition of the latest event info version.