ATLAS Offline Software
EventPropertyNtupleTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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/SmartDataPtr.h"
18 #include "GaudiKernel/ITHistSvc.h"
19 // #include "GaudiKernel/ISvcLocator.h"
20 // #include "GaudiKernel/PropertyMgr.h"
23 #include "EventInfo/EventInfo.h"
24 #include "EventInfo/EventID.h"
25 #include "EventInfo/TriggerInfo.h"
26 
27 // constructor
29  const std::string& t,
30  const std::string& n,
31  const IInterface* p )
32  :
33  AthAlgTool(t,n,p),
34  m_doTriggerInfo(true),
35  m_doTrtPhase(false),
36  m_comTimeName("TRT_Phase"),
37  m_runNumber(0),
38  m_eventNumber(0),
39  m_tdc_phase(0),
40  m_trigLvl1Type(0),
41  m_trigLvl1TAV(nullptr),
42  m_lumiBlock(0),
43  m_timeStamp(0),
44  m_bCID (0)
45 
46 {
47  declareInterface<IEventPropertyNtupleTool>(this);
48  declareProperty("FillTrtPhase",m_doTrtPhase);
49  declareProperty("FillTrigger",m_doTriggerInfo);
50 }
51 
52 // destructor
54 
56  m_trigLvl1TAV = new std::vector<unsigned int>();
57  ATH_MSG_DEBUG ("initialise successful in "<<name());
58  return AthAlgTool::initialize();
59 }
60 
62  delete m_trigLvl1TAV;
63  ATH_MSG_DEBUG ("finalize successfull in "<<name());
64  return StatusCode::SUCCESS;
65 }
66 
67 
69  if (!tree) return StatusCode::FAILURE;
70  //-----------------
71  // add items
72  tree->Branch("RunNumber", &m_runNumber, "RunNumber/I");
73  tree->Branch("EventNumber", &m_eventNumber, "EventNumber/I");
74  tree->Branch("LumiBlockN", &m_lumiBlock, "LumiBlockN/I");
75  tree->Branch("TimeStamp", &m_timeStamp, "TimeStamp/I");
76  tree->Branch("BCID", &m_bCID, "BCID/I");
77  if (m_doTrtPhase) {
78  tree->Branch("TRT_Phase", &m_tdc_phase, "TRT_Phase/F");
79  }
80  if (m_doTriggerInfo) {
81  tree->Branch("Trig_LVL1StreamType", &m_trigLvl1Type,"Trig_LVL1StreamType/I");
82  tree->Branch("Trig_LVL1InfoTAV", &m_trigLvl1TAV);
83  }
84  return StatusCode::SUCCESS;
85 }
86 
88  const EventInfo* eventInfo;
89  if ((evtStore()->retrieve(eventInfo)).isFailure()) {
90  msg(MSG::WARNING) << "Could not retrieve event info" << endmsg;
91  m_runNumber = -999;
92  m_eventNumber = -999;
93  m_timeStamp = -999;
94  m_lumiBlock = -999;
95  m_bCID = -999;
96  return StatusCode::SUCCESS;
97  } else {
98  const EventID* myEventID=eventInfo->event_ID();
99  m_runNumber = myEventID->run_number();
100  m_eventNumber = myEventID->event_number();
101  m_timeStamp = myEventID->time_stamp() ;
102  m_lumiBlock = myEventID->lumi_block() ;
103  m_bCID = myEventID->bunch_crossing_id() ;
104  }
105 
106  if (m_doTrtPhase) {
107  const ComTime* comtime=nullptr;
108 
109  if (evtStore()->contains<ComTime>(m_comTimeName)) {
110  StatusCode sc = evtStore()->retrieve(comtime,m_comTimeName);
111  if (sc.isFailure() || !comtime) {
112  ATH_MSG_WARNING ("Could not find the ComTime object with name "<< m_comTimeName);
113  } else {
114  m_tdc_phase = comtime->getTime();
115  }
116  } else {
117  ATH_MSG_WARNING ("Could not find the ComTime object with name "<< m_comTimeName);
118  return StatusCode::FAILURE;
119  }
120  }
121 
122  if (m_doTriggerInfo) {
123  const TriggerInfo* myTriggerInfo=eventInfo->trigger_info();
124  if (myTriggerInfo!=nullptr) {
125  m_trigLvl1Type = myTriggerInfo->level1TriggerType();
126  std::vector<unsigned int> l1trigger = myTriggerInfo->level1TriggerInfo();
127  if (l1trigger.size() == 24) { // size is 0 if trigger not simulated.
128  m_trigLvl1TAV->resize(8);
129  for (int i=0; i<8; ++i) {
130  m_trigLvl1TAV->at(i) = l1trigger.at(i+16);
131  }
132  }
133  } else m_trigLvl1Type = -1000;
134  }
135 
136  return StatusCode::SUCCESS;
137 
138  // remember calling algo is the one to record the content on the tree.
139 }
140 
142  m_eventNumber = 0;
143  m_runNumber = 0;
144  m_tdc_phase = 0.0;
145  m_lumiBlock = 0;
146  m_tdc_phase = 0;
147  m_bCID = 0;
148  if (m_doTriggerInfo) {
149  m_trigLvl1Type = 0;
150  m_trigLvl1TAV->clear();
151  }
152  return StatusCode::SUCCESS;
153 }
154 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ComTime.h
ComTime::getTime
double getTime() const
Definition: ComTime.h:44
Trk::EventPropertyNtupleTool::resetVariables
virtual StatusCode resetVariables()
reset ntuple variables (mainly for vectors which need to be cleared)
Definition: EventPropertyNtupleTool.cxx:141
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::EventPropertyNtupleTool::~EventPropertyNtupleTool
~EventPropertyNtupleTool()
initialize
void initialize()
Definition: run_EoverP.cxx:894
tree
TChain * tree
Definition: tile_monitor.h:30
TriggerInfo.h
This class contains trigger related information.
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ComTime
Definition: ComTime.h:17
Trk::EventPropertyNtupleTool::m_doTriggerInfo
bool m_doTriggerInfo
Definition: EventPropertyNtupleTool.h:70
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
Trk::EventPropertyNtupleTool::fillEventData
virtual StatusCode fillEventData()
calculate event-wide data and copy into TTree branches, but don't write the record yet.
Definition: EventPropertyNtupleTool.cxx:87
TriggerInfo::level1TriggerInfo
const std::vector< number_type > & level1TriggerInfo() const
get level1 trigger info
Definition: TriggerInfo.cxx:143
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
EventInfo::event_ID
EventID * event_ID()
the unique identification of the event.
Definition: EventInfo/EventInfo/EventInfo.h:210
EventPropertyNtupleTool.h
TriggerInfo::level1TriggerType
number_type level1TriggerType() const
get level1 trigger type
Definition: TriggerInfo.cxx:138
Trk::EventPropertyNtupleTool::addNtupleItems
virtual StatusCode addNtupleItems(TTree *, const std::string)
add branches to the tree Should be called once dunring the initialisation phase by the calling algori...
Definition: EventPropertyNtupleTool.cxx:68
TriggerInfo
This class contains trigger related information.
Definition: TriggerInfo.h:77
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
Trk::EventPropertyNtupleTool::EventPropertyNtupleTool
EventPropertyNtupleTool(const std::string &, const std::string &, const IInterface *)
Definition: EventPropertyNtupleTool.cxx:28
Trk::EventPropertyNtupleTool::initialize
StatusCode initialize()
Definition: EventPropertyNtupleTool.cxx:55
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
EventInfo::trigger_info
TriggerInfo * trigger_info()
trigger information (ptr may be NULL)
Definition: EventInfo/EventInfo/EventInfo.h:230
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
Trk::EventPropertyNtupleTool::m_doTrtPhase
bool m_doTrtPhase
Definition: EventPropertyNtupleTool.h:71
AthAlgTool
Definition: AthAlgTool.h:26
Trk::EventPropertyNtupleTool::finalize
StatusCode finalize()
Definition: EventPropertyNtupleTool.cxx:61
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7