ATLAS Offline Software
DummyDumperAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "DummyDumperAlg.h"
7 
8 #include "EventInfo/EventInfo.h"
9 #include "EventInfo/EventID.h"
10 
11 #include "GaudiKernel/ITHistSvc.h"
12 
13 #include <TList.h>
14 #include "TTree.h"
15 
16 DummyDumperAlg::DummyDumperAlg(const std::string& name, ISvcLocator* pSvcLocator)
17  : AthAlgorithm(name, pSvcLocator)
18  , m_tree(0)
19  , m_eventCounter(0)
20  , m_dummyInt(0)
21 {
22  declareProperty( "GRLNameVec", m_grlname );
23 }
24 
25 
27 {
30  //if (m_tree!=0) { delete m_tree; m_tree=0; }
31 }
32 
33 
35 {
36  ATH_MSG_DEBUG ("initialize()");
37 
38  MsgStream log (msgSvc(), name());
39 
40  if (service("THistSvc",m_ths).isFailure())
41  {
42  log << MSG::ERROR << "Couldn't get THistSvc" << endmsg;
43  return StatusCode::FAILURE;
44  }
45 
46  // make tree
47  m_tree = new TTree("tree","tree");
48  if (m_ths->regTree (m_tree->GetName(), m_tree).isFailure())
49  {
50  log << MSG::ERROR << "Couldn't register " << m_tree->GetName() << endmsg;
51  return StatusCode::FAILURE;
52  }
53 
54  (void) m_tree->Branch("eventNumber",&m_dummyInt,"eventNumber/I");
55  (void) m_tree->Branch("runNumber",&m_dummyInt,"runNumber/I");
56  (void) m_tree->Branch("lumiBlock",&m_dummyInt,"lumiBlock/I");
57  (void) m_tree->Branch("timeStamp",&m_dummyInt,"timeStamp/I");
58 
59  ATH_MSG_DEBUG ("initialize() successful");
60 
61  return StatusCode::SUCCESS;
62 }
63 
64 
67 {
68  ATH_MSG_DEBUG ("execute()");
69 
71 
72  // get event number here ...
73  int eventNumber(0);
74  int runNumber(0);
75  int lumiBlock(0);
76  int timeStamp(0);
77 
78  // retrieve event info
79  const EventInfo* p_evt = 0;
80  StatusCode status = evtStore()->retrieve(p_evt);
81 
82  if(status.isSuccess() && p_evt!=0) {
83  eventNumber = p_evt->event_ID()->event_number();
84  runNumber = p_evt->event_ID()->run_number();
85  lumiBlock = p_evt->event_ID()->lumi_block();
86  timeStamp = p_evt->event_ID()->time_stamp();
87  ATH_MSG_DEBUG ("Got run number = " << runNumber << ", event number = " << eventNumber);
88  } else {
89  ATH_MSG_WARNING ("Unable to retrieve EventInfo from StoreGate. Return failure.");
90  return status;
91  }
92 
93  // fill the dummy tree
94  m_tree->SetBranchAddress( "eventNumber", &eventNumber );
95  m_tree->SetBranchAddress( "runNumber", &runNumber );
96  m_tree->SetBranchAddress( "lumiBlock", &lumiBlock );
97  m_tree->SetBranchAddress( "timeStamp", &timeStamp );
98 
99  m_tree->Fill();
100 
101  ATH_MSG_DEBUG ("execute() successful");
102 
103  return StatusCode::SUCCESS;
104 }
105 
106 
108 {
109  ATH_MSG_DEBUG ("finalize()");
110  return StatusCode::SUCCESS;
111 }
112 
113 
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DummyDumperAlg::m_tree
TTree * m_tree
Definition: DummyDumperAlg.h:37
DummyDumperAlg::m_ths
ITHistSvc * m_ths
Definition: DummyDumperAlg.h:42
DummyDumperAlg::m_dummyInt
int m_dummyInt
Definition: DummyDumperAlg.h:40
DummyDumperAlg::m_eventCounter
int m_eventCounter
Definition: DummyDumperAlg.h:39
DummyDumperAlg::initialize
StatusCode initialize()
Definition: DummyDumperAlg.cxx:34
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
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
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
DummyDumperAlg::finalize
StatusCode finalize()
Definition: DummyDumperAlg.cxx:107
AthAlgorithm
Definition: AthAlgorithm.h:47
DummyDumperAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
DummyDumperAlg::execute
StatusCode execute()
Definition: DummyDumperAlg.cxx:66
DummyDumperAlg::DummyDumperAlg
DummyDumperAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: DummyDumperAlg.cxx:16
xAOD::timeStamp
setEventNumber timeStamp
Definition: EventInfo_v1.cxx:128
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
DummyDumperAlg::m_grlname
std::vector< std::string > m_grlname
Definition: DummyDumperAlg.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DummyDumperAlg::~DummyDumperAlg
virtual ~DummyDumperAlg()
Definition: DummyDumperAlg.cxx:26
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
merge.status
status
Definition: merge.py:17
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327