ATLAS Offline Software
Loading...
Searching...
No Matches
LArDigitalTriggMonAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// ********************************************************************
7//
8// NAME: LArDigitalTriggMonAlg.cxx
9// PACKAGE: LArMonitoring
10//
11// AUTHOR: Pavol Strizenec (pavol@mail.cern.ch)
12// Ljiljana Morvaj (ljiljana.morvaj@cern.ch)
13// Yesenia Hernadez (yesenia@cern.ch)
14// Based on LAtDigitMon tool by L. Hellary and LArOddCellsMonTool.cxx by Benjamin Trocme
15//
16// Monitor a few things in the LArDigit...
17//
18// 1) Check that the highest value of the LArDigit is contained in an interval.
19// If it is not the case increment 3 histograms for each subdetector:
20// a) Out of range histograms
21// b) The average histograms: give the average value of the highest digit sample
22// c) Channel VS FEB histograms: gives wich slot on wich FEB has his highest digit sample ou of the range
23// 2) Check if a digits samples are in saturation. If it's the case increment the saturation histograms.
24//
25// Available cuts in the jo file:
26//
27// a) SampleRangeLow-SampleRangeUp: range to check the digit sample.
28// b) ADCcut : To select Digits Samples with signal.
29// c) ADCsature: lowest value to check if a Digit sample is in saturation.
30// ********************************************************************
31
33
34//Histograms
35//LAr infos:
39#include "CaloGeoHelpers/CaloSampling.h"
43#include "CaloDetDescr/CaloDetDescrElement.h"
45
47
48//STL:
49#include <sstream>
50#include <iomanip>
51#include <cmath>
52#include <vector>
53#include <algorithm>
54#include <set>
55
56template<typename C>
57bool isEmptyCont(C& c) {
58 return (c.key().empty() || !c.isValid() || c->size()==0);
59}
60
61
62/*---------------------------------------------------------*/
66
67/*---------------------------------------------------------*/
69{
70 ATH_MSG_INFO( "Initialize LArDigitalTriggMonAlg" );
71
73 ATH_CHECK(detStore()->retrieve( m_LArOnlineIDHelper, "LArOnline_SuperCellID" ));
74
76 ATH_CHECK(detStore()->retrieve( m_SCID_helper, "CaloCell_SuperCell_ID" ).isSuccess());
77
78 ATH_MSG_INFO("Building tool map");
81
82 ATH_MSG_INFO("Done building tool map");
83
84 ATH_MSG_INFO("Input containers=" << m_rawSCContainerKey << " / " << m_rawSCEtRecoContainerKey);
85
86
88 ATH_CHECK(m_bcContKey.initialize());
89 ATH_CHECK(m_bcMask.buildBitMask(m_problemsToMask,msg()));
90
91 ATH_CHECK(m_digitContainerKey.initialize());
92 ATH_CHECK(m_keyPedestalSC.initialize());
93 ATH_CHECK(m_caloSuperCellMgrKey.initialize());
96 ATH_CHECK(m_cablingKey.initialize());
97 ATH_CHECK(m_actualMuKey.initialize());
99
100 // Property check:
101 constexpr unsigned expSize=MAXLYRNS*2+1;
102 if (m_layerNames.size() != expSize) {
103 ATH_MSG_ERROR("Unexpected size of LayerNames property. Expect "<< expSize << " entries, found "<< m_layerNames.size() << " entries");
104 return StatusCode::FAILURE;
105 }
106
107 if (m_isADCBaseline) {
108 ATH_MSG_INFO("IsADCBas set to true");
109 }
111}
112
113
135
136
162
163
164StatusCode LArDigitalTriggMonAlg::fillHistograms(const EventContext& ctx) const
165{
166
167 ATH_MSG_DEBUG("in fillHists()" );
168
169 // General Monitored variables
170 auto lumi_block = Monitored::Scalar<unsigned int>("lumi_block", 0);
171 auto time_stamp = Monitored::Scalar<unsigned int>("time_stamp", 0);
172 auto BCID = Monitored::Scalar<int>("BCID",0);
173 auto Pedestal = Monitored::Scalar<float>("Pedestal",0.0);
174 auto PedestalRMS = Monitored::Scalar<float>("PedestalRMS",0.0);
175
176 // From digi loop
177 auto Digi_Nsamples = Monitored::Scalar<int>("Digi_Nsamples",-1); // MNsamples
178 auto Digi_SCChannel = Monitored::Scalar<int>("Digi_SCChannel",-1); // MSCChannel
179 auto Digi_latomeSourceId = Monitored::Scalar<int>("Digi_latomeSourceId",-1); // MlatomeSourceId
180 auto Digi_latomeSourceIdBIN = Monitored::Scalar<int>("Digi_latomeSourceIdBIN",1); // MlatomeSourceIdBIN
181 auto Digi_phi = Monitored::Scalar<float>("Digi_phi",0.0); // MSCphi
182 auto Digi_eta = Monitored::Scalar<float>("Digi_eta",0.0); // MSCeta
183 auto Digi_iphi = Monitored::Scalar<int>("Digi_iphi",0.0);
184 auto Digi_ieta = Monitored::Scalar<int>("Digi_ieta",0.0);
185 auto Digi_maxpos = Monitored::Scalar<int>("Digi_maxpos",-1); // Mmaxpos
186 auto Digi_partition = Monitored::Scalar<int>("Digi_partition",-1); // Mpartition
187 auto Digi_sampos = Monitored::Scalar<int>("Digi_sampos",-1); // Msampos
188 auto Digi_ADC = Monitored::Scalar<int>("Digi_ADC",-1); // MADC
189 auto Digi_Diff_ADC_Ped = Monitored::Scalar<float>("Digi_Diff_ADC_Ped", -999); // Diff_ADC_Pedestal
190 auto Digi_Diff_ADC0_Ped = Monitored::Scalar<float>("Digi_Diff_ADC0_Ped", -999); // Pedestal diff
191 auto Digi_Diff_ADC_Ped_Norm = Monitored::Scalar<float>("Digi_Diff_ADC_Ped_Norm",-999); // Diff_ADC_Pedestal_Norm
192 auto Digi_ADC_RMS = Monitored::Scalar<float>("Digi_ADC_RMS",-1); // Digi_ADC_RMS
193
194 // cuts
195 auto notBadQual = Monitored::Scalar<bool>("notBadQual",false);
196 auto ADCped10RMS = Monitored::Scalar<bool>("ADCped10RMS",false);
197 auto passDigiNom = Monitored::Scalar<bool>("passDigiNom",false);
198 auto badNotMasked = Monitored::Scalar<bool>("badNotMasked",false);
199
200 // cuts which are used in both loops
201 auto notMasked = Monitored::Scalar<bool>("notMasked",false);
202
203 // From SC loop
204 auto SC_SCChannel = Monitored::Scalar<int>("SC_SCChannel",-1); // MSCChannel
205 auto SC_latomeSourceId = Monitored::Scalar<int>("SC_latomeSourceId",-1); // MlatomeSourceId
206 auto SC_partition = Monitored::Scalar<int>("SC_partition",-1); // Mpartition
207 auto SC_phi = Monitored::Scalar<float>("SC_phi",0.0); // MSCphi
208 auto SC_eta = Monitored::Scalar<float>("SC_eta",0.0); // MSCeta
209 auto SC_iphi = Monitored::Scalar<int>("SC_iphi",0.0);
210 auto SC_ieta = Monitored::Scalar<int>("SC_ieta",0.0);
211 auto SC_energy_onl = Monitored::Scalar<int>("SC_energy_onl",0.0); // Menergy_onl
212 auto SC_ET_onl = Monitored::Scalar<float>("SC_ET_onl",0.0); // Menergy_onl
213 auto SC_ET_onl_muscaled = Monitored::Scalar<float>("SC_ET_onl_muscaled",0.0); // Menergy_onl
214 auto SC_energy_ofl = Monitored::Scalar<int>("SC_energy_ofl",0.0); // Menergy_ofl
215 auto SC_ET_ofl = Monitored::Scalar<float>("SC_ET_ofl",0.0); // Menergy_onl
216 auto SC_ET_diff = Monitored::Scalar<int>("SC_ET_diff",0.0); // MSCEt_diff
217 auto SC_time = Monitored::Scalar<float>("SC_time",0.0); // MSCtime
218 auto SC_latomeSourceIdBIN = Monitored::Scalar<int>("SC_latomeSourceIdBIN",1); // MlatomeSourceIdBIN
219 auto SC_AvEnergyOverMu = Monitored::Scalar<float>("SC_AvEnergyOverMu",0); // LMAvEnergyOverMu
220 // cuts
221 auto passTauSel = Monitored::Scalar<bool>("passTauSel",false);
222 auto nonZeroET = Monitored::Scalar<bool>("nonZeroET",false); // eTgt0GeV
223 auto zeroET = Monitored::Scalar<bool>("zeroET",false); // eTgt0GeV
224 auto nonZeroETofl = Monitored::Scalar<bool>("nonZeroETofl",false); // eTgt0GeV
225 auto onlofflEmismatch = Monitored::Scalar<bool>("onlofflEmismatch",false);
226 auto notSatur = Monitored::Scalar<bool>("notSatur",false);
227 auto notOFCbOF = Monitored::Scalar<bool>("notOFCbOF",false);
228 auto tauGt3 = Monitored::Scalar<bool>("tauGt3",false);
229 auto nonZeroEtau = Monitored::Scalar<bool>("nonZeroEtau",false);
230 auto eTgt1GeV = Monitored::Scalar<bool>("eTgt1GeV",false);
231 auto eTlt1GeV = Monitored::Scalar<bool>("eTlt1GeV",false);
232 auto eTgt0p325GeV = Monitored::Scalar<bool>("eTgt0p325GeV",false);
233 auto eTgt0lt0p325GeV = Monitored::Scalar<bool>("eTgt0lt0p325GeV",false);
234 auto eTgt10GeV = Monitored::Scalar<bool>("eTgt10GeV",false);
235 auto eTlt10GeV = Monitored::Scalar<bool>("eTlt10GeV",false);
236 auto eToflGt1GeV = Monitored::Scalar<bool>("eToflGt1GeV",false);
237
238
239 //auto passSCNom = Monitored::Scalar<bool>("passSCNom",false); // pass tau, not satur, not OFCb OF, not masked nonZeroET < 10 GeV
240 auto passSCNomInvalid = Monitored::Scalar<bool>("passSCNomInvalid",false); // pass tau, not satur, not OFCb OF, not masked and raw E = -99999
241 auto passSCNom0_0p325 = Monitored::Scalar<bool>("passSCNom0_0p325",false); // pass tau, not satur, not OFCb OF, not masked nonZeroET < 0.2 GeV
242 auto passSCNom0p325_1 = Monitored::Scalar<bool>("passSCNom0p325_1",false); // pass tau, not satur, not OFCb OF, not masked 0.2 < ET < 1 GeV
243 auto passSCNom1 = Monitored::Scalar<bool>("passSCNom1",false); // pass tau, not satur, not OFCb OF, not masked eTgt1GeV
244 auto passSCNom10 = Monitored::Scalar<bool>("passSCNom10",false); // pass tau, not satur, not OFCb OF, not masked eTgt10GeV
245 auto passSCNom10tauGt3 = Monitored::Scalar<bool>("passSCNom10tauGt3",false); // pass tau, not satur, not OFCb OF, not masked eTgt10GeV tauGt3
246 auto saturNotMasked = Monitored::Scalar<bool>("saturNotMasked",false); // notSatur is false, notMasked is false
247 auto OFCbOFNotMasked = Monitored::Scalar<bool>("OFCbOFNotMasked",false); // notOFCbOF is false, notMasked is false
248 auto notMaskedEoflNe0 = Monitored::Scalar<bool>("notMaskedEoflNe0",false); // not masked OSUM, not satur, not OFCb OF, ET ofl != 0
249 auto notMaskedEoflGt1 = Monitored::Scalar<bool>("notMaskedEoflGt1",false); // not masked OSUM, not satur, not OFCb OF, ET ofl > 1
250
251 // From LATOME header loop
252 auto thisEvent=this->GetEventInfo(ctx);
253
254 const std::vector<unsigned> streamsThisEvent=LArMon::trigStreamMatching(m_streams,thisEvent->streamTags());
255
257 const LArOnOffIdMapping* cabling=*cablingHdl;
258
259 SG::ReadHandle<LArDigitContainer> hLArDigitContainer;
260 if (!m_digitContainerKey.empty()) {
261 hLArDigitContainer= SG::ReadHandle<LArDigitContainer>{m_digitContainerKey,ctx}; //"SC"
262 if (!hLArDigitContainer.isValid()) {
263 ATH_MSG_WARNING("The requested digit container key could not be retrieved. Was there a problem retrieving information from the run logger?");
264 }
265 }
266 else {
267 ATH_MSG_DEBUG("hLArDigitContainer.size() " << hLArDigitContainer->size());
268 }
269
270
272 if (!m_rawSCContainerKey.empty()) {
273 hSCetContainer = SG::ReadHandle<LArRawSCContainer>{m_rawSCContainerKey, ctx}; //"SC_ET"
274 if (!hSCetContainer.isValid()) {
275 ATH_MSG_WARNING("The requested SC ET container key could not be retrieved. Was there a problem retrieving information from the run logger?");
276 }
277 }
278 else {
279 ATH_MSG_DEBUG("hSCetContainer.size() " << hSCetContainer->size());
280 }
281
282 SG::ReadHandle<LArRawSCContainer> hSCetRecoContainer;
283 if (!m_rawSCEtRecoContainerKey.empty()) {
284 hSCetRecoContainer = SG::ReadHandle<LArRawSCContainer>{m_rawSCEtRecoContainerKey, ctx}; //"SC_ET_RECO"
285 if (!hSCetRecoContainer.isValid()) {
286 ATH_MSG_WARNING("The requested SC ET reco container key could not be retrieved. Was there a problem retrieving information from the run logger?");
287 }
288 }
289 else {
290 ATH_MSG_DEBUG("hSCetRecoContainer.size() " << hSCetRecoContainer->size());
291 }
292
293 SG::ReadHandle<LArLATOMEHeaderContainer> hLArLATOMEHeaderContainer{m_LATOMEHeaderContainerKey,ctx}; //"SC_LATOME_HEADER"
294 if (!hLArLATOMEHeaderContainer.isValid()) {
295 ATH_MSG_WARNING("The requested LATOME header container key could not be retrieved. Was there a problem retrieving information from the run logger?");
296 }else{
297 ATH_MSG_DEBUG("hLArLATOMEHeaderContainer.size() " << hLArLATOMEHeaderContainer->size());
298 }
299
300 if (isEmptyCont(hLArDigitContainer) && isEmptyCont(hSCetContainer) && isEmptyCont(hSCetRecoContainer) && isEmptyCont(hLArLATOMEHeaderContainer)) {
301 //Make this only warning, come CI tests use the runs without DT info
302 ATH_MSG_WARNING("All of the requested containers are empty. Was there a problem retrieving information from the run logger?");
303 return StatusCode::SUCCESS;
304 }
305
306 BCID = thisEvent->bcid(); // - 88)%((36+7)*4 + 36 + 31);
307 lumi_block = thisEvent->lumiBlock();
308 time_stamp = thisEvent->timeStamp();
309
310 float mu = lbInteractionsPerCrossing(ctx);
311 float event_mu = lbLuminosityPerBCID(ctx);
312
313 ATH_MSG_DEBUG("mu (LB): " << mu);
314 ATH_MSG_DEBUG("mu (BCID): " << event_mu);
315 ATH_MSG_DEBUG("Event number: " << thisEvent->eventNumber());
316 ATH_MSG_DEBUG("LB number: " << thisEvent->lumiBlock());
317 ATH_MSG_DEBUG("BCID: " << thisEvent->bcid());
319 const ILArPedestal* pedestals = *pedestalHdl;
320
322 const CaloSuperCellDetDescrManager* ddman = *caloSuperCellMgrHandle;
323
324 // retrieve BadChannel info:
325 const LArBadChannelCont* bcCont = nullptr;
327 bcCont = (*bcContHdl);
328
329 if ((hLArDigitContainer.isValid())) {
330 std::vector<std::vector<Digi_MonValues>> digiMonValueVec(m_layerNames.size());
331 for (auto& innerVec : digiMonValueVec) {
332 innerVec.reserve(1600); // (m_layerNcells[ilayer]) * nsamples;
333 }
334
335 // Loop over digits
336 for (const LArDigit* pLArDigit : *hLArDigitContainer) {
337 HWIdentifier id = pLArDigit->hardwareID(); // gives online ID
338 // skip disconnected channels:
339 if (!cabling->isOnlineConnected(id))
340 continue;
341
342 const unsigned trueNSamples = pLArDigit->nsamples();
343 if (trueNSamples == 0)
344 continue;
345 Digi_Nsamples = trueNSamples; // Fill the monitored variable
346 const int cgain = pLArDigit->gain();
347
348 const Identifier offlineID = cabling->cnvToIdentifier(id);
349 const CaloDetDescrElement* caloDetElement = ddman->get_element(offlineID);
350 if (caloDetElement == 0) {
351 ATH_MSG_ERROR("Cannot retrieve caloDetElement");
352 continue;
353 }
354 Digi_eta = caloDetElement->eta_raw();
355 Digi_phi = caloDetElement->phi_raw();
356
357 Digi_ieta = m_SCID_helper->eta(offlineID);
358 Digi_iphi = m_SCID_helper->phi(offlineID);
359
360 const int calosample = caloDetElement->getSampling();
361
362 const unsigned iLyrNS = m_caloSamplingToLyrNS[calosample];
363 const int side = m_LArOnlineIDHelper->pos_neg(id);
364 const unsigned iLyr = iLyrNS * 2 + side;
365 auto& lvaluemap_digi = digiMonValueVec[iLyr];
366 auto& lvaluemap_digi_ALL = digiMonValueVec.back();
367
368 // Determine to which partition this channel belongs to
369 const int ThisPartition = whatPartition(id, side);
370 Digi_partition = ThisPartition; // Fill the monitored variable
371
372 fill(m_scMonGroupName, Digi_Nsamples);
373
374 // Check if this is a maskedOSUM SC
375 notMasked = true;
376 if (m_bcMask.cellShouldBeMasked(bcCont, id)) {
377 notMasked = false;
378 }
379
380 if (pedestals) {
381 Pedestal = pedestals->pedestal(id, cgain);
382 PedestalRMS = pedestals->pedestalRMS(id, cgain);
383 } else
384 ATH_MSG_INFO("Pedestal values not received");
385
386 const LArSCDigit* scdigi = dynamic_cast<const LArSCDigit*>(pLArDigit);
387 if (!scdigi) {
388 ATH_MSG_DEBUG(" CAN'T CAST ");
389 } else {
390 Digi_SCChannel = scdigi->Channel();
391 Digi_latomeSourceId = scdigi->SourceId();
392 Digi_latomeSourceIdBIN = getXbinFromSourceID(Digi_latomeSourceId);
393 }
394 // Retrieve samples
395 const std::vector<short>* digito = &pLArDigit->samples();
396
397 // retrieve the max sample digit ie digitot.back().
398 std::vector<short>::const_iterator maxSam = std::max_element(digito->begin(), digito->end());
399 int thismaxPos = std::distance(digito->begin(), maxSam);
400 Digi_maxpos = thismaxPos + 1; // count samples [1,5]
401 float ADC_max = pLArDigit->samples().at(Digi_maxpos - 1);
402
403 float ADC_0 = pLArDigit->samples().at(0);
404 if (m_isADCBaseline) { // SC_ADC_BAS, have to divide by 8
405 ADC_0 = ADC_0 / 8;
406 }
407
408 float samp_sum = std::accumulate(digito->begin(), digito->end(), 0.0);
409 float samp_mean = samp_sum / static_cast<float>(trueNSamples);
410 float sq_sum = std::inner_product(digito->begin(), digito->end(), digito->begin(), 0.0);
411 float rms_arg = sq_sum / static_cast<float>(trueNSamples) - samp_mean * samp_mean;
412
413 if (rms_arg < 0)
414 Digi_ADC_RMS = -1;
415 else
416 Digi_ADC_RMS = std::sqrt(rms_arg);
417
418
419 // Start Loop over samples
420 Digi_Diff_ADC0_Ped = ADC_0 - Pedestal;
421 for (unsigned i = 0; i < trueNSamples; ++i) {
422 badNotMasked = false;
423 notBadQual = false;
424 ADCped10RMS = false;
425 passDigiNom = false;
426 Digi_sampos = i + 1;
427 Digi_ADC = pLArDigit->samples().at(i);
428 if (m_isADCBaseline) { // SC_ADC_BAS, have to divide by 8
429 Digi_ADC = Digi_ADC / 8;
430 }
431
432 Digi_Diff_ADC_Ped = Digi_ADC - Pedestal;
433 if (ADC_max != Pedestal) {
434 Digi_Diff_ADC_Ped_Norm = (Digi_ADC - Pedestal) / std::abs(ADC_max - Pedestal);
435 }
436
437 // Some selections
438 if (Digi_ADC != -1) {
439 notBadQual = true;
440 } else {
441 if (notMasked) {
442 badNotMasked = true;
443 }
444 }
445 if (ADC_max - Pedestal > 10 * PedestalRMS) {
446 ADCped10RMS = true;
447 }
448 if (notMasked && notBadQual && ADCped10RMS) {
449 passDigiNom = true;
450 }
451
452 lvaluemap_digi.emplace_back(Digi_eta, Digi_phi, Digi_ieta, Digi_iphi, Digi_sampos, Digi_ADC, Digi_latomeSourceIdBIN, Pedestal, Digi_maxpos,
453 Digi_partition, Digi_Diff_ADC_Ped_Norm, Digi_Diff_ADC_Ped, Digi_Diff_ADC0_Ped, Digi_ADC_RMS, BCID, lumi_block, passDigiNom,
454 badNotMasked);
455 lvaluemap_digi_ALL.emplace_back(Digi_eta, Digi_phi, Digi_ieta, Digi_iphi, Digi_sampos, Digi_ADC, Digi_latomeSourceIdBIN, Pedestal, Digi_maxpos,
456 Digi_partition, Digi_Diff_ADC_Ped_Norm, Digi_Diff_ADC_Ped, Digi_Diff_ADC0_Ped, Digi_ADC_RMS, BCID, lumi_block, passDigiNom,
457 badNotMasked);
458
459 } // End loop over samples
460
461 } // End of loop on LArDigit
462
463 // fill, for every layer/threshold
464 for (size_t ilayer = 0; ilayer < digiMonValueVec.size(); ++ilayer) {
465 const auto& tool = digiMonValueVec[ilayer];
466 auto digi_part_eta = Monitored::Collection("Digi_part_eta", tool, [](const auto& v) { return v.digi_eta; });
467 auto digi_part_phi = Monitored::Collection("Digi_part_phi", tool, [](const auto& v) { return v.digi_phi; });
468 auto digi_part_ieta = Monitored::Collection("Digi_part_ieta", tool, [](const auto& v) { return v.digi_ieta; });
469 auto digi_part_iphi = Monitored::Collection("Digi_part_iphi", tool, [](const auto& v) { return v.digi_iphi; });
470 auto digi_part_sampos = Monitored::Collection("Digi_part_sampos", tool, [](const auto& v) { return v.digi_sampos; });
471 auto digi_part_adc = Monitored::Collection("Digi_part_adc", tool, [](const auto& v) { return v.digi_adc; });
472 auto digi_part_latomesourceidbin = Monitored::Collection("Digi_part_latomesourceidbin", tool, [](const auto& v) { return v.digi_latomesourceidbin; });
473 auto digi_part_pedestal = Monitored::Collection("Digi_part_pedestal", tool, [](const auto& v) { return v.digi_pedestal; });
474 auto digi_part_maxpos = Monitored::Collection("Digi_part_maxpos", tool, [](const auto& v) { return v.digi_maxpos; });
475 auto digi_part_partition = Monitored::Collection("Digi_part_partition", tool, [](const auto& v) { return v.digi_partition; });
476 auto digi_part_diff_adc_ped_norm = Monitored::Collection("Digi_part_diff_adc_ped_norm", tool, [](const auto& v) { return v.digi_diff_adc_ped_norm; });
477 auto digi_part_diff_adc_ped = Monitored::Collection("Digi_part_diff_adc_ped", tool, [](const auto& v) { return v.digi_diff_adc_ped; });
478 auto digi_part_diff_adc0_ped = Monitored::Collection("Digi_part_diff_adc0_ped", tool, [](const auto& v) { return v.digi_diff_adc0_ped; });
479 auto digi_part_bcid = Monitored::Collection("Digi_part_BCID", tool, [](const auto& v) { return v.digi_bcid; });
480 auto digi_part_lb = Monitored::Collection("Digi_part_LB", tool, [](const auto& v) { return v.digi_lb; });
481 auto digi_part_passDigiNom = Monitored::Collection("Digi_part_passDigiNom", tool, [](const auto& v) { return v.digi_passDigiNom; });
482 auto digi_part_badNotMasked = Monitored::Collection("Digi_part_badNotMasked", tool, [](const auto& v) { return v.digi_badNotMasked; });
483 auto digi_part_adc_rms = Monitored::Collection("Digi_part_adc_rms", tool, [](const auto& v) { return v.digi_adc_rms; });
484
485 fill(m_tools[m_toolmapLayerNames_digi.at(m_layerNames[ilayer])], digi_part_eta, digi_part_phi, digi_part_ieta, digi_part_iphi, digi_part_sampos,
486 digi_part_adc, digi_part_latomesourceidbin, digi_part_pedestal, digi_part_maxpos, digi_part_diff_adc_ped_norm, digi_part_diff_adc_ped,
487 digi_part_diff_adc0_ped, digi_part_adc_rms, digi_part_bcid, digi_part_lb, digi_part_passDigiNom, digi_part_badNotMasked);
488 }
489
490 } // End if(LArDigitContainer is valid)
491
492
493 if (!isEmptyCont(hSCetContainer) && !isEmptyCont(hSCetRecoContainer)) {
494 LArRawSCContainer::const_iterator itSC = hSCetContainer->begin();
495 LArRawSCContainer::const_iterator itSC_e= hSCetContainer->end();
496 LArRawSCContainer::const_iterator itSCReco = hSCetRecoContainer->begin();
497 const LArRawSC* rawSC = 0;
498 const LArRawSC* rawSCReco = 0;
499
500 std::vector<std::vector<SC_MonValues>> scMonValueVec(m_layerNames.size());
501 for (auto& innerVec : scMonValueVec) {
502 innerVec.reserve(1600); // (m_layerNcells[ilayer]) * nsamples;
503 }
504
505 // Loop over SCs
506 for (; itSC != itSC_e; ++itSC, ++itSCReco) {
507 rawSC = *itSC;
508 if (itSCReco < hSCetRecoContainer->end()) {
509 rawSCReco = *itSCReco;
510 } else {
511 //temporarily removed
512 //ATH_MSG_WARNING("Looping SC ET container, but we have reached the end of the SC ET Reco iterator. Check the sizes of these containers. Is SC ET Reco size zero? Is there a problem with the digit container name sent by the run logger?");
513 rawSCReco = 0;
514 }
515 SC_SCChannel = rawSC->chan();
516 HWIdentifier id = rawSC->hardwareID(); // gives online ID
517 // skip disconnected channels:
518 if (!cabling->isOnlineConnected(id))
519 continue;
520
521 const Identifier offlineID = cabling->cnvToIdentifier(id); // converts online to offline ID
522 // Get Physical Coordinates
523 const CaloDetDescrElement* caloDetElement = ddman->get_element(offlineID);
524 if (caloDetElement == 0) {
525 ATH_MSG_ERROR("Cannot retrieve (eta,phi) coordinates for raw channels");
526 ATH_MSG_ERROR(" ==============> " << std::hex << "; offlineID = " << offlineID << "online ID =" << m_LArOnlineIDHelper->channel_name(id)
527 << "; rawSC->SourceId() = " << rawSC->SourceId());
528 continue;
529 }
530 SC_eta = caloDetElement->eta_raw();
531 SC_phi = caloDetElement->phi_raw();
532
533 SC_ieta = m_SCID_helper->eta(offlineID);
534 SC_iphi = m_SCID_helper->phi(offlineID);
535 int calosample = caloDetElement->getSampling();
536
537 const unsigned iLyrNS = m_caloSamplingToLyrNS[calosample];
538 const unsigned side = m_LArOnlineIDHelper->pos_neg(id);
539 const unsigned iLyr = iLyrNS * 2 + side;
540
541 auto& lvaluemap_sc = scMonValueVec[iLyr];
542 auto& lvaluemap_sc_ALL = scMonValueVec.back();
543
544 SC_latomeSourceIdBIN = getXbinFromSourceID(rawSC->SourceId());
545
546 // initialise cuts
547 notMasked = false;
548 passTauSel = false;
549 nonZeroET = false;
550 zeroET = false;
551 notSatur = false;
552 nonZeroEtau = false;
553 eTgt0p325GeV = false;
554 eTgt0lt0p325GeV = false;
555 eTgt1GeV = false;
556 eTlt1GeV = false;
557 eTgt10GeV = false;
558 eTlt10GeV = false;
559 notOFCbOF = false;
560 tauGt3 = false;
561 onlofflEmismatch = false;
562 passSCNom0_0p325 = false;
563 passSCNom0p325_1 = false;
564 passSCNom1 = false;
565 passSCNom10 = false;
566 passSCNom10tauGt3 = false;
567 saturNotMasked = false;
568 OFCbOFNotMasked = false;
569 notMaskedEoflNe0 = false;
570 notMaskedEoflGt1 = false;
571 nonZeroETofl = false;
572 eToflGt1GeV = false;
573 passSCNomInvalid = false;
574 // Check if this is a maskedOSUM SC
575 if (!m_bcMask.cellShouldBeMasked(bcCont, id)) {
576 notMasked = true;
577 }
578 // popopopo
579 if (rawSCReco != 0 && rawSCReco->passTauSelection().size() > 0) { // only compare Et if tau selection is passed
580 if (rawSCReco->passTauSelection().at(0) == true)
581 passTauSel = true;
582 }
583 unsigned int bcid_ind = 0;
584 if (rawSC->energies().size() > 0) {
585 for (auto& SCe : rawSC->bcids()) {
586 if (SCe == BCID)
587 break;
588 bcid_ind++;
589 }
590 if (bcid_ind >= rawSC->bcids().size()) {
591 ATH_MSG_WARNING("BCID not found in SC bcids list!! " << BCID << " BCIDs size: " << rawSC->bcids().size() << ", proposed index: " << bcid_ind);
592 } else if (rawSC->bcids().at(bcid_ind) != BCID) {
593 ATH_MSG_WARNING("BCID not found in SC bcids list!! " << BCID << " " << rawSC->bcids().at(bcid_ind));
594 }
595
596 if (rawSC->energies().size() > bcid_ind) {
597 SC_energy_onl = rawSC->energies().at(bcid_ind);
598 } else {
599 ATH_MSG_WARNING("rawSC energies vector is too small for the requested BCID index " << bcid_ind << " (size is " << rawSC->energies().size()
600 << ", bcid vec size is " << rawSC->bcids().size() << ")");
601 SC_energy_onl = 0;
602 }
603 } else {
604 ATH_MSG_WARNING("rawSC energies vector is empty!");
605 SC_energy_onl = 0;
606 }
607
608 if (rawSCReco != 0) {
609 if (rawSCReco->energies().size() > 0) {
610 SC_energy_ofl = rawSCReco->energies().at(0); // algorithm already selects the correct energy
611 } else {
612 ATH_MSG_WARNING("rawSCReco energies vector is empty!");
613 SC_energy_ofl = 0;
614 }
615 }
616 SC_ET_diff = SC_energy_onl - SC_energy_ofl;
617 SC_ET_onl = (SC_energy_onl * 12.5) / 1000; // Converted to GeV
618 SC_ET_ofl = (SC_energy_ofl * 12.5) / 1000; // Converted to GeV
619 SC_ET_onl_muscaled = event_mu > 0. ? SC_ET_onl / event_mu : SC_ET_onl;
620 int Etau = 0;
621 if (rawSCReco != 0) {
622 if (rawSCReco->tauEnergies().size() > 0) {
623 Etau = rawSCReco->tauEnergies().at(0);
624 }
625 }
626 SC_time = (SC_energy_ofl != 0) ? (float)Etau / (float)SC_energy_ofl : Etau;
627
628 ATH_MSG_DEBUG("Energy onl - Energy ofl: " << SC_energy_onl << ", " << SC_energy_ofl << std::endl);
629 if (SC_ET_onl != 0) {
630 nonZeroET = true;
631 } else {
632 zeroET = true;
633 }
634 if (SC_ET_onl > 0.325) {
635 eTgt0p325GeV = true;
636 } else if (SC_ET_onl < 0.325 && SC_ET_onl > 0.) {
637 eTgt0lt0p325GeV = true;
638 }
639 if (SC_ET_onl > 1) {
640 eTgt1GeV = true;
641 }
642 if (SC_ET_onl < 1) {
643 eTlt1GeV = true;
644 }
645 if (SC_ET_onl > 10) {
646 eTgt10GeV = true;
647 }
648 if (SC_ET_onl < 10) {
649 eTlt10GeV = true;
650 }
651 if (SC_ET_ofl != 0) {
652 nonZeroETofl = true;
653 }
654 if (SC_ET_ofl > 1) {
655 eToflGt1GeV = true;
656 }
657 if (rawSC->satur().size() > bcid_ind) {
658 if (rawSC->satur().at(bcid_ind)) {
659 if (notMasked) {
660 saturNotMasked = true;
661 }
662 } else {
663 notSatur = true;
664 }
665 }
666 if (Etau != 0) {
667 nonZeroEtau = true;
668 }
669 if (rawSCReco != 0 && rawSCReco->ofcbOverflow() == false) {
670 notOFCbOF = true;
671 } else {
672 if (notMasked) {
673 OFCbOFNotMasked = true;
674 }
675 }
676 if (std::abs(SC_time) > 3) {
677 tauGt3 = true;
678 }
679
680 if (notMasked && notSatur && notOFCbOF) {
681 if (nonZeroETofl) {
682 notMaskedEoflNe0 = true;
683 }
684 if (eToflGt1GeV) {
685 notMaskedEoflGt1 = true;
686 }
687 if (SC_energy_onl == -99999) {
688 passSCNomInvalid = true;
689 }
690
691 //if ( passTauSel ){
692 //if ( nonZeroET && eTgt0lt0p325GeV ){
693 if (eTgt0lt0p325GeV) {
694 passSCNom0_0p325 = true;
695 }
696 if (eTgt0p325GeV && eTlt1GeV) {
697 passSCNom0p325_1 = true;
698 }
699 if (eTgt1GeV) {
700 passSCNom1 = true;
701 }
702 if (eTgt10GeV) {
703 passSCNom10 = true;
704 if (tauGt3) {
705 passSCNom10tauGt3 = true;
706 }
707 }
708 if (SC_energy_onl != SC_energy_ofl) {
709 onlofflEmismatch = true;
710 }
711 //}
712 } // end nominal selections
713
714 lvaluemap_sc.emplace_back(SC_eta, SC_phi, SC_ieta, SC_iphi, SC_latomeSourceIdBIN, SC_ET_ofl, SC_ET_diff, SC_ET_onl, SC_ET_onl_muscaled, SC_time, BCID,
715 lumi_block, zeroET, passSCNomInvalid, passSCNom0_0p325, passSCNom0p325_1, passSCNom1, passSCNom10, passSCNom10tauGt3, saturNotMasked, OFCbOFNotMasked, notMaskedEoflNe0,
716 notMaskedEoflGt1);
717 lvaluemap_sc_ALL.emplace_back(SC_eta, SC_phi, SC_ieta, SC_iphi, SC_latomeSourceIdBIN, SC_ET_ofl, SC_ET_diff, SC_ET_onl, SC_ET_onl_muscaled, SC_time,
718 BCID, lumi_block, zeroET, passSCNomInvalid, passSCNom0_0p325, passSCNom0p325_1, passSCNom1, passSCNom10, passSCNom10tauGt3, saturNotMasked, OFCbOFNotMasked,
719 notMaskedEoflNe0, notMaskedEoflGt1);
720
721 } // end loop over SCs
722
723 // fill, for every layer/threshold
724 for (size_t ilayer = 0; ilayer < scMonValueVec.size(); ++ilayer) {
725 const auto& tool = scMonValueVec[ilayer];
726 auto sc_part_eta = Monitored::Collection("SC_part_eta", tool, [](const auto& v) { return v.sc_eta; });
727 auto sc_part_phi = Monitored::Collection("SC_part_phi", tool, [](const auto& v) { return v.sc_phi; });
728 auto sc_part_ieta = Monitored::Collection("SC_part_ieta", tool, [](const auto& v) { return v.sc_ieta; });
729 auto sc_part_iphi = Monitored::Collection("SC_part_iphi", tool, [](const auto& v) { return v.sc_iphi; });
730 auto sc_part_latomesourceidbin = Monitored::Collection("SC_part_latomesourceidbin", tool, [](const auto& v) { return v.sc_latomesourceidbin; });
731 auto sc_part_et_ofl = Monitored::Collection("SC_part_et_ofl", tool, [](const auto& v) { return v.sc_et_ofl; });
732 auto sc_part_et_diff = Monitored::Collection("SC_part_et_diff", tool, [](const auto& v) { return v.sc_et_diff; });
733 auto sc_part_et_onl = Monitored::Collection("SC_part_et_onl", tool, [](const auto& v) { return v.sc_et_onl; });
734 auto sc_part_et_onl_muscaled = Monitored::Collection("SC_part_et_onl_muscaled", tool, [](const auto& v) { return v.sc_et_onl_muscaled; });
735 auto sc_part_time = Monitored::Collection("SC_part_time", tool, [](const auto& v) { return v.sc_time; });
736 auto sc_part_bcid = Monitored::Collection("SC_part_BCID", tool, [](const auto& v) { return v.sc_bcid; });
737 auto sc_part_lb = Monitored::Collection("SC_part_LB", tool, [](const auto& v) { return v.sc_lb; });
738 // auto sc_part_passSCNom = Monitored::Collection("SC_part_passSCNom", tool, [](const auto& v) { return v.sc_passSCNom; });
739 auto sc_zeroET = Monitored::Collection("SC_part_zeroET", tool, [](const auto& v) { return v.sc_zeroET; });
740 auto sc_part_passSCNomInvalid = Monitored::Collection("SC_part_passSCNomInvalid", tool, [](const auto& v) { return v.sc_passSCNomInvalid; });
741 auto sc_part_passSCNom0_0p325 = Monitored::Collection("SC_part_passSCNom0_0p325", tool, [](const auto& v) { return v.sc_passSCNom0_0p325; });
742 auto sc_part_passSCNom0p325_1 = Monitored::Collection("SC_part_passSCNom0p325_1", tool, [](const auto& v) { return v.sc_passSCNom0p325_1; });
743 auto sc_part_passSCNom1 = Monitored::Collection("SC_part_passSCNom1", tool, [](const auto& v) { return v.sc_passSCNom1; });
744 auto sc_part_passSCNom10 = Monitored::Collection("SC_part_passSCNom10", tool, [](const auto& v) { return v.sc_passSCNom10; });
745 auto sc_part_passSCNom10tauGt3 = Monitored::Collection("SC_part_passSCNom10tauGt3", tool, [](const auto& v) { return v.sc_passSCNom10tauGt3; });
746 auto sc_part_saturNotMasked = Monitored::Collection("SC_part_saturNotMasked", tool, [](const auto& v) { return v.sc_saturNotMasked; });
747 auto sc_part_OFCbOFNotMasked = Monitored::Collection("SC_part_OFCbOFNotMasked", tool, [](const auto& v) { return v.sc_OFCbOFNotMasked; });
748 auto sc_part_notMaskedEoflNe0 = Monitored::Collection("SC_part_notMaskedEoflNe0", tool, [](const auto& v) { return v.sc_notMaskedEoflNe0; });
749 auto sc_part_notMaskedEoflGt1 = Monitored::Collection("SC_part_notMaskedEoflGt1", tool, [](const auto& v) { return v.sc_notMaskedEoflGt1; });
750
751
752 fill(m_tools[m_toolmapLayerNames_sc.at(m_layerNames[ilayer])], sc_part_eta, sc_part_phi, sc_part_ieta, sc_part_iphi, sc_part_latomesourceidbin,
753 sc_part_et_ofl, sc_part_et_diff, sc_part_et_onl, sc_part_et_onl_muscaled, sc_part_time, sc_part_bcid, sc_part_lb, sc_zeroET, sc_part_passSCNomInvalid,
754 sc_part_passSCNom0_0p325, sc_part_passSCNom0p325_1, sc_part_passSCNom1, sc_part_passSCNom10, sc_part_passSCNom10tauGt3, sc_part_saturNotMasked, sc_part_OFCbOFNotMasked, sc_part_notMaskedEoflNe0,
755 sc_part_notMaskedEoflGt1);
756 }
757
758
759 } // End if(LArSCContainer is valid)
760
761
762
763 // LATOME event size
764 if ((hLArLATOMEHeaderContainer.isValid())) {
765 auto event_size = Monitored::Scalar<float>("event_size", 0);
766 for (const LArLATOMEHeader* pLArLATOMEHeader : *hLArLATOMEHeaderContainer) {
767 event_size += pLArLATOMEHeader->ROBFragSize() + 48; // 48 is the offset between rod_ndata and ROB fragment size
768 }
769 event_size /= (1024 * 1024 / 4);
770 fill(m_scMonGroupName, lumi_block, event_size);
771 }
772
773 // end LATOME event size
774
775 return StatusCode::SUCCESS;
776 }
777
778/*---------------------------------------------------------*/
780
782{
783 if (m_LArOnlineIDHelper->isEMBchannel(id)) {
784 if(side==0) return 0;
785 else return 1;
786 } else if (m_LArOnlineIDHelper->isEMECchannel(id)) {
787 if(side==0) return 2;
788 else return 3;
789 } else if (m_LArOnlineIDHelper->isHECchannel(id)) {
790 if(side==0) return 4;
791 else return 5;
792 } else {
793 if(side==0) return 6;
794 else return 7;
795 }
796}
797
798
799
800unsigned LArDigitalTriggMonAlg::getXbinFromSourceID(const unsigned sourceID) const
801{
802 // int NLatomeBins = 117;
803 int detStartingBin=m_NLatomeBins;
804 const unsigned detID = sourceID >> 16;
805 const unsigned value = sourceID & 0xF;
806 auto mapit=m_LatomeDetBinMappingQ.find(detID);
807 if (mapit!=m_LatomeDetBinMappingQ.end()) {
808 detStartingBin=mapit->second;
809 }
810
811 unsigned binx = detStartingBin+value;
812 if (binx>m_NLatomeBins){
813 ATH_MSG_WARNING("something wrong with binning, filling overflowbin");
814 binx=m_NLatomeBins;
815 }
816
817 return binx;
818}
819
#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)
Helper class for offline supercell identifiers.
LArBadXCont< LArBadChannel > LArBadChannelCont
bool isEmptyCont(C &c)
const ServiceHandle< StoreGateSvc > & detStore() const
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.)
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
This class groups all DetDescr information related to a CaloCell.
CaloCell_ID::CaloSample getSampling() const
cell sampling
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual float pedestal(const HWIdentifier &id, int gain) const =0
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
Liquid Argon digit base class.
Definition LArDigit.h:25
const std::vector< short > & samples() const
Definition LArDigit.h:78
const CaloCell_SuperCell_ID * m_SCID_helper
virtual StatusCode initialize() override
initialize
std::map< std::string, int > m_toolmapLayerNames_sc
SG::ReadCondHandleKey< ILArPedestal > m_keyPedestalSC
Handle to pedestal.
SG::ReadHandleKey< LArDigitContainer > m_digitContainerKey
Handle to EventData (input)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
SG::ReadHandleKey< LArRawSCContainer > m_rawSCContainerKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
int whatPartition(HWIdentifier id, int side) const
private methods:
SG::ReadDecorHandleKey< xAOD::EventInfo > m_actualMuKey
Gaudi::Property< std::vector< std::string > > m_problemsToMask
SG::ReadHandleKey< LArLATOMEHeaderContainer > m_LATOMEHeaderContainerKey
const std::map< unsigned, unsigned > m_LatomeDetBinMappingQ
unsigned getXbinFromSourceID(const unsigned sourceID) const
StringArrayProperty m_layerNames
Gaudi::Property< std::vector< std::string > > m_streams
Give the name of the streams you want to monitor:
SG::ReadHandleKey< LArRawSCContainer > m_rawSCEtRecoContainerKey
virtual ~LArDigitalTriggMonAlg()
Default destructor.
Gaudi::Property< unsigned > m_NLatomeBins
Gaudi::Property< bool > m_isADCBaseline
const LArOnline_SuperCellID * m_LArOnlineIDHelper
Gaudi::Property< std::string > m_scMonGroupName
const std::array< unsigned, CaloSampling::Unknown > m_caloSamplingToLyrNS
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
Handle to Super Cell DD Manager.
LArBadChannelMask m_bcMask
Handle to bad-channel mask.
std::map< std::string, int > m_toolmapLayerNames_digi
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
Holds information from the LATOME Header.
Liquid Argon SuperCell raw data.
Definition LArRawSC.h:19
unsigned int SourceId() const
Definition LArRawSC.h:95
short chan() const
Definition LArRawSC.h:92
const std::vector< bool > & satur() const
Definition LArRawSC.h:107
const std::vector< bool > & passTauSelection() const
Definition LArRawSC.h:113
const std::vector< unsigned short > & bcids() const
Definition LArRawSC.h:104
bool ofcbOverflow() const
Definition LArRawSC.h:120
const std::vector< int > & tauEnergies() const
Definition LArRawSC.h:110
const std::vector< int > & energies() const
Definition LArRawSC.h:101
const HWIdentifier & hardwareID() const
Definition LArRawSC.h:89
Base class for LArDigits taken by LATOME.
Definition LArSCDigit.h:19
unsigned int SourceId() const
Definition LArSCDigit.h:45
short Channel() const
Definition LArSCDigit.h:42
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual float lbInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate instantaneous number of interactions, i.e.
virtual float lbLuminosityPerBCID(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the instantaneous luminosity per bunch crossing.
struct color C
std::vector< unsigned > trigStreamMatching(const std::vector< std::string > &streamsFromJobO, const std::vector< xAOD::EventInfo::StreamTag > &streamInEvent)
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case)
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
void fill(H5::Group &out_file, size_t iterations)