ATLAS Offline Software
Loading...
Searching...
No Matches
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
20
24
27
28
29LArPedestalAutoCorrBuilder::LArPedestalAutoCorrBuilder(const std::string& name, ISvcLocator* pSvcLocator)
30 : AthAlgorithm(name, pSvcLocator),
31 m_onlineHelper(nullptr),
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
47= default;
48
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
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//---------------------------------------------------------------------------
91//---------------------------------------------------------------------------
92{
93
94 StatusCode sc;
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
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
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";
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++) {
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
Container class for LArAccumulatedDigit.
Data class for ADC samples and autocorr preprocessed by the DSP.
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.
Holds information from the FEB Error Summary.
static std::string error_to_string(uint16_t error)
interpret the error in string
uint16_t feb_error(HWIdentifier febid) const
get error for feb
std::vector< std::string > m_keylist
LArPedestalAutoCorrBuilder(const std::string &name, ISvcLocator *pSvcLocator)
const LArOnlineID_Base * m_onlineHelper
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
@ LARNGAIN
Definition CaloGain.h:19