ATLAS Offline Software
Loading...
Searching...
No Matches
LArDigitMonAlg.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: LArDigitMonALg.cxx
8// PACKAGE: LArMonitoring
9//
10// AUTHOR: Pavol Strizenec (pavol@mail.cern.ch)
11// Based on LAtDigitMon tool by L. Hellary and LArOddCellsMonTool.cxx by Benjamin Trocme
12//
13// Monitor a few things in the LArDigit...
14//
15// 1) Check that the highest value of the LArDigit is contained in an interval.
16// If it is not the case increment 3 histograms for each subdetector:
17// a) Out of range histograms
18// b) The average histograms: give the average value of the highest digit sample
19// c) Channel VS FEB histograms: gives wich slot on wich FEB has his highest digit sample ou of the range
20// 2) Check if a digits samples are in saturation. If it's the case increment the saturation histograms.
21//
22// Available cuts in the jo file:
23//
24// a) SampleRangeLow-SampleRangeUp: range to check the digit sample.
25// b) ADCcut : To select Digits Samples with signal.
26// c) ADCsature: lowest value to check if a Digit sample is in saturation.
27// ********************************************************************
28
29#include "LArDigitMonAlg.h"
30
31//Histograms
32//LAr infos:
36
38
39//STL:
40#include <sstream>
41#include <iomanip>
42#include <cmath>
43#include <vector>
44#include <algorithm>
45
46/*---------------------------------------------------------*/
47LArDigitMonAlg::LArDigitMonAlg(const std::string& name, ISvcLocator* pSvcLocator )
48 : AthMonitorAlgorithm(name, pSvcLocator),
51 m_Samplenbr(-1)
52{}
53
54
55/*---------------------------------------------------------*/
59
60/*---------------------------------------------------------*/
61StatusCode
63{
64
65 ATH_MSG_INFO( "Initialize LArDigitMonAlg" );
66
67
69 if ( detStore()->retrieve( m_LArOnlineIDHelper, "LArOnlineID" ).isSuccess() ) {
70
71 ATH_MSG_DEBUG("connected non-tool: LArOnlineID" );
72
73 } else {
74
75 ATH_MSG_FATAL( "unable to connect non-tool: LArOnlineID" );
76 return StatusCode::FAILURE;
77
78 }
79
80
81 // Get LArEM Id Helper, not used now...
82 if ( detStore()->retrieve( m_LArEM_IDHelper, "LArEM_ID" ).isSuccess() ) {
83
84 ATH_MSG_DEBUG("connected non-tool: LArEM_ID" );
85
86 } else {
87
88 ATH_MSG_FATAL( "unable to connect non-tool: LArEM_ID" );
89 return StatusCode::FAILURE;
90
91 }
92
93 ATH_CHECK(m_digitContainerKey.initialize());
94 ATH_CHECK(m_eventInfoKey.initialize());
95 ATH_CHECK(m_keyPedestal.initialize());
96 ATH_CHECK(m_cablingKey.initialize());
97 ATH_CHECK(m_noisyROSummaryKey.initialize());
98
99
100
103 ATH_CHECK(m_bcMask.buildBitMask(m_problemsToMask,msg()));
104
105
106 m_histoGroups.reserve(m_SubDetNames.size());
107 for (unsigned i=0; i<m_SubDetNames.size(); ++i) {
108 std::vector<std::string> part;
109 part.push_back(m_partitions[2*i]);
110 part.push_back(m_partitions[2*i+1]);
112 }
113
115}
116
117StatusCode LArDigitMonAlg::fillHistograms(const EventContext& ctx) const
118{
119
120 ATH_MSG_DEBUG("in fillHists()" );
121
122
123
124 // retrieve LArNoisyROSummary and skip the event if number of FEB is greater than the one declare in JO.
126
127 if(noisyRO.isValid()) {
128 const std::vector<HWIdentifier>& noisyFEB = noisyRO->get_noisy_febs();
129 if(int(noisyFEB.size())>m_NumberBadFebs) {
130 ATH_MSG_DEBUG("Skip this Noisy event ");
131 return StatusCode::SUCCESS;
132 }
133 }
134
135 //monitored variables
136 auto weight = Monitored::Scalar<float>("weight",1.);
137 auto partition = Monitored::Scalar<int>("partition",-1);
138 auto gain = Monitored::Scalar<int>("gain",-1);
139 auto sumbin = Monitored::Scalar<int>("sumbin",-1);
140 auto slot_o = Monitored::Scalar<int>("Outslot",-1);
141 auto ft_o = Monitored::Scalar<int>("OutFT",-1);
142 auto weight_o = Monitored::Scalar<float>("Outweight",1.);
143 auto slot_n = Monitored::Scalar<int>("Nullslot",-1);
144 auto ft_n = Monitored::Scalar<int>("NullFT",-1);
145 auto weight_n = Monitored::Scalar<float>("Nullweight",1.);
146 auto slot_s = Monitored::Scalar<int>("Saturslot",-1);
147 auto ft_s = Monitored::Scalar<int>("SaturFT",-1);
148 auto weight_s = Monitored::Scalar<float>("Saturweight",1.);
149 auto slot_sl = Monitored::Scalar<int>("SaturLowslot",-1);
150 auto ft_sl = Monitored::Scalar<int>("SaturLowFT",-1);
151 auto weight_sl = Monitored::Scalar<float>("SaturLowweight",1.);
152 auto crate_o = Monitored::Scalar<int>("Outcrate",-1);
153 auto chan_o = Monitored::Scalar<int>("Outchan",-1);
154 auto crate_n = Monitored::Scalar<int>("Nullcrate",-1);
155 auto chan_n = Monitored::Scalar<int>("Nullchan",-1);
156 auto crate_s = Monitored::Scalar<int>("Saturcrate",-1);
157 auto chan_s = Monitored::Scalar<int>("Saturchan",-1);
158 auto crate_sl = Monitored::Scalar<int>("SaturLowcrate",-1);
159 auto chan_sl = Monitored::Scalar<int>("SaturLowchan",-1);
160
161
162 auto LBN = Monitored::Scalar<int>("LBN",-1);
163 auto slot = Monitored::Scalar<int>("slot",-1);
164 auto ft = Monitored::Scalar<int>("FT",-1);
165 auto maxpos = Monitored::Scalar<int>("MaxPos",-1);
166 auto l1Trig = Monitored::Scalar<int>("l1trig",-1);
167 auto energy = Monitored::Scalar<int>("Energy",-1);
168 auto sample = Monitored::Scalar<int>("Sample",-1);
169 auto signal = Monitored::Scalar<float>("SignalNorm",-1);
170
173
174 unsigned thisl1Trig = thisEvent->level1TriggerType();
175 unsigned thisLBN = thisEvent->lumiBlock();
176
177 LBN=thisLBN;
179
180 std::vector<unsigned int> streamsThisEvent=LArMon::trigStreamMatching(m_streams,thisEvent->streamTags());
181 if(streamsThisEvent[0] == m_streams.size()) streamsThisEvent[0]=m_streams.size()-1; // assuming others are last in the list of streams
182
183 auto streambin=Monitored::Collection("streamBin",streamsThisEvent);
184
186 const ILArPedestal* pedestals=*pedestalHdl;
187
189 const LArOnOffIdMapping* cabling=*cablingHdl;
190
191 //retrieve BadChannel info:
192 const LArBadChannelCont* bcCont=nullptr;
195 bcCont=(*bcContHdl);
196 }
197
199
201 LArDigitContainer::const_iterator itDig = pLArDigitContainer->begin();
202 LArDigitContainer::const_iterator itDig_e= pLArDigitContainer->end();
203 const LArDigit* pLArDigit;
204
205
206
209
210
211 if(m_Samplenbr < 0) { // get it from somewhere
212 std::lock_guard<std::mutex> lock(m_lock);
213
214 if(m_SampleNumberFromDB!=0) { // from jO
215 m_Samplenbr=m_SampleNumberFromDB;
216 ATH_MSG_DEBUG("Retrieve nSamples from jO" );
217 } else { // from data
218 if (itDig!=itDig_e) {
219 pLArDigit = *itDig;
220 m_Samplenbr=pLArDigit->nsamples();
221 ATH_MSG_DEBUG("Retrieve nSamples from first event" );
222 }
223 }
224 }
225
226 if((m_AskedSampleRangeLow < 0) && (m_AskedSampleRangeUp < 0)) { // detect automatically
227 if(m_ExpectedSampleMax!=0) { // set from expected max sample
228 m_SampleRangeLow=m_ExpectedSampleMax-1;
229 m_SampleRangeUp=m_ExpectedSampleMax+1;
230 ATH_MSG_DEBUG("Set Range number from expected Max sample" );
231 } else {
232 ATH_MSG_DEBUG("Set range by hand " );
234 if(m_Samplenbr == 5) {
235 m_SampleRangeLow=2;
236 m_SampleRangeUp=4;
237 }
238
239 if(m_Samplenbr == 7) {
240 m_SampleRangeLow=3;//nota has to be checked in real run, none are available now...
241 m_SampleRangeUp=5;
242 }
243
244 if(m_Samplenbr == 10) {
245 m_SampleRangeLow=4;
246 m_SampleRangeUp=6;
247 }
248
249 if(m_Samplenbr == 32) {
250 m_SampleRangeLow=5;
251 m_SampleRangeUp=9;
252 }
253
255 if(m_Samplenbr < 10&&m_Samplenbr!=5&&m_Samplenbr!=7) {
256 m_SampleRangeLow=2;//default is 4,7
257 m_SampleRangeUp=4;
258 }
259
260 if(m_Samplenbr <= 20&&m_Samplenbr>10) {
261 m_SampleRangeLow=4;//default is 4,7
262 m_SampleRangeUp=7;
263 }
264
265 if(m_Samplenbr > 20&&m_Samplenbr!=32) {
266 m_SampleRangeLow=5;//default is 4,7
267 m_SampleRangeUp=9;
268 }
269 }
270 } else {
271 ATH_MSG_DEBUG("Range has been set by user" );
272 m_SampleRangeLow=m_AskedSampleRangeLow;
273 m_SampleRangeUp=m_AskedSampleRangeUp;
274 }//Range and sample max are known now....
275
276
277 ATH_MSG_DEBUG("Range set to "<< m_SampleRangeLow << " - " << m_SampleRangeUp );
278
280 for ( ; itDig!=itDig_e;++itDig) {
281 pLArDigit = *itDig;
282
283
286 HWIdentifier id = pLArDigit->hardwareID();
287 //CaloGain::CaloGain gain = pLArDigit->gain();
288 if ( m_bcMask.cellShouldBeMasked(bcCont,id)) {
289 continue;
290 }
291 }
292
294 int cgain = pLArDigit->gain();
295 gain=cgain;
296 fill(m_summaryMonGroupName, gain, partition);
297
299 HWIdentifier id = pLArDigit->hardwareID();
300 float pedestal = pedestals->pedestal(id,cgain);
301 float pedestalRMS=pedestals->pedestalRMS(id,cgain);
302
304 if(pedestal <= (1.0+LArElecCalib::ERRORCODE)) continue;
305
307 if(!cabling->isOnlineConnected(id)) continue;
308
310 int side = m_LArOnlineIDHelper->pos_neg(id);
311 const int ThisPartition=WhatPartition(id,side);
312 std::string spart = m_partitions[ThisPartition];
313 partition = ThisPartition;
314 int subdet = ThisPartition / 2;
315
317 int channel = m_LArOnlineIDHelper->channel(id);
318 int thisSlot = m_LArOnlineIDHelper->slot(m_LArOnlineIDHelper->feb_Id(id));
319 int feedthrough = m_LArOnlineIDHelper->feedthrough(m_LArOnlineIDHelper->feedthrough_Id(id));
320 int crate=thisSlot + m_Nslots[ThisPartition]*feedthrough;
321
323 const std::vector<short>* digito = &pLArDigit->samples();
324
326 std::vector<short>::const_iterator maxSam = std::max_element(digito->begin(), digito->end());
327 std::vector<short>::const_iterator minSam = std::min_element(digito->begin(), digito->end());
328 int thismaxPos=(maxSam-digito->begin());
329 std::vector<short>::const_iterator iterSam= digito->begin();
330
332 if((*maxSam-pedestal)>pedestalRMS*m_SigmaCut)
333 {
335 for(int i=0;i<pLArDigit->nsamples();++i,++iterSam){
336 sample = i;
337 signal= (*iterSam-pedestal)/(*maxSam-pedestal);
338 weight = (*maxSam-pedestal);
339 fill(m_tools[m_histoGroups.at(subdet).at(spart)],sample,signal,weight);
340 }
341
343 slot = thisSlot;
344 ft = feedthrough;
345 maxpos=thismaxPos;
346 energy=(*maxSam-pedestal);
347 l1Trig=thisl1Trig;
348 fill(m_tools[m_histoGroups.at(subdet).at(spart)],slot,ft,LBN,maxpos,energy,l1Trig,streambin);
349
350
352 if(!(thismaxPos>=m_SampleRangeLow&&thismaxPos<=m_SampleRangeUp)){
353 sumbin=0;
354 slot_o = thisSlot;
355 ft_o = feedthrough;
356 weight_o=100./128;
357 crate_o=crate;
358 chan_o=channel;
359 weight = 1.;
360 fill(m_tools[m_histoGroups.at(subdet).at(spart)],slot_o,ft_o,weight,weight_o,crate_o,chan_o);
361 }
362 }
363
365 if ((*maxSam)>=m_ADCsatureCut) {
366 if(gain==0 || gain==1){
367 slot_s = thisSlot;
368 ft_s = feedthrough;
369 weight_s=100./128;
370 crate_s=crate;
371 chan_s=channel;
372 weight = 1.;
373 fill(m_tools[m_histoGroups.at(subdet).at(spart)],slot_s,ft_s,weight,weight_s,crate_s,chan_s);
374 } else {
375 slot_sl = thisSlot;
376 ft_sl = feedthrough;
377 weight_sl=100./128;
378 crate_sl=crate;
379 chan_sl=channel;
380 weight = 1.;
381 fill(m_tools[m_histoGroups.at(subdet).at(spart)],slot_sl,ft_sl,weight,weight_sl,crate_sl,chan_sl);
382 }
383 }
385 if((*minSam)==0){
386 sumbin=2;
387 fill(m_summaryMonGroupName, sumbin, partition);
388 slot_n = thisSlot;
389 ft_n = feedthrough;
390 weight_n=100./128;
391 crate_n=crate;
392 chan_n=channel;
393 weight = 1.;
394 fill(m_tools[m_histoGroups.at(subdet).at(spart)],slot_n,ft_n,weight,weight_n,crate_n,chan_n);
395 }
396
397 }
398
399 return StatusCode::SUCCESS;
400}
401
402/*---------------------------------------------------------*/
404
406{
407
408 if (m_LArOnlineIDHelper->isEmBarrelOnline(id)) {
409 if(side==0) return 0;
410 else return 1;
411 } else if (m_LArOnlineIDHelper-> isEMECchannel(id)) {
412 if(side==0) return 2;
413 else return 3;
414 } else if (m_LArOnlineIDHelper->isHECchannel(id)) {
415 if(side==0) return 4;
416 else return 5;
417 } else {
418 if(side==0) return 6;
419 else return 7;
420 }
421}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
LArBadXCont< LArBadChannel > LArBadChannelCont
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
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
const LArOnlineID * m_LArOnlineIDHelper
Gaudi::Property< int > m_ExpectedSampleMax
Use the SampleMax expected and the SampleNumber from DB.
Gaudi::Property< std::vector< int > > m_Nslots
Gaudi::Property< int > m_AskedSampleRangeUp
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
const LArEM_ID * m_LArEM_IDHelper
LArBadChannelMask m_bcMask
Handle to bad-channel mask.
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
LArDigitMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< int > m_ADCsatureCut
default saturation cuts
SG::ReadHandleKey< LArDigitContainer > m_digitContainerKey
Handle to digits.
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
SG::ReadCondHandleKey< ILArPedestal > m_keyPedestal
Handle to pedestal.
Gaudi::Property< bool > m_ignoreKnownBadChannels
bool use to mask the bad channels
Gaudi::Property< std::vector< std::string > > m_SubDetNames
SG::ReadHandleKey< LArNoisyROSummary > m_noisyROSummaryKey
Handle to NoisyRO info.
Gaudi::Property< int > m_SampleNumberFromDB
std::vector< std::map< std::string, int > > m_histoGroups
virtual StatusCode initialize() override
initialize
std::mutex m_lock
Gaudi::Property< int > m_NumberBadFebs
Number of Bad FEBs used to declare an event noisy and exclude it from monitoring.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Gaudi::Property< std::vector< std::string > > m_streams
Give the name of the streams you want to monitor:
Gaudi::Property< int > m_AskedSampleRangeLow
Range to check for the max sample.
Gaudi::Property< std::string > m_summaryMonGroupName
virtual ~LArDigitMonAlg()
Default destructor.
Gaudi::Property< int > m_SigmaCut
default cut to select events
int WhatPartition(HWIdentifier id, int side) const
Say which partition is a channel.
Gaudi::Property< std::vector< std::string > > m_problemsToMask
Gaudi::Property< std::vector< std::string > > m_partitions
Liquid Argon digit base class.
Definition LArDigit.h:25
CaloGain::CaloGain gain() const
Definition LArDigit.h:72
const HWIdentifier & hardwareID() const
Definition LArDigit.h:66
int nsamples() const
Definition LArDigit.h:75
const std::vector< short > & samples() const
Definition LArDigit.h:78
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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)