ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRecAlgs
src
TileRawChannelToHit.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//*****************************************************************************
6
// Filename : TileRawChannelToHit.cxx
7
// Author : Alexander Solodkov
8
// Created : Feb, 2005
9
//
10
// DESCRIPTION:
11
// Implementation comments only. Class level comments go in .h file.
12
//
13
// HISTORY:
14
//
15
// BUGS:
16
//
17
//*****************************************************************************
18
19
// Tile includes
20
#include "
TileRawChannelToHit.h
"
21
22
#include "
TileIdentifier/TileHWID.h
"
23
#include "
TileIdentifier/TileFragHash.h
"
24
#include "
TileCalibBlobObjs/TileCalibUtils.h
"
25
#include "
TileConditions/TileCondToolEmscale.h
"
26
#include "
TileConditions/TileInfo.h
"
27
#include "
TileSimEvent/TileHit.h
"
28
#include "
TileEvent/TileRawChannel.h
"
29
30
// Calo includes
31
#include "
CaloIdentifier/TileID.h
"
32
33
// Atlas includes
34
#include "
StoreGate/ReadHandle.h
"
35
#include "
StoreGate/WriteHandle.h
"
36
#include "
StoreGate/ReadCondHandle.h
"
37
#include "
AthenaKernel/errorcheck.h
"
38
// access all RawChannels inside container
39
#include "
EventContainers/SelectAllObject.h
"
40
41
#include <memory>
42
43
//
44
// Constructor
45
//
46
TileRawChannelToHit::TileRawChannelToHit
(
const
std::string& name, ISvcLocator* pSvcLocator)
47
:
AthAlgorithm
(name, pSvcLocator)
48
,
m_tileToolEmscale
(
"TileCondToolEmscale"
)
49
{
50
declareProperty
(
"UseSamplFract"
,
m_useSamplFract
=
false
);
// if true energy in TileHit is the as it is coming from G4 simulation
51
// and by default it is equal to final - TileCell energy
52
declareProperty
(
"TileCondToolEmscale"
,
m_tileToolEmscale
);
53
}
54
55
TileRawChannelToHit::~TileRawChannelToHit
()
56
{}
57
58
//****************************************************************************
59
//* Initialization
60
//****************************************************************************
61
62
StatusCode
TileRawChannelToHit::initialize
() {
63
64
if
(
m_useSamplFract
)
65
ATH_MSG_INFO
(
"Sampling fraction is taken into account for TileHit energy"
);
66
else
67
ATH_MSG_INFO
(
"TileHit will contain CELL energy (not divided by sampling fraction)"
);
68
69
// retrieve TileID helper and TileIfno from det store
70
ATH_CHECK
(
detStore
()->retrieve(
m_tileID
) );
71
ATH_CHECK
(
detStore
()->retrieve(
m_tileHWID
) );
72
73
//=== get TileCondToolEmscale
74
ATH_CHECK
(
m_tileToolEmscale
.retrieve() );
75
76
ATH_CHECK
(
m_rawChannelContainerKey
.initialize() );
77
ATH_CHECK
(
m_hitVectorKey
.initialize() );
78
79
ATH_CHECK
(
m_samplingFractionKey
.initialize(
m_useSamplFract
) );
80
81
ATH_MSG_INFO
(
"TileRawChannelToHit initialization completed"
);
82
83
return
StatusCode::SUCCESS;
84
}
85
86
87
//****************************************************************************
88
//* Execution
89
//****************************************************************************
90
91
StatusCode
TileRawChannelToHit::execute
(
const
EventContext& ctx) {
92
93
/* zero all counters and sums */
94
int
nHit = 0;
95
int
nChan = 0;
96
float
eCh = 0.0;
97
float
eHitTot = 0.0;
98
99
const
TileSamplingFraction
* samplingFraction =
nullptr
;
100
if
(
m_useSamplFract
) {
101
SG::ReadCondHandle<TileSamplingFraction>
samplingFractionHandle(
m_samplingFractionKey
, ctx);
102
ATH_CHECK
( samplingFractionHandle.
isValid
() );
103
samplingFraction = samplingFractionHandle.
cptr
();
104
}
105
106
SG::WriteHandle<TileHitVector>
hitVector
(
m_hitVectorKey
, ctx);
107
108
/* Register the set of TileHits to the event store. */
109
ATH_CHECK
(
hitVector
.record(std::make_unique<TileHitVector>()) );
110
111
//**
112
//* Get TileRawChannels
113
//**
114
SG::ReadHandle<TileRawChannelContainer>
rawChannelContainer(
m_rawChannelContainerKey
, ctx);
115
116
if
(!rawChannelContainer.isValid()) {
117
ATH_MSG_WARNING
(
" Could not find container "
<<
m_rawChannelContainerKey
.key() );
118
ATH_MSG_WARNING
(
" creating empty TileHitVector container "
);
119
120
}
else
{
121
122
TileRawChannelUnit::UNIT
rChUnit = rawChannelContainer->get_unit();
123
//TileFragHash::TYPE rChType = rawChannelContainer->get_type();
124
125
// iterate over all collections in a container
126
for
(
const
TileRawChannelCollection
* rawChannelCollection : *rawChannelContainer) {
127
128
HWIdentifier
drawer_id =
m_tileHWID
->drawer_id(rawChannelCollection->identify());
129
int
ros =
m_tileHWID
->ros(drawer_id);
130
int
drawer =
m_tileHWID
->drawer(drawer_id);
131
int
drawerIdx =
TileCalibUtils::getDrawerIdx
(ros, drawer);
132
133
bool
is_calibration = (rawChannelCollection->size() == 96);
134
if
(is_calibration)
135
ATH_MSG_DEBUG
(
"Calibration mode, ignore high gain"
);
136
137
// iterate over all raw channels in a collection, creating new TileHits
138
// Add each new TileHit to the TileHitContainer.
139
140
for
(
const
TileRawChannel
* rawChannel : *rawChannelCollection) {
141
142
HWIdentifier
adc_id = rawChannel->adc_HWID();
143
int
channel =
m_tileHWID
->channel(adc_id);
144
int
adc =
m_tileHWID
->adc(adc_id);
145
146
// skip high gain in calibration mode
147
if
(is_calibration &&
TileHWID::HIGHGAIN
== adc)
148
continue
;
149
150
float
amp = rawChannel->amplitude();
151
float
time = rawChannel->time();
152
153
++nChan;
154
eCh += amp;
155
156
Identifier
pmt_id = rawChannel->pmt_ID();
157
if
(pmt_id.
is_valid
()) {
158
159
float
ener =
m_tileToolEmscale
->channelCalib(drawerIdx, channel, adc,
160
amp, rChUnit,
161
TileRawChannelUnit::MegaElectronVolts
);
162
163
if
(
m_useSamplFract
) {
// divide by sampling fraction (about 40)
164
ener /= samplingFraction->
getSamplingFraction
(drawerIdx, channel);
165
}
166
167
TileHit
hit
(pmt_id, ener, time);
168
eHitTot += ener;
169
++nHit;
170
171
ATH_MSG_VERBOSE
(
"TileRawChannelToHit: "
172
<<
" pmt_id="
<<
m_tileID
->to_string(pmt_id, -1)
173
<<
" adc_id="
<<
m_tileHWID
->to_string(adc_id)
174
<<
" nHit="
<< nHit
175
<<
" amp="
<< amp
176
<<
" ene="
<< ener
177
<<
" time="
<< time );
178
179
hitVector
->push_back(
hit
);
180
181
}
else
{
182
183
ATH_MSG_VERBOSE
(
"TileRawChannelToHit: "
184
<<
" channel with adc_id="
<<
m_tileHWID
->to_string(adc_id)
185
<<
" is not connected"
);
186
}
187
}
188
}
189
}
190
191
192
193
194
// Execution completed.
195
ATH_MSG_DEBUG
(
"TileRawChannelToHit execution completed."
);
196
ATH_MSG_DEBUG
(
" nChan="
<< nChan
197
<<
" RawChSum="
<< eCh
198
<<
" nHit="
<< nHit
199
<<
" eneTot="
<< eHitTot );
200
201
202
ATH_MSG_VERBOSE
(
"TileHitVector container registered to the TES with name"
203
<<
m_hitVectorKey
.key() );
204
205
return
StatusCode::SUCCESS;
206
}
207
208
//************************************************************************
209
210
211
//****************************************************************************
212
//* Finalize
213
//****************************************************************************
214
215
StatusCode
TileRawChannelToHit::finalize
() {
216
217
ATH_MSG_INFO
(
"TileRawChannelToHit::finalize() end"
);
218
219
return
StatusCode::SUCCESS;
220
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
errorcheck.h
Helpers for checking error return status codes and reporting errors.
hitVector
std::vector< FPGATrackSimHit > hitVector
Definition
FPGATrackSimCluster.h:22
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
ReadCondHandle.h
SelectAllObject.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
TileCalibUtils.h
TileCondToolEmscale.h
TileFragHash.h
TileHWID.h
TileID.h
TileInfo.h
TileRawChannelToHit.h
TileRawChannel.h
TileHit.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
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::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition
ReadCondHandle.h:67
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition
TileCalibUtils.cxx:60
TileHWID::HIGHGAIN
@ HIGHGAIN
Definition
TileHWID.h:73
TileHit
Definition
TileSimEvent/TileSimEvent/TileHit.h:30
TileRawChannelCollection
Definition
TileRawChannelCollection.h:12
TileRawChannelToHit::m_hitVectorKey
SG::WriteHandleKey< TileHitVector > m_hitVectorKey
Definition
TileRawChannelToHit.h:75
TileRawChannelToHit::~TileRawChannelToHit
virtual ~TileRawChannelToHit()
Definition
TileRawChannelToHit.cxx:55
TileRawChannelToHit::m_tileHWID
const TileHWID * m_tileHWID
Definition
TileRawChannelToHit.h:89
TileRawChannelToHit::m_rawChannelContainerKey
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Definition
TileRawChannelToHit.h:71
TileRawChannelToHit::finalize
StatusCode finalize()
Definition
TileRawChannelToHit.cxx:215
TileRawChannelToHit::m_useSamplFract
bool m_useSamplFract
Definition
TileRawChannelToHit.h:86
TileRawChannelToHit::m_samplingFractionKey
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
Definition
TileRawChannelToHit.h:82
TileRawChannelToHit::m_tileToolEmscale
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
main Tile Calibration tool
Definition
TileRawChannelToHit.h:91
TileRawChannelToHit::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TileRawChannelToHit.cxx:91
TileRawChannelToHit::initialize
StatusCode initialize()
Definition
TileRawChannelToHit.cxx:62
TileRawChannelToHit::TileRawChannelToHit
TileRawChannelToHit(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TileRawChannelToHit.cxx:46
TileRawChannelToHit::m_tileID
const TileID * m_tileID
Definition
TileRawChannelToHit.h:88
TileRawChannelUnit::UNIT
UNIT
Definition
TileRawChannelUnit.h:16
TileRawChannelUnit::MegaElectronVolts
@ MegaElectronVolts
Definition
TileRawChannelUnit.h:20
TileRawChannel
Definition
TileRawChannel.h:35
TileSamplingFraction
Condition object to keep and provide Tile Calorimeter sampling fraction and number of photoelectrons.
Definition
TileSamplingFraction.h:16
TileSamplingFraction::getSamplingFraction
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.
Definition
TileSamplingFraction.h:53
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0