ATLAS Offline Software
Loading...
Searching...
No Matches
LArCaliWaveValidationAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <cmath>
7
8LArCaliWaveValidationAlg::LArCaliWaveValidationAlg(const std::string& name, ISvcLocator* pSvcLocator) :
9 LArCaliWaveValidationBase(name,pSvcLocator) {
10
11 declareProperty("TimeShiftDetection",m_timeShift=false,
12 "Enable detection of Pulse timeShift");
13 declareProperty("AmplitudeTolerance",m_ampToleranceInit,
14 "CaloCellGroup of allowed deviation of the amplitude (in permills)");
15 declareProperty("CaliWaveFWHMTolerance",m_fwhmToleranceInit,
16 "CaloCellGroup of llowed deviation of the FWHM (in permills)");
17 declareProperty("AmplitudeToleranceFEB",m_ampToleranceFEBInit,
18 "CaloCellGroup of llowed deviation of the amplitude (average over one FEB, in permills)");
19 declareProperty("CaliWaveFWHMToleranceFEB",m_fwhmToleranceFEBInit,
20 "CaloCellGroup of allowed deviation of the FWHM (average over one FEB, in permills)");
21}
22
23
30 bool stat;
31
32 //Initialize CaloCellGroups:
33
34 ATH_MSG_INFO ( "Initialize Amplitude Tolerances (CaloCellGroup)" ) ;
35 stat=m_ampTolerance.setDefinition(m_caloId,m_ampToleranceInit,msg());
36 if (!stat) {
37 ATH_MSG_ERROR ( "Failed to initialize CaloCellGroup of amplitude tolerances!" ) ;
38 return StatusCode::FAILURE;
39 }
40 if (m_ampTolerance.getDefaults().size()!=3) {
41 ATH_MSG_ERROR ( "Configuration error: Expected three amplitude tolerance values (one per gain), got "
42 << m_ampTolerance.getDefaults().size() ) ;
43 return StatusCode::FAILURE;
44 }
45 if (this->msgLvl(MSG::DEBUG)) m_ampTolerance.printDef();//for debugging....
46
47
48
49 ATH_MSG_INFO ( "Initialize FWHM Tolerances (CaloCellGroup)" ) ;
50 stat=m_fwhmTolerance.setDefinition(m_caloId,m_fwhmToleranceInit,msg());
51 if (!stat) {
52 ATH_MSG_ERROR ( "Failed to initialize CaloCellGroup of FWHM tolerances!" ) ;
53 return StatusCode::FAILURE;
54 }
55 if (m_fwhmTolerance.getDefaults().size()!=3) {
56 ATH_MSG_ERROR ( "Configuration error: Expected three FWHM tolerance values (one per gain), got "
57 << m_fwhmTolerance.getDefaults().size() ) ;
58 return StatusCode::FAILURE;
59 }
60 if (this->msgLvl(MSG::DEBUG)) m_fwhmTolerance.printDef();//for debugging....
61
62
63
64 ATH_MSG_INFO ( "Initialize FEB Amplitude Tolerances (CaloCellGroup)" ) ;
66 if (!stat) {
67 ATH_MSG_ERROR ( "Failed to initialize CaloCellGroup of FEB amplitude tolerances!" ) ;
68 return StatusCode::FAILURE;
69 }
70 if (m_ampToleranceFEB.getDefaults().size()!=3) {
71 ATH_MSG_ERROR ( "Configuration error: Expected three FEB amplitude tolerance values (one per gain), got "
72 << m_ampToleranceFEB.getDefaults().size() ) ;
73 return StatusCode::FAILURE;
74 }
75 if (this->msgLvl(MSG::DEBUG)) m_ampToleranceFEB.printDef();//for debugging....
76
77
78
79 ATH_MSG_INFO ( "Initialize FEB FWHM Tolerances (CaloCellGroup)" ) ;
81 if (!stat) {
82 ATH_MSG_ERROR ( "Failed to initialize CaloCellGroup of FEB FWHM tolerances!" ) ;
83 return StatusCode::FAILURE;
84 }
85 if (m_fwhmToleranceFEB.getDefaults().size()!=3) {
86 ATH_MSG_ERROR ( "Configuration error: Expected three FEB FWHM tolerance values (one per gain), got "
87 << m_fwhmToleranceFEB.getDefaults().size() ) ;
88 return StatusCode::FAILURE;
89 }
90 if (this->msgLvl(MSG::DEBUG)) m_fwhmToleranceFEB.printDef();//for debugging....
91
92 return StatusCode::SUCCESS;
93}
94
95bool LArCaliWaveValidationAlg::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 double ampVal=0;
103 double ampRef=0;
104
105 float fwhmVal=0;
106 float fwhmRef=0;
107
108 float TmaxVal=0;
109 float TmaxRef=0;
110
111 float TMaxshift=5.;
112
113
114 const Identifier id=cabling->cnvToIdentifier(chid);
115
116 const float ampTolerance=m_ampTolerance.valuesForCell(id)[gain];
117 const float fwhmTolerance=m_fwhmTolerance.valuesForCell(id)[gain];
118
119 if (val.size()>0 && ref.size()>0){
120
121 //We assume that the caliwavevec has only one entry.
122 const LArWave& wave=val[0];
123 const LArWave& waver=ref[0];
124 TmaxVal=m_waveHelper.getMax(wave);
125 TmaxRef=m_waveHelper.getMax(waver);
126 ampVal=m_waveHelper.getMaxAmp(wave);
127 ampRef=m_waveHelper.getMaxAmp(waver);
128 fwhmVal=wave.getDt()*m_waveHelper.getWidth(wave);
129 fwhmRef=waver.getDt()*m_waveHelper.getWidth(waver);
130 }
131
132 const HWIdentifier febid=m_onlineHelper->feb_Id(chid);
133
134
135 DataPerFEB* dataPerFEB = m_vDataPerFEB.empty() ? nullptr : &(m_vDataPerFEB.back());
136 if (!dataPerFEB || dataPerFEB->febid!=febid) {//Got to new FEB
137 m_vDataPerFEB.push_back(DataPerFEB(chid,febid,gain));
138 dataPerFEB=&(m_vDataPerFEB.back());
139 }
140
141 dataPerFEB->ampVal+=ampVal;
142 dataPerFEB->ampRef+=ampRef;
143 dataPerFEB->fwhmVal+=fwhmVal;
144 dataPerFEB->fwhmRef+=fwhmRef;
145 ++(dataPerFEB->nEntries);
146
147
148 m_ampGlobalVal+=ampVal;
149 m_fwhmGlobalVal+=fwhmVal;
150 m_ampGlobalRef+=ampRef;
151 m_fwhmGlobalRef+=fwhmRef;
153
154 bool retval=true;
155 if (fabs(TmaxVal-TmaxRef)> TMaxshift && m_timeShift==true) {
156 retval=false;
158 msg() << m_myMsgLvl << "Shifted! " << channelDescription(chid,cabling,bcCont,gain) << " Tmax: " << TmaxVal << " ( " << TmaxRef << " ) " << endmsg;
159
160 }
161
162
163 if (ampRef!=0 && fwhmRef!=0 && (1000*fabs(ampVal-ampRef)/ampRef > ampTolerance || 1000*fabs(fwhmVal-fwhmRef)/fwhmRef > fwhmTolerance)) {
164 retval=false;
166 msg().precision(2);
167 msg().setf(std::ios::fixed,std::ios::floatfield);
168 msg() << this->m_myMsgLvl << "Deviating! " << channelDescription(chid,cabling,bcCont,gain) << " Amp: " << ampVal << "( " << ampRef
169 << ", " << 100.*(ampVal-ampRef)/ampRef << " %)"
170 << " FWHM: " << fwhmVal << " ( " << fwhmRef << ", " << 100*(fwhmVal-fwhmRef)/fwhmVal << " %)" << endmsg;
171 ATH_MSG_DEBUG ( "Amplitude FEB tolerance: " << ampTolerance << ", FWHM FEB tolerance: " << fwhmTolerance ) ;
172 }
173 }
174 if (!retval && m_nFailedValidation==m_maxmessages)
175 msg() << this->m_myMsgLvl << "Channel deviation message has already been printed " << m_maxmessages << " times. Now silent..." << endmsg;
176
177 return retval;
178}
179
180
182
183 unsigned nBadFebs=0;
184
185 msg().precision(3);
186 msg().setf(std::ios::fixed,std::ios::floatfield);
187
188 for (DataPerFEB& dataPerFeb : m_vDataPerFEB) {
189 dataPerFeb.ampVal/=dataPerFeb.nEntries;
190 dataPerFeb.ampRef/=dataPerFeb.nEntries;
191 dataPerFeb.fwhmVal/=dataPerFeb.nEntries;
192 dataPerFeb.fwhmRef/=dataPerFeb.nEntries;
193
194 const Identifier id=cabling->cnvToIdentifier(dataPerFeb.chid);
195 const float& ampToleranceFEB=m_ampToleranceFEB.valuesForCell(id)[dataPerFeb.gain];
196 const float& fwhmToleranceFEB=m_fwhmToleranceFEB.valuesForCell(id)[dataPerFeb.gain];
197
198 if (fabs(dataPerFeb.ampVal-dataPerFeb.ampRef)/dataPerFeb.ampRef*1000>ampToleranceFEB ||
199 fabs(dataPerFeb.fwhmVal-dataPerFeb.fwhmRef)/dataPerFeb.fwhmRef*1000>fwhmToleranceFEB) {
200 msg() << m_myMsgLvl << "Deviating! " <<channelDescription(dataPerFeb.febid,cabling,bcCont,dataPerFeb.gain,true)<< "Average Amp: " << dataPerFeb.ampVal << " (" << dataPerFeb.ampRef << ")"
201 << " FWHM: " << dataPerFeb.fwhmVal << " (" << dataPerFeb.fwhmRef << ")" << endmsg;
202 ++nBadFebs;
203 ATH_MSG_DEBUG ( "Amplitude FEB tolerance: " << ampToleranceFEB << ", FWHM FEB tolerance: " << fwhmToleranceFEB ) ;
204 }
205 }
206
207 if (nBadFebs) {
208 ATH_MSG_ERROR ( "Found " << nBadFebs << " out of " << m_vDataPerFEB.size() << " FEBs deviating from reference" ) ;
209 return false;
210 }
211 else {
212 ATH_MSG_INFO ( "All " << m_vDataPerFEB.size() << " FEBs withing given tolerance." ) ;
213 return true;
214 }
215}
217 StatusCode sc=StatusCode::SUCCESS;
218 //1nd step: Check the FEB-averages:
219 if (m_doFebAverages && !febSummary(cabling, bcCont))
220 sc=StatusCode::RECOVERABLE;
221 //2st step: Call the summary method from base-class (single-channel summary)
222 if (!LArCaliWaveValidationBase::summary(cabling, bcCont).isSuccess())
223 sc=StatusCode::RECOVERABLE;
224 //3rd step: Check the gobal averages:
225 if (m_nEntriesGlobal) {
230 }
231 ATH_MSG_INFO ( "Global amplitude average: " << m_ampGlobalVal << " Reference:" << m_ampGlobalRef
232 << " Deviation:" << (m_ampGlobalVal-m_ampGlobalRef)/m_ampGlobalRef*1000 <<" permille" ) ;
233 ATH_MSG_INFO ( "Gobal FWHM average: " << m_fwhmGlobalVal << " Reference:" << m_fwhmGlobalRef
234 << " Deviation:" << (m_fwhmGlobalVal-m_fwhmGlobalRef)/m_fwhmGlobalRef*1000 <<" permille" ) ;
235 return sc;
236}
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< LArCaliWaveContainer, LArCaliWaveContainer > LArCaliWaveValidationBase
static Double_t sc
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode summary(const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont) override
Summary method executed after the loop over all channels.
LArCaliWaveValidationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Regular algorithm constructor.
bool febSummary(const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont)
Method to compare FEB averages.
std::vector< std::string > m_ampToleranceFEBInit
Tolerance for the average amplitude of one FEB (in permills) (job-Property)
std::vector< DataPerFEB > m_vDataPerFEB
virtual StatusCode preLoop() override
Executed before the loop over all channels to reset global sums.
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.
std::vector< std::string > m_ampToleranceInit
Amplitude tolerance (in permills) (job-Property)
std::vector< std::string > m_fwhmToleranceFEBInit
Tolerance for the average FWHM of one FEB (in permills) (job-Property)
std::vector< std::string > m_fwhmToleranceInit
FWHM tolerance (in permills) (job-Property)
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
const double & getDt() const
delta time
Definition LArWave.h:50