ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileRecUtils
src
TileRawChannelMaker.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Tile includes
6
#include "
TileRecUtils/TileRawChannelMaker.h
"
7
#include "
TileConditions/TileInfo.h
"
8
9
// Atlas includes
10
#include "
AthenaKernel/errorcheck.h
"
11
// access all RawChannels inside container
12
#include "
EventContainers/SelectAllObject.h
"
13
#include "
StoreGate/ReadHandle.h
"
14
15
// Gaudi includes
16
17
#include <algorithm>
18
#include <set>
19
25
TileRawChannelMaker::TileRawChannelMaker
(
const
std::string& name,
26
ISvcLocator* pSvcLocator)
27
:
AthAlgorithm
(name, pSvcLocator)
28
,
m_fitOverflow
(false)
29
,
m_tileInfo
(0)
30
,
m_ADCmaxMinusEps
(0)
31
{
32
declareProperty
(
"FitOverflow"
,
m_fitOverflow
,
"Fit or not overflows"
);
33
declareProperty
(
"TileInfoName"
,
m_infoName
=
"TileInfo"
);
34
35
m_overflowReplaceTimeCut
= 50.0;
36
m_overflowReplacePedestalCut
= 170.0;
37
m_overflowReplaceChi2Cut
= 40000.0;
38
}
39
43
TileRawChannelMaker::~TileRawChannelMaker
() {
44
}
45
49
StatusCode
TileRawChannelMaker::initialize
() {
50
51
ATH_MSG_DEBUG
(
"starting to retrieve list "
<<
m_tileRawChannelBuilderList
);
52
ATH_CHECK
(
m_tileRawChannelBuilderList
.retrieve());
53
54
ATH_MSG_DEBUG
(
m_tileRawChannelBuilderList
<<
"retrieved"
);
55
56
if
(
m_tileRawChannelBuilderList
.begin() ==
m_tileRawChannelBuilderList
.end() ) {
57
ATH_MSG_INFO
(
"TileRawChannelBuilder list is empty - will not do anything"
);
58
m_fitOverflow
=
false
;
59
}
60
61
if
(
m_fitOverflow
) {
62
ATH_CHECK
(
m_tileRawChannelBuilderFitOverflow
.retrieve() );
63
}
else
{
64
m_tileRawChannelBuilderFitOverflow
.disable();
65
}
66
67
ATH_CHECK
(
m_digitsContainerKey
.initialize() );
68
69
ATH_MSG_INFO
(
"Initialization completed successfully"
);
70
71
// TileInfo
72
ATH_CHECK
(
detStore
()->retrieve(
m_tileInfo
,
m_infoName
) );
73
m_ADCmaxMinusEps
=
m_tileInfo
->ADCmax() - 0.01;
// indicates channels which were masked in background dataset
74
75
return
StatusCode::SUCCESS;
76
}
77
81
StatusCode
TileRawChannelMaker::execute
(
const
EventContext& ctx) {
82
83
84
// get named TileDigitsContaner from TES
85
SG::ReadHandle<TileDigitsContainer>
digitsContaner(
m_digitsContainerKey
, ctx);
86
87
if
(!digitsContaner.
isValid
()) {
88
ATH_MSG_WARNING
(
"Can't retrieve TileDigitsContainer '"
89
<<
m_digitsContainerKey
.key() <<
"' from TDS"
);
90
91
return
StatusCode::SUCCESS;
92
}
93
94
ATH_MSG_DEBUG
(
"Got TileDigitsContainer '"
<<
m_digitsContainerKey
.key() <<
"'"
);
95
96
// create RawChannel Containers for all sub-algs
97
for
(ToolHandle<TileRawChannelBuilder>& rawChannelBuilder :
m_tileRawChannelBuilderList
) {
98
ATH_CHECK
( rawChannelBuilder->createContainer(ctx) );
99
rawChannelBuilder->resetDrawer();
100
}
101
102
// clean memory about overflows
103
if
(
m_fitOverflow
) {
104
for
(ToolHandle<TileRawChannelBuilder>& rawChannelBuilder :
m_tileRawChannelBuilderList
) {
105
rawChannelBuilder->resetOverflows();
106
}
107
}
108
109
// Iterate over all collections (drawers) with digits
110
for
(
const
TileDigitsCollection
* digitsCollection : *digitsContaner) {
111
112
// Iterate over all sub-algs
113
for
(ToolHandle<TileRawChannelBuilder>& rawChannelBuilder :
m_tileRawChannelBuilderList
) {
114
// reconstruct all channels in one drawer
115
ATH_CHECK
( rawChannelBuilder->build(digitsCollection, ctx) );
116
}
117
118
}
119
120
if
(
m_fitOverflow
121
&& !(*
m_tileRawChannelBuilderList
.begin())->getOverflowedChannels().empty()) {
122
fitOverflowedChannels
(ctx);
123
}
124
125
// commit RawChannel Containers for all sub-algs
126
for
(ToolHandle<TileRawChannelBuilder>& rawChannelBuilder :
m_tileRawChannelBuilderList
) {
127
ATH_CHECK
( rawChannelBuilder->commitContainer(ctx) );
128
}
129
130
ATH_MSG_DEBUG
(
"execute completed successfully"
);
131
132
return
StatusCode::SUCCESS;
133
}
134
138
StatusCode
TileRawChannelMaker::finalize
() {
139
140
ATH_MSG_INFO
(
" finalize completed successfully"
);
141
142
return
StatusCode::SUCCESS;
143
}
144
145
void
TileRawChannelMaker::fitOverflowedChannels
(
const
EventContext& ctx) {
146
147
for
(ToolHandle<TileRawChannelBuilder> rawChannelBuilder :
m_tileRawChannelBuilderList
) {
148
149
Overflows_t
overflows = rawChannelBuilder->getOverflowedChannels();
150
151
for
(std::pair<TileRawChannel*, const TileDigits*>& overflow : overflows) {
152
153
TileRawChannel
* rwCh = overflow.first;
154
const
TileDigits
* pDigits = overflow.second;
155
156
TileRawChannel
* fittedRwCh =
m_tileRawChannelBuilderFitOverflow
->rawChannel(pDigits, ctx);
157
158
bool
fitOK = ( ( fabs(fittedRwCh->
time
()) <
m_overflowReplaceTimeCut
) &&
159
( fittedRwCh->
pedestal
() <
m_overflowReplacePedestalCut
) &&
160
( fittedRwCh->
quality
() <
m_overflowReplaceChi2Cut
) );
161
162
int
nSatSamples = 0;
163
std::vector<double> digits = pDigits->
get_digits
();
164
for
(
size_t
ii = 0; ii<digits.size(); ii++) {
165
if
(digits[ii] >
m_ADCmaxMinusEps
) nSatSamples++;
166
}
167
168
// NOTE: Optimal filtering is always run first and the fit method is used just in cases when there is an overflow.
169
// NOTE: Mathematically, a maximum pedestal range is [-460.607488, 4556.603392] and it happens for the phase 0.1 ns.
170
// Therefore, we use the following intervals:
171
// - if optimal filtering is used: (-500, 4600)
172
// - if fit method is used: (5000, 9095)
173
// NOTE: Overlay magic number is 4800.
174
175
if
( !fitOK || nSatSamples > 2) {
176
// If the fit is bad, reset the energy.
177
//The same if the number of saturated samples is 3 (or bigger)
178
179
//If we reject pulse, the quality must be above 9999 in order to mask the
180
// channel. So we set it at 10000 * nSatSamples. But if the fit completely fails,
181
// the quality is 100000, and we can keep this info in quality as well.
182
float
quality = 10000. * ( (nSatSamples) ? nSatSamples : 9);
183
if
(fittedRwCh->
quality
() > 99999.9) quality += 100000.;
184
rwCh->
insert
(0.0, 0.0, quality);
185
186
// 20000 - Indicates overflow, 9400 - indicates bad fit or >2 saturations.
187
// 30000 - Indicates overflow + underflow, 9400 - indicates bad fit or >2 saturations.
188
float
pedestal = (rwCh->
pedestal
() < 29500.) ? (29400.)
189
: (39400.);
190
ATH_MSG_DEBUG
(
"Overflow "
<< (std::string)(*rwCh) <<
191
" change ped from "
<< rwCh->
pedestal
() <<
" to "
<< pedestal);
192
rwCh->
setPedestal
(pedestal);
193
}
else
{
194
//If the fit is OK replace
195
196
//The range of the quality factor is very different in the fit (0-100k)
197
//than in the OF (0-255). So we rescale by a factor of 400.
198
rwCh->
insert
(fittedRwCh->
amplitude
(),
199
fittedRwCh->
time
(),
200
fittedRwCh->
quality
()*(1./400.));
201
// 20000 - Indicates overflow, 5000 - indicates fitted
202
// 30000 - Indicates overflow + underflow, 5000 - indicates fitted.
203
float
pedestal = (rwCh->
pedestal
() < 29500.) ? fittedRwCh->
pedestal
() + 25000.
204
: fittedRwCh->
pedestal
() + 35000.;
205
ATH_MSG_DEBUG
(
"Overflow "
<< (std::string)(*rwCh) <<
206
" change ped from "
<< rwCh->
pedestal
() <<
" to "
<< pedestal);
207
rwCh->
setPedestal
(pedestal);
208
}
209
210
}
211
}
212
213
}
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_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.
SelectAllObject.h
ReadHandle.h
Handle class for reading from StoreGate.
TileInfo.h
Overflows_t
std::vector< std::pair< TileRawChannel *, const TileDigits * > > Overflows_t
Definition
TileRawChannelBuilder.h:57
TileRawChannelMaker.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
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TileDigitsCollection
Definition
TileDigitsCollection.h:18
TileDigits
Definition
TileDigits.h:30
TileDigits::get_digits
std::vector< double > get_digits(void) const
Definition
TileDigits.h:65
TileRawChannelMaker::m_infoName
std::string m_infoName
Definition
TileRawChannelMaker.h:84
TileRawChannelMaker::m_overflowReplacePedestalCut
float m_overflowReplacePedestalCut
Definition
TileRawChannelMaker.h:80
TileRawChannelMaker::fitOverflowedChannels
void fitOverflowedChannels(const EventContext &ctx)
Definition
TileRawChannelMaker.cxx:145
TileRawChannelMaker::m_tileRawChannelBuilderList
ToolHandleArray< TileRawChannelBuilder > m_tileRawChannelBuilderList
Vector of builder algtools.
Definition
TileRawChannelMaker.h:72
TileRawChannelMaker::m_digitsContainerKey
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
Definition
TileRawChannelMaker.h:60
TileRawChannelMaker::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute.
Definition
TileRawChannelMaker.cxx:81
TileRawChannelMaker::~TileRawChannelMaker
virtual ~TileRawChannelMaker()
Destructor.
Definition
TileRawChannelMaker.cxx:43
TileRawChannelMaker::TileRawChannelMaker
TileRawChannelMaker(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition
TileRawChannelMaker.cxx:25
TileRawChannelMaker::m_overflowReplaceTimeCut
float m_overflowReplaceTimeCut
Definition
TileRawChannelMaker.h:79
TileRawChannelMaker::m_ADCmaxMinusEps
float m_ADCmaxMinusEps
Definition
TileRawChannelMaker.h:86
TileRawChannelMaker::finalize
virtual StatusCode finalize() override
Finalize.
Definition
TileRawChannelMaker.cxx:138
TileRawChannelMaker::m_tileInfo
const TileInfo * m_tileInfo
Definition
TileRawChannelMaker.h:85
TileRawChannelMaker::m_overflowReplaceChi2Cut
float m_overflowReplaceChi2Cut
Definition
TileRawChannelMaker.h:81
TileRawChannelMaker::m_tileRawChannelBuilderFitOverflow
ToolHandle< TileRawChannelBuilder > m_tileRawChannelBuilderFitOverflow
Definition
TileRawChannelMaker.h:76
TileRawChannelMaker::initialize
virtual StatusCode initialize() override
Initialize algorithm.
Definition
TileRawChannelMaker.cxx:49
TileRawChannelMaker::m_fitOverflow
bool m_fitOverflow
Definition
TileRawChannelMaker.h:75
TileRawChannel
Definition
TileRawChannel.h:35
TileRawChannel::pedestal
float pedestal(void) const
Definition
TileRawChannel.h:106
TileRawChannel::time
float time(int ind=0) const
Definition
TileRawChannel.h:103
TileRawChannel::quality
float quality(int ind=0) const
Definition
TileRawChannel.h:105
TileRawChannel::setPedestal
void setPedestal(float ped)
Definition
TileRawChannel.h:94
TileRawChannel::insert
int insert(float amplitude, float time, float quality)
Definition
TileRawChannel.cxx:81
TileRawChannel::amplitude
float amplitude(int ind=0) const
Definition
TileRawChannel.h:101
Generated on
for ATLAS Offline Software by
1.17.0