ATLAS Offline Software
EventInfoRDOAnalysis.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 #include "EventInfoRDOAnalysis.h"
6 #include "StoreGate/ReadHandle.h"
7 
8 #include <TH1.h>
9 #include <TTree.h>
10 
11 
13 {
14  // This will check that the properties were initialized
15  // properly by job configuration.
17 
18 
19  m_tree = new TTree(m_ntupleName.value().c_str(), "EventInfoRDOAnalysis");
20  ATH_CHECK(histSvc()->regTree(m_ntuplePath.value() + m_ntupleName.value(), m_tree));
21  m_tree->Branch("runNumber", &m_runNumber);
22  m_tree->Branch("eventNumber", &m_eventNumber);
23  m_tree->Branch("lumiBlock", &m_lumiBlock);
24  m_tree->Branch("bcid", &m_bcid);
25 
26  m_tree->Branch("actualInteractionsPerCrossing", &m_actualInteractionsPerCrossing);
27  m_tree->Branch("averageInteractionsPerCrossing", &m_averageInteractionsPerCrossing);
28 
29  m_tree->Branch("beamPosX", &m_beamPosX);
30  m_tree->Branch("beamPosY", &m_beamPosY);
31  m_tree->Branch("beamPosZ", &m_beamPosZ);
32  m_tree->Branch("beamPosSigmaX", &m_beamPosSigmaX);
33  m_tree->Branch("beamPosSigmaY", &m_beamPosSigmaY);
34  m_tree->Branch("beamPosSigmaZ", &m_beamPosSigmaZ);
35 
36 
37  // HISTOGRAMS
38  m_h_actualInteractionsPerCrossing = new TH1F("h_actualInteractionsPerCrossing", "actualInteractionsPerCrossing", 100, 0, 100);
39  m_h_actualInteractionsPerCrossing->StatOverflows();
41 
42  m_h_averageInteractionsPerCrossing = new TH1F("h_averageInteractionsPerCrossing", "averageInteractionsPerCrossing", 100, 0, 100);
43  m_h_averageInteractionsPerCrossing->StatOverflows();
45 
46  return StatusCode::SUCCESS;
47 }
48 
50 {
51 
52  const xAOD::EventInfo* eventInfo{nullptr};
53  ATH_CHECK(SG::get(eventInfo, m_eventInfoKey, Gaudi::Hive::currentContext()));
54 
55  m_runNumber = eventInfo->runNumber();
56  m_eventNumber = eventInfo->eventNumber();
57  m_lumiBlock = eventInfo->lumiBlock();
58  m_bcid = eventInfo->bcid();
59 
60  m_actualInteractionsPerCrossing = eventInfo->actualInteractionsPerCrossing();
61  m_averageInteractionsPerCrossing = eventInfo->averageInteractionsPerCrossing();
64 
65  m_beamPosX = eventInfo->beamPosX();
66  m_beamPosY = eventInfo->beamPosY();
67  m_beamPosZ = eventInfo->beamPosZ();
68 
69  m_beamPosSigmaX = eventInfo->beamPosSigmaX();
70  m_beamPosSigmaY = eventInfo->beamPosSigmaY();
71  m_beamPosSigmaZ = eventInfo->beamPosSigmaZ();
72 
73  m_tree->Fill();
74 
75  return StatusCode::SUCCESS;
76 }
EventInfoRDOAnalysis::m_lumiBlock
uint32_t m_lumiBlock
Definition: EventInfoRDOAnalysis.h:41
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition: AthHistogramAlgorithm.h:113
EventInfoRDOAnalysis::m_h_actualInteractionsPerCrossing
TH1 * m_h_actualInteractionsPerCrossing
Definition: EventInfoRDOAnalysis.h:56
EventInfoRDOAnalysis::m_beamPosSigmaY
float m_beamPosSigmaY
Definition: EventInfoRDOAnalysis.h:52
EventInfoRDOAnalysis::m_beamPosSigmaZ
float m_beamPosSigmaZ
Definition: EventInfoRDOAnalysis.h:53
EventInfoRDOAnalysis::m_beamPosZ
float m_beamPosZ
Definition: EventInfoRDOAnalysis.h:49
EventInfoRDOAnalysis::initialize
virtual StatusCode initialize() override final
Definition: EventInfoRDOAnalysis.cxx:12
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
EventInfoRDOAnalysis.h
EventInfoRDOAnalysis::m_beamPosX
float m_beamPosX
Definition: EventInfoRDOAnalysis.h:47
EventInfoRDOAnalysis::m_tree
TTree * m_tree
Definition: EventInfoRDOAnalysis.h:59
EventInfoRDOAnalysis::m_averageInteractionsPerCrossing
float m_averageInteractionsPerCrossing
Definition: EventInfoRDOAnalysis.h:45
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
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
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
EventInfoRDOAnalysis::m_beamPosSigmaX
float m_beamPosSigmaX
Definition: EventInfoRDOAnalysis.h:51
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
EventInfoRDOAnalysis::execute
virtual StatusCode execute() override final
Definition: EventInfoRDOAnalysis.cxx:49
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
ReadHandle.h
Handle class for reading from StoreGate.