ATLAS Offline Software
Loading...
Searching...
No Matches
EventPropertyNtupleTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// EventPropertyNtupleTool.cxx
7// Source file for class EventPropertyNtupleTool
9// (c) ATLAS Detector software
11// Wolfgang.Liebig -at- cern.ch
13
14
15#include "TTree.h"
16//Gaudi
17#include "GaudiKernel/ITHistSvc.h"
18
21#include "EventInfo/EventInfo.h"
22#include "EventInfo/EventID.h"
24
25// constructor
27 const std::string& t,
28 const std::string& n,
29 const IInterface* p )
30 :
31 AthAlgTool(t,n,p),
32 m_doTriggerInfo(true),
33 m_doTrtPhase(false),
34 m_comTimeName("TRT_Phase"),
35 m_runNumber(0),
37 m_tdc_phase(0),
39 m_trigLvl1TAV(nullptr),
40 m_lumiBlock(0),
41 m_timeStamp(0),
42 m_bCID (0)
43
44{
45 declareInterface<IEventPropertyNtupleTool>(this);
46 declareProperty("FillTrtPhase",m_doTrtPhase);
47 declareProperty("FillTrigger",m_doTriggerInfo);
48}
49
50// destructor
52
54 m_trigLvl1TAV = new std::vector<unsigned int>();
55 ATH_MSG_DEBUG ("initialise successful in "<<name());
56 return AthAlgTool::initialize();
57}
58
60 delete m_trigLvl1TAV;
61 ATH_MSG_DEBUG ("finalize successfull in "<<name());
62 return StatusCode::SUCCESS;
63}
64
65
66StatusCode Trk::EventPropertyNtupleTool::addNtupleItems( TTree* tree, const std::string & ) {
67 if (!tree) return StatusCode::FAILURE;
68 //-----------------
69 // add items
70 tree->Branch("RunNumber", &m_runNumber, "RunNumber/I");
71 tree->Branch("EventNumber", &m_eventNumber, "EventNumber/I");
72 tree->Branch("LumiBlockN", &m_lumiBlock, "LumiBlockN/I");
73 tree->Branch("TimeStamp", &m_timeStamp, "TimeStamp/I");
74 tree->Branch("BCID", &m_bCID, "BCID/I");
75 if (m_doTrtPhase) {
76 tree->Branch("TRT_Phase", &m_tdc_phase, "TRT_Phase/F");
77 }
78 if (m_doTriggerInfo) {
79 tree->Branch("Trig_LVL1StreamType", &m_trigLvl1Type,"Trig_LVL1StreamType/I");
80 tree->Branch("Trig_LVL1InfoTAV", &m_trigLvl1TAV);
81 }
82 return StatusCode::SUCCESS;
83}
84
86 const EventInfo* eventInfo;
87 if ((evtStore()->retrieve(eventInfo)).isFailure()) {
88 msg(MSG::WARNING) << "Could not retrieve event info" << endmsg;
89 m_runNumber = -999;
90 m_eventNumber = -999;
91 m_timeStamp = -999;
92 m_lumiBlock = -999;
93 m_bCID = -999;
94 return StatusCode::SUCCESS;
95 } else {
96 const EventID* myEventID=eventInfo->event_ID();
97 m_runNumber = myEventID->run_number();
98 m_eventNumber = myEventID->event_number();
99 m_timeStamp = myEventID->time_stamp() ;
100 m_lumiBlock = myEventID->lumi_block() ;
101 m_bCID = myEventID->bunch_crossing_id() ;
102 }
103
104 if (m_doTrtPhase) {
105 const ComTime* comtime=nullptr;
106
108 StatusCode sc = evtStore()->retrieve(comtime,m_comTimeName);
109 if (sc.isFailure() || !comtime) {
110 ATH_MSG_WARNING ("Could not find the ComTime object with name "<< m_comTimeName);
111 } else {
112 m_tdc_phase = comtime->getTime();
113 }
114 } else {
115 ATH_MSG_WARNING ("Could not find the ComTime object with name "<< m_comTimeName);
116 return StatusCode::FAILURE;
117 }
118 }
119
120 if (m_doTriggerInfo) {
121 const TriggerInfo* myTriggerInfo=eventInfo->trigger_info();
122 if (myTriggerInfo!=nullptr) {
123 m_trigLvl1Type = myTriggerInfo->level1TriggerType();
124 std::vector<unsigned int> l1trigger = myTriggerInfo->level1TriggerInfo();
125 if (l1trigger.size() == 24) { // size is 0 if trigger not simulated.
126 m_trigLvl1TAV->resize(8);
127 for (int i=0; i<8; ++i) {
128 m_trigLvl1TAV->at(i) = l1trigger.at(i+16);
129 }
130 }
131 } else m_trigLvl1Type = -1000;
132 }
133
134 return StatusCode::SUCCESS;
135
136 // remember calling algo is the one to record the content on the tree.
137}
138
140 m_eventNumber = 0;
141 m_runNumber = 0;
142 m_tdc_phase = 0.0;
143 m_lumiBlock = 0;
144 m_tdc_phase = 0;
145 m_bCID = 0;
146 if (m_doTriggerInfo) {
147 m_trigLvl1Type = 0;
148 m_trigLvl1TAV->clear();
149 }
150 return StatusCode::SUCCESS;
151}
152
#define endmsg
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
static Double_t sc
This class contains trigger related information.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
double getTime() const
Definition ComTime.h:44
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition EventID.h:35
EventID * event_ID()
the unique identification of the event.
TriggerInfo * trigger_info()
trigger information (ptr may be NULL)
This class contains trigger related information.
Definition TriggerInfo.h:77
number_type level1TriggerType() const
get level1 trigger type
const std::vector< number_type > & level1TriggerInfo() const
get level1 trigger info
int m_trigLvl1Type
level 1 trigger type bitted word (2008: equivalent with stream) UNIT:8-bit
virtual StatusCode addNtupleItems(TTree *, const std::string &)
add branches to the tree Should be called once dunring the initialisation phase by the calling algori...
virtual StatusCode fillEventData()
calculate event-wide data and copy into TTree branches, but don't write the record yet.
EventPropertyNtupleTool(const std::string &, const std::string &, const IInterface *)
std::vector< unsigned int > * m_trigLvl1TAV
level 1 trigger-after-veto info (256 bits in vector) UNIT:bitted
float m_tdc_phase
event phase in cosmic events (optional) UNIT:nsec
int m_lumiBlock
lumi block number of current event
int m_runNumber
run number this event belongs to
int m_timeStamp
time stamp of current event
virtual StatusCode resetVariables()
reset ntuple variables (mainly for vectors which need to be cleared)
int m_bCID
bunch crossing ID for current event
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
MsgStream & msg
Definition testRead.cxx:32
TChain * tree