ATLAS Offline Software
Loading...
Searching...
No Matches
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
8LArPedestalValidationAlg::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)");
25}
26
27
34
35 bool stat;
36
37
38 ATH_MSG_INFO ( "Initialize Pedestal Tolerances (CaloCellGroup)" ) ;
39 stat=m_pedTolerance.setDefinition(m_caloId,m_pedToleranceInit,msg());
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)" ) ;
53 stat=m_rmsTolerance.setDefinition(m_caloId,m_rmsToleranceInit,msg());
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
95bool LArPedestalValidationAlg::validateChannel(const LArCondObj& ref, const LArCondObj& val, const HWIdentifier chid, const int gain, const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont) {
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}
const boost::regex ref(r_ef)
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
LArBadXCont< LArBadChannel > LArBadChannelCont
LArCalibValidationAlg< LArPedestalComplete, ILArPedestal > LArPedestalValidationBase
static Double_t sc
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode summary(const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont)
const std::string channelDescription(const HWIdentifier &chid, const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont, const unsigned gain=99, bool isFeb=false) const
std::vector< DataPerFEB > m_vDataPerFEB
std::vector< std::string > m_rmsToleranceInit
Pedestal RMS tolerances as CaloCellGroupList (job-Properties)
virtual StatusCode summary(const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont) override
Summary method executed after the loop over all channels.
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.
std::vector< std::string > m_rmsToleranceFEBInit
Tolerance fro the average pedestal RMS (noise) of one FEB (in ADC counts) (job-Property)
bool febSummary(const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont)
Method to compare FEB averages.
LArPedestalValidationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Regular algorithm constructor.
virtual StatusCode preLoop() override
Executed before the loop over all channels to reset global sums.
std::vector< std::string > m_pedToleranceFEBInit
Tolerance fro the average pedestal of one FEB (in ADC counts) (job-Property)
std::vector< std::string > m_pedToleranceInit
Pedestal tolerance (in ADC counts) (job-Property)
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.