ATLAS Offline Software
LArPedestalValidationAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <cmath>
7 
8 LArPedestalValidationAlg::LArPedestalValidationAlg(const std::string& name, ISvcLocator* pSvcLocator) :
9  LArPedestalValidationBase(name,pSvcLocator) {
10 
11  declareProperty("PedestalTolerance",m_pedToleranceInit,
12  "CaloCellGroup of allowed deviation of the pedestal (in ADC counts)");
13  declareProperty("PedestalRMSTolerance",m_rmsToleranceInit,
14  "CaloCellGroup of allowed deviation of the pedestal RMS (in ADC counts)");
15 
16  declareProperty("PedestalToleranceFEB",m_pedToleranceFEBInit,
17  "CaloCellGroup of allowed deviation of the pedestal (average over one FEB, in ADC counts)");
18  declareProperty("PedestalRMSToleranceFEB",m_rmsToleranceFEBInit,
19  "CaloCellGroup Allowed deviation of the pedestal RMS (average over one FEB, in ADC counts)");
20  m_pedGlobalRef=0.;
21  m_rmsGlobalRef=0.;
22  m_pedGlobalVal=0.;
23  m_rmsGlobalVal=0.;
25 }
26 
27 
29  m_pedGlobalRef=0.;
30  m_rmsGlobalRef=0.;
31  m_pedGlobalVal=0.;
32  m_rmsGlobalVal=0.;
34 
35  bool stat;
36 
37 
38  ATH_MSG_INFO ( "Initialize Pedestal Tolerances (CaloCellGroup)" ) ;
40  if (!stat) {
41  ATH_MSG_ERROR ( "Failed to initialize CaloCellGroup of pedestal tolerances!" ) ;
42  return StatusCode::FAILURE;
43  }
44  if (m_pedTolerance.getDefaults().size()!=3) {
45  ATH_MSG_ERROR ( "Configuration error: Expected three pedestal tolerance values (one per gain), got "
46  << m_pedTolerance.getDefaults().size() ) ;
47  return StatusCode::FAILURE;
48  }
49  if (this->msgLvl(MSG::DEBUG)) m_pedTolerance.printDef();//for debugging....
50 
51 
52  ATH_MSG_INFO ( "Initialize Pedestal RMS Tolerances (CaloCellGroup)" ) ;
54  if (!stat) {
55  ATH_MSG_ERROR ( "Failed to initialize CaloCellGroup of rms tolerances!" ) ;
56  return StatusCode::FAILURE;
57  }
58  if (m_rmsTolerance.getDefaults().size()!=3) {
59  ATH_MSG_ERROR ( "Configuration error: Expected three rms tolerance values (one per gain), got "
60  << m_rmsTolerance.getDefaults().size() ) ;
61  return StatusCode::FAILURE;
62  }
63  if (this->msgLvl(MSG::DEBUG)) m_rmsTolerance.printDef();//for debugging...
64 
65 
66  ATH_MSG_INFO ( "Initialize FEB Pedestal Tolerances (CaloCellGroup)" ) ;
68  if (!stat) {
69  ATH_MSG_ERROR ( "Failed to initialize CaloCellGroup of pedestal tolerances!" ) ;
70  return StatusCode::FAILURE;
71  }
72  if (m_pedToleranceFEB.getDefaults().size()!=3) {
73  ATH_MSG_ERROR ( "Configuration error: Expected three pedestal tolerance values (one per gain), got "
74  << m_pedToleranceFEB.getDefaults().size() ) ;
75  return StatusCode::FAILURE;
76  }
77  if (this->msgLvl(MSG::DEBUG)) m_pedToleranceFEB.printDef();//for debugging....
78 
79  ATH_MSG_INFO ( "Initialize FEB Pedestal RMS Tolerances (CaloCellGroup)" ) ;
81  if (!stat) {
82  ATH_MSG_ERROR ( "Failed to initialize CaloCellGroup of rms tolerances!" ) ;
83  return StatusCode::FAILURE;
84  }
85  if (m_rmsToleranceFEB.getDefaults().size()!=3) {
86  ATH_MSG_ERROR ( "Configuration error: Expected three rms tolerance values (one per gain), got "
87  << m_rmsToleranceFEB.getDefaults().size() ) ;
88  return StatusCode::FAILURE;
89  }
90  if (this->msgLvl(MSG::DEBUG)) m_rmsToleranceFEB.printDef();//for debugging...
91 
92  return StatusCode::SUCCESS;
93 }
94 
96 
97  if (gain<0 || gain>2) {
98  ATH_MSG_ERROR ( "Unexpected gain value " << gain ) ;
99  return false;
100  }
101 
102  const float& pedVal=val.m_Pedestal;
103  const float& pedRef=ref.m_Pedestal;
104 
105  const float& rmsVal=val.m_PedestalRMS;
106  const float& rmsRef=ref.m_PedestalRMS;
107 
108  const Identifier id=cabling->cnvToIdentifier(chid);
109 
110  const float pedTolerance=m_pedTolerance.valuesForCell(id)[gain];
111  const float rmsTolerance=m_rmsTolerance.valuesForCell(id)[gain];
112 
113 
114  const HWIdentifier febid=m_onlineHelper->feb_Id(chid);
115 
116  DataPerFEB* dataPerFEB = m_vDataPerFEB.empty() ? nullptr : &(m_vDataPerFEB.back());
117  if (!dataPerFEB || dataPerFEB->febid!=febid) {//Got to new FEB
118  m_vDataPerFEB.push_back(DataPerFEB(chid,febid,gain));
119  dataPerFEB=&(m_vDataPerFEB.back());
120  }
121 
122  dataPerFEB->pedVal+=pedVal;
123  dataPerFEB->pedRef+=pedRef;
124  dataPerFEB->rmsVal+=rmsVal;
125  dataPerFEB->rmsRef+=rmsRef;
126  ++(dataPerFEB->nEntries);
127 
128 
129  m_pedGlobalVal+=pedVal;
130  m_rmsGlobalVal+=rmsVal;
131  m_pedGlobalRef+=pedRef;
132  m_rmsGlobalRef+=rmsRef;
134 
135 
136  if (fabs(pedVal-pedRef)> pedTolerance ||
137  fabs(rmsVal-rmsRef)> rmsTolerance){
139  msg().precision(2);
140  msg().setf(std::ios::fixed,std::ios::floatfield);
141  msg() << this->m_myMsgLvl << "Deviating! " << channelDescription(chid,cabling,bcCont,gain) << " Ped: " << val.m_Pedestal
142  << " (" << ref.m_Pedestal << ", " << val.m_Pedestal-ref.m_Pedestal << " ADC)"
143  << " RMS: " << val.m_PedestalRMS << " (" << ref.m_PedestalRMS << ", "
144  << ((val.m_PedestalRMS-ref.m_PedestalRMS)/ref.m_PedestalRMS)*100 << "%)" << endmsg;
145 
146  ATH_MSG_DEBUG ( "Pedestal Tolerance: " << pedTolerance << " RMS Tolerance:" << rmsTolerance ) ;
147  }
149  msg() << this->m_myMsgLvl << "Channel deviation message has already been printed " << m_maxmessages << " times. Now silent..." << endmsg;
150  return false;
151  }
152  else
153  return true;
154 }
155 
156 
158 
159  unsigned nBadFebs=0;
160 
161  msg().precision(3);
162  msg().setf(std::ios::fixed,std::ios::floatfield);
163 
164 
165  for (DataPerFEB& dataPerFeb : m_vDataPerFEB) {
166  dataPerFeb.pedVal/=dataPerFeb.nEntries;
167  dataPerFeb.pedRef/=dataPerFeb.nEntries;
168  dataPerFeb.rmsVal/=dataPerFeb.nEntries;
169  dataPerFeb.rmsRef/=dataPerFeb.nEntries;
170 
171 
172  const Identifier id=cabling->cnvToIdentifier(dataPerFeb.chid);
173  const float& pedToleranceFEB=m_pedToleranceFEB.valuesForCell(id)[dataPerFeb.gain];
174  const float& rmsToleranceFEB=m_rmsToleranceFEB.valuesForCell(id)[dataPerFeb.gain];
175 
176  if (fabs(dataPerFeb.pedVal-dataPerFeb.pedRef)>pedToleranceFEB ||
177  fabs(dataPerFeb.rmsVal-dataPerFeb.rmsRef)>rmsToleranceFEB) {
178 
179  msg() << m_myMsgLvl << "Deviating!" <<channelDescription(dataPerFeb.febid, cabling, bcCont, dataPerFeb.gain, true)
180  << "Average Ped: " << dataPerFeb.pedVal << " (" << dataPerFeb.pedRef << ")"
181  << " RMS: " << dataPerFeb.rmsVal << " (" << dataPerFeb.rmsRef << ")" << endmsg;
182  ATH_MSG_DEBUG ( "Pdestal FEB Tolerance: " << pedToleranceFEB << " RMS FEB Tolerance:" << rmsToleranceFEB ) ;
183  ++nBadFebs;
184  }
185  }
186 
187  if (nBadFebs) {
188  msg() << m_myMsgLvl << "Found " << nBadFebs << " out of " << m_vDataPerFEB.size() << " FEBs devating from reference" << endmsg;
189  return false;
190  }
191  else {
192  ATH_MSG_INFO ( "All " << m_vDataPerFEB.size() << " FEBs withing given tolerance." ) ;
193  return true;
194  }
195 }
197  StatusCode sc=StatusCode::SUCCESS;
198  //1nd step: Check the FEB-averages:
199  if (m_doFebAverages && !febSummary(cabling,bcCont))
200  sc=StatusCode::RECOVERABLE;
201 
202  //2st step: Call the summary method from base-class (single-channel summary)
203  if (!LArPedestalValidationBase::summary(cabling, bcCont).isSuccess())
204  sc=StatusCode::RECOVERABLE;
205 
206  //3rd step: Check the gobal averages:
207  if (m_nEntriesGlobal) {
212  }
213  msg().precision(3);
214  msg().setf(std::ios::fixed,std::ios::floatfield);
215  ATH_MSG_INFO ( "Global pedestal average: " << m_pedGlobalVal << " Reference:" << m_pedGlobalRef
216  << " Deviation:" << m_pedGlobalVal-m_pedGlobalRef ) ;
217  ATH_MSG_INFO ( "Global elec noise average: " << m_rmsGlobalVal << " Reference:" << m_rmsGlobalRef
218  << " Deviation:" << m_rmsGlobalVal-m_rmsGlobalRef ) ;
219  return sc;
220 }
221 
222 
224  return LArCondObj(m_reference->pedestal(chid,gain),m_reference->pedestalRMS(chid,gain));
225 
226 }
LArPedestalValidationAlg::m_rmsGlobalRef
double m_rmsGlobalRef
Definition: LArPedestalValidationAlg.h:114
LArPedestalValidationAlg::DataPerFEB::nEntries
unsigned nEntries
Definition: LArPedestalValidationAlg.h:107
LArPedestalValidationAlg::m_pedTolerance
CaloCellGroupList m_pedTolerance
Definition: LArPedestalValidationAlg.h:70
LArCalibValidationAlg::m_onlineHelper
const LArOnlineID_Base * m_onlineHelper
Definition: LArCalibValidationAlg.h:177
LArCalibValidationAlg::m_nFailedValidation
unsigned m_nFailedValidation
Number of channels for which vaildateChannel returned false.
Definition: LArCalibValidationAlg.h:221
LArCalibValidationAlg::m_reference
const REFCONTAINER * m_reference
Pointer to container with reference values.
Definition: LArCalibValidationAlg.h:182
LArPedestalValidationAlg::m_rmsToleranceFEBInit
std::vector< std::string > m_rmsToleranceFEBInit
Tolerance fro the average pedestal RMS (noise) of one FEB (in ADC counts) (job-Property)
Definition: LArPedestalValidationAlg.h:86
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArPedestalValidationAlg::DataPerFEB::rmsVal
double rmsVal
Definition: LArPedestalValidationAlg.h:104
LArPedestalValidationAlg::preLoop
virtual StatusCode preLoop() override
Executed before the loop over all channels to reset global sums.
Definition: LArPedestalValidationAlg.cxx:28
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCellGroupList::getDefaults
const std::vector< float > & getDefaults() const
Definition: CaloCellGroup.h:72
LArBadXCont
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
Definition: LArBadChannelCont.h:28
LArPedestalValidationAlg::m_pedGlobalVal
double m_pedGlobalVal
Definition: LArPedestalValidationAlg.h:113
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArPedestalValidationAlg::m_pedToleranceInit
std::vector< std::string > m_pedToleranceInit
Pedestal tolerance (in ADC counts) (job-Property)
Definition: LArPedestalValidationAlg.h:69
LArPedestalValidationAlg::m_vDataPerFEB
std::vector< DataPerFEB > m_vDataPerFEB
Definition: LArPedestalValidationAlg.h:110
AthCommonMsg< Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
HWIdentifier
Definition: HWIdentifier.h:13
LArPedestalValidationAlg::m_rmsGlobalVal
double m_rmsGlobalVal
Definition: LArPedestalValidationAlg.h:113
LArPedestalValidationAlg::m_nEntriesGlobal
unsigned m_nEntriesGlobal
Definition: LArPedestalValidationAlg.h:115
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArPedestalValidationAlg.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArPedestalValidationAlg::m_rmsToleranceFEB
CaloCellGroupList m_rmsToleranceFEB
Definition: LArPedestalValidationAlg.h:87
LArPedestalValidationAlg::m_pedToleranceFEBInit
std::vector< std::string > m_pedToleranceFEBInit
Tolerance fro the average pedestal of one FEB (in ADC counts) (job-Property)
Definition: LArPedestalValidationAlg.h:81
LArCalibValidationAlg::summary
virtual StatusCode summary(const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont)
Method executed after the loop over all channels The implementation in the base class writes out only...
LArCalibValidationAlg::m_caloId
const CaloCell_Base_ID * m_caloId
Definition: LArCalibValidationAlg.h:178
LArPedestalValidationAlg::m_rmsToleranceInit
std::vector< std::string > m_rmsToleranceInit
Pedestal RMS tolerances as CaloCellGroupList (job-Properties)
Definition: LArPedestalValidationAlg.h:75
LArCalibValidationAlg::LArCondObj
CONDITIONSCONTAINER::LArCondObj LArCondObj
Definition: LArCalibValidationAlg.h:80
beamspotman.stat
stat
Definition: beamspotman.py:266
LArPedestalValidationAlg::LArPedestalValidationAlg
LArPedestalValidationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Regular algorithm constructor.
Definition: LArPedestalValidationAlg.cxx:8
LArPedestalValidationAlg::DataPerFEB::pedVal
double pedVal
Definition: LArPedestalValidationAlg.h:103
LArOnlineID_Base::feb_Id
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
Definition: LArOnlineID_Base.cxx:1483
LArPedestalValidationAlg::validateChannel
bool validateChannel(const LArCondObj &ref, const LArCondObj &val, const HWIdentifier chid, const int gain, const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont) override final
Method to validate the pedestal single readout channels.
Definition: LArPedestalValidationAlg.cxx:95
LArPedestalValidationAlg::summary
virtual StatusCode summary(const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont) override
Summary method executed after the loop over all channels.
Definition: LArPedestalValidationAlg.cxx:196
LArPedestalValidationAlg::DataPerFEB::rmsRef
double rmsRef
Definition: LArPedestalValidationAlg.h:106
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArCalibValidationAlg::m_myMsgLvl
MSG::Level m_myMsgLvl
Message level for reporting deviations.
Definition: LArCalibValidationAlg.h:163
LArPedestalValidationAlg::DataPerFEB::febid
HWIdentifier febid
Definition: LArPedestalValidationAlg.h:101
LArPedestalValidationAlg::m_pedGlobalRef
double m_pedGlobalRef
Definition: LArPedestalValidationAlg.h:114
ref
const boost::regex ref(r_ef)
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArCalibValidationAlg::m_maxmessages
unsigned m_maxmessages
Limit for the number of messages about indiviual deviating channels (usd only by derived class)
Definition: LArCalibValidationAlg.h:213
LArCalibValidationAlg
Algorithm to validate LAr Autocorr;.
Definition: LArCalibValidationAlg.h:47
LArPedestalValidationAlg::m_rmsTolerance
CaloCellGroupList m_rmsTolerance
Definition: LArPedestalValidationAlg.h:76
CaloCellGroupList::printDef
void printDef() const
Definition: CaloCellGroup.cxx:301
LArPedestalValidationAlg::febSummary
bool febSummary(const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont)
Method to compare FEB averages.
Definition: LArPedestalValidationAlg.cxx:157
LArCalibValidationAlg::channelDescription
const std::string channelDescription(const HWIdentifier &chid, const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont, const unsigned gain=99, bool isFeb=false) const
Textual representation of gain and location of a certain cell or FEB.
CaloCellGroupList::valuesForCell
const std::vector< float > & valuesForCell(const Identifier id)
Definition: CaloCellGroup.cxx:266
LArPedestalValidationAlg::getRefObj
virtual LArCondObj getRefObj(const HWIdentifier chid, const int gain) const override final
Method implmented in derived class to get the reference object from ref-container.
Definition: LArPedestalValidationAlg.cxx:223
CaloCellGroupList::setDefinition
bool setDefinition(const CaloCell_Base_ID *caloCellId, const std::vector< std::string > &definitions, MsgStream &logStr)
Definition: CaloCellGroup.cxx:225
LArPedestalValidationAlg::DataPerFEB::pedRef
double pedRef
Definition: LArPedestalValidationAlg.h:105
LArCalibValidationAlg::m_doFebAverages
bool m_doFebAverages
wether to compare feb-averages (used only by derived class)
Definition: LArCalibValidationAlg.h:210
LArPedestalValidationAlg::DataPerFEB
Definition: LArPedestalValidationAlg.h:94
LArPedestalValidationAlg::m_pedToleranceFEB
CaloCellGroupList m_pedToleranceFEB
Definition: LArPedestalValidationAlg.h:82
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20