ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibUtils
src
LArPedestalAutoCorrBuilder.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/********************************************************************
6
7
NAME: LArPedestalAutoCorrBuilder.cxx
8
PACKAGE: offline/LArCalorimeter/LArCalibUtils
9
10
AUTHORS: W. Lampl
11
CREATED: Aug 17th, 2009, merging LArPedestalBuilder & LArAutoCorrBuilder
12
13
PURPOSE: Create LArPedestalComplete and LArAutoCorrComplete objects
14
out of pre-accmulated LArAccumulatedDigits
15
16
********************************************************************/
17
18
// Include files
19
#include "
LArCalibUtils/LArPedestalAutoCorrBuilder.h
"
20
21
#include "
LArRawEvent/LArFebErrorSummary.h
"
22
#include "
LArRawConditions/LArPedestalComplete.h
"
23
#include "
LArRawConditions/LArAutoCorrComplete.h
"
24
25
#include "
LArIdentifier/LArOnlineID.h
"
26
#include "
LArIdentifier/LArOnline_SuperCellID.h
"
27
28
29
LArPedestalAutoCorrBuilder::LArPedestalAutoCorrBuilder
(
const
std::string& name, ISvcLocator* pSvcLocator)
30
:
AthAlgorithm
(name, pSvcLocator),
31
m_onlineHelper
(nullptr),
32
m_event_counter
(0),
33
m_fatalFebErrorPattern
(0xffff)
34
{
35
declareProperty
(
"KeyList"
,
m_keylist
);
36
declareProperty
(
"PedestalKey"
,
m_pedContName
=
"LArPedestal"
);
37
declareProperty
(
"normalize"
,
m_normalize
=1);
38
declareProperty
(
"AutoCorrKey"
,
m_acContName
=
"LArAutoCorr"
);
39
declareProperty
(
"GroupingType"
,
m_groupingType
=
"ExtendedFeedThrough"
);
40
declareProperty
(
"doPedestal"
,
m_doPedestal
=
true
);
41
declareProperty
(
"doAutoCorr"
,
m_doAutoCorr
=
true
);
42
declareProperty
(
"sample_min"
,
m_sample_min
=-1);
43
declareProperty
(
"sample_max"
,
m_sample_max
=-1);
44
}
45
46
LArPedestalAutoCorrBuilder::~LArPedestalAutoCorrBuilder
()
47
=
default
;
48
49
StatusCode
LArPedestalAutoCorrBuilder::initialize
()
50
{
51
if
(
m_groupingType
==
"SuperCells"
) {
52
ATH_MSG_INFO
(
"Processing LAr SuperCells"
);
53
const
LArOnline_SuperCellID
* onlID;
54
ATH_CHECK
(
detStore
()->retrieve(onlID,
"LArOnline_SuperCellID"
));
55
m_onlineHelper
=onlID;
// cast to base-class
56
}
57
else
{
58
ATH_MSG_INFO
(
"Processing regular LArCells"
);
59
const
LArOnlineID
* onlID;
60
ATH_CHECK
(
detStore
()->retrieve(onlID,
"LArOnlineID"
));
61
m_onlineHelper
=onlID;
// cast to base-class
62
}
63
64
65
66
if
(!
m_doPedestal
&& !
m_doAutoCorr
) {
67
ATH_MSG_ERROR
(
"Configuration Problem: Neither doPedstal nor doAutoCorr set!"
);
68
return
StatusCode::FAILURE;
69
}
70
71
if
(
m_keylist
.empty())
// Not key list given
72
{
m_keylist
.emplace_back(
"HIGH"
);
73
m_keylist
.emplace_back(
"MEDIUM"
);
74
m_keylist
.emplace_back(
"LOW"
);
75
m_keylist
.emplace_back(
"FREE"
);
//For H6....
76
}
77
78
//Container for internal accumulation
79
m_accu
.setGroupingType(
m_groupingType
==
"SuperCells"
?
LArConditionsContainerBase::SuperCells
:
LArConditionsContainerBase::SingleGroup
);
80
StatusCode
sc
=
m_accu
.initialize();
81
if
(
sc
.isFailure()) {
82
ATH_MSG_ERROR
(
"Failed initialize LArConditionsContainer 'm_accu'"
);
83
return
sc
;
84
}
85
return
StatusCode::SUCCESS;
86
}
87
88
89
//---------------------------------------------------------------------------
90
StatusCode
LArPedestalAutoCorrBuilder::execute
(
const
EventContext&
/*ctx*/
)
91
//---------------------------------------------------------------------------
92
{
93
94
StatusCode
sc
;
95
++
m_event_counter
;
96
if
(
m_keylist
.empty()) {
97
ATH_MSG_ERROR
(
"Key list is empty! No containers processed!"
);
98
return
StatusCode::FAILURE;
99
}
100
101
102
const
LArFebErrorSummary
* febErrSum=
nullptr
;
103
if
(
evtStore
()->
contains<LArFebErrorSummary>
(
"LArFebErrorSummary"
)) {
104
sc
=
evtStore
()->retrieve(febErrSum);
105
if
(
sc
.isFailure()) {
106
ATH_MSG_ERROR
(
"Failed to retrieve FebErrorSummary object!"
);
107
return
sc
;
108
}
109
}
110
else
111
if
(
m_event_counter
==1)
112
ATH_MSG_WARNING
(
"No FebErrorSummaryObject found! Feb errors not checked!"
);
113
114
115
const
LArAccumulatedDigitContainer
* container =
nullptr
;
116
//Outermost loop goes over all gains (different containers).
117
int
foundkey = 0;
118
119
for
(
const
std::string& key :
m_keylist
) {
120
sc
=
evtStore
()->retrieve(container,key);
121
if
(
sc
.isFailure() || !container) {
122
ATH_MSG_DEBUG
(
"Cannot read LArAccumulatedDigitContainer from StoreGate! key="
<< key);
123
if
( ( (&key == &
m_keylist
.back()) ) && foundkey==0 ){
124
ATH_MSG_ERROR
(
"None of the provided LArAccumulatedDigitContainer keys could be read"
);
125
return
StatusCode::FAILURE;
126
}
else
{
127
continue
;
128
}
129
}
130
foundkey+=1;
131
132
// check that container is not empty
133
if
(container->empty() ) {
134
ATH_MSG_DEBUG
(
"LArAccumulatedDigitContainer (key="
<< key <<
") is empty "
);
135
continue
;
136
}
else
{
137
ATH_MSG_DEBUG
(
"LArAccumulatedDigitContainer (key="
<< key <<
") has length "
<< container->size());
138
}
139
140
HWIdentifier
lastFailedFEB(0);
141
//Inner loop goes over the cells.
142
for
(
const
LArAccumulatedDigit
* dg : *container) {
//Loop over all cells
143
if
(dg->nTrigger()==0)
continue
;
//Don't care about empty digits
144
const
HWIdentifier
chid=dg->hardwareID();
145
const
HWIdentifier
febid=
m_onlineHelper
->feb_Id(chid);
146
if
(febErrSum) {
147
const
uint16_t febErrs=febErrSum->
feb_error
(febid);
148
if
(febErrs &
m_fatalFebErrorPattern
) {
149
if
(febid!=lastFailedFEB) {
150
lastFailedFEB=febid;
151
ATH_MSG_ERROR
(
"Event "
<<
m_event_counter
<<
" Feb "
<<
m_onlineHelper
->channel_name(febid)
152
<<
" reports error(s):"
<< febErrSum->
error_to_string
(febErrs) <<
". Data ignored."
);
153
}
154
continue
;
155
}
//end if fatal feb error
156
}
//end if check feb error summary
157
158
const
CaloGain::CaloGain
gain=dg->gain();
159
160
LArAccumulatedDigit
& accDg=
m_accu
.get(chid,gain);
161
if
(!accDg.
setAddSubStep
(*dg))
162
ATH_MSG_ERROR
(
"Failed to accumulate sub-steps! Inconsistent number of ADC samples"
);
163
}
//end loop over input container
164
}
//end loop over keys
165
return
StatusCode::SUCCESS;
166
}
167
168
169
170
StatusCode
LArPedestalAutoCorrBuilder::stop
() {
171
172
std::unique_ptr<LArAutoCorrComplete> larAutoCorrComplete;
173
std::unique_ptr<LArPedestalComplete> larPedestalComplete;
174
175
if
(
m_doAutoCorr
) {
176
//Book and initialize LArAutoCorrComplete object
177
ATH_MSG_INFO
(
"Creating LArAutoCorrComplete"
);
178
larAutoCorrComplete = std::make_unique<LArAutoCorrComplete>();
179
ATH_CHECK
( larAutoCorrComplete->setGroupingType(
m_groupingType
,
msg
()) );
180
ATH_CHECK
( larAutoCorrComplete->initialize() );
181
}
182
183
if
(
m_doPedestal
) {
184
//Book and initialize LArPedestalComplete object
185
ATH_MSG_INFO
(
"Creating LArAutoPedestalComplete"
);
186
larPedestalComplete = std::make_unique<LArPedestalComplete>();
187
ATH_CHECK
( larPedestalComplete->setGroupingType(
m_groupingType
,
msg
()) );
188
ATH_CHECK
( larPedestalComplete->initialize() );
189
}
190
191
//For the log output further down
192
std::string objName;
193
if
(
m_doPedestal
)
194
objName=
"pedestal"
;
195
if
(
m_doAutoCorr
)
196
objName=
"autocorr"
;
197
if
(
m_doAutoCorr
&&
m_doPedestal
)
198
objName=
"pedestal & autocorr"
;
199
200
int
n_zero,n_min, n_max, n_cur;
201
n_zero=0; n_max=n_min=-1;
202
unsigned
NCells=0;
203
std::vector<float> cov;
204
//Loop over gains
205
for
(
unsigned
k=0;k<(int)
CaloGain::LARNGAIN
;k++) {
206
CaloGain::CaloGain
gain=(
CaloGain::CaloGain
)k;
207
//Loop over cells
208
ACCU::ConditionsMapIterator
cell_it=
m_accu
.begin(gain);
209
ACCU::ConditionsMapIterator
cell_it_e=
m_accu
.end(gain);
210
211
if
(cell_it==cell_it_e){
212
continue
;
//No data for this gain
213
}
214
for
(;cell_it!=cell_it_e;cell_it++) {
215
const
LArAccumulatedDigit
& dg=*cell_it;
216
n_cur = dg.nTrigger();
217
if
(n_cur==0) { n_zero++;
continue
; }
218
219
HWIdentifier
chid = cell_it.
channelId
();
220
221
if
(n_cur<n_min || n_min<0) n_min=n_cur;
222
if
(n_cur>n_max || n_max<0) n_max=n_cur;
223
224
// Fill the data class with pedestal and rms values
225
if
(larPedestalComplete)
226
larPedestalComplete->set(chid,gain,dg.mean(
m_sample_min
,
m_sample_max
),dg.RMS(
m_sample_min
,
m_sample_max
));
227
228
if
(larAutoCorrComplete) {
229
dg.getCov(cov,
m_normalize
);
230
larAutoCorrComplete->set(chid,gain,cov);
231
}
232
NCells++;
233
}
//end loop over all cells
234
235
ATH_MSG_INFO
(
"Gain "
<< gain <<
" Number of cells with 0 events to compute "
<<objName<<
": "
<< n_zero );
236
ATH_MSG_INFO
(
"Gain "
<< gain <<
" Minimum number of events*samples to compute "
<<objName<<
": "
<< n_min );
237
ATH_MSG_INFO
(
"Gain "
<< gain <<
" Maximum number of events*samples to compute "
<<objName<<
": "
<<n_max );
238
}
// End loop over all containers
239
240
ATH_MSG_INFO
(
" Summary : Number of cells with "
<<objName<<
" value computed : "
<< NCells );
241
ATH_MSG_INFO
(
" Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 = 4096 "
);
242
ATH_MSG_INFO
(
" Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 = 53248 "
);
243
ATH_MSG_INFO
(
" Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 = 35328 "
);
244
ATH_MSG_INFO
(
" Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 = 3072 "
);
245
ATH_MSG_INFO
(
" Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 = 1792 "
);
246
247
if
(larPedestalComplete) {
248
ATH_CHECK
(
detStore
()->record(std::move(larPedestalComplete),
m_pedContName
) );
249
}
250
251
252
if
(larAutoCorrComplete) {
253
ATH_CHECK
(
detStore
()->record(std::move(larAutoCorrComplete),
m_acContName
) );
254
}
255
256
return
StatusCode::SUCCESS;
257
}
258
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_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
LArAutoCorrComplete.h
LArFebErrorSummary.h
LArOnlineID.h
LArOnline_SuperCellID.h
LArPedestalAutoCorrBuilder.h
LArPedestalComplete.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
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 >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
HWIdentifier
Definition
HWIdentifier.h:13
LArAccumulatedDigitContainer
Container class for LArAccumulatedDigit.
Definition
LArAccumulatedDigitContainer.h:22
LArAccumulatedDigit
Data class for ADC samples and autocorr preprocessed by the DSP.
Definition
LArAccumulatedDigit.h:32
LArAccumulatedDigit::setAddSubStep
bool setAddSubStep(const CaloGain::CaloGain gain_value, const HWIdentifier chid, const std::vector< uint64_t > &sampleSum, const std::vector< uint64_t > &sampleSquare, const unsigned nTrigger)
Accumulate new values.
Definition
LArAccumulatedDigit.cxx:113
LArConditionsContainerBase::SuperCells
@ SuperCells
Definition
LArConditionsContainerBase.h:51
LArConditionsContainerBase::SingleGroup
@ SingleGroup
Definition
LArConditionsContainerBase.h:46
LArConditionsContainerDB::iteratorT::channelId
HWIdentifier channelId() const
LArConditionsContainer< LArAccumulatedDigit >::ConditionsMapIterator
ConditionsMap::iterator ConditionsMapIterator
Definition
LArConditionsContainer.h:87
LArFebErrorSummary
Holds information from the FEB Error Summary.
Definition
LArFebErrorSummary.h:23
LArFebErrorSummary::error_to_string
static std::string error_to_string(uint16_t error)
interpret the error in string
Definition
LArFebErrorSummary.cxx:58
LArFebErrorSummary::feb_error
uint16_t feb_error(HWIdentifier febid) const
get error for feb
Definition
LArFebErrorSummary.cxx:20
LArOnlineID
Definition
LArOnlineID.h:21
LArOnline_SuperCellID
Definition
LArOnline_SuperCellID.h:21
LArPedestalAutoCorrBuilder::m_keylist
std::vector< std::string > m_keylist
Definition
LArPedestalAutoCorrBuilder.h:54
LArPedestalAutoCorrBuilder::m_sample_min
int m_sample_min
Definition
LArPedestalAutoCorrBuilder.h:74
LArPedestalAutoCorrBuilder::m_groupingType
std::string m_groupingType
Definition
LArPedestalAutoCorrBuilder.h:57
LArPedestalAutoCorrBuilder::m_doAutoCorr
bool m_doAutoCorr
Definition
LArPedestalAutoCorrBuilder.h:68
LArPedestalAutoCorrBuilder::m_pedContName
std::string m_pedContName
Definition
LArPedestalAutoCorrBuilder.h:65
LArPedestalAutoCorrBuilder::m_doPedestal
bool m_doPedestal
Definition
LArPedestalAutoCorrBuilder.h:68
LArPedestalAutoCorrBuilder::~LArPedestalAutoCorrBuilder
~LArPedestalAutoCorrBuilder()
LArPedestalAutoCorrBuilder::LArPedestalAutoCorrBuilder
LArPedestalAutoCorrBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition
LArPedestalAutoCorrBuilder.cxx:29
LArPedestalAutoCorrBuilder::m_sample_max
int m_sample_max
Definition
LArPedestalAutoCorrBuilder.h:75
LArPedestalAutoCorrBuilder::m_onlineHelper
const LArOnlineID_Base * m_onlineHelper
Definition
LArPedestalAutoCorrBuilder.h:52
LArPedestalAutoCorrBuilder::m_accu
ACCU m_accu
Definition
LArPedestalAutoCorrBuilder.h:61
LArPedestalAutoCorrBuilder::m_event_counter
unsigned m_event_counter
Definition
LArPedestalAutoCorrBuilder.h:63
LArPedestalAutoCorrBuilder::initialize
StatusCode initialize()
Definition
LArPedestalAutoCorrBuilder.cxx:49
LArPedestalAutoCorrBuilder::stop
virtual StatusCode stop()
Definition
LArPedestalAutoCorrBuilder.cxx:170
LArPedestalAutoCorrBuilder::m_fatalFebErrorPattern
uint16_t m_fatalFebErrorPattern
Definition
LArPedestalAutoCorrBuilder.h:70
LArPedestalAutoCorrBuilder::m_normalize
int m_normalize
Definition
LArPedestalAutoCorrBuilder.h:72
LArPedestalAutoCorrBuilder::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
LArPedestalAutoCorrBuilder.cxx:90
LArPedestalAutoCorrBuilder::m_acContName
std::string m_acContName
Definition
LArPedestalAutoCorrBuilder.h:66
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
CaloGain::CaloGain
CaloGain
Definition
CaloGain.h:11
CaloGain::LARNGAIN
@ LARNGAIN
Definition
CaloGain.h:19
Generated on
for ATLAS Offline Software by
1.17.0