ATLAS Offline Software
EventInfoRDOAnalysis.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "EventInfoRDOAnalysis.h"
6 
7 #include <TH1.h>
8 #include <TTree.h>
9 
10 
11 EventInfoRDOAnalysis::EventInfoRDOAnalysis(const std::string& name, ISvcLocator *pSvcLocator)
12  : AthAlgorithm(name, pSvcLocator)
13 {
14 }
15 
17 {
18  // This will check that the properties were initialized
19  // properly by job configuration.
21 
22  // Grab Ntuple and histogramming service for tree
23  ATH_CHECK(m_thistSvc.retrieve());
24 
25  m_tree = new TTree(m_ntupleName.value().c_str(), "EventInfoRDOAnalysis");
26  ATH_CHECK(m_thistSvc->regTree(m_ntuplePath.value() + m_ntupleName.value(), m_tree));
27  if (m_tree) {
28  m_tree->Branch("runNumber", &m_runNumber);
29  m_tree->Branch("eventNumber", &m_eventNumber);
30  m_tree->Branch("lumiBlock", &m_lumiBlock);
31  m_tree->Branch("bcid", &m_bcid);
32 
33  m_tree->Branch("actualInteractionsPerCrossing", &m_actualInteractionsPerCrossing);
34  m_tree->Branch("averageInteractionsPerCrossing", &m_averageInteractionsPerCrossing);
35 
36  m_tree->Branch("beamPosX", &m_beamPosX);
37  m_tree->Branch("beamPosY", &m_beamPosY);
38  m_tree->Branch("beamPosZ", &m_beamPosZ);
39  m_tree->Branch("beamPosSigmaX", &m_beamPosSigmaX);
40  m_tree->Branch("beamPosSigmaY", &m_beamPosSigmaY);
41  m_tree->Branch("beamPosSigmaZ", &m_beamPosSigmaZ);
42  } else {
43  ATH_MSG_ERROR("No tree found!");
44  return StatusCode::FAILURE;
45  }
46 
47  // HISTOGRAMS
48  m_h_actualInteractionsPerCrossing = new TH1F("h_actualInteractionsPerCrossing", "actualInteractionsPerCrossing", 100, 0, 100);
49  m_h_actualInteractionsPerCrossing->StatOverflows();
51 
52  m_h_averageInteractionsPerCrossing = new TH1F("h_averageInteractionsPerCrossing", "averageInteractionsPerCrossing", 100, 0, 100);
53  m_h_averageInteractionsPerCrossing->StatOverflows();
55 
56  return StatusCode::SUCCESS;
57 }
58 
60 {
62  if (!eventInfo.isValid()) {
63  return StatusCode::FAILURE;
64  }
65 
66  m_runNumber = eventInfo->runNumber();
67  m_eventNumber = eventInfo->eventNumber();
68  m_lumiBlock = eventInfo->lumiBlock();
69  m_bcid = eventInfo->bcid();
70 
75 
76  m_beamPosX = eventInfo->beamPosX();
77  m_beamPosY = eventInfo->beamPosY();
78  m_beamPosZ = eventInfo->beamPosZ();
79 
80  m_beamPosSigmaX = eventInfo->beamPosSigmaX();
81  m_beamPosSigmaY = eventInfo->beamPosSigmaY();
82  m_beamPosSigmaZ = eventInfo->beamPosSigmaZ();
83 
84  if (m_tree) {
85  m_tree->Fill();
86  }
87 
88  return StatusCode::SUCCESS;
89 }
EventInfoRDOAnalysis::m_lumiBlock
uint32_t m_lumiBlock
Definition: EventInfoRDOAnalysis.h:41
EventInfoRDOAnalysis::m_h_actualInteractionsPerCrossing
TH1 * m_h_actualInteractionsPerCrossing
Definition: EventInfoRDOAnalysis.h:56
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
EventInfoRDOAnalysis::m_beamPosSigmaY
float m_beamPosSigmaY
Definition: EventInfoRDOAnalysis.h:52
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
EventInfoRDOAnalysis::m_beamPosSigmaZ
float m_beamPosSigmaZ
Definition: EventInfoRDOAnalysis.h:53
EventInfoRDOAnalysis::m_beamPosZ
float m_beamPosZ
Definition: EventInfoRDOAnalysis.h:49
xAOD::EventInfo_v1::beamPosSigmaX
float beamPosSigmaX() const
The width of the beam spot in the X direction.
EventInfoRDOAnalysis::initialize
virtual StatusCode initialize() override final
Definition: EventInfoRDOAnalysis.cxx:16
EventInfoRDOAnalysis::m_h_averageInteractionsPerCrossing
TH1 * m_h_averageInteractionsPerCrossing
Definition: EventInfoRDOAnalysis.h:57
EventInfoRDOAnalysis::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: EventInfoRDOAnalysis.h:30
xAOD::EventInfo_v1::beamPosX
float beamPosX() const
X coordinate of the beam spot position.
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
EventInfoRDOAnalysis.h
EventInfoRDOAnalysis::m_beamPosX
float m_beamPosX
Definition: EventInfoRDOAnalysis.h:47
xAOD::EventInfo_v1::beamPosY
float beamPosY() const
Y coordinate of the beam spot position.
EventInfoRDOAnalysis::m_tree
TTree * m_tree
Definition: EventInfoRDOAnalysis.h:59
EventInfoRDOAnalysis::m_averageInteractionsPerCrossing
float m_averageInteractionsPerCrossing
Definition: EventInfoRDOAnalysis.h:45
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EventInfoRDOAnalysis::m_bcid
uint32_t m_bcid
Definition: EventInfoRDOAnalysis.h:42
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EventInfoRDOAnalysis::m_actualInteractionsPerCrossing
float m_actualInteractionsPerCrossing
Definition: EventInfoRDOAnalysis.h:44
EventInfoRDOAnalysis::m_runNumber
uint32_t m_runNumber
Definition: EventInfoRDOAnalysis.h:39
xAOD::EventInfo_v1::beamPosSigmaZ
float beamPosSigmaZ() const
The length of the beam spot in the Z direction.
EventInfoRDOAnalysis::EventInfoRDOAnalysis
EventInfoRDOAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
Definition: EventInfoRDOAnalysis.cxx:11
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EventInfoRDOAnalysis::m_thistSvc
ServiceHandle< ITHistSvc > m_thistSvc
Definition: EventInfoRDOAnalysis.h:36
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
TH1::Fill
int Fill(double)
Definition: rootspy.cxx:285
EventInfoRDOAnalysis::m_eventNumber
unsigned long long m_eventNumber
Definition: EventInfoRDOAnalysis.h:40
EventInfoRDOAnalysis::m_histPath
Gaudi::Property< std::string > m_histPath
Definition: EventInfoRDOAnalysis.h:32
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
EventInfoRDOAnalysis::m_ntuplePath
Gaudi::Property< std::string > m_ntuplePath
Definition: EventInfoRDOAnalysis.h:33
EventInfoRDOAnalysis::m_ntupleName
Gaudi::Property< std::string > m_ntupleName
Definition: EventInfoRDOAnalysis.h:34
xAOD::EventInfo_v1::beamPosSigmaY
float beamPosSigmaY() const
The width of the beam spot in the Y direction.
xAOD::EventInfo_v1::averageInteractionsPerCrossing
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Definition: EventInfo_v1.cxx:397
xAOD::EventInfo_v1::beamPosZ
float beamPosZ() const
Z coordinate of the beam spot position.
EventInfoRDOAnalysis::m_beamPosSigmaX
float m_beamPosSigmaX
Definition: EventInfoRDOAnalysis.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfoRDOAnalysis::execute
virtual StatusCode execute() override final
Definition: EventInfoRDOAnalysis.cxx:59
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
EventInfoRDOAnalysis::m_beamPosY
float m_beamPosY
Definition: EventInfoRDOAnalysis.h:48
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
xAOD::EventInfo_v1::actualInteractionsPerCrossing
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
Definition: EventInfo_v1.cxx:380