ATLAS Offline Software
Hist.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // Hist.cxx
8 // Implementation file for class AthEx::Hist
9 // Author: S.Binet<binet@cern.ch>
11 
12 // AthExHistNtup includes
13 #include "Hist.h"
14 
15 // STL includes
16 
17 // FrameWork includes
18 #include "Gaudi/Property.h"
19 
20 // ROOT includes
21 #include "TH1F.h"
22 
23 // event includes
25 
26 using namespace AthEx;
27 
29 // Public methods:
31 
32 // Constructors
34 Hist::Hist( const std::string& name,
35  ISvcLocator* pSvcLocator ) :
36  ::AthAlgorithm( name, pSvcLocator ),
37  m_ntsvc("THistSvc/THistSvc", name),
38  m_hist (0)
39 {
40  //
41  // Property declaration
42  //
43 
44  declareProperty( "EvtInfo",
45  m_evtInfoName = "",
46  "key to the event-info instance to histogram-ize.");
47 
48 }
49 
50 // Destructor
53 {}
54 
55 // Athena Algorithm's Hooks
58 {
59  ATH_MSG_INFO ("Initializing " << name() << "...");
60 
61  if (!m_ntsvc.retrieve().isSuccess()) {
62  ATH_MSG_ERROR("could not retrieve handle to ntuple svc");
63  return StatusCode::FAILURE;
64  }
65 
66  // register our histogram with the svc
67  m_hist = new TH1F("h1", "histogram title", 100,0.,100.);
68  if (!m_ntsvc->regHist("/stat/simple1D/h1", m_hist).isSuccess()) {
69  ATH_MSG_ERROR("could not register histogram [h1]");
70  delete m_hist; m_hist = 0;
71  return StatusCode::FAILURE;
72  }
73 
74  return StatusCode::SUCCESS;
75 }
76 
78 {
79  ATH_MSG_INFO ("Finalizing " << name() << "...");
80 
81  return StatusCode::SUCCESS;
82 }
83 
85 {
86  ATH_MSG_DEBUG ("Executing " << name() << "...");
87 
88  // get event data...
89  const xAOD::EventInfo* evt = 0;
90  if (!evtStore()->retrieve(evt, m_evtInfoName).isSuccess() ||
91  0==evt) {
92  ATH_MSG_ERROR("could not get event-info at [" << m_evtInfoName << "]");
93  return StatusCode::FAILURE;
94  }
95 
96  int event = evt->eventNumber();
97 
98  // fill the histogram
99  m_hist->Fill( float(event), 1.);
100 
101  return StatusCode::SUCCESS;
102 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AthEx::Hist::Hist
Hist()
Default constructor:
AthEx::Hist::m_evtInfoName
std::string m_evtInfoName
key to the event-info
Definition: Hist.h:67
AthEx::Hist::m_hist
TH1F * m_hist
pointer to our histogram
Definition: Hist.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Hist.h
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
AthEx::Hist::m_ntsvc
ServiceHandle< ITHistSvc > m_ntsvc
handle to the n-tuple svc
Definition: Hist.h:61
AthEx::Hist::~Hist
virtual ~Hist()
Destructor:
Definition: Hist.cxx:52
AthEx::Hist::initialize
virtual StatusCode initialize()
Definition: Hist.cxx:57
AthEx::Hist::execute
virtual StatusCode execute()
Definition: Hist.cxx:84
AthEx::Hist::finalize
virtual StatusCode finalize()
Definition: Hist.cxx:77
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
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
AthEx
Definition: Hist.h:25
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24