ATLAS Offline Software
Loading...
Searching...
No Matches
LArCalibPedMonAlg.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#include "LArCalibPedMonAlg.h"
9
10
11/*---------------------------------------------------------*/
12LArCalibPedMonAlg::LArCalibPedMonAlg(const std::string& name,ISvcLocator* pSvcLocator )
13 : AthMonitorAlgorithm(name,pSvcLocator),
14 m_onlineHelper(nullptr),
16{}
17
18/*---------------------------------------------------------*/
20 ATH_MSG_INFO( "Initialize LArCalibPedMonAlg" );
21
22/*For pedestal run ONLY, not delay and ramp*/
23 ATH_MSG_INFO( "m_accDigitContainerKey.empty() " << m_accDigitContainerKey.empty() );
25 if (m_accDigitContainerKey.empty()) {
26 ATH_MSG_FATAL("LArAccumulatedDigitContainerKey must be set");
27 return StatusCode::FAILURE;
28 }
29
30 StatusCode sc = detStore()->retrieve(m_onlineHelper, "LArOnlineID");
31 if (sc.isFailure()) {
32 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
33 return StatusCode::FAILURE;
34 }
35
36 ATH_CHECK( m_hdrContKey.initialize() );
37 ATH_CHECK( m_lArFebErrorSummaryKey.initialize() );
38 ATH_CHECK( m_eventInfoDecorKey.initialize() );
39
40 m_histoGroups.reserve(m_SubDetNames.size());
41 for (unsigned i=0; i<m_SubDetNames.size(); ++i) {
42 std::vector<std::string> part;
43 part.push_back(m_partitions[2*i]);
44 part.push_back(m_partitions[2*i+1]);
46 }
48}
49
50
51/*---------------------------------------------------------*/
52StatusCode LArCalibPedMonAlg::fillHistograms( const EventContext& ctx ) const {
53
54 ATH_MSG_DEBUG( "in fillHists()" );
55
57
58 bool eventRejected = false;
59 std::bitset<13> rejectionBits;
60 std::vector<int> febInErrorTree(0);
61 std::unordered_set<unsigned int> chanids;
62
63 if(!m_accDigitContainerKey.empty()) {
65 if(pLArAccDigitContainer.isValid()){
66 ATH_MSG_DEBUG("Got LArAccumulatedDigitContainer with key "<< m_accDigitContainerKey.key());
67 } else {
68 ATH_MSG_WARNING("Do not have LArAccumulatedDigitContainer with key "<< m_accDigitContainerKey.key());
69 }
70
71 if(pLArAccDigitContainer->empty()) return StatusCode::SUCCESS; // Nothing to fill
72
73 for (auto itDig: * pLArAccDigitContainer) {
74 unsigned int id = (itDig->hardwareID()).get_identifier32().get_compact();
75 chanids.emplace(id);
76 }
77
78 ATH_MSG_DEBUG("Filling nbChan: "<<chanids.size());
79 auto nbchan = Monitored::Scalar<unsigned int>("nbChan",chanids.size());
80 fill(m_MonGroupName,nbchan);
81 }
82
84 ATH_CHECK(thisEvent.isValid());
85 unsigned lumi_block = thisEvent->lumiBlock();
86 bool lar_inerror = (thisEvent->errorState(xAOD::EventInfo::LAr)==xAOD::EventInfo::Error);
87 ATH_MSG_DEBUG( "LArFEBMonAlg Lumi block: "<<lumi_block);
88
91 if (!hdrCont.isValid()) {
92 ATH_MSG_ERROR( "No LArFebHeaderContainer found in TDS" );
93 return StatusCode::FAILURE;
94 }
95
96 if (hdrCont->empty()) {
97 ATH_MSG_WARNING( "Got empty LArFebHeaderContainer. Do nothing" );
98 }
99
100 if (!lArFebErrorSummary.isValid()) {
101 ATH_MSG_ERROR( "No LArFebErrorSummary found in TDS" );
102 return StatusCode::FAILURE;
103 }
104 // Eventype = 2 : transparent/raw data - 4 : Physic - 7 : calibration - 10 : pedestal - 14 : raw data + results
105 uint32_t firstEventType = (*hdrCont->begin())->DetEventType();
106
107 std::vector<unsigned int> nfeb(m_partitions.size());
108
109 float larEventSize = 0;
110
111 auto slmon = Monitored::Scalar<int>("slotnb",-1);
112 auto ftmon = Monitored::Scalar<int>("FTnb",-1);
113
114 for ( auto it: * hdrCont) {
115 HWIdentifier febid=it->FEBId();
116 if (febid.get_identifier32().get_compact() >= 0x38000000 && febid.get_identifier32().get_compact() <= 0x3bc60000 && !(febid.get_identifier32().get_compact() & 0xFFF)) {
117 int barrel_ec = m_onlineHelper->barrel_ec(febid);
118 int pos_neg = m_onlineHelper->pos_neg(febid);
119 ftmon = m_onlineHelper->feedthrough(febid);
120 slmon = m_onlineHelper->slot(febid);
121 unsigned int partitionNb_dE = returnPartition(barrel_ec,pos_neg,ftmon,slmon);
122 unsigned int subdet = partitionNb_dE / 2;
123
124 if (partitionNb_dE < m_partitions.size()) {
125 nfeb[partitionNb_dE]++ ;
126 }else{
127 ATH_MSG_WARNING("Unknown partition number: "<< partitionNb_dE << " not filling !");
128 continue;
129 }
130 larEventSize += (float) (it->RodRawDataSize() + it->RodResults1Size() + it->RodResults2Size()); // This quantity is now in megabytes
131
132 // Eventype = 2 : transparent/raw data - 4 : Physic - 7 : calibration - 10 : pedestal - 14 : raw data + results
133 uint32_t eventType = it->DetEventType();
134 // If physic mode && raw data != 0, we are in rawdata+results
135 if (eventType == 4 && it->RodRawDataSize() != 0) eventType = 14;
136 //if (firstEventType == 999) firstEventType = eventType;
137
138 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitionNb_dE])],slmon,ftmon);
139 } //Test on FEBid
140 } //end of loop over FEB headers
141 // Loop over all febs to plot the error from statusword
142 // This is mandatory to also monitor the FEBs with missing headers
143
144 for (auto allFeb = m_onlineHelper->feb_begin(); allFeb != m_onlineHelper->feb_end(); ++allFeb) {
145 HWIdentifier febid = HWIdentifier(*allFeb);
146 bool currentFebStatus = false;
147 uint16_t feberrorSummary = lArFebErrorSummary->feb_error(febid);
148
149 if ( feberrorSummary != 0 ){
150 int barrel_ec = m_onlineHelper->barrel_ec(febid);
151 int pos_neg = m_onlineHelper->pos_neg(febid);
152 int ft = m_onlineHelper->feedthrough(febid);
153 int slot = m_onlineHelper->slot(febid);
154 unsigned int partitionNb_dE = returnPartition(barrel_ec,pos_neg,ft,slot);
155
156 if (partitionNb_dE < m_partitions.size()) {
157 // Fill the errors in partition histograms
158 fillErrorsSummary(partitionNb_dE,ft,slot,feberrorSummary,lar_inerror, rejectionBits, currentFebStatus, eventRejected);
159 } else{
160 ATH_MSG_WARNING("Unknown partition number: "<< partitionNb_dE << " not filling !");
161 }
162
163 if (currentFebStatus && febInErrorTree.size()<33) febInErrorTree.push_back(febid.get_identifier32().get_compact());
164 } else{
165 ATH_MSG_WARNING("Summarry FEB error: "<< feberrorSummary << " The histogram not created !");
166 }
167 }
168
169
170//Fill general data histos
171 auto evttype = Monitored::Scalar<int>("EvtType",firstEventType);
172
173 float nbOfFeb = 0.;
174 for(auto nf: nfeb) nbOfFeb+=nf;// (nfeb[0]+nfeb[1]+nfeb[2]+nfeb[3]+nfeb[4]+nfeb[5]+nfeb[6]+nfeb[7]);
175
176 bool newHighWaterMarkNFebBlocksTotal = false;
177 if(m_nbOfFebBlocksTotal < nbOfFeb){ // new number of Febs
178 m_nbOfFebBlocksTotal = nbOfFeb;
179 newHighWaterMarkNFebBlocksTotal = true;
180 }
181 auto nbfeb = Monitored::Scalar<int>("nbFEB",nbOfFeb);
182 fill(m_MonGroupName, evttype, nbfeb);
183
184 auto part = Monitored::Scalar<int>("part",-1);
185 auto nbfebpart = Monitored::Scalar<int>("nbFEBpart",-1);
186 for(unsigned i=0; i<m_partitions.size(); ++i) {
187 part=i;
188 unsigned subdet = i / 2;
189 nbfebpart=nfeb[i];
190 fill(m_MonGroupName,part,nbfebpart);
191 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[i])],nbfebpart);
192 }
193// LB histograms filling
194 auto evtrej = Monitored::Scalar<int>("EvtRej",-1);
195 float evt_yield=-1.;
196 auto evtyield = Monitored::Scalar<float>("EvtRejYield",-1);
197 if (febInErrorTree.size()>=1 || newHighWaterMarkNFebBlocksTotal || nbOfFeb < m_nbOfFebBlocksTotal ){
198 evtrej=1; evt_yield = 100.;
199 if (febInErrorTree.size()>=4) evtrej=2;
200 }
201
202 evtyield=evt_yield;
203 auto evSize = Monitored::Scalar<float>("LArEvSize",larEventSize/262144);
204 auto lb0 = Monitored::Scalar<int>("LB0",lumi_block);
205 fill(m_MonGroupName,evtrej,evtyield,evSize,lb0);
206
207 return StatusCode::SUCCESS;
208}
209
210unsigned int LArCalibPedMonAlg::returnPartition(int be,int pn,int ft,int sl) const {
211 // partitionNb_dE = 0 : EMBC / 1 : EMBA / 2 : EMECC / 3 : EMECA / 4 : HECC / 5 : HECA / 6 : FCALC / 7 : FCALA
212 unsigned int part = be*2+pn;
213 if (be == 1){
214 // This is a HEC FEB - Dirty method as IsHECOnlineFEBId is buggy!
215 if ((ft == 3 || ft == 10 || ft == 16 || ft == 22) && (sl > 2)) part = be*2+pn + 2;
216 if (ft == 6) part = be*2 + pn + 4; // This is FCAL FEB
217 }
218 return part;
219}
220
221void LArCalibPedMonAlg::fillErrorsSummary(unsigned int partitNb_2,int ft,int slot,uint16_t error, bool lar_inerror, std::bitset<13> &rejectionBits, bool &currentFebStatus, bool &eventRejected) const
222{
223 auto part = Monitored::Scalar<int>("part",partitNb_2);
224 auto ferror = Monitored::Scalar<int>("febError",-1);
225 if ( error & (1<<0) ){
226 unsigned subdet = partitNb_2 / 2;
227 auto sl = Monitored::Scalar<int>("slotPar",slot);
228 auto ftmon = Monitored::Scalar<int>("FTPar",ft);
229 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
230 currentFebStatus = true;
231 rejectionBits.set(0);
232 ferror=1;
233 fill(m_MonGroupName, ferror, part);
234 }
235
236 if ( error & (1<<1) ){
237 unsigned subdet = partitNb_2 / 2;
238 auto sl = Monitored::Scalar<int>("slotBcid",slot);
239 auto ftmon = Monitored::Scalar<int>("FTBcid",ft);
240 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
241 currentFebStatus = true;
242 rejectionBits.set(1);
243 ferror=2;
244 fill(m_MonGroupName, ferror, part);
245 }
246
247 if ( error & (1<<2) ){
248 unsigned subdet = partitNb_2 / 2;
249 auto sl = Monitored::Scalar<int>("slotRadd",slot);
250 auto ftmon = Monitored::Scalar<int>("FTRadd",ft);
251 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
252 currentFebStatus = true;
253 rejectionBits.set(2);
254 ferror=3;
255 fill(m_MonGroupName, ferror, part);
256 }
257
258 if ( error & (1<<3) ){
259 unsigned subdet = partitNb_2 / 2;
260 auto sl = Monitored::Scalar<int>("slotEvtid",slot);
261 auto ftmon = Monitored::Scalar<int>("FTEvtid",ft);
262 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
263 currentFebStatus = true;
264 rejectionBits.set(3);
265 ferror=4;
266 fill(m_MonGroupName, ferror, part);
267 }
268
269 if ( error & (1<<4) ){
270 unsigned subdet = partitNb_2 / 2;
271 auto sl = Monitored::Scalar<int>("slotScac",slot);
272 auto ftmon = Monitored::Scalar<int>("FTScac",ft);
273 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
274 currentFebStatus = true;
275 rejectionBits.set(4);
276 ferror=5;
277 fill(m_MonGroupName, ferror, part);
278 }
279
280 if ( error & (1<<5) ){
281 unsigned subdet = partitNb_2 / 2;
282 auto sl = Monitored::Scalar<int>("slotscout",slot);
283 auto ftmon = Monitored::Scalar<int>("FTscout",ft);
284 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
285 currentFebStatus = true;
286 rejectionBits.set(5);
287 ferror=6;
288 fill(m_MonGroupName, ferror, part);
289 }
290
291 if ( error & (1<<6) ){
292 unsigned subdet = partitNb_2 / 2;
293 auto sl = Monitored::Scalar<int>("slotgain",slot);
294 auto ftmon = Monitored::Scalar<int>("FTgain",ft);
295 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
296 currentFebStatus = true;
297 rejectionBits.set(6);
298 ferror=7;
299 fill(m_MonGroupName, ferror, part);
300 }
301
302 if ( error & (1<<7) ){
303 unsigned subdet = partitNb_2 / 2;
304 auto sl = Monitored::Scalar<int>("slottype",slot);
305 auto ftmon = Monitored::Scalar<int>("FTtype",ft);
306 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
307 currentFebStatus = true;
308 rejectionBits.set(7);
309 ferror=8;
310 fill(m_MonGroupName, ferror, part);
311 }
312
313 if ( error & (1<<8) ){
314 unsigned subdet = partitNb_2 / 2;
315 auto sl = Monitored::Scalar<int>("slotsmp",slot);
316 auto ftmon = Monitored::Scalar<int>("FTsmp",ft);
317 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
318 currentFebStatus = true;
319 rejectionBits.set(8);
320 ferror=9;
321 fill(m_MonGroupName, ferror, part);
322 }
323
324 if ( error & (1<<9) ){
325 unsigned subdet = partitNb_2 / 2;
326 auto sl = Monitored::Scalar<int>("slotzero",slot);
327 auto ftmon = Monitored::Scalar<int>("FTzero",ft);
328 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
329 currentFebStatus = true;
330 rejectionBits.set(9);
331 ferror=10;
332 fill(m_MonGroupName, ferror, part);
333 }
334
335
336 if ( error & (1<<11) ){
337 unsigned subdet = partitNb_2 / 2;
338 auto sl = Monitored::Scalar<int>("slotsum",slot);
339 auto ftmon = Monitored::Scalar<int>("FTsum",ft);
340 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
341 currentFebStatus = true;
342 rejectionBits.set(10);
343 ferror=11;
344 fill(m_MonGroupName, ferror, part);
345 }
346
347 if ( error & (1<<12) ){
348 // Check whether this error can be ignored. Useful for calibration run of PS or EMB
349 if (!((m_ignoreMissingHeaderEMB && partitNb_2<2 && slot>=2) || (m_ignoreMissingHeaderPS && partitNb_2<2 && slot==1))){
350 unsigned subdet = partitNb_2 / 2;
351 auto sl = Monitored::Scalar<int>("slotmis",slot);
352 auto ftmon = Monitored::Scalar<int>("FTmis",ft);
353 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
354 currentFebStatus = true;
355 rejectionBits.set(11);
356 ferror=12;
357 fill(m_MonGroupName, ferror, part);
358 }
359 }
360
361 if ( error & (1<<13) ){
362 unsigned subdet = partitNb_2 / 2;
363 auto sl = Monitored::Scalar<int>("slotgain",slot);
364 auto ftmon = Monitored::Scalar<int>("FTgain",ft);
365 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
366 currentFebStatus = true;
367 rejectionBits.set(12);
368 ferror=13;
369 fill(m_MonGroupName, ferror, part);
370 }
371
372
373 if (currentFebStatus){
374 unsigned subdet = partitNb_2 / 2;
375 auto sl = Monitored::Scalar<int>("slotabs",slot);
376 auto ftmon = Monitored::Scalar<int>("FTabs",ft);
377 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],sl,ftmon);
378 float ferr=0.;
379 if (lar_inerror) {// LArinError
380 eventRejected = true;
381 if(environment() == Environment_t::online) ferr=100.;
382 } else {
383 if(environment() == Environment_t::online) ferr=50.;
384 }
386 auto lbf = Monitored::Scalar<float>("LBf",0.5);
387 auto erry = Monitored::Scalar<float>("erronl",ferr);
388 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitNb_2])],lbf,erry);
389 }
390 }
391
392 return;
393}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
Header file to be included by clients of the Monitored infrastructure.
Handle class for reading a decoration on an object.
const ServiceHandle< StoreGateSvc > & detStore() const
Environment_t environment() const
Accessor functions for the environment.
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Gaudi::Property< std::vector< std::string > > m_partitions
Gaudi::Property< bool > m_ignoreMissingHeaderEMB
unsigned int returnPartition(int be, int pn, int ft, int sl) const
Gaudi::Property< std::string > m_MonGroupName
std::atomic< int > m_nbOfFebBlocksTotal
const LArOnlineID * m_onlineHelper
virtual StatusCode initialize() override
Overwrite dummy method from AlgTool.
Gaudi::Property< bool > m_ignoreMissingHeaderPS
void fillErrorsSummary(unsigned int partitNb_2, int ft, int slot, uint16_t error, bool lar_inerror, std::bitset< 13 > &rejectionBits, bool &currentFebStatus, bool &eventRejected) const
std::vector< std::map< std::string, int > > m_histoGroups
Gaudi::Property< std::vector< std::string > > m_SubDetNames
SG::ReadHandleKey< LArFebHeaderContainer > m_hdrContKey
LArCalibPedMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
SG::ReadHandleKey< LArFebErrorSummary > m_lArFebErrorSummaryKey
SG::ReadHandleKey< LArAccumulatedDigitContainer > m_accDigitContainerKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override
Called each event.
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ LAr
The LAr calorimeter.
@ Error
The sub-detector issued an error.
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case)
void fill(H5::Group &out_file, size_t iterations)