Install fatal handler with default options.
This is meant to be easy to call from python via ctypes.
Install fatal handler with default options.
getRawOccupancy() Read RawOccupancy from Monitoring HIST and write out into local DB
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Only dead or distorted, or short known BCs are considered below.
117 {
120
123
126
127 if (m_undoCorr) {
131 }
132
135 if(!bcCont) {
136 ATH_MSG_ERROR(
"Do not have Bad chan container " << m_BCKey.key() );
137 return StatusCode::FAILURE;
138 }
141 if(!clCont) {
143 return StatusCode::FAILURE;
144 }
147 if(!cabling) {
148 ATH_MSG_ERROR(
"Do not have cabling object LArOnOffIdMapping" );
149 return StatusCode::FAILURE;
150 }
151
154
155
156
157 std::map<unsigned,Average> averageMap;
158
160
161 std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin();
162 std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end();
163
164 for(; itOnId!=itOnIdEnd;++itOnId){
166 if (!
cabling->isOnlineConnected(chid))
continue;
167
171 const float ampl=waveHelper.
getMaxAmp(cwv[0]);
172 const float wid =waveHelper.
getWidth(cwv[0])*cwv[0].getDt();
173 const float tmax=waveHelper.
getMax(cwv[0])*cwv[0].getDt();
174
175 CellData thisCellData;
176 thisCellData.m_chid=chid;
177 thisCellData.m_ampl=ampl;
178 thisCellData.m_wid =wid;
179 thisCellData.m_tmax=tmax;
180
181 const unsigned regId=getSymId(chid, cabling);
182 Average& avreg=averageMap[regId];
183
185
190 avreg.m_nPed[
igain]++;
191 avreg.m_vmedPedRMS[
igain].push_back(ped);
193 }
194 }
195
196 avreg.m_avAmpl[0]+=ampl;
197 avreg.m_avAmplSD[0]+=ampl*ampl;
198 avreg.m_nAmpls[0]++;
199 avreg.m_vmedAmpl[0].push_back(ampl);
200
201 avreg.m_avWid[0]+=wid;
202 avreg.m_avWidSD[0]+=wid*wid;
203 avreg.m_nWids[0]++;
204 avreg.m_vmedWid[0].push_back(wid);
205
206 avreg.m_avTmax[0]+=tmax;
207 avreg.m_avTmaxSD[0]+=tmax*tmax;
208 avreg.m_nTmaxs[0]++;
209 avreg.m_vmedTmax[0].push_back(tmax);
210
212 }
213
215 for(auto &[i, average]:averageMap) {
217 }
218
219
221
223 typedef std::vector<std::pair<HWIdentifier,LArBadChannel> > BCV_t;
224
225 BCV_t badChanVec;
231
235
236 typedef std::pair<unsigned,std::vector<size_t> > goodAndBad_t;
237 typedef std::map<HWIdentifier,goodAndBad_t> goodAndBadMap_t;
238
239 goodAndBadMap_t calibLineMap;
240
241
242 std::vector<CellData>::const_iterator itcells=
cellData.begin();
243 std::vector<CellData>::const_iterator itcells_e=
cellData.end();
244
245 for (;itcells!=itcells_e;++itcells) {
246 const CellData& thisCellData=*itcells;
248
249 unsigned regId=getSymId(chid, cabling);
251 std::map<unsigned,Average>::const_iterator febit=averageMap.find(regId);
252 if (febit==averageMap.end()) continue;
253 const Average& avreg=febit->second;
254
257
259 if (avreg.m_nPed[igain]>2) {
260 const float rms=thisCellData.m_pedRMS[
igain];
261 float lowCut_rms=0.;
262 float higCut_rms=0.;
263 if ( m_cutType=="SIG" ) {
264 lowCut_rms=m_lowNoiseTh[
igain]*avreg.m_avPedRMSSD[
igain];
265 higCut_rms=m_highNoiseTh[
igain]*avreg.m_avPedRMSSD[
igain];
266 }
267 else if ( m_cutType=="PER") {
268 lowCut_rms=m_lowNoiseTh[
igain]*avreg.m_avPedRMS[
igain]*0.01;
269 higCut_rms=m_highNoiseTh[
igain]*avreg.m_avPedRMS[
igain]*0.01;
270 }
271
272 if (rms==-1)
273 ATH_MSG_ERROR (
"No Pedestal found for " << channelDescription(chid,cabling, igain) ) ;
274 else {
275 ATH_MSG_VERBOSE (
"PedRMS, gain: " << igain <<
":" << rms <<
" Average: "
276 << avreg.m_avPedRMS[igain] << " Median: " << avreg.m_medPedRMS ) ;
278 if ( (rms-avreg.m_avPedRMS[igain]) > higCut_rms ) {
279 packing.
setBit(highnoiseProb[igain],problem);
280 }
281 else if ( (rms-avreg.m_avPedRMS[igain]) > lowCut_rms ) {
282 packing.
setBit(lownoiseProb[igain],problem);
283 }
286 std::string my_status;
288 my_status="BCN ";
289 else
291
292 ATH_MSG_INFO( my_status << channelDescription(chid,cabling,igain)
293 << " RMS: " << rms << " ( " << avreg.m_avPedRMS[igain] << " , "
294 << float(int(10000*(rms-avreg.m_avPedRMS[igain])/avreg.m_avPedRMS[igain]))/100 <<" %) " << ", #Sig: "
295 << float(int(100*(rms-avreg.m_avPedRMS[igain])/avreg.m_avPedRMSSD[igain]))/100
296 << " ( " << avreg.m_avPedRMSSD[igain] << " ) " ) ;
297 }
298 }
299 }
300 }
301
303 if (avreg.m_nAmpls[0]>2 && avreg.m_nWids[0]>2 && avreg.m_nTmaxs[0]>2) {
304 const float ampl=thisCellData.m_ampl;
305 const float wid=thisCellData.m_wid;
306 const float tmax=thisCellData.m_tmax;
307
308 float lowCut_amp=0.;
309 float higCut_amp=0.;
310 float lowCut_wid=0.;
311 float higCut_wid=0.;
312 float Cut_tmax=0.;
313
314 if ( m_cutType=="SIG" ) {
315 lowCut_amp=m_distampTh[0]*avreg.m_avAmplSD[0];
316 higCut_amp=m_amplTh[0]*avreg.m_avAmplSD[0];
317 lowCut_wid=m_distwidTh[0]*avreg.m_avWidSD[0];
318 higCut_wid=m_widTh[0]*avreg.m_avWidSD[0];
319 Cut_tmax=m_tmaxampTh[0]*avreg.m_avTmaxSD[0];
320 }
321 else if ( m_cutType=="PER") {
322 lowCut_amp=m_distampTh[0]*avreg.m_avAmpl[0]*0.01;
323 higCut_amp=m_amplTh[0]*avreg.m_avAmpl[0]*0.01;
324 lowCut_wid=m_distwidTh[0]*avreg.m_avWid[0]*0.01;
325 higCut_wid=m_widTh[0]*avreg.m_avWid[0]*0.01;
326 Cut_tmax=m_tmaxampTh[0]*avreg.m_avTmax[0]*0.01;
327 }
328
329
330 if (ampl==-1 || wid==-1) {
331 ATH_MSG_INFO (
"No Amplitude or Width found for " << channelDescription(chid,cabling,0) ) ;
333 }
334 else {
335 ATH_MSG_VERBOSE (
"Ampl gain: "<< 0<<
":"<< ampl<<
" Average: " << avreg.m_avAmpl[0]) ;
337 if (fabs(ampl-avreg.m_avAmpl[0])>higCut_amp || fabs(wid-avreg.m_avWid[0])>higCut_wid) {
339 }
341 else if (fabs(ampl-avreg.m_avAmpl[0])>lowCut_amp || fabs(wid-avreg.m_avWid[0])>lowCut_wid){
343 }
345 else if (fabs(tmax-avreg.m_avTmax[0])>Cut_tmax) {
347
348
349
350
351
352 }
354
357 std::string my_status;
358 if ( !(problem.deadReadout()||problem.distorted())
360 my_status="BCN ";
361 else
363
364 ATH_MSG_INFO ( my_status << channelDescription(chid,cabling,0)
365 << " Amp: " << ampl << " ( " << avreg.m_avAmpl[0] << " , "
366 << float(int(10000*(ampl-avreg.m_avAmpl[0])/avreg.m_avAmpl[0]))/100 << " %) " << " #Sig: "
367 << float(int(100*(ampl-avreg.m_avAmpl[0])/avreg.m_avAmplSD[0]))/100 << " ( " << avreg.m_avAmplSD[0] <<" ) "
368 << " FWHM: " << wid << " ( " << avreg.m_avWid[0] << " , "
369 << float(int(10000*(wid-avreg.m_avWid[0])/avreg.m_avWid[0]))/100 << " %) " << " #Sig: "
370 << float(int(100*(wid-avreg.m_avWid[0])/avreg.m_avWidSD[0]))/100
371 << " ( " << avreg.m_avWidSD[0] << " ) "
372 << " Tmax: " << tmax << " ( " << avreg.m_avTmax[0] << " , "
373 << float(int(10000*(tmax-avreg.m_avTmax[0])/avreg.m_avTmax[0]))/100 << " %) " << " #Sig:"
374 << float(int(100*(tmax-avreg.m_avTmax[0])/avreg.m_avTmaxSD[0]))/100
375 ) ;
376 }
377 }
378 }
379
380
381 const std::vector<HWIdentifier>& cLids=clCont->
calibSlotLine(chid);
383 goodAndBad_t& gb=calibLineMap[hwid];
384 if (problem.deadReadout()||problem.distorted())
385 gb.second.push_back(badChanVec.size());
386 else
387 ++gb.first;
388 }
389 if (!problem.good()) badChanVec.push_back(std::make_pair(chid,problem));
390
391 }
392
393
394 for(const auto & kv: calibLineMap) {
395 const goodAndBad_t& gb=kv.second;
396 for (
unsigned i=0;
i<gb.second.size();
i++) {
397 if (gb.first==0) {
398 ATH_MSG_INFO (
"All channels belonging to calibLine " << channelDescription(badChanVec[gb.second[i]].first, cabling)
399 << " don't respond to pulses. Assume bad calib line." ) ;
403 }
404 }
405 }
406
407 if (m_outFileName.size()) {
408 std::ofstream
outfile(m_outFileName.c_str());
410 ATH_MSG_ERROR (
"Failed to open output file " << m_outFileName <<
". No output will be written." ) ;
411 }
412 else {
413 BCV_t::const_iterator bcvit=badChanVec.begin();
414 BCV_t::const_iterator bcvit_e=badChanVec.end();
415 for(;bcvit!=bcvit_e;++bcvit) {
420 std::string my_ps=(bc2.
good())?
"NEW " :
"BC ";
421 if (!bc2.
good()&&m_outOnlyNew)
continue;
422 outfile << m_onlineId->barrel_ec(chid) <<
" "
423 << m_onlineId->pos_neg(chid) << " "
424 << m_onlineId->feedthrough(chid) << " "
425 << m_onlineId->slot(chid) << " "
426 << m_onlineId->channel(chid) << " "
427 << m_onlineId->channel(cLid) << " "
429 << my_ps << std::endl;
430
431 }
433 }
434 }
435 return StatusCode::SUCCESS;
436}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
LArBadXCont< LArBadChannel > LArBadChannelCont
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
bool shortProblem() const
bool good() const
Returns true if no problems at all (all bits at zero)
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
Liquid Argon Cumulative Wave Container.
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
StatusCode undoCorrections()
undo corrections that have been already applied
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
double getMaxAmp(const LArWave &theWave) const
double getWidth(const LArWave &theWave) const
unsigned int getMax(const LArWave &theWave) const
return index of maximum sample
void setBit(typename T::ProblemType pb, LArBadChannel::BitWord &word, bool value=true) const
std::string stringStatus(const LArBadChannel &bc) const
retrieve(aClass, aKey=None)