ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRec
src
TileDigitsToNtuple.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
//*****************************************************************************
6
// Filename : TileDigitsToNtuple.cxx
7
// Author :
8
// Created :
9
//
10
// DESCRIPTION:
11
// Implement the algorithm
12
//
13
// HISTORY:
14
//
15
// BUGS:
16
//
17
//*****************************************************************************
18
19
//Gaudi includes
20
#include "GaudiKernel/INTupleSvc.h"
21
22
//Atlas include
23
#include "
AthenaKernel/errorcheck.h
"
24
#include "
EventContainers/SelectAllObject.h
"
25
#include "
StoreGate/ReadHandle.h
"
26
27
// Calo include
28
#include "
CaloIdentifier/TileID.h
"
29
#include "
CaloIdentifier/TileTBID.h
"
30
31
//TileCalo include
32
#include "
TileConditions/TileInfo.h
"
33
#include "
TileEvent/TileDigitsContainer.h
"
34
#include "
TileRec/TileDigitsToNtuple.h
"
35
#include "
TileIdentifier/TileHWID.h
"
36
37
38
//****************************************************************************
39
//* Initialization
40
//****************************************************************************
41
42
StatusCode
TileDigitsToNtuple::initialize
() {
43
44
ATH_MSG_INFO
(
"Initialization started"
);
45
46
// retrieve TileID helper from det store
47
CHECK
(
detStore
()->retrieve(
m_tileID
) );
48
CHECK
(
detStore
()->retrieve(
m_tileHWID
) );
49
CHECK
(
detStore
()->retrieve(
m_tileTBID
) );
50
51
const
TileInfo
* tileInfo =
nullptr
;
52
CHECK
(
detStore
()->retrieve(tileInfo,
m_infoName
) );
53
m_nSamples
= tileInfo->
NdigitSamples
();
// number of time slices for each chan
54
55
m_ntupleLoc
=
"/NTUPLES"
+
m_ntupleLoc
;
56
std::string ntupleCompleteID =
m_ntupleLoc
+
"/"
+
m_ntupleID
;
57
NTuplePtr nt(
ntupleSvc
(), ntupleCompleteID);
58
59
if
( nt ) {
// Check if already booked
60
m_ntuplePtr
= nt;
61
ATH_MSG_INFO
(
"Reaccessing ntuple "
<< ntupleCompleteID );
62
}
else
{
63
m_ntuplePtr
=
ntupleSvc
()->book(ntupleCompleteID, CLID_ColumnWiseTuple,
"TileDigits-Ntuple"
);
64
if
(
m_ntuplePtr
) {
65
66
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/n_channels"
,
m_nChannel
, 0,
m_saveMaxChannels
.value()) );
67
68
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/ros"
,
m_nChannel
,
m_ros
, 0, 4) );
69
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/drawer"
,
m_nChannel
,
m_drawer
, 0, 63) );
70
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/channel"
,
m_nChannel
,
m_channel
, 0, 47) );
71
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/gain"
,
m_nChannel
,
m_gain
, 0, 1) );
72
73
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/side"
,
m_nChannel
,
m_side
, -1, 1) );
74
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/section"
,
m_nChannel
,
m_section
, 0, 15) );
75
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/phi"
,
m_nChannel
,
m_phi
, 0, 63) );
76
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/eta"
,
m_nChannel
,
m_eta
, 0, 15) );
77
78
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/samples"
,
m_nChannel
,
m_samples
,
m_nSamples
) );
79
80
if
(!
m_saveAll
&& !
m_saveE4prAndMBTS
) {
81
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/sample"
,
m_nChannel
,
m_sample
, 0, 15) );
82
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/pmt"
,
m_nChannel
,
m_pmt
, 0, 1) );
83
CHECK
(
m_ntuplePtr
->addItem(
"TileDigits/adc"
,
m_nChannel
,
m_adc
, 0, 1) );
84
}
85
86
}
else
{
87
ATH_MSG_ERROR
(
"Failed to book or to retrieve ntuple "
<< ntupleCompleteID );
88
return
StatusCode::FAILURE;
89
}
90
ATH_MSG_INFO
(
"Finished booking ntuple "
<< ntupleCompleteID );
91
}
92
93
ATH_CHECK
(
m_digitsContainerKey
.initialize());
94
95
ATH_MSG_INFO
(
"Initialization completed"
);
96
return
StatusCode::SUCCESS;
97
}
98
99
//****************************************************************************
100
//* Execution
101
//****************************************************************************
102
103
StatusCode
TileDigitsToNtuple::execute
(
const
EventContext& ctx) {
104
105
// step1: read TileDigitss from TDS
106
SG::ReadHandle<TileDigitsContainer>
digitsContainer(
m_digitsContainerKey
, ctx);
107
ATH_CHECK
( digitsContainer.
isValid
() );
108
109
m_nChannel
= 0;
110
111
SelectAllObject<TileDigitsContainer>
allTileDigits(digitsContainer.
cptr
());
112
113
for
(
const
TileDigits
* tile_digits : allTileDigits) {
114
115
HWIdentifier
adc_hwid = tile_digits->adc_HWID();
116
Identifier
adc_id = tile_digits->adc_ID();
117
118
std::vector<float> samples = tile_digits->samples();
119
int
n_samples = samples.size();
120
121
if
(
m_saveAll
) {
122
m_ros
[
m_nChannel
] =
m_tileHWID
->ros(adc_hwid);
123
m_drawer
[
m_nChannel
] =
m_tileHWID
->drawer(adc_hwid);
124
m_channel
[
m_nChannel
] =
m_tileHWID
->channel(adc_hwid);
125
m_gain
[
m_nChannel
] =
m_tileHWID
->adc(adc_hwid);
126
127
if
(
m_tileTBID
->is_tiletb(adc_id)) {
128
m_section
[
m_nChannel
] =
m_tileTBID
->section(adc_id);
129
m_side
[
m_nChannel
] =
m_tileTBID
->side(adc_id);
130
m_phi
[
m_nChannel
] =
m_tileTBID
->phi(adc_id);
131
m_eta
[
m_nChannel
] =
m_tileTBID
->eta(adc_id);
132
}
else
{
133
if
(adc_id.
is_valid
()) {
134
m_section
[
m_nChannel
] =
m_tileID
->section(adc_id);
135
m_side
[
m_nChannel
] =
m_tileID
->side(adc_id);
136
m_phi
[
m_nChannel
] =
m_tileID
->module(adc_id);
137
m_eta
[
m_nChannel
] =
m_tileID
->tower(adc_id);
138
}
else
{
139
m_section
[
m_nChannel
] = std::numeric_limits<short>::min();
140
m_side
[
m_nChannel
] = std::numeric_limits<short>::min();
141
m_phi
[
m_nChannel
] = std::numeric_limits<short>::min();
142
m_eta
[
m_nChannel
] = std::numeric_limits<short>::min();
143
}
144
}
145
146
for
(
int
i = 0; i < n_samples && i <
m_nSamples
; ++i)
m_samples
[
m_nChannel
][i] = samples[i];
147
148
++
m_nChannel
;
149
150
}
else
if
(
m_saveE4prAndMBTS
) {
151
if
(
m_tileTBID
->is_tiletb(adc_id)) {
152
m_ros
[
m_nChannel
] =
m_tileHWID
->ros(adc_hwid);
153
m_drawer
[
m_nChannel
] =
m_tileHWID
->drawer(adc_hwid);
154
m_channel
[
m_nChannel
] =
m_tileHWID
->channel(adc_hwid);
155
m_gain
[
m_nChannel
] =
m_tileHWID
->adc(adc_hwid);
156
157
m_section
[
m_nChannel
] =
m_tileTBID
->section(adc_id);
158
m_side
[
m_nChannel
] =
m_tileTBID
->side(adc_id);
159
m_phi
[
m_nChannel
] =
m_tileTBID
->phi(adc_id);
160
m_eta
[
m_nChannel
] =
m_tileTBID
->eta(adc_id);
161
162
for
(
int
i = 0; i < n_samples && i <
m_nSamples
; ++i)
m_samples
[
m_nChannel
][i] = samples[i];
163
164
++
m_nChannel
;
165
}
166
}
else
{
167
if
(!
m_tileTBID
->is_tiletb(adc_id)) {
168
m_ros
[
m_nChannel
] =
m_tileHWID
->ros(adc_hwid);
169
m_drawer
[
m_nChannel
] =
m_tileHWID
->drawer(adc_hwid);
170
m_channel
[
m_nChannel
] =
m_tileHWID
->channel(adc_hwid);
171
m_gain
[
m_nChannel
] =
m_tileHWID
->adc(adc_hwid);
172
173
if
(adc_id.
is_valid
()) {
174
m_section
[
m_nChannel
] =
m_tileID
->section(adc_id);
175
m_side
[
m_nChannel
] =
m_tileID
->side(adc_id);
176
m_phi
[
m_nChannel
] =
m_tileID
->module(adc_id);
177
m_eta
[
m_nChannel
] =
m_tileID
->tower(adc_id);
178
179
m_sample
[
m_nChannel
] =
m_tileID
->sample(adc_id);
180
m_pmt
[
m_nChannel
] =
m_tileID
->pmt(adc_id);
181
m_adc
[
m_nChannel
] =
m_tileID
->adc(adc_id);
182
183
}
else
{
184
m_section
[
m_nChannel
] = std::numeric_limits<short>::min();
185
m_side
[
m_nChannel
] = std::numeric_limits<short>::min();
186
m_phi
[
m_nChannel
] = std::numeric_limits<short>::min();
187
m_eta
[
m_nChannel
] = std::numeric_limits<char>::min();
188
189
m_sample
[
m_nChannel
] =std::numeric_limits<short>::min();
190
m_pmt
[
m_nChannel
] = std::numeric_limits<short>::min();
191
m_adc
[
m_nChannel
] = std::numeric_limits<short>::min();
192
}
193
194
for
(
int
i = 0; i < n_samples && i <
m_nSamples
; ++i)
m_samples
[
m_nChannel
][i] = samples[i];
195
196
++
m_nChannel
;
197
}
198
}
199
200
if
(
m_nChannel
>=
m_saveMaxChannels
) {
201
ATH_MSG_DEBUG
(
"Number of channels exceeds maximum ("
<<
m_saveMaxChannels
<<
"), ignore all the rest"
);
202
break
;
203
}
204
}
205
206
207
if
(
m_commitNtuple
) {
208
ATH_MSG_DEBUG
(
"Committing Ntuple"
);
209
CHECK
(
ntupleSvc
()->writeRecord(
m_ntuplePtr
) );
210
}
211
212
// Execution completed.
213
ATH_MSG_DEBUG
(
"execute() completed successfully"
);
214
return
StatusCode::SUCCESS;
215
}
216
217
//****************************************************************************
218
//* Finalize
219
//****************************************************************************
220
221
StatusCode
TileDigitsToNtuple::finalize
() {
222
ATH_MSG_INFO
(
"finalize() completed successfully"
);
223
return
StatusCode::SUCCESS;
224
}
225
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
TileTBID.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
SelectAllObject.h
SelectAllObject
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
Definition
SelectAllObject.h:11
ntupleSvc
INTupleSvc * ntupleSvc()
Definition
ServiceAccessor.h:14
ReadHandle.h
Handle class for reading from StoreGate.
TileDigitsContainer.h
TileDigitsToNtuple.h
TileHWID.h
TileID.h
TileInfo.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
HWIdentifier
Definition
HWIdentifier.h:13
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
TileDigitsToNtuple::m_saveAll
Gaudi::Property< bool > m_saveAll
Definition
TileDigitsToNtuple.h:54
TileDigitsToNtuple::m_nChannel
NTuple::Item< short > m_nChannel
Definition
TileDigitsToNtuple.h:84
TileDigitsToNtuple::m_gain
NTuple::Array< short > m_gain
Definition
TileDigitsToNtuple.h:89
TileDigitsToNtuple::m_phi
NTuple::Array< short > m_phi
Definition
TileDigitsToNtuple.h:93
TileDigitsToNtuple::m_tileTBID
const TileTBID * m_tileTBID
Definition
TileDigitsToNtuple.h:80
TileDigitsToNtuple::m_ntuplePtr
NTuple::Tuple * m_ntuplePtr
Definition
TileDigitsToNtuple.h:82
TileDigitsToNtuple::m_digitsContainerKey
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
Definition
TileDigitsToNtuple.h:75
TileDigitsToNtuple::m_ntupleID
Gaudi::Property< std::string > m_ntupleID
Definition
TileDigitsToNtuple.h:72
TileDigitsToNtuple::m_channel
NTuple::Array< short > m_channel
Definition
TileDigitsToNtuple.h:88
TileDigitsToNtuple::m_tileHWID
const TileHWID * m_tileHWID
Definition
TileDigitsToNtuple.h:79
TileDigitsToNtuple::execute
StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
TileDigitsToNtuple.cxx:103
TileDigitsToNtuple::m_drawer
NTuple::Array< short > m_drawer
Definition
TileDigitsToNtuple.h:87
TileDigitsToNtuple::m_infoName
Gaudi::Property< std::string > m_infoName
Definition
TileDigitsToNtuple.h:66
TileDigitsToNtuple::m_ntupleLoc
Gaudi::Property< std::string > m_ntupleLoc
Definition
TileDigitsToNtuple.h:69
TileDigitsToNtuple::m_saveE4prAndMBTS
Gaudi::Property< bool > m_saveE4prAndMBTS
Definition
TileDigitsToNtuple.h:57
TileDigitsToNtuple::m_section
NTuple::Array< short > m_section
Definition
TileDigitsToNtuple.h:91
TileDigitsToNtuple::initialize
StatusCode initialize() override
Definition
TileDigitsToNtuple.cxx:42
TileDigitsToNtuple::m_nSamples
int m_nSamples
Definition
TileDigitsToNtuple.h:102
TileDigitsToNtuple::finalize
StatusCode finalize() override
Definition
TileDigitsToNtuple.cxx:221
TileDigitsToNtuple::m_ros
NTuple::Array< short > m_ros
Definition
TileDigitsToNtuple.h:86
TileDigitsToNtuple::m_sample
NTuple::Array< short > m_sample
Definition
TileDigitsToNtuple.h:95
TileDigitsToNtuple::m_commitNtuple
Gaudi::Property< int > m_commitNtuple
Definition
TileDigitsToNtuple.h:63
TileDigitsToNtuple::m_adc
NTuple::Array< short > m_adc
Definition
TileDigitsToNtuple.h:97
TileDigitsToNtuple::m_pmt
NTuple::Array< short > m_pmt
Definition
TileDigitsToNtuple.h:96
TileDigitsToNtuple::m_samples
NTuple::Matrix< short > m_samples
Definition
TileDigitsToNtuple.h:99
TileDigitsToNtuple::m_eta
NTuple::Array< short > m_eta
Definition
TileDigitsToNtuple.h:94
TileDigitsToNtuple::m_side
NTuple::Array< short > m_side
Definition
TileDigitsToNtuple.h:92
TileDigitsToNtuple::m_tileID
const TileID * m_tileID
Definition
TileDigitsToNtuple.h:78
TileDigitsToNtuple::m_saveMaxChannels
Gaudi::Property< int > m_saveMaxChannels
Definition
TileDigitsToNtuple.h:60
TileDigits
Definition
TileDigits.h:30
TileInfo
Definition
TileInfo.h:49
TileInfo::NdigitSamples
int NdigitSamples() const
Returns the number of sammples (digits) per event.
Definition
TileInfo.h:75
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0