39 "Channels with pedestal rms x sigma or percent above average are tagged 'low noise' (in high gain) ");
41 "Channels with pedestal rms x sigma or percent above average are tagged 'low noise' (in medium gain) ");
43 "Channels with pedestal rms x sigma or percent above average are tagged 'low noise' (in low gain) ");
46 "Channels with pedestal rms x sigma or percent above average are tagged 'High noise' (in high gain) ");
48 "Channels with pedestal rms x sigma or percent above average are tagged 'High noise' (in medium gain) ");
50 "Channels with pedestal rms x sigma or percent above average are tagged 'High noise' (in low gain) ");
54 "Channels with amplitudes x sigma or percent above the average are tagged as 'deadReadout' or 'deadCalib' (H gain)");
56 "Channels with amplitudes x sigma or percent above the average are tagged as 'deadReadout' or 'deadCalib' (M gain)");
58 "Channels with amplitudes x sigma or percent above the average are tagged as 'deadReadout' or 'deadCalib' (L gain)");
61 "Channels with a width x sigma or percent above the average are tagged as 'distorted' (H gain)");
63 "Channels with a width x sigma or percent above the average are tagged as 'distorted' (M gain)");
65 "Channels with a width x sigma or percent above the average are tagged as 'distorted' (L gain)");
69 "Channels with a width x sigma or percent above the average are tagged as 'deadReadout' or 'deadCalib' (H gain)");
71 "Channels with a width x sigma or percent above the average are tagged as 'deadReadout' or 'deadCalib' (M gain)");
73 "Channels with a width x sigma or percent above the average are tagged as 'deadReadout' or 'deadCalib' (L gain)");
76 "Channels with a width x sigma or percent above the average are tagged as 'distorted' (H gain)");
78 "Channels with a width x sigma or percent above the average are tagged as 'distorted' (M gain)");
80 "Channels with a width x sigma or percent above the average are tagged as 'distorted' (L gain)");
84 "Distorted with a TamxAmpl x sigma or percent above the average are tagged as 'distorted' (H gain)");
86 "Distorted with a TamxAmpl x sigma or percent above the average are tagged as 'distorted' (M gain)");
88 "Distorted with a TamxAmpl x sigma or percent above the average are tagged as 'distorted' (L gain)");
99 return StatusCode::FAILURE;
106 return StatusCode::FAILURE;
113 return StatusCode::SUCCESS;
136 ATH_MSG_ERROR(
"Do not have Bad chan container " << m_BCKey.key() );
137 return StatusCode::FAILURE;
143 return StatusCode::FAILURE;
148 ATH_MSG_ERROR(
"Do not have cabling object LArOnOffIdMapping" );
149 return StatusCode::FAILURE;
157 std::map<unsigned,Average> averageMap;
161 std::vector<HWIdentifier>::const_iterator itOnId = m_onlineId->channel_begin();
162 std::vector<HWIdentifier>::const_iterator itOnIdEnd = m_onlineId->channel_end();
164 for(; itOnId!=itOnIdEnd;++itOnId){
166 if (!
cabling->isOnlineConnected(chid))
continue;
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();
175 CellData thisCellData;
176 thisCellData.m_chid=chid;
177 thisCellData.m_ampl=ampl;
178 thisCellData.m_wid =wid;
179 thisCellData.m_tmax=tmax;
181 const unsigned regId=getSymId(chid,
cabling);
182 Average& avreg=averageMap[regId];
190 avreg.m_nPed[
igain]++;
191 avreg.m_vmedPedRMS[
igain].push_back(
ped);
196 avreg.m_avAmpl[0]+=ampl;
197 avreg.m_avAmplSD[0]+=ampl*ampl;
199 avreg.m_vmedAmpl[0].push_back(ampl);
201 avreg.m_avWid[0]+=wid;
202 avreg.m_avWidSD[0]+=wid*wid;
204 avreg.m_vmedWid[0].push_back(wid);
206 avreg.m_avTmax[0]+=tmax;
207 avreg.m_avTmaxSD[0]+=tmax*tmax;
209 avreg.m_vmedTmax[0].push_back(tmax);
215 for(
auto &[
i,
average]:averageMap) {
223 typedef std::vector<std::pair<HWIdentifier,LArBadChannel> > BCV_t;
236 typedef std::pair<unsigned,std::vector<size_t> > goodAndBad_t;
237 typedef std::map<HWIdentifier,goodAndBad_t> goodAndBadMap_t;
239 goodAndBadMap_t calibLineMap;
242 std::vector<CellData>::const_iterator itcells=
cellData.begin();
243 std::vector<CellData>::const_iterator itcells_e=
cellData.end();
245 for (;itcells!=itcells_e;++itcells) {
246 const CellData& thisCellData=*itcells;
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;
259 if (avreg.m_nPed[
igain]>2) {
260 const float rms=thisCellData.m_pedRMS[
igain];
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];
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;
276 << avreg.m_avPedRMS[
igain] <<
" Median: " << avreg.m_medPedRMS ) ;
278 if ( (
rms-avreg.m_avPedRMS[
igain]) > higCut_rms ) {
281 else if ( (
rms-avreg.m_avPedRMS[
igain]) > lowCut_rms ) {
286 std::string my_status;
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] <<
" ) " ) ;
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;
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];
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;
330 if (ampl==-1 || wid==-1) {
331 ATH_MSG_INFO (
"No Amplitude or Width found for " << channelDescription(chid,
cabling,0) ) ;
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) {
341 else if (fabs(ampl-avreg.m_avAmpl[0])>lowCut_amp || fabs(wid-avreg.m_avWid[0])>lowCut_wid){
345 else if (fabs(tmax-avreg.m_avTmax[0])>Cut_tmax) {
357 std::string my_status;
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
381 const std::vector<HWIdentifier>& cLids=clCont->calibSlotLine(chid);
383 goodAndBad_t& gb=calibLineMap[hwid];
385 gb.second.push_back(badChanVec.size());
389 if (!problem.
good()) badChanVec.push_back(std::make_pair(chid,problem));
394 for(
const auto & kv: calibLineMap) {
395 const goodAndBad_t& gb=kv.second;
396 for (
unsigned i=0;
i<gb.second.size();
i++) {
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." ) ;
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." ) ;
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;
435 return StatusCode::SUCCESS;
440 const unsigned gain)
const {
444 std::ostringstream
output;
468 if (
cabling->isOnlineConnected(chid)) {
479 output <<
",disconnected";
522 m_avPedRMSSD[
igain]=sqrt(m_avPedRMSSD[
igain]);
527 if (m_nAmpls[
igain]) {
536 if (m_nWids[
igain]) {
545 if (m_nTmaxs[
igain]) {
559 if (my_recalcPer>=0.){
561 if ( m_avPedRMSSD[
igain]>my_recalcPer*m_avPedRMS[
igain]) {
562 float re_avPed=0.;
float re_avPedSD=0.;
int re_nPed=0;
565 for (;p_loop!=p_loop_e; ++p_loop){
566 if ( fabs(*p_loop-m_medPedRMS[
igain])<my_recalcPer*m_medPedRMS[
igain] ){
568 re_avPedSD+=*p_loop*(*p_loop);
574 re_avPedSD=(re_avPedSD- re_nPed*re_avPed*re_avPed)/(re_nPed);
576 re_avPedSD=sqrt(re_avPedSD);
577 std::cout <<
" PedRMS mean && RMS are recalc: Orig (recalc) are: "<< m_avPedRMS[
igain]<<
" ( "<< re_avPed
578 <<
" ) and "<< m_avPedRMSSD[
igain]<<
" ( "<<re_avPedSD<<
" )"<<std::endl;
579 m_avPedRMS[
igain]=re_avPed; m_avPedRMSSD[
igain]=re_avPedSD;
582 if ( m_avAmplSD[
igain]>my_recalcPer*m_avAmpl[
igain] ) {
583 float re_avAmpl=0.;
float re_avAmplSD=0.;
int re_nAmpl=0;
586 for (;re_loop!=re_loop_e; ++re_loop){
587 if ( fabs(*re_loop-m_medAmpl[
igain])<my_recalcPer*m_medAmpl[
igain] ){
589 re_avAmplSD+=*re_loop*(*re_loop);
595 re_avAmplSD=(re_avAmplSD- re_nAmpl*re_avAmpl*re_avAmpl)/(re_nAmpl);
597 re_avAmplSD=sqrt(re_avAmplSD);
598 std::cout <<
" MaxAmp mean && RMS are recalc: Orig (recalc) are: "<< m_avAmpl[
igain]<<
" ( "<< re_avAmpl
599 <<
" ) and "<< m_avAmplSD[
igain]<<
" ( "<<re_avAmplSD<<
" )"<<std::endl;
600 m_avAmpl[
igain]=re_avAmpl; m_avAmplSD[
igain]=re_avAmplSD;
603 if ( m_avWidSD[
igain]>my_recalcPer*m_avWid[
igain] ) {
604 float re_avWid=0.;
float re_avWidSD=0.;
int re_nWid=0;
607 for (;w_loop!=w_loop_e; ++w_loop){
608 if ( fabs(*w_loop-m_medWid[
igain])<my_recalcPer*m_medWid[
igain] ){
610 re_avWidSD+=*w_loop*(*w_loop);
616 re_avWidSD=(re_avWidSD- re_nWid*re_avWid*re_avWid)/(re_nWid);
618 re_avWidSD=sqrt(re_avWidSD);
619 std::cout <<
" FWHM mean && RMS are recalc: Orig (recalc) are: "<< m_avWid[
igain]<<
" ( "<< re_avWid
620 <<
" ) and "<< m_avWidSD[
igain]<<
" ( "<<re_avWidSD<<
" )"<<std::endl;
621 m_avWid[
igain]=re_avWid; m_avWidSD[
igain]=re_avWidSD;
624 if ( m_avTmaxSD[
igain]>my_recalcPer*m_avTmax[
igain] ) {
625 float re_avTmax=0.;
float re_avTmaxSD=0.;
int re_nTmax=0;
628 for (;t_loop!=t_loop_e; ++t_loop){
629 if ( fabs(*t_loop-m_medTmax[
igain])<my_recalcPer*m_medTmax[
igain] ){
631 re_avTmaxSD+=*t_loop*(*t_loop);
637 re_avTmaxSD=(re_avTmaxSD- re_nTmax*re_avTmax*re_avTmax)/(re_nTmax);
639 re_avTmaxSD=sqrt(re_avTmaxSD);
640 std::cout <<
"TmaxAmp mean && RMS are recalc: Orig (recalc) are: "<< m_avTmax[
igain]<<
" ( "<< re_avTmax
641 <<
" ) and "<< m_avTmaxSD[
igain]<<
" ( "<<re_avTmaxSD<<
" )"<<std::endl;
642 m_avTmax[
igain]=re_avTmax; m_avTmaxSD[
igain]=re_avTmaxSD;
664 std::cout <<
"ERROR unexpected idetifier:"
665 << std::hex <<
" id=0x" <<
id <<
" regionId=0x" << regid
666 << std::dec <<
" reghash=" << reghash <<
" eta=" <<
eta
667 <<
" caloRegionHashMax=" << caloRegionHashMax
673 const unsigned retval= (
eta<<8) | reghash;