ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TestBeam
TBRec
src
CBNT_TBRecBase.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CBNT_TBRecBase.h
"
6
7
#include "
LArIdentifier/LArOnlineID.h
"
8
#include "
CaloIdentifier/CaloCell_ID.h
"
9
#include "GaudiKernel/ITHistSvc.h"
10
11
12
CBNT_TBRecBase::CBNT_TBRecBase
(
const
std::string& name, ISvcLocator* pSvcLocator):
13
AthAlgorithm
(name, pSvcLocator),
m_initialized
(false),
m_nt
(NULL),
m_log
(NULL),
14
m_emId
(NULL),
m_hecId
(NULL),
m_fcalId
(NULL),
m_onlineId
(NULL)
15
{
16
}
17
18
CBNT_TBRecBase::~CBNT_TBRecBase
() {
19
delete
m_log
;
20
}
21
22
StatusCode
CBNT_TBRecBase::initialize
() {
23
m_log
=
new
MsgStream(msgSvc(), name());
24
25
*
m_log
<< MSG::DEBUG <<
"Initializing CBNT_TBRecBase base class"
<<
endmsg
;
26
27
const
CaloCell_ID
* idHelper =
nullptr
;
28
ATH_CHECK
(
detStore
()->retrieve (idHelper,
"CaloCell_ID"
) );
29
m_emId
=idHelper->
em_idHelper
();
30
m_fcalId
=idHelper->
fcal_idHelper
();
31
m_hecId
=idHelper->
hec_idHelper
();
32
33
34
if
(!
m_emId
) {
35
(*m_log) << MSG::ERROR <<
"Could not access lar EM ID helper"
<<
endmsg
;
36
return
StatusCode::FAILURE;
37
}
38
if
(!
m_fcalId
) {
39
(*m_log) << MSG::ERROR <<
"Could not access lar FCAL ID helper"
<<
endmsg
;
40
return
StatusCode::FAILURE;
41
}
42
if
(!
m_hecId
) {
43
(*m_log) << MSG::ERROR <<
"Could not access lar HEC ID helper"
<<
endmsg
;
44
return
StatusCode::FAILURE;
45
}
46
47
StatusCode
sc
=
detStore
()->retrieve(
m_onlineId
,
"LArOnlineID"
);
48
if
(
sc
.isFailure()) {
49
(*m_log) << MSG::ERROR <<
"Could not get LArOnlineID helper !"
<<
endmsg
;
50
return
StatusCode::FAILURE;
51
}
52
else
{
53
(*m_log) << MSG::DEBUG <<
" Found the LArOnlineID helper. "
<<
endmsg
;
54
}
55
56
57
m_initialized
=
true
;
58
return
StatusCode::SUCCESS;
59
}
60
61
StatusCode
CBNT_TBRecBase::pre_execute
() {
62
63
StatusCode
sc
;
64
65
if
(!
m_initialized
) {
66
67
if
(
m_ntpath
.size()==0 ||
m_ntTitle
.size()==0) {
68
*
m_log
<< MSG::ERROR <<
"Need to set variable 'm_ntpath' and 'm_ntTitle' in constructor of deriving class!"
<<
endmsg
;
69
return
StatusCode::FAILURE;
70
}
71
72
size_t
i=
m_ntpath
.rfind(
'/'
);
73
if
(i==std::string::npos) {
74
*
m_log
<< MSG::ERROR <<
"Expected at least on '/' in path "
<<
m_ntpath
<<
endmsg
;
75
return
StatusCode::FAILURE;
76
}
77
std::string basepath(
m_ntpath
.begin(),
m_ntpath
.begin()+i);
78
//std::cout << "Basepath" << basepath << std::endl;
79
80
// retrieve pointer to THistSvc
81
ServiceHandle<ITHistSvc>
tHistSvc(
"THistSvc"
, name());
82
ATH_CHECK
( tHistSvc.retrieve() );
83
84
// get TTree
85
sc
= tHistSvc->getTree(
m_ntpath
,
m_nt
);
86
if
(
sc
.isFailure()) {
87
*
m_log
<< MSG::ERROR <<
"Unable to retrieve TTree : "
<<
m_ntpath
<<
endmsg
;
88
return
sc
;
89
}
90
/*
91
NTupleFilePtr file1(ntupleSvc(),basepath);
92
if (!file1){
93
(*m_log) << MSG::ERROR << "Could not get NTupleFilePtr with path " << basepath << " failed" << endmsg;
94
return StatusCode::FAILURE;
95
}
96
NTuplePtr nt(ntupleSvc(),m_ntpath);
97
if (!nt) {
98
nt=ntupleSvc()->book(m_ntpath,CLID_ColumnWiseTuple,m_ntTitle);
99
}
100
if (!nt){
101
(*m_log) << MSG::ERROR << "Booking of NTuple at "<< m_ntpath << " and name " << m_ntTitle << " failed" << endmsg;
102
return StatusCode::FAILURE;
103
}
104
m_nt=nt;
105
*/
106
//std::cout << "Ntuple ptr:" << m_nt << std::endl;
107
108
// subalgorithm initialisation
109
try
{
110
sc
= this->
CBNT_initialize
();
111
}
112
catch
(
const
std::exception& Exception ) {
113
*
m_log
<< MSG::ERROR <<
" Standard exception "
114
<< Exception.what()
115
<<
" caught from sub-algorithm::CBNT_initialize () :"
<<
endmsg
;
116
}
117
catch
(...) {
118
*
m_log
<< MSG::ERROR <<
" Unknown exception "
119
<<
" caught from sub-algorithm::CBNT_initialize () :"
<<
endmsg
;
120
}
121
122
if
(
sc
.isFailure())
123
{
124
*
m_log
<< MSG::ERROR <<
"CBNT_initialize() failed"
<<
endmsg
;
125
return
sc
;
126
}
127
128
m_initialized
=
true
;
129
}
130
131
// clear data members
132
try
{
133
sc
= this->
CBNT_clear
();
134
}
135
catch
(
const
std::exception& Exception ) {
136
*
m_log
<< MSG::ERROR <<
" Standard exception "
137
<< Exception.what()
138
<<
" caught from sub-algorithm::CBNT_clear () :"
<<
endmsg
;
139
}
140
catch
(...) {
141
*
m_log
<< MSG::ERROR <<
" Unknown exception "
142
<<
" caught from sub-algorithm::CBNT_clear () :"
<<
endmsg
;
143
}
144
145
if
(
sc
.isFailure()) {
146
*
m_log
<< MSG::ERROR <<
"CBNT_clear() failed"
<<
endmsg
;
147
return
sc
;
148
}
149
150
return
StatusCode::SUCCESS ;
151
}
152
153
154
StatusCode
CBNT_TBRecBase::execute
(
const
EventContext&
/*ctx*/
) {
155
156
StatusCode
sc
;
157
158
// run pre-execution
159
try
{
160
sc
= this->
pre_execute
();
161
}
162
163
catch
(
const
std::exception& Exception ) {
164
*
m_log
<< MSG::ERROR <<
" Standard exception "
165
<< Exception.what()
166
<<
" caught from sub-algorithm::CBNT_pre_execute (). Disable !"
<<
endmsg
;
167
sc
= this->
setProperty
(BooleanProperty(
"Enable"
,
false
) );
168
return
StatusCode::FAILURE;
169
170
}
171
catch
(...) {
172
*
m_log
<< MSG::ERROR <<
" Unknown exception "
173
<<
" caught from sub-algorithm::CBNT_pre_execute (). Disable !"
<<
endmsg
;
174
sc
= this->
setProperty
(BooleanProperty(
"Enable"
,
false
) );
175
return
StatusCode::FAILURE;
176
}
177
178
if
(
sc
.isFailure()) {
179
*
m_log
<< MSG::ERROR <<
"CBNT_pre_execute() failed. Disable !"
<<
endmsg
;
180
sc
= this->
setProperty
(BooleanProperty(
"Enable"
,
false
) );
181
return
sc
;
182
}
183
184
// now subalgorithm execution
185
try
{
186
sc
= this->
CBNT_execute
();
187
}
188
189
catch
(
const
std::exception& Exception ) {
190
*
m_log
<< MSG::ERROR <<
" Standard exception "
191
<< Exception.what()
192
<<
" caught from sub-algorithm::CBNT_execute () :"
<<
endmsg
;
193
return
StatusCode::FAILURE;
194
}
195
catch
(...) {
196
*
m_log
<< MSG::ERROR <<
" Unknown exception "
197
<<
" caught from sub-algorithm::CBNT_execute () :"
<<
endmsg
;
198
return
StatusCode::FAILURE;
199
}
200
201
return
sc
;
202
}
203
204
205
StatusCode
CBNT_TBRecBase::finalize
() {
206
207
StatusCode
sc
;
208
209
//now subalgorithm finalisation
210
try
{
211
sc
= this->
CBNT_finalize
();
212
}
213
catch
(
const
std::exception& Exception ) {
214
*
m_log
<< MSG::ERROR <<
" Standard exception "
215
<< Exception.what()
216
<<
" caught from sub-algorithm::CBNT_finalize () :"
<<
endmsg
;
217
}
218
catch
(...) {
219
*
m_log
<< MSG::ERROR <<
" Unknown exception "
220
<<
" caught from sub-algorithm::CBNT_finalize () :"
<<
endmsg
;
221
}
222
223
return
sc
;
224
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:61
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
CBNT_TBRecBase.h
CaloCell_ID.h
LArOnlineID.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
setProperty
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
Definition
NanobindBindings.cxx:75
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
CBNT_TBRecBase::m_onlineId
const LArOnlineID * m_onlineId
Definition
CBNT_TBRecBase.h:68
CBNT_TBRecBase::initialize
virtual StatusCode initialize() override
Definition
CBNT_TBRecBase.cxx:22
CBNT_TBRecBase::finalize
virtual StatusCode finalize() override
Definition
CBNT_TBRecBase.cxx:205
CBNT_TBRecBase::m_fcalId
const LArFCAL_ID * m_fcalId
Definition
CBNT_TBRecBase.h:67
CBNT_TBRecBase::m_ntTitle
std::string m_ntTitle
Definition
CBNT_TBRecBase.h:58
CBNT_TBRecBase::CBNT_clear
virtual StatusCode CBNT_clear()
Definition
CBNT_TBRecBase.h:37
CBNT_TBRecBase::CBNT_execute
virtual StatusCode CBNT_execute()
Definition
CBNT_TBRecBase.h:35
CBNT_TBRecBase::m_log
MsgStream * m_log
Definition
CBNT_TBRecBase.h:63
CBNT_TBRecBase::m_ntpath
std::string m_ntpath
Definition
CBNT_TBRecBase.h:58
CBNT_TBRecBase::CBNT_finalize
virtual StatusCode CBNT_finalize()
Definition
CBNT_TBRecBase.h:36
CBNT_TBRecBase::m_initialized
bool m_initialized
Definition
CBNT_TBRecBase.h:40
CBNT_TBRecBase::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
CBNT_TBRecBase.cxx:154
CBNT_TBRecBase::m_emId
const LArEM_ID * m_emId
Definition
CBNT_TBRecBase.h:65
CBNT_TBRecBase::m_nt
TTree * m_nt
Definition
CBNT_TBRecBase.h:61
CBNT_TBRecBase::pre_execute
virtual StatusCode pre_execute()
Definition
CBNT_TBRecBase.cxx:61
CBNT_TBRecBase::CBNT_TBRecBase
CBNT_TBRecBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CBNT_TBRecBase.cxx:12
CBNT_TBRecBase::CBNT_initialize
virtual StatusCode CBNT_initialize()
Definition
CBNT_TBRecBase.h:34
CBNT_TBRecBase::~CBNT_TBRecBase
virtual ~CBNT_TBRecBase()
Definition
CBNT_TBRecBase.cxx:18
CBNT_TBRecBase::m_hecId
const LArHEC_ID * m_hecId
Definition
CBNT_TBRecBase.h:66
CaloCell_ID
Helper class for offline cell identifiers.
Definition
CaloCell_ID.h:34
CaloCell_ID::fcal_idHelper
const LArFCAL_ID * fcal_idHelper() const
access to FCAL idHelper
Definition
CaloCell_ID.h:75
CaloCell_ID::em_idHelper
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition
CaloCell_ID.h:63
CaloCell_ID::hec_idHelper
const LArHEC_ID * hec_idHelper() const
access to HEC idHelper
Definition
CaloCell_ID.h:69
ServiceHandle
Definition
ClusterMakerTool.h:36
Generated on
for ATLAS Offline Software by
1.17.0