ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExHistNtup
src
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
18
using namespace
AthEx
;
19
21
// Public methods:
23
24
// Constructors
26
Hist::Hist
(
const
std::string& name,
27
ISvcLocator* pSvcLocator ) :
28
::
AthAlgorithm
( name, pSvcLocator ),
29
m_hist
(0)
30
{ }
31
32
// Destructor
34
Hist::~Hist
()
35
{}
36
37
// Athena Algorithm's Hooks
39
StatusCode
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
56
StatusCode
Hist::finalize
()
57
{
58
ATH_MSG_INFO
(
"Finalizing "
<< name() <<
"..."
);
59
60
return
StatusCode::SUCCESS;
61
}
62
63
StatusCode
Hist::execute
(
const
EventContext& ctx)
64
{
65
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
"..."
);
66
67
// get event data...
68
SG::ReadHandle<xAOD::EventInfo>
evt(
m_evt
, ctx);
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
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
Hist.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthEx::Hist::~Hist
virtual ~Hist()
Destructor:
Definition
Hist.cxx:34
AthEx::Hist::Hist
Hist()
Default constructor:
AthEx::Hist::initialize
virtual StatusCode initialize()
Definition
Hist.cxx:39
AthEx::Hist::execute
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition
Hist.cxx:63
AthEx::Hist::finalize
virtual StatusCode finalize()
Definition
Hist.cxx:56
AthEx::Hist::m_evt
SG::ReadHandleKey< xAOD::EventInfo > m_evt
key to the event-info
Definition
Hist.h:69
AthEx::Hist::m_hist
TH1F * m_hist
pointer to our histogram
Definition
Hist.h:66
AthEx::Hist::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
handle to the histogram service
Definition
Hist.h:63
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
AthEx
Definition
Hist.h:27
Generated on
for ATLAS Offline Software by
1.17.0