ATLAS Offline Software
Loading...
Searching...
No Matches
Hist.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 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// ROOT includes
16#include "TH1F.h"
17
18using namespace AthEx;
19
21// Public methods:
23
24// Constructors
26Hist::Hist( const std::string& name,
27 ISvcLocator* pSvcLocator ) :
28 ::AthAlgorithm( name, pSvcLocator ),
29 m_hist (0)
30{ }
31
32// Destructor
36
37// Athena Algorithm's Hooks
39StatusCode Hist::initialize()
40{
41 ATH_MSG_INFO ("Initializing " << name() << "...");
42 ATH_CHECK( m_histSvc.retrieve() );
43 ATH_CHECK( m_evt.initialize() );
44
45 // register our histogram with the svc
46 m_hist = new TH1F("h1", "histogram title", 100,0.,100.);
47 if (!m_histSvc->regHist("/stat/simple1D/h1", m_hist).isSuccess()) {
48 ATH_MSG_ERROR("could not register histogram [h1]");
49 delete m_hist; m_hist = 0;
50 return StatusCode::FAILURE;
51 }
52
53 return StatusCode::SUCCESS;
54}
55
56StatusCode Hist::finalize()
57{
58 ATH_MSG_INFO ("Finalizing " << name() << "...");
59
60 return StatusCode::SUCCESS;
61}
62
63StatusCode Hist::execute()
64{
65 ATH_MSG_DEBUG ("Executing " << name() << "...");
66
67 // get event data...
69 if (!evt.isValid()) {
70 ATH_MSG_ERROR ("Could not retrieve EventInfo obj");
71 return StatusCode::FAILURE;
72 }
73
74 int event = evt->eventNumber();
75 ATH_MSG_INFO(" EventInfo: r: " << event << " e: " << evt->eventNumber() );
76
77 // fill the histogram
78 m_hist->Fill( float(event), 1.);
79
80 return StatusCode::SUCCESS;
81}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual ~Hist()
Destructor:
Definition Hist.cxx:34
Hist()
Default constructor:
virtual StatusCode initialize()
Definition Hist.cxx:39
virtual StatusCode execute()
Definition Hist.cxx:63
virtual StatusCode finalize()
Definition Hist.cxx:56
SG::ReadHandleKey< xAOD::EventInfo > m_evt
key to the event-info
Definition Hist.h:69
TH1F * m_hist
pointer to our histogram
Definition Hist.h:66
ServiceHandle< ITHistSvc > m_histSvc
handle to the histogram service
Definition Hist.h:63
Definition Hist.h:27