ATLAS Offline Software
FixLArElecCalib.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
82 #include "FixLArElecCalib.h"
83 #include "Gaudi/Property.h"
84 #include "GaudiKernel/IToolSvc.h"
85 
90 #include "StoreGate/StoreGateSvc.h"
91 
101 
103 
104 #include <fstream>
105 #include "TTree.h"
106 #include "TFile.h"
107 
109 #include "CoralBase/Blob.h"
110 
111 FixLArElecCalib::FixLArElecCalib(const std::string& name, ISvcLocator* pSvcLocator) :
112  AthAlgorithm(name,pSvcLocator),
113  m_em_idhelper(nullptr),
114  m_hec_idhelper(nullptr),
115  m_fcal_idhelper(nullptr),
116  m_online_idhelper(nullptr),
117  m_sem_idhelper(nullptr),
118  m_shec_idhelper(nullptr),
119  m_sonline_idhelper(nullptr),
120  m_scell_idhelper(nullptr)
121 {
122 
123 }
124 
126  ATH_MSG_INFO ( " in initialize " );
127 
136 
139 
140  return StatusCode::SUCCESS;
141 }
142 
144 
145  const EventContext& ctx = Gaudi::Hive::currentContext();
146 
148  const LArOnOffIdMapping* cabling{*cablingHdl};
149  if(!cabling) {
150  ATH_MSG_WARNING( "Do not have cabling mapping from key " << m_cablingKey.key() );
151  }
152  if(m_fixFlag==13)
153  return fix13(cabling);
154 
155  return StatusCode::SUCCESS;
156 }
157 
159 
160  ATH_MSG_INFO ( " in stop " );
161 
162  const EventContext& ctx = Gaudi::Hive::currentContext();
163 
164  SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey, ctx};
165  const LArOnOffIdMapping* cabling{*cablingHdl};
166  if(!cabling) {
167  ATH_MSG_WARNING( "Do not have cabling mapping from key " << m_cablingKey.key() );
168  }
169  SG::ReadCondHandle<LArCalibLineMapping> clHdl{m_CLKey, ctx};
170  const LArCalibLineMapping *clCont {*clHdl};
171  if(!clCont) {
172  ATH_MSG_ERROR( "Do not have calib line mapping !!!" );
173  return StatusCode::FAILURE;
174  }
175 
176 
177  if(m_fixFlag==1)
178  return fix1(cabling);
179  if(m_fixFlag==2)
180  return fix2(cabling);
181  if(m_fixFlag==3)
182  return fix3(cabling);
183  if(m_fixFlag==4)
184  return fix4(cabling);
185  if(m_fixFlag==5)
186  return fix5(cabling);
187  if(m_fixFlag==6)
188  return fix6(cabling);
189  if(m_fixFlag==7)
190  return fix7(cabling);
191  if(m_fixFlag==8)
192  return fix8(cabling);
193  if(m_fixFlag==9)
194  return fix9(cabling);
195  if(m_fixFlag==10)
196  return fix10(cabling);
197  if(m_fixFlag==11)
198  return fix11(cabling);
199  if(m_fixFlag==12)
200  return fix12(cabling);
201  if(m_fixFlag==13)
202  return fix13(cabling);
203  if(m_fixFlag==14)
204  return fix14(cabling);
205  if(m_fixFlag==15)
206  return fix15();
207  if(m_fixFlag==16)
208  return fix16();
209  if(m_fixFlag==17)
210  return fix17(cabling);
211  if(m_fixFlag==18)
212  return fix18(clCont);
213 
214  return StatusCode::SUCCESS;
215 
216 }
217 
219 
220  ATH_MSG_INFO ( " in fix1() " );
221 
222  // Fix1 is for updating the EM DAC2uA, assuming symmetry.
223  // Input should be MC Conditions data with DetDescrVersion=ATLAS-DC3-05
224 
225  // Pointer to StoreGate
226  const LArEM_ID* em_idhelper = nullptr;
227  ATH_CHECK( detStore()->retrieve(em_idhelper) );
228 
229  const LArOnlineID* online_idhelper = nullptr;
230  ATH_CHECK( detStore()->retrieve(online_idhelper) );
231 
232  // retrieve DetDescrManager
233  SmartIF<IToolSvc> toolSvc{Gaudi::svcLocator()->service("ToolSvc")};
234  ATH_CHECK(toolSvc.isValid());
235 
236  LArDAC2uAMC * dac2ua = nullptr;
237  ATH_CHECK( detStore()->retrieve(dac2ua) );
238 
239  // read in the file
240 
241  std::ifstream infile("barrel_dac2ua_oct06.txt") ;
242  if(! infile.good() )
243  {
244  ATH_MSG_ERROR(" fail to open file ");
245  return StatusCode::FAILURE;
246  }
247 
248 
249  int det,samp,reg,eta;
250  float value ;
251  int n = 0;
252  while ( infile>>det>>samp>>reg>>eta>>value )
253  {
254  ++n;
255  ATH_MSG_DEBUG(" det,samp,reg,eta,value="
256  <<det<<" "
257  <<samp<<" "
258  <<reg<<" "
259  <<eta<<" "
260  <<value<<" " );
261 
262  Identifier id ;
263  if ( det==1 && samp==1 && reg==0 && eta==0 ){
264  // eta=0 for strip, not connected, but keep it
265  // Removed disconnected channels: 03/2016 RDS
266  // ATH_MSG_DEBUG(" disconnected strip ");
267  // id = em_idhelper->disc_channel_id(det,samp,reg,eta,0);
268  }else
269  id = em_idhelper->channel_id(det,samp,reg,eta,0);
270 
271  HWIdentifier hid = cabling->createSignalChannelID(id);
272  LArDAC2uAComplete::LArCondObj & t = dac2ua->get(hid,0);
273  ATH_MSG_DEBUG(" online id = "<<online_idhelper->print_to_string(hid));
274 
275  if( t.isEmpty() )
276  {
277  ATH_MSG_WARNING(" No existing conditions data " );
278  continue ;
279  }
280  ATH_MSG_DEBUG(" Old DAC2uA = "<< t.m_data<< " " );
281 
282  t.m_data = value ;
283 
284  const LArDAC2uAComplete::LArCondObj & t3 = dac2ua->get(hid,0);
285  ATH_MSG_DEBUG(" New DAC2uA = "<< t3.m_data << " " );
286 
287  }
288 
289  ATH_MSG_DEBUG(" Number of entries changes = " <<n );
290  return StatusCode::SUCCESS;
291 }
292 
293 
295 
296  ATH_MSG_INFO ( " in fix2() " );
297 
298  // Fix2 is for updating the FCAL conditions data after IdFix7
299  // Input should be MC Conditions data with DetDescrVersion=ATLAS-DC3-05
300 
301  const LArFCAL_ID* fcal_idhelper = nullptr;
302  ATH_CHECK( detStore()->retrieve(fcal_idhelper) );
303 
304  const LArOnlineID* online_idhelper = nullptr;
305  ATH_CHECK( detStore()->retrieve(online_idhelper) );
306 
307  // retrieve DetDescrManager
308  SmartIF<IToolSvc> toolSvc{Gaudi::svcLocator()->service("ToolSvc")};
309  ATH_CHECK(toolSvc.isValid());
310 
311  LArDAC2uAMC * dac2ua = nullptr;
312  ATH_CHECK( detStore()->retrieve(dac2ua) );
313 
314  LAruA2MeVMC * ua2mev = nullptr;
315  ATH_CHECK( detStore()->retrieve(ua2mev) );
316 
317  LArRampMC * ramp = nullptr;
318  ATH_CHECK( detStore()->retrieve(ramp) );
319 
320  LArShape32MC * shape = nullptr;
321  ATH_CHECK( detStore()->retrieve(shape) );
322 
323  LArNoiseMC * noise = nullptr;
325 
326  LArfSamplMC * fsampl = nullptr;
327  ATH_CHECK( detStore()->retrieve(fsampl) );
328 
329  LArMinBiasMC * minbias = nullptr;
330  ATH_CHECK( detStore()->retrieve(minbias) );
331 
332  LArAutoCorrMC * ac = nullptr;
333  ATH_CHECK( detStore()->retrieve(ac) );
334 
335 
336  for( unsigned int gain=0;gain<3;++gain)
337  {
338  // loop over all the old data
341 
342  int n=0;
343  for (; it!=it_e;++it)
344  {
345  HWIdentifier hid = it.channelId();
346  if( (*it).isEmpty() ) continue;
347  if(cabling->isOnlineConnected(hid)){
348  continue;
349  }else
350  {
351  ATH_MSG_DEBUG(" unconnected channel"
352  << online_idhelper->print_to_string(hid) );
354  ramp->get(hid,gain) = LArRampComplete::LArCondObj();
355  shape->get(hid,gain) = LArShape32MC::LArCondObj();
356  noise->get(hid,gain) = LArNoiseComplete::LArCondObj();
357  if(gain==0){
358  dac2ua->get(hid,gain) = LArDAC2uAComplete::LArCondObj();
359  ua2mev->get(hid,gain) = LAruA2MeVComplete::LArCondObj();
360  fsampl->get(hid,gain) = LArfSamplComplete::LArCondObj();
361  minbias->get(hid,gain) = LArMinBiasComplete::LArCondObj();
362  }
363  ++n ;
364  }
365 
366  }
367  ATH_MSG_DEBUG(" Gain="<<gain<<
368  " Number of entries removed = " <<n );
369  }
370 
371 
372  HWIdentifier hid_mod[3];
373  hid_mod[0] = online_idhelper->channel_Id(1,1,6,1,33);
374  hid_mod[1] = online_idhelper->channel_Id(1,1,6,10,12);
375  hid_mod[2] = online_idhelper->channel_Id(1,1,6,14,12);
376 
377  // loop over all FCAL channels
378  std::vector<Identifier>::const_iterator it= fcal_idhelper->fcal_begin();
379  std::vector<Identifier>::const_iterator it_e= fcal_idhelper->fcal_end();
380  int n = 0;
381  for(;it!=it_e; ++it)
382  {
383  Identifier id = *it;
384  int pn = fcal_idhelper->pos_neg(id);
385  if(pn!=2) continue;
386  int phi = fcal_idhelper->phi(id);
387  if (phi>7) continue;
388 
389  int module = fcal_idhelper->module(id)-1;
390 
391  HWIdentifier hid = cabling->createSignalChannelID(id);
392 
393  for(unsigned int gain = 0;gain<3;++gain){
394 
395  LArRampComplete::LArCondObj& rampP = ramp->get(hid,gain) ;
396  if (!rampP.isEmpty()) continue ;
397 
398  ATH_MSG_DEBUG(" channel needs repair "
399  << online_idhelper->print_to_string(hid) );
400  ATH_MSG_DEBUG ( fcal_idhelper->print_to_string(id) );
401  ATH_MSG_DEBUG ( "module = "<<module );
402 
403  ++n;
404 
405  LArRampComplete::LArCondObj ramp_std = ramp->get(hid_mod[module],gain) ;
406  ramp->setPdata(hid,ramp_std,gain);
407 
408  LArAutoCorrComplete::LArCondObj ac_std = ac->get(hid_mod[module],gain) ;
409  ac->setPdata(hid,ac_std,gain);
410 
411  LArShape32MC::LArCondObj shape_std = shape->get(hid_mod[module],gain) ;
412  shape->setPdata(hid,shape_std,gain);
413 
414  LArNoiseComplete::LArCondObj noise_std = noise->get(hid_mod[module],gain) ;
415  noise->setPdata(hid,noise_std,gain);
416 
417  if(gain==0){
418 
419  LAruA2MeVComplete::LArCondObj ua2mev_std = ua2mev->get(hid_mod[module],gain) ;
420  ua2mev->setPdata(hid,ua2mev_std,gain);
421 
422  LArDAC2uAComplete::LArCondObj dac2ua_std = dac2ua->get(hid_mod[module],gain) ;
423  dac2ua->setPdata(hid,dac2ua_std,gain);
424 
425  LArfSamplComplete::LArCondObj fsampl_std = fsampl->get(hid_mod[module],gain) ;
426  fsampl->setPdata(hid,fsampl_std,gain);
427 
428  LArMinBiasComplete::LArCondObj minbias_std = minbias->get(hid_mod[module],gain) ;
429  minbias->setPdata(hid,minbias_std,gain);
430 
431  }
432 
433  }
434  }
435 
436  ATH_MSG_DEBUG( " Number of entries fixed " <<n );
437  return StatusCode::SUCCESS;
438 }
439 
441 
442  ATH_MSG_INFO ( " in fix3() " );
443  std::string filename ;
444 
445  // updated for 13.0.20
446  if(m_g4Phys=="QGSP_EMV"){
447  filename = "fsampl_1302_qgsp-emv.txt";
448  }
449  else
450  if( m_g4Phys=="QGSP_BERT"){
451  filename = "fsampl_1303_qgsp-bert.txt";
452  }
453  else {
454  ATH_MSG_ERROR ( " wrong option "<<m_g4Phys );
455  return StatusCode::FAILURE;
456  }
457 
458  // Fix3 is for updating the FCAL conditions data after IdFix7
459  // Input should be MC Conditions data with DetDescrVersion=ATLAS-DC3-05
460 
461  ATH_CHECK( updateEMfSampl(filename, cabling ) );
462  ATH_CHECK( updateHADfSampl(cabling) );
463  return StatusCode::SUCCESS;
464 }
465 
466 
467 StatusCode FixLArElecCalib::fix4 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
468  ATH_MSG_INFO ( " in fix4() " );
469  return updateEM_DACuAMeV( "dac2ua_ua2mev_rel13.txt", cabling );
470 }
471 
472 StatusCode FixLArElecCalib::updateHADfSampl ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
473 
474  float fsampl_fcal1,fsampl_fcal2,fsampl_fcal3;
475  float fsampl_hec1,fsampl_hec2;
476 
477  if(m_g4Phys=="QGSP_EMV"){
478  fsampl_hec1=0.04355;
479  fsampl_hec2=0.021775;
480 
481 
482  // numbers for G4.8.3
483  fsampl_fcal1=0.01366;
484  fsampl_fcal2=0.00854;
485  fsampl_fcal3=0.01107;
486  // numbers for G4.8.2
487  //fsampl_fcal1=0.01412;
488  //fsampl_fcal2=0.00894;
489  //fsampl_fcal3=0.01149;
490  }
491  else
492  if( m_g4Phys=="QGSP_BERT"){
493  fsampl_hec1=0.0447;
494  fsampl_hec2=0.02235;
495 
496  // for G4.8.3
497  fsampl_fcal1=0.01591;
498  fsampl_fcal2=0.01144;
499  fsampl_fcal3=0.01405;
500 
501  // for G4.8.2
502  //fsampl_fcal1=0.01512 ;
503  //fsampl_fcal2=0.01086;
504  //fsampl_fcal3=0.01352;
505  }
506  else {
507  ATH_MSG_ERROR ( " wrong option "<<m_g4Phys );
508  return StatusCode::FAILURE;
509  }
510 
511 
512  const LArfSamplMC * fsampl_c = nullptr;
513  ATH_CHECK( detStore()->retrieve(fsampl_c) );
514 
515  LArfSamplMC* fsampl = const_cast<LArfSamplMC*>(fsampl_c);
516 
517  // loop over all the old data
519  LArfSamplMC::ConditionsMapIterator it_e = fsampl->end(0);
520  int n_hec=0;
521  int n_fcal=0;
522 
523  for (; it!=it_e;++it){
524 
525  HWIdentifier hid = it.channelId();
526  if( (*it).isEmpty() ) continue;
527  if(!cabling->isOnlineConnected(hid)){
528  continue;
529  }
530 
532 
533  Identifier id = cabling->cnvToIdentifier(hid);
534 
535 
536  if(m_hec_idhelper->is_lar_hec(id)){
537  ATH_MSG_INFO(" HEC Old fsampl = "<< t2.m_fSampl<< " " );
538  int sam = m_hec_idhelper->sampling(id);
539 
540  if(sam<=1){
541  t2.m_fSampl = fsampl_hec1;
542  }else
543  {
544  t2.m_fSampl = fsampl_hec2;
545  }
546 
547  const LArfSamplComplete::LArCondObj & t3 = fsampl->get(hid,0);
548  ATH_MSG_INFO(" New fSampl = "<< t3.m_fSampl<< " " );
549 
550  ++n_hec;
551  }
552  if(m_fcal_idhelper->is_lar_fcal(id)){
553  ATH_MSG_INFO(" FCAL Old fsampl = "<< t2.m_fSampl<< " " );
554  int sam = m_fcal_idhelper->module(id);
555 
556  if(sam==1){
557  t2.m_fSampl = fsampl_fcal1;
558  }else
559  if(sam==2){
560  t2.m_fSampl = fsampl_fcal2;
561  }else
562  {
563  t2.m_fSampl = fsampl_fcal3;
564  }
565 
566  const LArfSamplComplete::LArCondObj & t3 = fsampl->get(hid,0);
567  ATH_MSG_INFO(" New fSampl = "<< t3.m_fSampl<< " " );
568 
569  ++n_fcal;
570  }
571 
572  }
573 
574  ATH_MSG_INFO(" number of hec cells "<<n_hec);
575  ATH_MSG_INFO(" number of fcal cells "<<n_fcal);
576 
577  return StatusCode::SUCCESS;
578 }
579 
580 
581 StatusCode FixLArElecCalib::updateEMfSampl ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling) {
582 
583  ATH_MSG_INFO ( " in updateEMfSampl() " );
584 
585  // this method updates the EM fSample, assuming symmetry.
586  // input is the text file.
587 
588  const LArfSamplMC * fsampl_c = nullptr;
589  ATH_CHECK( detStore()->retrieve(fsampl_c) );
590  LArfSamplMC* fsampl = const_cast<LArfSamplMC*>(fsampl_c);
591 
592  // read in the file
593 
594  ATH_MSG_INFO(" opening file "<< filename );
595  std::ifstream infile( filename.c_str() );
596  if(! infile.good() )
597  {
598  ATH_MSG_ERROR(" fail to open file ");
599  return StatusCode::FAILURE;
600  }
601  int det,samp,reg,eta;
602  float value ;
603  int n = 0;
604  while ( infile>>det>>samp>>reg>>eta>>value )
605  {
606  ++n;
607  ATH_MSG_INFO(" det,samp,reg,eta,value="
608  <<det<<" "
609  <<samp<<" "
610  <<reg<<" "
611  <<eta<<" "
612  <<value<<" " );
613 
614  Identifier id ;
615  if ( det==1 && samp==1 && reg==0 && eta==0 ){
616  // eta=0 for strip, not connected, but keep it
617  // Removed disconnected channels: 03/2016 RDS
618  // ATH_MSG_INFO(" disconnected strip ");
619  // id = m_em_idhelper->disc_channel_id(det,samp,reg,eta,0);
620  }else
621  id = m_em_idhelper->channel_id(det,samp,reg,eta,0);
622 
623  HWIdentifier hid = cabling->createSignalChannelID(id);
624  const LArfSamplComplete::LArCondObj & t = fsampl->get(hid,0);
625  std::string id_str = m_online_idhelper->print_to_string(hid);
626  ATH_MSG_INFO(" online id = "<<id_str);
627 
628  if( t.isEmpty() )
629  {
630  ATH_MSG_ERROR(" No existing conditions data " );
631  ATH_MSG_ERROR( m_em_idhelper->print_to_string(id) );
632  // return StatusCode::FAILURE ;
633  continue ;
634  }
635  ATH_MSG_INFO(" Old fsampl = "<< t.m_fSampl<< " " );
636 
638  t2.m_fSampl = value ;
639 
640  const LArfSamplComplete::LArCondObj & t3 = fsampl->get(hid,0);
641  ATH_MSG_INFO(" New fSampl = "<< t3.m_fSampl<< " " );
642  }
643 
644  ATH_MSG_INFO(" Number of entries changes = " <<n );
645  return StatusCode::SUCCESS;
646 }
647 
648 
649 StatusCode FixLArElecCalib::updateEM_DACuAMeV ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling) {
650  // read in the file
651 
652  const LArDAC2uAMC * dac2ua_c = nullptr;
653  ATH_CHECK( detStore()->retrieve(dac2ua_c) );
654  LArDAC2uAMC* dac2uaMC = const_cast<LArDAC2uAMC*>(dac2ua_c);
655 
656  const LAruA2MeVMC * ua2mev_c = nullptr;
657  ATH_CHECK( detStore()->retrieve(ua2mev_c) );
658  LAruA2MeVMC* ua2mevMC = const_cast<LAruA2MeVMC*>(ua2mev_c);
659 
660  std::ifstream infile(filename.c_str() ) ;
661 
662  if(! infile.good() )
663  {
664  ATH_MSG_ERROR(" fail to open file ");
665  return StatusCode::FAILURE;
666  }
667 
668 
669  char s[200];
670  infile.getline(s,200);
671  ATH_MSG_INFO(" first line of the file "<<s);
672 
673  int det,samp,reg,eta;
674  int n = 0;
675  float dac2ua0, ua2mev0,attenuation,dac2ua,ua2mev;
676  while ( infile>>det>>samp>>reg>>eta>>
677  dac2ua0>>ua2mev0>>attenuation>>dac2ua>>ua2mev )
678  {
679  ++n;
680  ATH_MSG_DEBUG(" det,samp,reg,eta,values="
681  <<det<<" "
682  <<samp<<" "
683  <<reg<<" "
684  <<eta<<" "
685  <<dac2ua<<" "
686  <<ua2mev<<" " );
687 
688  Identifier id ;
689  if ( det==1 && samp==1 && reg==0 && eta==0 ){
690  // eta=0 for strip, not connected, but keep it
691  // Removed disconnected channels: 03/2016 RDS
692  // ATH_MSG_DEBUG(" disconnected strip ");
693  // id = m_em_idhelper->disc_channel_id(det,samp,reg,eta,0);
694  }else
695  id = m_em_idhelper->channel_id(det,samp,reg,eta,0);
696 
697  HWIdentifier hid = cabling->createSignalChannelID(id);
698 
699  const LArDAC2uAComplete::LArCondObj & t = dac2uaMC->get(hid,0);
700  std::string id_str = m_online_idhelper->print_to_string(hid);
701  std::string id_str_off = m_em_idhelper->print_to_string(id);
702  ATH_MSG_DEBUG(" online id = "<<id_str);
703  ATH_MSG_DEBUG(" offline id = "<<id_str_off);
704 
705  if( t.isEmpty() )
706  {
707  ATH_MSG_WARNING(" No existing conditions data " );
708  continue ;
709  }
710  ATH_MSG_DEBUG(" Old DAC2uA = "<< t.m_data<< " " );
711 
713  t2.m_data= dac2ua ;
714 
715  const LArDAC2uAComplete::LArCondObj & t3 = dac2uaMC->get(hid,0);
716  ATH_MSG_DEBUG(" New DAC2uA = "<< t3.m_data<< " " );
717 
718  /**************************/
719 
720  const LAruA2MeVComplete::LArCondObj & u = ua2mevMC->get(hid,0);
721 
722  if( u.isEmpty() )
723  {
724  ATH_MSG_ERROR(" No existing conditions data " );
725  // return StatusCode::FAILURE ;
726  continue ;
727  }
728  ATH_MSG_DEBUG(" Old uA2MeV = "<< u.m_data<< " " );
729 
731  u2.m_data = ua2mev ;
732 
733  const LAruA2MeVComplete::LArCondObj & u3 = ua2mevMC->get(hid,0);
734  ATH_MSG_DEBUG(" New uA2MeV = "<< u3.m_data<< " " );
735 
736  }
737 
738  ATH_MSG_DEBUG(" Number of entries changes = " <<n );
739  return StatusCode::SUCCESS;
740 }
741 
742 
743 
744 StatusCode FixLArElecCalib::fix5 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
745 
746  ATH_MSG_INFO ( " in fix5() " );
747 
748  // update EM
749  ATH_CHECK( updateMinBias("mbrms_em_rel12.txt", cabling) );
750  ATH_CHECK( updateMinBias("mbrms_hec_rel12.txt", cabling) );
751 
752  // Fix5 is for updating the FCAL noise and MinBiasRMS data using
753  // Sven Menke's file.
754 
755  const LArNoiseMC * noise_c = nullptr;
756  ATH_CHECK( detStore()->retrieve(noise_c) );
757  LArNoiseMC* noise = const_cast<LArNoiseMC*>(noise_c);
758 
759  const LArMinBiasMC * minbias_c = nullptr;
760  ATH_CHECK( detStore()->retrieve(minbias_c) );
761  LArMinBiasMC* minbias = const_cast<LArMinBiasMC*>(minbias_c);
762 
763  int ndisc=0;
764  int nconn=0;
765  for( unsigned int gain=0;gain<3;++gain)
766  {
767  // loop over all the old data
770 
771  for (; it!=it_e;++it)
772  {
773  HWIdentifier hid = it.channelId();
774  if( (*it).isEmpty() ) continue;
775 
776  Identifier id = cabling->cnvToIdentifier(hid);
777  if(!m_fcal_idhelper->is_lar_fcal(id)) continue;
778 
779  if(cabling->isOnlineConnected(hid)){
780  ++nconn;
781  }else {
782  ATH_MSG_ERROR(" unconnected channel"
783  << m_online_idhelper->print_to_string(hid) );
784 
785  ++ndisc ;
786  }
787 
788  }
789 
790  ATH_MSG_INFO(" Gain="<<gain<<
791  " Number of connected and disconnected = " <<nconn<<" " <<ndisc );
792 
793  }
794 
795 
796  int n=0;
797 
798  std::string filename("FCal_noise_minbias.txt");
799 
800  std::ifstream infile(filename.c_str() ) ;
801 
802  if(! infile.good() )
803  {
804  ATH_MSG_ERROR(" fail to open file "<<filename);
805  return StatusCode::FAILURE;
806  }
807 
808 
809  char s[200];
810 
811  ATH_MSG_INFO("Opened FCAL file");
812  for(int i = 0;i<11;++i){
813  infile.getline(s,200);
814  ATH_MSG_INFO(s);
815  }
816 
817  std::string str_id;
818 
819  float vol,noise_p,noise_h, noise_m,noise_l;
820 
821  while ( infile>>str_id >>vol>>noise_p>>noise_h>>noise_m>>noise_l )
822  {
823  const char* ch_id = str_id.c_str();
824  if(ch_id[0] != 'A') {
825  ATH_MSG_DEBUG(" skipping string"<<str_id);
826  continue;
827  }
828 
829  int mod,phi,eta;
830  std::sscanf(ch_id, "A%d.%d.%d", &mod,&phi,&eta);
831  if(phi>7){
832  ATH_MSG_DEBUG(" skipping phi"<<str_id<<" phi="<<phi);
833  continue;
834  }
835  ++n;
836 
837  ATH_MSG_INFO(" Setting channel "<<str_id);
838  Identifier id = m_fcal_idhelper->channel_id(2,mod,eta,phi);
839  HWIdentifier hid = cabling->createSignalChannelID(id);
840 
841  const LArMinBiasComplete::LArCondObj& t1 = minbias->get(hid,0) ;
843  ATH_MSG_INFO(" minBiasRMS, old new "<<t2.m_MinBiasRMS<<" " <<noise_p);
844  t2.m_MinBiasRMS = noise_p;
845 
846  LArNoiseComplete::LArCondObj& u0 = const_cast<LArNoiseComplete::LArCondObj&>(noise->get(hid,0));
847  if(u0.m_Noise!=noise_h)
848  ATH_MSG_INFO(" noise, old new "<<u0.m_Noise<<" " <<noise_h);
849  u0.m_Noise=noise_h;
850 
851  LArNoiseComplete::LArCondObj& u1 = const_cast<LArNoiseComplete::LArCondObj&>(noise->get(hid,1));
852  if(u1.m_Noise!=noise_m)
853  ATH_MSG_INFO(" noise, old new "<<u1.m_Noise<<" " <<noise_m);
854  u1.m_Noise=noise_m;
855 
856  LArNoiseComplete::LArCondObj& u2 = const_cast<LArNoiseComplete::LArCondObj&>(noise->get(hid,2));
857  if(u2.m_Noise!=noise_l)
858  ATH_MSG_INFO(" noise, old new "<<u2.m_Noise<<" " <<noise_l);
859  u2.m_Noise=noise_l;
860 
861  }
862 
863  ATH_MSG_INFO(" number of channels in file ="<<n);
864 
865  return StatusCode::SUCCESS;
866 }
867 
868 StatusCode FixLArElecCalib::updateMinBias ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling) {
869 
870  ATH_MSG_INFO ( " in updateMinBias(), filename = "<<filename );
871 
872  // this method updates the EM MinBias
873  // input is the text file.
874 
875  const LArMinBiasMC * minbias_c = nullptr;
876  ATH_CHECK( detStore()->retrieve(minbias_c) );
877  LArMinBiasMC* minbias = const_cast<LArMinBiasMC*>(minbias_c);
878 
879  // read in the file
880 
881  ATH_MSG_INFO(" opening file "<< filename );
882  std::ifstream infile( filename.c_str() );
883  if(! infile.good() )
884  {
885  ATH_MSG_ERROR(" fail to open file ");
886  return StatusCode::FAILURE;
887  }
888 
889  int lar,tp,det,samp,reg,eta,phi;
890  //tp=1 for EM, 2=HEC
891 
892  float value ;
893  int n = 0;
894  while ( infile>>lar>>tp>>det>>samp>>reg>>eta>>phi>>value )
895  {
896  ++n;
897  ATH_MSG_INFO(" det,samp,reg,eta,value="
898  <<det<<" "
899  <<samp<<" "
900  <<reg<<" "
901  <<eta<<" "
902  <<value<<" " );
903 
904  Identifier id ;
905  if ( det==1 && samp==1 && reg==0 && eta==0 ){
906  // eta=0 for strip, not connected, but keep it
907  // Removed disconnected channels: 03/2016 RDS
908  // ATH_MSG_INFO(" disconnected strip ");
909  // id = m_em_idhelper->disc_channel_id(det,samp,reg,eta,0);
910  }else
911  {
912  if (tp==1){
913  id = m_em_idhelper->channel_id(det,samp,reg,eta,0);
914  }else
915  if(tp==2)
916  {
917  id = m_hec_idhelper->channel_id(det,samp,reg,eta,0);
918  }
919  else
920  {
921  ATH_MSG_ERROR(" unknown type "<<tp);
922  continue;
923  }
924  }
925 
926  HWIdentifier hid = cabling->createSignalChannelID(id);
927  const LArMinBiasComplete::LArCondObj & t = minbias->get(hid,0);
928  ATH_MSG_INFO(" online id = "<<m_online_idhelper->print_to_string(hid));
929 
930  if( t.isEmpty() )
931  {
932  ATH_MSG_ERROR(" No existing conditions data " );
933  ATH_MSG_ERROR( m_em_idhelper->print_to_string(id) );
934  // return StatusCode::FAILURE ;
935  continue ;
936  }
937  ATH_MSG_INFO(" Old MinBias = "<< t.m_MinBiasRMS<< " " );
938 
940  t2.m_MinBiasRMS = value ;
941 
942  const LArMinBiasComplete::LArCondObj & t3 = minbias->get(hid,0);
943  ATH_MSG_INFO(" New MinBias = "<< t3.m_MinBiasRMS<< " " );
944 
945  }
946 
947  ATH_MSG_INFO(" Number of entries changes = " <<n );
948  return StatusCode::SUCCESS;
949 }
950 
951 
952 StatusCode FixLArElecCalib::fix6 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
953 
954  ATH_MSG_INFO ( " in fix6() " );
955 
956  // update FCAL noise and gain
957  // Fix6 is for updating the FCAL noise and ADC2DAC, uA2MeV and DAC2uA.
958 
959  const LArNoiseMC * noise_c = nullptr;
960  ATH_CHECK( detStore()->retrieve(noise_c) );
961  LArNoiseMC* noise = const_cast<LArNoiseMC*>(noise_c);
962 
963  const LArRampMC * ramp_c = nullptr;
964  ATH_CHECK( detStore()->retrieve(ramp_c) );
965  LArRampMC* ramp = const_cast<LArRampMC*>(ramp_c);
966 
967  const LAruA2MeVMC * ua2MeV_c = nullptr;
968  ATH_CHECK( detStore()->retrieve(ua2MeV_c) );
969  LAruA2MeVMC* ua2MeV = const_cast<LAruA2MeVMC*>(ua2MeV_c);
970 
971  const LArDAC2uAMC * dac2uA_c = nullptr;
972  ATH_CHECK( detStore()->retrieve(dac2uA_c) );
973  LArDAC2uAMC* dac2uA = const_cast<LArDAC2uAMC*>(dac2uA_c);
974 
975  int ndisc=0;
976  int nconn=0;
977  for( unsigned int gain=0;gain<3;++gain)
978  {
979  // loop over all the old data
982 
983  for (; it!=it_e;++it)
984  {
985  HWIdentifier hid = it.channelId();
986  if( (*it).isEmpty() ) continue;
987 
988  Identifier id = cabling->cnvToIdentifier(hid);
989  if(!m_fcal_idhelper->is_lar_fcal(id)) continue;
990 
991  if(cabling->isOnlineConnected(hid)){
992  ++nconn;
993  continue;
994  }else
995  {
996  ATH_MSG_ERROR(" unconnected channel"
997  << m_online_idhelper->print_to_string(hid) );
998 
999  ++ndisc ;
1000  }
1001 
1002  }
1003 
1004  ATH_MSG_INFO(" Gain="<<gain<<
1005  " Number of connected and disconnected = " <<nconn<<" " <<ndisc );
1006 
1007  }
1008 
1009 
1010  int n=0;
1011 
1012  std::string filename("FCal_noise_minbias_adc2mev.txt");
1013  std::ifstream infile(filename.c_str() ) ;
1014 
1015  if(! infile.good() )
1016  {
1017  ATH_MSG_ERROR(" fail to open file "<<filename);
1018  return StatusCode::FAILURE;
1019  }
1020 
1021 
1022  char s[200];
1023 
1024  ATH_MSG_INFO("Opened FCAL file");
1025  for(int i = 0;i<27;++i){
1026  infile.getline(s,200);
1027  ATH_MSG_INFO(s);
1028  }
1029 
1030  std::string str_id;
1031 
1032  float vol,noise_p,noise_h, noise_m,noise_l;
1033  float ramp_val,ua2MeV_val,dac2uA_val;
1034  std::string channel_type;
1035  while ( infile>>str_id >>vol>>noise_p >> noise_h>>noise_m>>noise_l
1036  >>channel_type>> ramp_val>>ua2MeV_val>>dac2uA_val )
1037  {
1038  const char* ch_id = str_id.c_str();
1039 
1040  if(str_id.substr(0,1)!=std::string("A")){
1041  ATH_MSG_INFO(" skipping string"<<str_id);
1042  continue;
1043  }
1044 
1045  int mod,phi,eta;
1046  sscanf(ch_id, "A%d.%d.%d", &mod,&phi,&eta);
1047  if(phi>7){
1048  ATH_MSG_INFO(" skipping phi"<<str_id<<" phi="<<phi);
1049  continue;
1050  }
1051 
1052  ++n;
1053 
1054  ATH_MSG_INFO(" Setting channel "<<str_id);
1055  Identifier id = m_fcal_idhelper->channel_id(2,mod,eta,phi);
1056  HWIdentifier hid = cabling->createSignalChannelID(id);
1057 
1058  const LArNoiseComplete::LArCondObj& noise0 = noise->get(hid,0) ;
1059  LArNoiseComplete::LArCondObj& u0 = const_cast<LArNoiseComplete::LArCondObj&>(noise0);
1060  if(u0.m_Noise!=noise_h)
1061  ATH_MSG_INFO(" noise, old new "<<u0.m_Noise<<" " <<noise_h);
1062  u0.m_Noise=noise_h;
1063 
1064  const LArNoiseComplete::LArCondObj& noise1 = noise->get(hid,1) ;
1065  LArNoiseComplete::LArCondObj& u1 = const_cast<LArNoiseComplete::LArCondObj&>(noise1);
1066  if(u1.m_Noise!=noise_m)
1067  ATH_MSG_INFO(" noise, old new "<<u1.m_Noise<<" " <<noise_m);
1068  u1.m_Noise=noise_m;
1069 
1070  const LArNoiseComplete::LArCondObj& noise2 = noise->get(hid,2) ;
1071  LArNoiseComplete::LArCondObj& u2 = const_cast<LArNoiseComplete::LArCondObj&>(noise2);
1072  if(u2.m_Noise!=noise_l)
1073  ATH_MSG_INFO(" noise, old new "<<u2.m_Noise<<" " <<noise_l);
1074  u2.m_Noise=noise_l;
1075 
1076  LArRampComplete::LArCondObj& ramp0 = const_cast<LArRampComplete::LArCondObj&>(ramp->get(hid,0));
1077  LArRampComplete::LArCondObj& ramp1 = const_cast<LArRampComplete::LArCondObj&>(ramp->get(hid,1));
1078  LArRampComplete::LArCondObj& ramp2 = const_cast<LArRampComplete::LArCondObj&>(ramp->get(hid,2));
1079 
1080  ramp0.m_vRamp={0., ramp_val};
1081 
1082  ramp1.m_vRamp={0., ramp_val/(float)9.96};
1083 
1084  ramp2.m_vRamp={0., ramp_val/(float)9.96/(float)9.67};
1085 
1086  LAruA2MeVComplete::LArCondObj& ua2MeV0 = const_cast<LAruA2MeVComplete::LArCondObj&>(ua2MeV->get(hid,0));
1087  ua2MeV0.m_data=ua2MeV_val;
1088 
1089  LArDAC2uAComplete::LArCondObj& dac2ua0 = const_cast<LArDAC2uAComplete::LArCondObj&>(dac2uA->get(hid,0));
1090  dac2ua0.m_data = dac2uA_val;
1091 
1092  }
1093 
1094  ATH_MSG_INFO(" number of channels in file ="<<n);
1095  return StatusCode::SUCCESS;
1096 }
1097 
1098 
1099 StatusCode FixLArElecCalib::fix7 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
1100 
1101  ATH_MSG_INFO ( " in fix7() " );
1102  std::string filename ;
1103 
1104  // updating fSampl from 13.0.30 for QGSP_BERT
1105  if( m_g4Phys=="QGSP_BERT"){
1106  filename = "fsampl_1303_qgsp-bert.txt";
1107  }
1108  else {
1109  ATH_MSG_ERROR ( " wrong option "<<m_g4Phys );
1110  return StatusCode::FAILURE;
1111  }
1112 
1113  ATH_CHECK( updateEMfSampl(filename, cabling ) );
1114  return StatusCode::SUCCESS;
1115 }
1116 
1117 StatusCode FixLArElecCalib::fix8 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
1118 
1119  ATH_MSG_INFO ( " in fix8() " );
1120  // update EM/HEC 7 data objects.
1121 
1122  ATH_CHECK( addMphysOverMcal(cabling) );
1123 
1124  // withGain , nvar
1125  ATH_CHECK( update_EM_HEC<LArNoiseMC>("noise_em.txt","noise_hec.txt", cabling, true, 1 ) );
1126  ATH_CHECK( update_EM_HEC<LArAutoCorrMC>("","autocorr_hec.txt", cabling, true, 4 ) );
1127 
1128  ATH_CHECK( update_EM_HEC<LArAutoCorrMC>("autocorr_em.txt","", cabling, true,5) );
1129  ATH_CHECK( update_EM_HEC<LArRampMC>("ramp_em.txt","ramp_hec.txt", cabling, true, 1 ) );
1130  ATH_CHECK( update_EM_HEC<LAruA2MeVMC>("ua2mev_em.txt","ua2mev_hec.txt", cabling, false, 1 ) );
1131  ATH_CHECK( update_EM_HEC<LArDAC2uAMC>("dac2ua_em.txt","dac2ua_hec.txt", cabling, false, 1 ) );
1132  ATH_CHECK( update_EM_HEC<LArShape32MC>("shape_em.txt","shape_hec.txt", cabling, true, 64 ) );
1133  ATH_CHECK( update_EM_HEC<LArMphysOverMcalMC>("mphys_em.txt","", cabling, true, 1 ) );
1134 
1135  // additional fix for LArDAC2uA and LAruA2MeV
1136  ATH_CHECK( fixDACuAMeV() );
1137  return StatusCode::SUCCESS;
1138 }
1139 
1140 
1141 StatusCode FixLArElecCalib::ReadFile(const std::string& filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar ) {
1142 
1143  std::ifstream infile(filename.c_str() ) ;
1144 
1145  if(! infile.good() )
1146  {
1147  ATH_MSG_ERROR(" fail to open file "<<filename );
1148  return StatusCode::FAILURE;
1149  }
1150 
1151  ATH_MSG_INFO(" Opened file "<<filename );
1152 
1153  m_cache[0].clear();
1154  m_cache[1].clear();
1155  m_cache[2].clear();
1156 
1157  char s[200];
1158  infile.getline(s,200);
1159  ATH_MSG_INFO(" first line of the file "<<s);
1160 
1161  int det=2;
1162  int samp,reg,eta;
1163  int first;
1164  while ( infile>>first )
1165  {
1166  if (EM) {
1167  det = first;
1168  infile>>samp>>reg>>eta;
1169  }else
1170  {
1171  samp=first;
1172  infile>>reg>>eta;
1173  }
1174 
1175  int gain=0;
1176  if(withGain) infile>>gain ;
1177  std::vector<float> vfl;
1178  float x;
1179 
1180  for (int i=0;i<nvar;++i)
1181  {
1182  infile>>x;
1183  vfl.push_back(x);
1184  }
1185  ATH_MSG_DEBUG(" det,samp,reg,eta,values="
1186  <<det<<" "
1187  <<samp<<" "
1188  <<reg<<" "
1189  <<eta<<" " );
1190 
1191  Identifier id ;
1192  if (EM)
1193  {
1194  if ( det==1 && samp==1 && reg==0 && eta==0 ){
1195  // eta=0 for strip, not connected, but keep it
1196  // Removed disconnected channels: 03/2016 RDS
1197  ATH_MSG_DEBUG(" disconnected strip ");
1198  }else
1199  id = m_em_idhelper->channel_id(det,samp,reg,eta,0);
1200  }else //HEC
1201  {
1202  id = m_hec_idhelper->channel_id(2,samp,reg,eta,0);
1203  }
1204  HWIdentifier hid = cabling->createSignalChannelID(id);
1205 
1206  if (gain >= 0 && gain < 3)
1207  m_cache[gain].push_back(ROW_t(hid,vfl));
1208  }
1209 
1210  return StatusCode::SUCCESS;
1211 }
1212 
1213 StatusCode FixLArElecCalib::ReadFileAll(const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar ) {
1214 
1215  std::ifstream infile(filename.c_str() ) ;
1216 
1217  if(! infile.good() )
1218  {
1219  ATH_MSG_ERROR(" fail to open file "<<filename );
1220  return StatusCode::FAILURE;
1221  }
1222 
1223  ATH_MSG_INFO(" Opened file "<<filename );
1224 
1225  m_cache[0].clear();
1226  m_cache[1].clear();
1227  m_cache[2].clear();
1228 
1229  char s[200];
1230  infile.getline(s,200);
1231  ATH_MSG_INFO(" first line of the file "<<s);
1232 
1233  int det,samp,reg,eta;
1234  int first;
1235  while ( infile>>first>>samp>>reg>>eta ) {
1236  Identifier id ;
1237  int gain=0;
1238  float x;
1239  if(first <= 2) { // Calo 0,1,2 is EM
1240  det = first+1;
1241  if ( det==1 && samp==1 && reg==0 && eta==0 ){
1242  // eta=0 for strip, not connected, but keep it
1243  // Removed disconnected channels: 03/2016 RDS
1244  ATH_MSG_DEBUG(" disconnected strip ");
1245  // id = m_em_idhelper->disc_channel_id(det,samp,reg,eta,0);
1246  }else
1247  id = m_em_idhelper->channel_id(det,samp,reg,eta,0);
1248  } else if (first == 3) { // HEC
1249  id = m_hec_idhelper->channel_id(2,samp,reg,eta,0);
1250  } else if (first == 4) { // FCAL
1251  id = m_fcal_idhelper->channel_id(2,samp+1,eta,0);
1252  } else {
1253  ATH_MSG_WARNING(" Wrong calo number "<<first<<" skipping !!!");
1254  if(withGain) infile>>gain ;
1255  for (int i=0;i<nvar;++i) infile>>x;
1256  continue;
1257  }
1258  if(withGain) infile>>gain ;
1259  std::vector<float> vfl;
1260 
1261  for (int i=0;i<nvar;++i)
1262  {
1263  infile>>x;
1264  vfl.push_back(x);
1265  }
1266  ATH_MSG_DEBUG(" first, det,samp,reg,eta,values="
1267  <<first<<" " <<det<<" " <<samp<<" " <<reg<<" " <<eta<<" " );
1268 
1269  HWIdentifier hid = cabling->createSignalChannelID(id);
1270 
1271  if (gain >= 0 && gain < 3) m_cache[gain].push_back(ROW_t(hid,vfl));
1272  else {
1273  ATH_MSG_WARNING(" Wrong gain " <<gain<<" skipping !");
1274  }
1275  }// while
1276 
1277  return StatusCode::SUCCESS;
1278 }
1279 
1281 {
1282  if( obj.isEmpty()){
1283  ATH_MSG_INFO(" LArNoiseMC " << msg << " is empty" );
1284  }else
1285  ATH_MSG_DEBUG(" LArNoiseMC" << msg << obj.m_Noise );
1286  return ;
1287 }
1288 
1289 void FixLArElecCalib::set_object(LArNoiseMC::LArCondObj& obj, const std::vector<float>& v )
1290 {
1291  if (v.size()!=1)
1292  {
1293  ATH_MSG_ERROR ("for LArNoiseMC, size of vector = "<< v.size() <<" differs from one");
1294  return ;
1295  }
1296  obj.m_Noise = v[0];
1297  return;
1298 }
1299 
1301 {
1302  if( obj.isEmpty()){
1303  ATH_MSG_INFO(" LArAutoCorrMC " << s << " is empty" );
1304  }else
1305  {
1306  msg()<<MSG::DEBUG<<" LArAutoCorrMC" << s ;
1307  for (unsigned int i =0 ; i<obj.m_vAutoCorr.size();++i)
1308  msg()<< " " << obj.m_vAutoCorr[i];
1309  msg()<<endmsg;
1310  }
1311  return ;
1312 }
1313 
1315 {
1316  if (v.size()<4 )
1317  {
1318  ATH_MSG_ERROR( "for LArAutoCorrMC, size of vector = "<< v.size()<<" is less then 4" );
1319  return ;
1320  }
1321 
1322  obj.m_vAutoCorr.resize(4);
1323  std::copy_n(v.begin(), 4, obj.m_vAutoCorr.begin());
1324  return;
1325 }
1326 
1328 {
1329  if( obj.isEmpty()){
1330  ATH_MSG_INFO(" LArRampMC " << s << " is empty" );
1331  }else
1332  {
1333  msg()<<MSG::DEBUG<<" LArRampMC" << s ;
1334  for (unsigned int i =0 ; i<obj.m_vRamp.size();++i)
1335  msg()<< " " << obj.m_vRamp[i];
1336  msg()<<endmsg;
1337  }
1338  return ;
1339 }
1340 
1341 void FixLArElecCalib::set_object(LArRampMC::LArCondObj& obj, const std::vector<float>& v )
1342 {
1343  if (v.size()!=1 )
1344  {
1345  ATH_MSG_ERROR ("for LArRampMC, size of vector = "<< v.size());
1346  return ;
1347  }
1348  obj.m_vRamp.resize(3);
1349  obj.m_vRamp[0]=0;
1350  obj.m_vRamp[1]=v[0];
1351  obj.m_vRamp[2]=0;
1352 
1353  return;
1354 }
1355 
1357 {
1358  if( obj.isEmpty()){
1359  ATH_MSG_INFO(" LArShape32MC " << s << " is empty" );
1360  }else
1361  {
1362  msg()<<MSG::DEBUG<<" LArShape" << s ;
1363  for (unsigned int i =0 ; i<obj.m_vShape.size();++i)
1364  msg()<< " " << obj.m_vShape[i];
1365  msg()<<endmsg;
1366 
1367  msg()<<MSG::DEBUG<<" LArShapeDer" << s ;
1368  for (unsigned int i =0 ; i<obj.m_vShapeDer.size();++i)
1369  msg()<< " " << obj.m_vShapeDer[i];
1370  msg()<<endmsg;
1371  }
1372  return ;
1373 }
1374 
1375 void FixLArElecCalib::set_object(LArShape32MC::LArCondObj& obj, const std::vector<float>& v )
1376 {
1377 
1378  if (v.size()!=64 && v.size()!=32 )
1379  {
1380  ATH_MSG_ERROR ("for LArShape32MC, size of vector = "<< v.size());
1381  return ;
1382  }
1383 
1384  unsigned int size = 32;
1385  obj.m_vShape.resize(size);
1386  obj.m_vShapeDer.resize(size);
1387 
1388  for(unsigned int i=0;i<size;++i){
1389  obj.m_vShape[i]=v[i];
1390  if(v.size() == 64 ) obj.m_vShapeDer[i]=v[i+size]; else obj.m_vShapeDer[i]=0.;
1391  }
1392 
1393  return;
1394 }
1395 
1396 
1397 
1398 
1399 
1400 void FixLArElecCalib::print_object(const std::string& msg, const LArSingleFloatP& obj)
1401 {
1402  if( obj.isEmpty()){
1403  ATH_MSG_INFO(" LArSingleFloatP " << msg << " is empty" );
1404  }else
1405  ATH_MSG_DEBUG(" LArSingleFloatP " << msg << obj.m_data );
1406  return ;
1407 }
1408 
1409 void FixLArElecCalib::set_object(LArSingleFloatP& obj, const std::vector<float>& v )
1410 {
1411  if (v.size()!=1)
1412  {
1413  ATH_MSG_ERROR( "for LArSingleFloatP, size of vector = "<< v.size() );
1414  return ;
1415  }
1416  obj.m_data = v[0];
1417  return;
1418 }
1419 
1420 
1421 
1422 
1424  // add the contain to DetStore.
1425  // fill 1 for all FCAL/HEC channels
1426 
1427  ATH_MSG_INFO ( " addMphysOverMcal() " );
1428  // create LArMphysOverMcal with FCAL numbers = 1.
1429 
1430  std::unique_ptr<LArMphysOverMcalMC> mphys = std::make_unique<LArMphysOverMcalMC>();
1431  mphys->setGroupingType(LArConditionsContainerBase::SingleGroup);
1432  ATH_CHECK( mphys->initialize() );
1433 
1434  int n=0;
1435 
1436  std::string filename("FCal_noise_minbias_adc2mev.txt");
1437 
1438  std::ifstream infile(filename.c_str() ) ;
1439 
1440  if(! infile.good() )
1441  {
1442  ATH_MSG_ERROR(" fail to open file "<<filename);
1443  return StatusCode::FAILURE;
1444  }
1445 
1446 
1447  char s[200];
1448 
1449  ATH_MSG_INFO("Opened FCAL file");
1450  for(int i = 0;i<27;++i){
1451  infile.getline(s,200);
1452  ATH_MSG_INFO(s);
1453  }
1454 
1455  std::string str_id;
1456 
1457  float vol,noise_p,noise_h, noise_m,noise_l;
1458  float ramp_val,ua2MeV_val,dac2uA_val;
1459  std::string channel_type;
1460  while ( infile>>str_id >>vol>>noise_p >> noise_h>>noise_m>>noise_l
1461  >>channel_type>> ramp_val>>ua2MeV_val>>dac2uA_val )
1462  {
1463  const char* ch_id = str_id.c_str();
1464 
1465  if(str_id.substr(0,1)!=std::string("A")){
1466  ATH_MSG_INFO(" skipping string"<<str_id);
1467  continue;
1468  }
1469 
1470  int mod,phi,eta;
1471  sscanf(ch_id, "A%d.%d.%d", &mod,&phi,&eta);
1472  if(phi>7){
1473  ATH_MSG_INFO(" skipping phi"<<str_id<<" phi="<<phi);
1474  continue;
1475  }
1476 
1477  ++n;
1478 
1479  ATH_MSG_INFO(" Setting channel "<<str_id);
1481  HWIdentifier hid = cabling->createSignalChannelID(id);
1482 
1484  t.m_data =1. ;
1485  mphys->setPdata(hid,t,0);
1486  mphys->setPdata(hid,t,1);
1487  mphys->setPdata(hid,t,2);
1488  }
1489 
1490  ATH_MSG_INFO(" MphysOverMcal added "<<n<<" FCAL channels");
1491 
1492  bool EM=false ;
1493  bool withGain=false;
1494  int nvar = 1;
1495  std::string hec_filename("mphys_hec.txt");
1496  ATH_CHECK( ReadFile(hec_filename,cabling,EM,withGain,nvar) );
1497 
1498  int igain=0;
1499  n=0;
1500  for( ROW_t &it : m_cache[igain])
1501  {
1502  HWIdentifier hid = it.first;
1504  t.m_data =1. ;
1505  mphys->setPdata(hid,t,0);
1506  mphys->setPdata(hid,t,1);
1507  mphys->setPdata(hid,t,2);
1508  ++n;
1509 
1510  }
1511 
1512  ATH_CHECK( detStore()->record(std::move(mphys),"LArMphysOverMcal") );
1513  ILArMphysOverMcal* imphys=nullptr;
1514  ATH_CHECK (detStore()->symLink(mphys.get(),imphys) );
1515 
1516  ATH_MSG_ERROR(" Number of HEC channel added "<<n <<" per gain ");
1517  return StatusCode::SUCCESS ;
1518 }
1519 
1520 
1521 StatusCode FixLArElecCalib::fixDACuAMeV ATLAS_NOT_THREAD_SAFE ()
1522 {
1523  // the old data has -10000000 for invalid. change it to {ERRORCODE = -999};
1524 
1525  const LArDAC2uAMC * dac2ua_c = nullptr;
1526  ATH_CHECK( detStore()->retrieve(dac2ua_c) );
1527  LArDAC2uAMC* dac2uaMC = const_cast<LArDAC2uAMC*>(dac2ua_c);
1528 
1529  const LAruA2MeVMC * ua2mev_c = nullptr;
1530  ATH_CHECK( detStore()->retrieve(ua2mev_c) );
1531  LAruA2MeVMC* ua2mevMC = const_cast<LAruA2MeVMC*>(ua2mev_c);
1532 
1533  int n=0;
1534 
1536  LAruA2MeVMC::ConditionsMapIterator it_e = ua2mevMC->end(0);
1537 
1538  for(;it!=it_e;++it){
1539  HWIdentifier hid = it.channelId();
1540  const LAruA2MeVComplete::LArCondObj & u = (*it);
1541 
1542  if( u.m_data> -990)
1543  {
1544  ATH_MSG_DEBUG(" ua2MeV channel OK "<<u.m_data );
1545  continue ;
1546  }
1547 
1548  ATH_MSG_DEBUG(" Old uA2MeV = "<< u.m_data<< " " );
1549 
1552 
1553  const LAruA2MeVComplete::LArCondObj & u3 = ua2mevMC->get(hid,0);
1554  ATH_MSG_DEBUG(" New uA2MeV = "<< u3.m_data<< " " );
1555 
1556  ++n;
1557  }
1558 
1559  ATH_MSG_DEBUG(" Number of uA2MeV entries changes = " <<n );
1560 
1561  for(unsigned int igain=0;igain<3;++igain)
1562  {
1564  LArDAC2uAMC::ConditionsMapIterator it_e = dac2uaMC->end(igain);
1565 
1566  n=0;
1567  for( ;it!=it_e;++it){
1568  HWIdentifier hid = it.channelId();
1569  const LArDAC2uAMC::LArCondObj & u = (*it);
1570 
1571  if( u.m_data> -990.)
1572  {
1573  ATH_MSG_DEBUG(" DAC2uA channel OK "<<u.m_data );
1574  continue ;
1575  }
1576 
1577  ATH_MSG_DEBUG(" Old DAC2uA = "<< u.m_data<< " " );
1578 
1579  LArDAC2uAMC::LArCondObj& u2 = const_cast<LArDAC2uAMC::LArCondObj&>(u);
1581 
1582  const LArDAC2uAMC::LArCondObj & u3 = dac2uaMC->get(hid,igain);
1583  ATH_MSG_DEBUG(" New DACuA2 = "<< u3.m_data << " " );
1584  ++n;
1585  }
1586 
1587  }
1588 
1589  ATH_MSG_DEBUG(" Number of DAC2uA entries changes = " <<n );
1590  return StatusCode::SUCCESS;
1591 }
1592 
1593 
1594 StatusCode FixLArElecCalib::fix9 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
1595 
1596  ATH_MSG_INFO ( " in fix9(), replace FCAL AutoCorr " );
1597 
1598  std::vector<float> fcal_autoCorr[3][3] ; //[module][gain]
1599  fcal_autoCorr[0][0] = {-0.01, -0.30, -0.09, 0.08};
1600  fcal_autoCorr[0][1] = { 0.01, -0.07, -0.01, 0.03};
1601  fcal_autoCorr[0][2] = { 0.2, 0.2, 0.2, 0.2};
1602  fcal_autoCorr[1][0] = { -0.02, -0.31, -0.06, 0.06};
1603  fcal_autoCorr[1][1] = { 0.0, -0.08, -0.01, 0.02};
1604  fcal_autoCorr[1][2] = { 0.02, 0.01, 0.02, 0.02};
1605  fcal_autoCorr[2][0] = { -0.03, -0.31, -0.05, 0.07};
1606  fcal_autoCorr[2][1] = { 0.01, -0.07, -0.01, 0.02};
1607  fcal_autoCorr[2][2] = { 0.02, 0.02, 0.02, 0.02};
1608 
1609  // Fix9 is for updating the FCAL AutoCorr conditions data
1610  // Input should be MC Conditions data with DetDescrVersion=ATLAS-CSC-02-00-00
1611 
1612  const LArAutoCorrMC * ac_c = nullptr;
1613  ATH_CHECK( detStore()->retrieve(ac_c) );
1614  LArAutoCorrMC* ac = const_cast<LArAutoCorrMC*>(ac_c);
1615 
1616 
1617  for( unsigned int gain=0;gain<3;++gain)
1618  {
1619  // loop over all the old data
1622 
1623  int n=0;
1624  for (; it!=it_e;++it)
1625  {
1626  HWIdentifier hid = it.channelId();
1627  const LArAutoCorrMC::LArCondObj & u = (*it);
1628  if( (*it).isEmpty() ) continue;
1629 
1630  Identifier id = cabling->cnvToIdentifier(hid);
1631  if(! m_fcal_idhelper->is_lar_fcal(id)) continue ;
1632  int module = m_fcal_idhelper->module(id) - 1;
1633 
1634  ATH_MSG_DEBUG("module= " << module << " Old AutoCorr = "
1635  << u.m_vAutoCorr[0]<< " "
1636  << u.m_vAutoCorr[1]<< " "
1637  << u.m_vAutoCorr[2]<< " "
1638  << u.m_vAutoCorr[3]<< " " );
1639 
1641  u2.m_vAutoCorr = fcal_autoCorr[module][gain] ;
1642 
1643  const LArAutoCorrMC::LArCondObj & u3 = ac->get(hid,gain);
1644  ATH_MSG_DEBUG(" New AutoCorr = "
1645  << u3.m_vAutoCorr[0]<< " "
1646  << u3.m_vAutoCorr[1]<< " "
1647  << u3.m_vAutoCorr[2]<< " "
1648  << u3.m_vAutoCorr[3]<< " " );
1649  ++n;
1650 
1651  }
1652  ATH_MSG_DEBUG(" Gain="<<gain<<
1653  " Number of entries modified = " <<n );
1654  }
1655 
1656  return StatusCode::SUCCESS;
1657 }
1658 
1659 
1660 StatusCode FixLArElecCalib::fix10 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
1661 
1662  ATH_MSG_INFO ( " in fix10() " );
1663  // fix medium and low gain ramp
1664 
1665  const LArRampMC * ramp_c = nullptr;
1666  ATH_CHECK( detStore()->retrieve(ramp_c) );
1667  LArRampMC* ramp = const_cast<LArRampMC*>(ramp_c);
1668 
1670  LArRampMC::ConditionsMapIterator it_e = ramp->end(0);
1671 
1672  int n=0;
1673  int ndisc=0;
1674  for (; it!=it_e;++it)
1675  {
1676  HWIdentifier hid = it.channelId();
1677  if( (*it).isEmpty() ) continue;
1678 
1679  Identifier id = cabling->cnvToIdentifier(hid);
1680  if(!m_fcal_idhelper->is_lar_fcal(id)) continue;
1681 
1682  if( ! cabling->isOnlineConnected(hid)){
1683  ATH_MSG_ERROR(" unconnected channel"
1684  << m_online_idhelper->print_to_string(hid) );
1685  ++ndisc ;
1686  continue ;
1687  }
1688 
1689 
1690  const LArRampComplete::LArCondObj& ramp0_c = ramp->get(hid,0) ;
1691  const LArRampComplete::LArCondObj& ramp1_c = ramp->get(hid,1) ;
1692  const LArRampComplete::LArCondObj& ramp2_c = ramp->get(hid,2) ;
1693  LArRampComplete::LArCondObj& ramp0 = const_cast<LArRampComplete::LArCondObj&>(ramp0_c);
1694  LArRampComplete::LArCondObj& ramp1 = const_cast<LArRampComplete::LArCondObj&>(ramp1_c);
1695  LArRampComplete::LArCondObj& ramp2 = const_cast<LArRampComplete::LArCondObj&>(ramp2_c);
1696 
1697  float ramp_high = ramp0.m_vRamp[1];
1698 
1699  std::vector<float> v_m ;
1700  v_m.push_back(0);
1701  v_m.push_back(ramp_high*9.96);
1702  ramp1.m_vRamp=v_m;
1703 
1704  std::vector<float> v_l ;
1705  v_l.push_back(0);
1706  v_l.push_back(ramp_high*9.96*9.67);
1707  ramp2.m_vRamp=v_l;
1708  ++n;
1709 
1710  ATH_MSG_DEBUG(" ramp hi,med,low"<< ramp0.m_vRamp[1]<< " "<<ramp1.m_vRamp[1]<< " " <<
1711  ramp2.m_vRamp[1]);
1712 
1713  }
1714 
1715  ATH_MSG_INFO( " Number of channels updted = " <<n );
1716  ATH_MSG_INFO( " Number of disconnected = " <<ndisc );
1717 
1718  return StatusCode::SUCCESS;
1719 }
1720 
1721 
1722 StatusCode FixLArElecCalib::fix11 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
1723 
1724  ATH_MSG_INFO ( " in fix8() " );
1725  // update EM/HEC 7 data objects.
1726 
1727  ATH_CHECK( update_EM_HEC<LArRampMC>("","ramp_hec_june2008.txt", cabling, true, 1 ) );
1728  return StatusCode::SUCCESS;
1729 }
1730 
1731 
1733 
1734  ATH_MSG_INFO ( " in fix13() " );
1735  // update EM/HEC 7 data objects.
1736 
1737  ToolHandle<ICaloSuperCellIDTool> scidtool("CaloSuperCellIDTool");
1738  if ( scidtool.retrieve().isFailure() ) {
1739  ATH_MSG_ERROR ( " Could not retrieve scitool " );
1740  }
1741 
1742  std::set<Identifier> scidset;
1743  std::map<HWIdentifier,int> sslot_schannel_idx;
1744  std::vector<unsigned int> OrderOnlHash_OffID;
1745  std::vector<unsigned int> OrderOffHash_OnlID;
1746  OrderOnlHash_OffID.resize(40000,0);
1747  OrderOffHash_OnlID.resize(40000,0);
1748 
1750  unsigned int min_onl_hash = 999999;
1751  unsigned int max_onl_hash = 0;
1752  unsigned int min_off_hash = 999999;
1753  unsigned int max_off_hash = 0;
1754  std::ofstream hashes("AllHashChannels_All.txt");
1755  std::ofstream of("AllChannels_EM.txt");
1756 
1757  for(size_t i = 0; i < channel_size ; i++) {
1759  bool isEM = ( m_em_idhelper->is_em_barrel( chid ) || m_em_idhelper->is_em_endcap( chid ) ) ;
1760  if ( ! isEM ) continue;
1761  Identifier SCID = scidtool->offlineToSuperCellID(chid);
1762  if ( scidset.find(SCID) == scidset.end() && (m_scell_idhelper->calo_cell_hash( SCID ).value() < 99999) )
1763  scidset.insert(SCID);
1764  else continue;
1765  HWIdentifier hwid = cabling->createSignalChannelID(chid);
1766  if ( i == 0 ){
1767  of << "Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl;
1768  }
1769  of << chid.get_identifier32().get_compact() << "\t0x" <<
1770  SCID.get_identifier32().get_compact() << "\t0x" <<
1771  hwid.get_identifier32().get_compact() ;
1772  Identifier regId = m_em_idhelper->region_id( chid );
1773  int reg = m_em_idhelper->region( chid );
1774  IdentifierHash regHash = m_em_idhelper->region_hash( regId );
1775  int samp = m_em_idhelper->sampling( chid );
1776  int feedthrough = m_online_idhelper->feedthrough( hwid );
1777  int bar_ec = m_online_idhelper->barrel_ec( hwid );
1778  int pos_neg = m_online_idhelper->pos_neg( hwid );
1779  int slot = m_online_idhelper->slot( hwid );
1780  float etaG = m_em_idhelper->etaGranularity(regHash);
1781  float phiG = m_em_idhelper->phiGranularity(regHash);
1782  float eta0 = m_em_idhelper->eta0(regHash);
1783  float phi0 = m_em_idhelper->phi0(regHash);
1784  float eta = etaG*m_em_idhelper->eta( chid ) + eta0;
1785  float phi = phiG*m_em_idhelper->phi( chid ) + phi0;
1786  char etaChar[10];
1787  char phiChar[10];
1788  sprintf(etaChar,"%5.4f",eta);
1789  sprintf(phiChar,"%5.4f",phi);
1790  of << std::dec << "\t" << feedthrough << "\t" << slot;
1791  of << "\t" << bar_ec << " " << pos_neg << "\t\t" << samp << "\t";
1792  of << etaChar << " " << phiChar << "\t0x";
1793  HWIdentifier feb_id = m_online_idhelper->feb_Id(hwid);
1794  int sslot=1;
1795  bool InSlot= m_em_idhelper->is_em_endcap_inner ( chid );
1796  bool OutSlot= m_em_idhelper->is_em_endcap_outer ( chid ) ;
1797  bool secondOutSlot=false;
1798  if ( OutSlot ) {
1799  if ( (samp==1) && (reg==5) ) secondOutSlot=true;
1800  if ( (samp==2) && (reg==1) && ( m_em_idhelper->eta( chid )>=39 ) )
1801  secondOutSlot=true;
1802  if ( (samp==3) && (reg==0) && ( m_em_idhelper->eta( chid )>=18 ) )
1803  secondOutSlot=true;
1804  }
1805  HWIdentifier sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot);
1806 
1807  if ( InSlot ) {
1808  sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough-1,sslot+1);
1809  }
1810  if ( secondOutSlot ) {
1811  sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot+1);
1812  }
1813  if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1814  sslot_schannel_idx[sfeb_id]=0;
1815  else sslot_schannel_idx[sfeb_id]++;
1816  HWIdentifier shwid = m_sonline_idhelper->channel_Id(sfeb_id,sslot_schannel_idx[sfeb_id]);
1817  unsigned int onl_hash = m_sonline_idhelper->channel_Hash( shwid ).value();
1818  if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1819  if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1820  unsigned int off_hash = m_scell_idhelper->calo_cell_hash( SCID ).value();
1821  if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1822  if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1823  of << std::hex;
1824  of << feb_id.get_identifier32().get_compact();
1825  of << "\t0x" << shwid.get_identifier32().get_compact();
1826  of << " " << m_online_idhelper->channel_name(hwid) << " " << m_sonline_idhelper->channel_name(shwid);
1827  of << std::dec;
1828  of << " " << onl_hash << " " << off_hash;
1829  of << std::endl;
1830 
1831  if ( m_scell_idhelper->calo_cell_hash( SCID ).value() < 40000 )
1832  OrderOffHash_OnlID[m_scell_idhelper->calo_cell_hash( SCID ).value()] = shwid.get_identifier32().get_compact();
1833  if ( m_sonline_idhelper->channel_Hash( shwid ).value() < 40000 )
1834  OrderOnlHash_OffID[m_sonline_idhelper->channel_Hash( shwid ).value()] = SCID.get_identifier32().get_compact();
1835  }
1836  of << "Hash check. Onl : " << min_onl_hash << " " << max_onl_hash;
1837  of << "; Off : " << min_off_hash << " " << max_off_hash << std::endl;;
1838  of.close();
1839 
1840  channel_size = m_hec_idhelper->channel_hash_max();
1841  min_onl_hash = 999999;
1842  max_onl_hash = 0;
1843  min_off_hash = 999999;
1844  max_off_hash = 0;
1845  std::ofstream of1("AllChannels_HEC.txt");
1846 
1847  of1 << "Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl;
1848  for(size_t i = 0; i < channel_size ; i++) {
1850  if ( ! ( m_hec_idhelper->is_lar_hec( chid ) ) ) continue;
1851  Identifier SCID = scidtool->offlineToSuperCellID(chid);
1852  if ( scidset.find(SCID) == scidset.end() )
1853  scidset.insert(SCID);
1854  else continue;
1855  HWIdentifier hwid = cabling->createSignalChannelID(chid);
1856  of1 << chid.get_identifier32().get_compact() << "\t0x" <<
1857  SCID.get_identifier32().get_compact() << "\t0x" <<
1858  hwid.get_identifier32().get_compact() ;
1859  Identifier regId = m_hec_idhelper->region_id( chid );
1860  IdentifierHash regHash = m_hec_idhelper->region_hash( regId );
1861  int samp = m_hec_idhelper->sampling( chid );
1862  int feedthrough = m_online_idhelper->feedthrough( hwid );
1863  int bar_ec = m_online_idhelper->barrel_ec( hwid );
1864  int pos_neg = m_online_idhelper->pos_neg( hwid );
1865  int slot = m_online_idhelper->slot( hwid );
1866  float etaG = m_hec_idhelper->etaGranularity(regHash);
1867  float phiG = m_hec_idhelper->phiGranularity(regHash);
1868  float eta0 = m_hec_idhelper->eta0(regHash);
1869  float phi0 = m_hec_idhelper->phi0(regHash);
1870  float eta = etaG*m_hec_idhelper->eta( chid ) + eta0;
1871  float phi = phiG*m_hec_idhelper->phi( chid ) + phi0;
1872  char etaChar[10];
1873  char phiChar[10];
1874  sprintf(etaChar,"%5.4f",eta);
1875  sprintf(phiChar,"%5.4f",phi);
1876  of1 << std::dec << "\t" << feedthrough << "\t" << slot;
1877  of1 << "\t" << bar_ec << " " << pos_neg << "\t\t" << samp << "\t";
1878  of1 << etaChar << " " << phiChar << "\t0x";
1879  HWIdentifier feb_id = m_online_idhelper->feb_Id(hwid);
1880  int sslot=1;
1881  int subtract=0;
1882  HWIdentifier sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot);
1883  if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1884  sslot_schannel_idx[sfeb_id]=0;
1885  else sslot_schannel_idx[sfeb_id]++;
1886  if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) {
1887  sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot+1);
1888  subtract=192;
1889  }
1890  HWIdentifier shwid = m_sonline_idhelper->channel_Id(sfeb_id,sslot_schannel_idx[sfeb_id]-subtract);
1891  unsigned int onl_hash = m_sonline_idhelper->channel_Hash( shwid ).value();
1892  if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1893  if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1894  unsigned int off_hash = m_scell_idhelper->calo_cell_hash( SCID ).value();
1895  if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1896  if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1897  of1 << std::hex;
1898  of1 << feb_id.get_identifier32().get_compact();
1899  of1 << "\t0x" << shwid.get_identifier32().get_compact();
1900  of1 << " " << m_online_idhelper->channel_name(hwid) << " " << m_sonline_idhelper->channel_name(shwid);
1901  of1 << std::dec;
1902  of1 << " " << onl_hash << " " << off_hash;
1903  of1 << std::endl;
1904 
1905  OrderOffHash_OnlID[m_scell_idhelper->calo_cell_hash( SCID ).value()] = shwid.get_identifier32().get_compact();
1906  OrderOnlHash_OffID[m_sonline_idhelper->channel_Hash( shwid ).value()] = SCID.get_identifier32().get_compact();
1907  }
1908 
1909  channel_size = m_fcal_idhelper->channel_hash_max();
1910  min_onl_hash = 999999;
1911  max_onl_hash = 0;
1912  min_off_hash = 999999;
1913  max_off_hash = 0;
1914  std::ofstream of3("AllChannels_FCAL.txt");
1915 
1916  of3 << "Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl;
1917  for(size_t i = 0; i < channel_size ; i++) {
1919  if ( ! ( m_fcal_idhelper->is_lar_fcal( chid ) ) ) continue;
1920  Identifier SCID = scidtool->offlineToSuperCellID(chid);
1921  if ( scidset.find(SCID) == scidset.end() )
1922  scidset.insert(SCID);
1923  else continue;
1924  HWIdentifier hwid = cabling->createSignalChannelID(chid);
1925  of3 << chid.get_identifier32().get_compact() << "\t0x" <<
1926  SCID.get_identifier32().get_compact() << "\t0x" <<
1927  hwid.get_identifier32().get_compact() ;
1928  int samp = 0;
1929  int feedthrough = m_online_idhelper->feedthrough( hwid );
1930  int bar_ec = m_online_idhelper->barrel_ec( hwid );
1931  int pos_neg = m_online_idhelper->pos_neg( hwid );
1932  int slot = m_online_idhelper->slot( hwid );
1933  of3 << std::dec << "\t" << feedthrough << "\t" << slot;
1934  of3 << "\t" << bar_ec << " " << pos_neg << "\t\t" << samp << "\t";
1935  HWIdentifier feb_id = m_online_idhelper->feb_Id(hwid);
1936  int sslot=1;
1937  HWIdentifier sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot);
1938  if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) {
1939  sfeb_id = m_sonline_idhelper->feb_Id(bar_ec,pos_neg,feedthrough,sslot+1);
1940  }
1941  if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1942  sslot_schannel_idx[sfeb_id]=0;
1943  else sslot_schannel_idx[sfeb_id]++;
1944  HWIdentifier shwid = m_sonline_idhelper->channel_Id(sfeb_id,sslot_schannel_idx[sfeb_id]);
1945  unsigned int onl_hash = m_sonline_idhelper->channel_Hash( shwid ).value();
1946  if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1947  if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1948  unsigned int off_hash = m_scell_idhelper->calo_cell_hash( SCID ).value();
1949  if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1950  if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1951  of3 << std::hex;
1952  of3 << feb_id.get_identifier32().get_compact();
1953  of3 << "\t0x" << shwid.get_identifier32().get_compact();
1954  of3 << " " << m_online_idhelper->channel_name(hwid) << " " << m_sonline_idhelper->channel_name(shwid);
1955  of3 << std::dec;
1956  of3 << " " << onl_hash << " " << off_hash;
1957  of3 << std::endl;
1958 
1959  OrderOffHash_OnlID[m_scell_idhelper->calo_cell_hash( SCID ).value()] = shwid.get_identifier32().get_compact();
1960  OrderOnlHash_OffID[m_sonline_idhelper->channel_Hash( shwid ).value()] = SCID.get_identifier32().get_compact();
1961  }
1962 
1963  of3 << "Hash check. Onl : " << min_onl_hash << " " << max_onl_hash;
1964  of3 << "; Off : " << min_off_hash << " " << max_off_hash << std::endl;;
1965  of3.close();
1966 
1967 
1968 
1969  const uint32_t onlHashMax=m_sonline_idhelper->channelHashMax();
1970  coral::AttributeListSpecification *spec_onOff = new coral::AttributeListSpecification();
1971  spec_onOff->extend("OnlineHashToOfflineId", "blob");
1972  spec_onOff->extend<unsigned>("version");
1973  std::unique_ptr<AthenaAttributeList> al_onOff = std::make_unique<AthenaAttributeList>(*spec_onOff);
1974  coral::Blob& blobOnOff=(*al_onOff)["OnlineHashToOfflineId"].data<coral::Blob>();
1975  (*al_onOff)["version"].setValue(0U);
1976  blobOnOff.resize(onlHashMax*sizeof(uint32_t));
1977  uint32_t* pBlobOnOff=static_cast<uint32_t*>(blobOnOff.startingAddress());
1978  unsigned nConn=0;
1979 
1980  const uint32_t emptyId=Identifier().get_identifier32().get_compact();
1981  for(size_t ii=0;ii<onlHashMax;ii++) {
1982  if (OrderOnlHash_OffID[ii] != 0) {
1983  pBlobOnOff[ii]=OrderOnlHash_OffID[ii];
1984  nConn++;
1985  }
1986  else
1987  pBlobOnOff[ii]=emptyId;
1988  }
1989 
1990  ATH_MSG_INFO ( "HashMax=" << onlHashMax << ", connected=" << nConn );
1991 
1992  ATH_CHECK( detStore()->record(std::move(al_onOff),"/LAR/IdentifierOfl/OnOffIdMap_SC") );
1993 
1994  hashes << "idx \t Off2OnlId \t Onl2OffId" << std::endl;
1995  for(size_t ii=0;ii<40000;ii++)
1996  if ( (OrderOffHash_OnlID[ii] != 0) || ( OrderOnlHash_OffID[ii] != 0 ) )
1997  hashes << std::dec << ii << std::hex << " \t " << OrderOffHash_OnlID[ii] << " \t\t " << OrderOnlHash_OffID[ii] << std::endl;
1998  hashes.close();
1999 
2000  return StatusCode::SUCCESS;
2001 }
2002 
2004 
2005  ATH_MSG_INFO ( " in fix12() " );
2006 
2007  // Fix12 is for filling the MinBiasRMS and MinBiasAverage from ntuple
2008 
2009  // Will try to regenerate from scratch
2010  // Create new container
2011  std::unique_ptr<LArMinBiasMC> minbias = std::make_unique<LArMinBiasMC>();
2012  ATH_CHECK( minbias->setGroupingType("Single", msg()) );
2013  ATH_CHECK( minbias->initialize() );
2014  std::unique_ptr<LArMinBiasAverageMC> minbias_av = std::make_unique<LArMinBiasAverageMC>();
2015  ATH_CHECK( minbias_av->setGroupingType("Single", msg()) );
2016  ATH_CHECK( minbias_av->initialize() );
2017  //
2018  std::unique_ptr<TFile> fin= std::make_unique<TFile>("ntuple_av.root");
2019  TTree *tin=dynamic_cast<TTree*>(fin->Get("m_tree"));
2020  int ncell;
2021  int identifier[2862];
2022  int layer[2862];
2023  int region[2862];
2024  int ieta[2862];
2025  float eta[2862];
2026  double average[2862];
2027  double rms[2862];
2028  TBranch *b_ncell;
2029  TBranch *b_identifier;
2030  TBranch *b_layer;
2031  TBranch *b_region;
2032  TBranch *b_ieta;
2033  TBranch *b_eta;
2034  TBranch *b_average;
2035  TBranch *b_rms;
2036  tin->SetMakeClass(1);
2037  tin->SetBranchAddress("ncell", &ncell, &b_ncell);
2038  tin->SetBranchAddress("identifier", identifier, &b_identifier);
2039  tin->SetBranchAddress("layer", layer, &b_layer);
2040  tin->SetBranchAddress("region", region, &b_region);
2041  tin->SetBranchAddress("ieta", ieta, &b_ieta);
2042  tin->SetBranchAddress("eta", eta, &b_eta);
2043  tin->SetBranchAddress("average", average, &b_average);
2044  tin->SetBranchAddress("rms", rms, &b_rms);
2045  tin->GetEntry(0);
2046 
2047 
2048  for(int icell=0; icell<ncell; ++icell) {
2049 
2050  Identifier32 id32(identifier[icell]);
2051  Identifier id(id32);
2052  HWIdentifier hid = cabling->createSignalChannelID(id);
2053 
2054  minbias->set(hid, rms[icell]);
2055  minbias_av->set(hid, average[icell]);
2056 
2057  }
2058 
2059  ATH_MSG_INFO(" number of channels in intuple ="<<ncell);
2060 
2061  ATH_MSG_INFO ( "Stored container " << minbias->totalNumberOfConditions() << " conditions, key LArMinBias " );
2062  ATH_CHECK( detStore()->record(std::move(minbias),"LArMinBias") );
2063  ATH_CHECK( detStore()->symLink(minbias.get(), dynamic_cast<ILArMinBias*>(minbias.get())) );
2064  ATH_MSG_INFO ( "Stored container " << minbias_av->totalNumberOfConditions() << " conditions, key LArMinBiasAverage " );
2065  ATH_CHECK( detStore()->record(std::move(minbias_av),"LArMinBiasAverage") );
2066  ATH_CHECK( detStore()->symLink(minbias_av.get(), dynamic_cast<ILArMinBiasAverage*>(minbias_av.get())) );
2067 
2068  return StatusCode::SUCCESS;
2069 }
2070 
2072 
2073  ATH_MSG_INFO ( " in fix14() " );
2074 
2075  // Fix14 is for filling the LArPileupAverage from ntuple
2076 
2077  const ILArfSampl* larfSampl = nullptr;
2078  ATH_CHECK( detStore()->retrieve(larfSampl,"") );
2079  // Will try to regenerate from scratch
2080  // Create new container
2081  std::unique_ptr<LArMinBiasAverageMC> minbias_av = std::make_unique<LArMinBiasAverageMC>();
2082  ATH_CHECK( minbias_av->setGroupingType("Single", msg()) );
2083  ATH_CHECK( minbias_av->initialize() );
2084  //
2085  std::unique_ptr<TFile> fin= std::make_unique<TFile>(m_infile.value().c_str());
2086  TTree *tin=dynamic_cast<TTree*>(fin->Get("m_tree"));
2087  int ncell;
2088  int identifier[2862];
2089  int layer[2862];
2090  int region[2862];
2091  int ieta[2862];
2092  float eta[2862];
2093  double average[2862];
2094  double rms[2862];
2095  TBranch *b_ncell;
2096  TBranch *b_identifier;
2097  TBranch *b_layer;
2098  TBranch *b_region;
2099  TBranch *b_ieta;
2100  TBranch *b_eta;
2101  TBranch *b_average;
2102  TBranch *b_rms;
2103  tin->SetMakeClass(1);
2104  tin->SetBranchAddress("ncell", &ncell, &b_ncell);
2105  tin->SetBranchAddress("identifier", identifier, &b_identifier);
2106  tin->SetBranchAddress("layer", layer, &b_layer);
2107  tin->SetBranchAddress("region", region, &b_region);
2108  tin->SetBranchAddress("ieta", ieta, &b_ieta);
2109  tin->SetBranchAddress("eta", eta, &b_eta);
2110  tin->SetBranchAddress("average", average, &b_average);
2111  tin->SetBranchAddress("rms", rms, &b_rms);
2112  tin->GetEntry(0);
2113 
2114 
2115  for(int icell=0; icell<ncell; ++icell) {
2116 
2117  Identifier32 id32(identifier[icell]);
2118  Identifier id(id32);
2119  HWIdentifier hid = cabling->createSignalChannelID(id);
2120  float fsampl = larfSampl->FSAMPL(hid);
2121  minbias_av->set(hid, 6.31*average[icell]/fsampl);
2122 
2123  }
2124 
2125  ATH_MSG_INFO(" number of channels in intuple ="<<ncell);
2126 
2127  ATH_MSG_INFO ( "Stored container " << minbias_av->totalNumberOfConditions() << " conditions, key LArPileupAverage " );
2128  ATH_CHECK( detStore()->record(std::move(minbias_av),"LArPileupAverage") );
2129  ATH_CHECK( detStore()->symLink(minbias_av.get(), dynamic_cast<ILArMinBiasAverage*>(minbias_av.get())) );
2130 
2131  return StatusCode::SUCCESS;
2132 }
2133 
2134 StatusCode FixLArElecCalib::fix15 ATLAS_NOT_THREAD_SAFE () {
2135 
2136  ATH_MSG_INFO ( " in fix15 " );
2137 
2138  // this method updates the EM MinBias
2139  // input is the text file.
2140 
2141  const LArMinBiasAverageMC * minbias_c = nullptr;
2142  ATH_CHECK( detStore()->retrieve(minbias_c,"LArPileupAverage") );
2143  LArMinBiasAverageMC* minbias = const_cast<LArMinBiasAverageMC*>(minbias_c);
2144 
2145 
2146  // here some iterator loop is needed
2147  int n=0;
2148 
2151 
2152  for(;it!=it_e;++it){
2153  HWIdentifier hid = it.channelId();
2154  const LArMinBiasAverageComplete::LArCondObj & u = (*it);
2155 
2156  ATH_MSG_INFO(" Old pileup = "<< u.m_MinBiasAverage<< " " );
2157 
2159 
2160  u2.m_MinBiasAverage *= 1.0838; // correction value
2161 
2162 
2163  const LArMinBiasAverageComplete::LArCondObj & t3 = minbias->get(hid,0);
2164  ATH_MSG_INFO(" New Pileup = "<< t3.m_MinBiasAverage<< " " );
2165 
2166  }
2167 
2168  ATH_MSG_INFO(" Number of entries changes = " <<n );
2169  return StatusCode::SUCCESS;
2170 }
2171 
2172 StatusCode FixLArElecCalib::fix16 ATLAS_NOT_THREAD_SAFE () {
2173 
2174  ATH_MSG_INFO ( " in fix16() " );
2175 
2176  std::string onOffIdKey="/LAR/Identifier/OnOffIdMap";
2177  const AthenaAttributeList *attrOnOff=nullptr;
2178  StatusCode sc=detStore()->retrieve(attrOnOff,onOffIdKey);
2179  if (sc.isFailure()) {
2180  ATH_MSG_ERROR("Failed to read AthenaAttributeList with key " << onOffIdKey);
2181  return StatusCode::FAILURE;
2182  }
2183  const coral::Blob& blobOnOff=(*attrOnOff)["OnlineHashToOfflineId"].data<coral::Blob>();
2184  unsigned nChan=blobOnOff.size()/sizeof(uint32_t);
2185  uint32_t* pBlobOnOff=const_cast<uint32_t*>(static_cast<const uint32_t*>(blobOnOff.startingAddress()));
2186 
2187 
2188  if (nChan!=m_online_idhelper->channelHashMax()) {
2189  ATH_MSG_WARNING("Number of channels read from DB (" << nChan << ") does not match online hash max ("
2190  <<m_online_idhelper->channelHashMax() << ")");
2191  nChan=std::min(nChan,static_cast<unsigned int>(m_online_idhelper->channelHashMax()));
2192  }
2193  std::vector<std::pair<unsigned int, unsigned int> > swapindex(8, std::make_pair(nChan+10,nChan+10)); // here we store, which indexes to swap
2194  // loop over all online hashes
2195  for (unsigned i=0;i<nChan;++i) {
2196  const HWIdentifier hwid = m_online_idhelper->channel_Id(IdentifierHash(i));
2197  if(m_online_idhelper->isEMECchannel(hwid) && m_online_idhelper->pos_neg(hwid) == 1 && m_online_idhelper->feedthrough(hwid) == 7 && m_online_idhelper->slot(hwid) == 11) { //EMEC-A FT 7, Slot 11
2198  if(m_online_idhelper->channel(hwid)>=96 && m_online_idhelper->channel(hwid)<=103) swapindex[m_online_idhelper->channel(hwid)-96].first=i;
2199  if(m_online_idhelper->channel(hwid)>=112 && m_online_idhelper->channel(hwid)<=129) swapindex[m_online_idhelper->channel(hwid)-112].second=i;
2200  }
2201  }
2202  for(unsigned i=0; i<8; ++i) {
2203  }
2204  // now do swaping
2205  for(unsigned i=0; i<8; ++i) {
2206  // check consistency of swapindex
2207  if (swapindex[i].first > nChan || swapindex[i].second > nChan ) {
2208  ATH_MSG_ERROR("Problem in swapindex: "<< i << " : " << swapindex[i].first << " " << swapindex[i].second);
2209  return StatusCode::FAILURE;
2210  }
2211  uint32_t id = pBlobOnOff[swapindex[i].first];
2212  pBlobOnOff[swapindex[i].first] = pBlobOnOff[swapindex[i].second];
2213  pBlobOnOff[swapindex[i].second] = id;
2214  }
2215  // and now record the changed blob to SG
2216  ATH_CHECK(detStore()->record(const_cast<AthenaAttributeList *>(attrOnOff),"/LAR/Identifier/OnOffIdMapNew"));
2217 
2218  return StatusCode::SUCCESS;
2219 }
2220 
2221 StatusCode FixLArElecCalib::fix17 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling) {
2222 
2223  ATH_MSG_INFO ( " in fix17() " );
2224 
2225  // withGain , nvar
2226  ATH_CHECK( update_All<LArShape32MC>(m_infile.value(), cabling, true, 32 ) );
2227 
2228  return StatusCode::SUCCESS;
2229 }
2230 
2232 
2233  ATH_MSG_INFO ( " in fix18() " );
2234 
2235  const uint32_t onlHashMax=m_online_idhelper->channelHashMax();
2236 
2237  coral::AttributeListSpecification* spec_calib = new coral::AttributeListSpecification();
2238  spec_calib->extend("OnlineHashToCalibIds", "blob");
2239  spec_calib->extend<unsigned>("version");
2240  std::unique_ptr<AthenaAttributeList> al_calib = std::make_unique<AthenaAttributeList>(*spec_calib);
2241  coral::Blob& blobCalib=(*al_calib)["OnlineHashToCalibIds"].data<coral::Blob>();
2242  (*al_calib)["version"].setValue(0U);
2243  blobCalib.resize(onlHashMax*sizeof(uint32_t)*4); //Bigger than necessary
2244 
2245  spec_calib->release();
2246  // cppcheck-suppress memleak
2247  spec_calib = nullptr;
2248 
2249  uint32_t* pBlobCalib=static_cast<uint32_t*>(blobCalib.startingAddress());
2250  size_t calibIndex=0;
2251 
2252 
2253  // loop over all online hashes
2254  for (unsigned i=0;i<onlHashMax;++i) {
2256 
2257  const std::vector<HWIdentifier>& calibIDs=cabling->calibSlotLine(hwid);
2258  const size_t nCalibLines=calibIDs.size();
2259 
2260  if (m_online_idhelper->isEMBchannel(hwid) && m_online_idhelper->pos_neg(hwid) == 1 && m_online_idhelper->feedthrough(hwid) == 0 ) { // EMB-A FT 0
2261  if(nCalibLines > 1) { //should not be in our channels
2262  ATH_MSG_ERROR("Wrong number of CL in our channels");
2263  return StatusCode::FAILURE;
2264  }
2265  if(nCalibLines==0) {
2266  pBlobCalib[calibIndex++]=0;
2267  } else {
2268  const HWIdentifier cmodule = m_online_idhelper->calib_module_Id(calibIDs[0]);
2269  const HWIdentifier newcl = m_online_idhelper->calib_channel_Id(cmodule, m_online_idhelper->channel(hwid) );
2270  if(!m_online_idhelper->isCalibration(newcl)) {
2271  ATH_MSG_ERROR("Something wrong, new CL not a calibration");
2272  ATH_MSG_ERROR("Channel: "<<hwid.get_identifier32().get_compact()<<" old CL: "<< calibIDs[0].get_identifier32().get_compact()<<" new CL: "<<newcl.get_identifier32().get_compact());
2273  return StatusCode::FAILURE;
2274  }
2275  ATH_MSG_INFO("Channel: "<<hwid.get_identifier32().get_compact()<<" old CL: "<< calibIDs[0].get_identifier32().get_compact()<<" new CL: "<<newcl.get_identifier32().get_compact());
2276  pBlobCalib[calibIndex++]=1;
2277  pBlobCalib[calibIndex++]=newcl.get_identifier32().get_compact();
2278  }
2279  } else {
2280  pBlobCalib[calibIndex++]=nCalibLines;
2281  for(uint32_t iCalib=0;iCalib<nCalibLines;++iCalib)
2282  pBlobCalib[calibIndex++]=calibIDs[iCalib].get_identifier32().get_compact();
2283  }
2284  }
2285  blobCalib.resize(calibIndex*sizeof(uint32_t)); //Size down to actual size
2286  ATH_MSG_INFO( "BlobSize CalibId:" << calibIndex);
2287 
2288  // and now record the blob to SG
2289  ATH_CHECK(detStore()->record(std::move(al_calib),"/LAR/Identifier/CalibIdMap_EMF"));
2290 
2291  return StatusCode::SUCCESS;
2292 }
python.root_lsr_rank.hashes
hashes
Definition: root_lsr_rank.py:34
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
FixLArElecCalib::ReadFileAll
StatusCode ReadFileAll(const std::string &filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
Definition: FixLArElecCalib.cxx:1213
Identifier32
Definition: Identifier32.h:25
LArEM_Base_ID::phi
int phi(const Identifier id) const
return phi according to :
FixLArElecCalib.h
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1632
LArConditionsContainer::setPdata
void setPdata(const HWIdentifier id, const T &payload, unsigned int gain=0)
put payload in persistent data
LArRampP1::isEmpty
bool isEmpty() const
Definition: LArRampP1.h:29
LArEM_ID.h
FixLArElecCalib::m_fixFlag
IntegerProperty m_fixFlag
Definition: FixLArElecCalib.h:73
LAruA2MeVMC
Implementation of the interface ILAruA2MeV for MC Derives from LAruA2MeVComplete, and implements the ...
Definition: LAruA2MeVMC.h:22
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
LArHEC_Base_ID::eta
int eta(const Identifier id) const
return eta [0,9] outer part [0,3] inner part
LArMphysOverMcalMC::initialize
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
Definition: LArMphysOverMcalMC.cxx:13
run.infile
string infile
Definition: run.py:13
WriteCellNoiseToCool.icell
icell
Definition: WriteCellNoiseToCool.py:339
ATLAS_NOT_THREAD_SAFE
StatusCode FixLArElecCalib::stop ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: FixLArElecCalib.cxx:158
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
drawFromPickle.average
def average(lst)
Definition: drawFromPickle.py:38
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArConditionsContainer< LArRampP1 >::LArCondObj
LArRampP1 LArCondObj
Definition: LArConditionsContainer.h:69
LArConditionsContainerBase::SingleGroup
@ SingleGroup
Definition: LArConditionsContainerBase.h:46
AtlasDetectorID::is_lar_fcal
bool is_lar_fcal(Identifier id) const
Definition: AtlasDetectorID.h:834
python.ZdcOnlineRecMonitorConfig.pn
pn
Definition: ZdcOnlineRecMonitorConfig.py:341
FixLArElecCalib::initialize
virtual StatusCode initialize() override
Definition: FixLArElecCalib.cxx:125
LArRampMC
Implementation of the interface ILArRamp for MC Derives from LArRampComplete, and implements the phi-...
Definition: LArRampMC.h:22
LArFCAL_Base_ID::pos_neg
int pos_neg(const Identifier id) const
pos_neg : +/- 2 (A/C side)
CaloIDHelper::channel_hash_max
size_type channel_hash_max() const
One more than the largest channel (cell) hash code.
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LArEM_Base_ID::is_em_endcap_outer
bool is_em_endcap_outer(const Identifier id) const
test if the id belongs to the EM Endcap outer wheel
LArEM_Base_ID::region_hash
IdentifierHash region_hash(Identifier regionId) const
Convert a connected region Identifier to a hash code.
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
LAruA2MeVMC.h
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
LArMinBiasMC.h
LUCID_EventTPCnv_Dict::t3
std::vector< LUCID_RawData_p1 > t3
Definition: LUCID_EventTPCnvDict.h:28
LArSingleFloatP
Definition: LArSingleFloatP.h:11
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
LArEM_Base_ID::region_id
Identifier region_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
LArConditionsContainerDB::iteratorT
Declaration of const iterator.
Definition: LArConditionsContainerDB.h:72
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
LArRampP1
Persistent data for LArRamp Copied from LAr.
Definition: LArRampP1.h:24
LArCalibLineMapping
Definition: LArCalibLineMapping.h:17
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
skel.it
it
Definition: skel.GENtoEVGEN.py:407
LArAutoCorrP1
c-struct reproducing the structure of the persistent data
Definition: LArAutoCorrP1.h:25
python.SystemOfUnits.second
float second
Definition: SystemOfUnits.py:135
LArMinBiasAverageComplete::set
void set(const HWIdentifier &CellID, float vMinBiasAverage)
Definition: LArMinBiasAverageComplete.cxx:13
LArOnlineID_Base::slot
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
Definition: LArOnlineID_Base.cxx:1957
LArDAC2uAMC.h
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
LArFCAL_Base_ID::module
int module(const Identifier id) const
module [1,3]
ParticleTest.tp
tp
Definition: ParticleTest.py:25
LArEM_Base_ID::region
int region(const Identifier id) const
return region according to :
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
athena.value
value
Definition: athena.py:124
LArEM_Base_ID::sampling
int sampling(const Identifier id) const
return sampling according to :
ILArMinBiasAverage
Definition: ILArMinBiasAverage.h:13
FixLArElecCalib::m_sonline_idhelper
const LArOnline_SuperCellID * m_sonline_idhelper
Definition: FixLArElecCalib.h:132
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
LArOnlineID_Base::calib_module_Id
HWIdentifier calib_module_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Build calibration module identifier from fields.
Definition: LArOnlineID_Base.h:575
FixLArElecCalib::m_hec_idhelper
const LArHEC_ID * m_hec_idhelper
Definition: FixLArElecCalib.h:127
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
FixLArElecCalib::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: FixLArElecCalib.h:70
FixLArElecCalib::m_fcal_idhelper
const LArFCAL_ID * m_fcal_idhelper
Definition: FixLArElecCalib.h:128
xAOD::identifier
identifier
Definition: UncalibratedMeasurement_v1.cxx:15
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
LArOnlineID_Base::barrel_ec
int barrel_ec(const HWIdentifier id) const
Return the position barrel or endcap of a hardware cell identifier: barrel_ec = [0,...
Definition: LArOnlineID_Base.cxx:1938
x
#define x
LArHEC_Base_ID::region_id
Identifier region_id(const ExpandedIdentifier &exp_id) const
region identifier for a channel from ExpandedIdentifier
AthenaAttributeList.h
LArEM_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
FixLArElecCalib::m_shec_idhelper
const LArHEC_SuperCell_ID * m_shec_idhelper
Definition: FixLArElecCalib.h:131
ICaloSuperCellIDTool.h
LArEM_Base_ID::eta
int eta(const Identifier id) const
return eta according to :
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArMinBiasAverageMC::initialize
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
Definition: LArMinBiasAverageMC.cxx:10
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArRampP1::m_vRamp
std::vector< float > m_vRamp
Definition: LArRampP1.h:30
LArOnlineID_Base::channelHashMax
size_type channelHashMax() const
Define channel hash tables max size.
Definition: LArOnlineID_Base.cxx:1897
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
LArConditionsContainer::totalNumberOfConditions
unsigned int totalNumberOfConditions() const
Statistics: total number of conditions.
python.PyAthena.module
module
Definition: PyAthena.py:131
LArFCAL_Base_ID::phi
int phi(const Identifier id) const
phi [0,15]
LArOnlineID_Base::channel
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
Definition: LArOnlineID_Base.cxx:1963
LArMinBiasMC
Implementation of the interface ILArMinBias for MC Derives from LArMinBiasComplete,...
Definition: LArMinBiasMC.h:19
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
Ringer::EM
@ EM
Definition: CaloRingsDefs.h:19
LArConditionsContainer::end
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
FixLArElecCalib::m_em_idhelper
const LArEM_ID * m_em_idhelper
Definition: FixLArElecCalib.h:126
LArMinBiasAverageP
c-struct reproducing the structure of the persistent data
Definition: LArMinBiasAverageP.h:15
FixLArElecCalib::m_sem_idhelper
const LArEM_SuperCell_ID * m_sem_idhelper
Definition: FixLArElecCalib.h:130
CaloIDHelper::etaGranularity
float etaGranularity(const IdentifierHash regHash) const
Return the eta granularity of a region, or NOT_VALID.
Definition: CaloIDHelper.cxx:185
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArRampMC.h
beamspotman.n
n
Definition: beamspotman.py:727
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
LArShapeP1
c-struct reproducing the structure of the persistent data
Definition: LArShapeP1.h:16
LArConditionsContainer::get
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
ILArfSampl::FSAMPL
virtual const float & FSAMPL(const HWIdentifier &id) const =0
LArfSamplMC
Implementation of the interface ILArfSampl for MC Derives from LArfSamplComplete, and implements the ...
Definition: LArfSamplMC.h:23
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LArFCAL_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
FixLArElecCalib::m_online_idhelper
const LArOnlineID * m_online_idhelper
Definition: FixLArElecCalib.h:129
LArOnlineID_Base::channel_Id
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Definition: LArOnlineID_Base.cxx:1565
LArOnlineID_Base::pos_neg
int pos_neg(const HWIdentifier id) const
Return the side of a hardware cell identifier pos_neg = [0,1] positive-side or negative-side Barrel...
Definition: LArOnlineID_Base.cxx:1950
CaloCell_SuperCell_ID.h
Helper class for offline supercell identifiers.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArFCAL_Base_ID::fcal_end
id_iterator fcal_end() const
end iterator over full set of Fcal Identifiers for channels
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
LArfSamplMC.h
AtlasDetectorID::is_lar_hec
bool is_lar_hec(Identifier id) const
Definition: AtlasDetectorID.h:824
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
FixLArElecCalib::fix14
StatusCode fix14(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:2071
ILArMinBias
Definition: ILArMinBias.h:13
AthAlgorithm
Definition: AthAlgorithm.h:47
LArNoiseP
Definition: LArNoiseP.h:12
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:1479
LArShape32MC
This class implements the ILArShape interface.
Definition: LArShape32MC.h:27
ReadCellNoiseFromCool.ncell
ncell
Definition: ReadCellNoiseFromCool.py:197
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
AtlasDetectorID::print_to_string
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:422
FixLArElecCalib::set_object
void set_object(LArNoiseMC::LArCondObj &obj, const std::vector< float > &v)
Definition: FixLArElecCalib.cxx:1289
LArMinBiasMC::initialize
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
Definition: LArMinBiasMC.cxx:10
FixLArElecCalib::execute
virtual StatusCode execute() override
Definition: FixLArElecCalib.cxx:143
CaloIDHelper::eta0
float eta0(const IdentifierHash regHash) const
Return the minimum eta of region, or NOT_VALID.
Definition: CaloIDHelper.cxx:207
LArNoiseP::m_Noise
float m_Noise
Definition: LArNoiseP.h:16
ILArMphysOverMcal
Definition: ILArMphysOverMcal.h:13
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:239
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
LArAutoCorrMC.h
ILAruA2MeV::ERRORCODE
@ ERRORCODE
Definition: ILAruA2MeV.h:35
LArHEC_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
channel identifier for a channel from ExpandedIdentifier
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
FixLArElecCalib::print_object
void print_object(const std::string &msg, const LArNoiseMC::LArCondObj &obj)
Definition: FixLArElecCalib.cxx:1280
LArOnlineID_Base::isCalibration
bool isCalibration(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1783
IdentifierHash::value
value_type value() const
LArOnlineID_Base::isEMBchannel
bool isEMBchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1648
FixLArElecCalib::FixLArElecCalib
FixLArElecCalib(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FixLArElecCalib.cxx:111
LArEM_Base_ID::is_em_endcap_inner
bool is_em_endcap_inner(const Identifier id) const
test if the id belongs to the EM Endcap inner wheel
python.PyAthena.v
v
Definition: PyAthena.py:154
FixLArElecCalib::m_cache
VROW_t m_cache[3]
Definition: FixLArElecCalib.h:141
FixLArElecCalib::fix2
StatusCode fix2(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:294
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
LArMinBiasP
c-struct reproducing the structure of the persistent data
Definition: LArMinBiasP.h:15
LArOnlineID_Base::feedthrough
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
Definition: LArOnlineID_Base.cxx:1944
LArfSamplP
c-struct reproducing the structure of the persistent data
Definition: LArfSamplP.h:20
Muon::nsw::channel_type
channel_type
Definition: NSWDecodeHelper.h:21
CaloIDHelper::phi0
float phi0(const IdentifierHash regHash) const
Return the minimum phi of region, or NOT_VALID.
Definition: CaloIDHelper.cxx:218
LArEM_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
FixLArElecCalib::fix13
StatusCode fix13(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:1732
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArShape32MC.h
DeMoScan.first
bool first
Definition: DeMoScan.py:534
DEBUG
#define DEBUG
Definition: page_access.h:11
LArHEC_Base_ID::sampling
int sampling(const Identifier id) const
return sampling [0,3] (only 0 for supercells)
FixLArElecCalib::fix18
StatusCode fix18(const LArCalibLineMapping *clmap)
Definition: FixLArElecCalib.cxx:2231
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArFCAL_Base_ID::fcal_begin
id_iterator fcal_begin() const
begin iterator over full set of Fcal Identifiers for channels
FixLArElecCalib::ROW_t
std::pair< HWIdentifier, std::vector< float > > ROW_t
Definition: FixLArElecCalib.h:138
LArConditionsContainer::begin
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1265
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
FixLArElecCalib::fix1
StatusCode fix1(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:218
FixLArElecCalib::ReadFile
StatusCode ReadFile(const std::string &filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar)
Definition: FixLArElecCalib.cxx:1141
LArDAC2uAMC
Implementation of the interface ILArDAC2uA for MC Derives from LArDAC2uAComplete, and implements the ...
Definition: LArDAC2uAMC.h:21
LArMinBiasAverageMC.h
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
LArOnline_SuperCellID.h
compute_lumi.fin
fin
Definition: compute_lumi.py:19
LArAutoCorrComplete::LArCondObj
LArAutoCorrP1 LArCondObj
Definition: LArAutoCorrComplete.h:31
FixLArElecCalib::addMphysOverMcal
StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:1423
LArEM_ID
Helper class for LArEM offline identifiers.
Definition: LArEM_ID.h:118
LArSingleFloatP::m_data
float m_data
Definition: LArSingleFloatP.h:18
FixLArElecCalib::fix12
StatusCode fix12(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:2003
CaloIDHelper::phiGranularity
float phiGranularity(const IdentifierHash regHash) const
Return the phi granularity of a region, or NOT_VALID.
Definition: CaloIDHelper.cxx:196
LArAutoCorrP1::m_vAutoCorr
std::vector< float > m_vAutoCorr
Definition: LArAutoCorrP1.h:31
FixLArElecCalib::m_CLKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
Definition: FixLArElecCalib.h:71
Identifier::size_type
unsigned long long size_type
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:29
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
LArNoiseMC
Implementation of the interface ILArNoise for MC Derives from LArNoiseComplete, and implements the ph...
Definition: LArNoiseMC.h:20
LArMinBiasAverageMC
Implementation of the interface ILArMinBiasAverage for MC Derives from LArMinBiasAverageComplete,...
Definition: LArMinBiasAverageMC.h:19
LArOnlineID_Base::channel_name
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
Definition: LArOnlineID_Base.cxx:221
python.PyAthena.obj
obj
Definition: PyAthena.py:132
LArFCAL_ID
Helper class for LArFCAL offline identifiers.
Definition: LArFCAL_ID.h:60
FixLArElecCalib::m_infile
StringProperty m_infile
Definition: FixLArElecCalib.h:75
ILArDAC2uA::ERRORCODE
@ ERRORCODE
Definition: ILArDAC2uA.h:37
LArOnlineID_Base::calib_channel_Id
HWIdentifier calib_channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create calibration channel identifiers from fields
Definition: LArOnlineID_Base.h:624
StoreGateSvc.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
CaloIDHelper::region_hash
IdentifierHash region_hash(Identifier regionId) const
Convert a connected region Identifier to a hash code.
LArAutoCorrMC
Implementation of the interface ILArAutoCorr for MC Derives from LArAutoCorrComplete,...
Definition: LArAutoCorrMC.h:24
WriteCellNoiseToCool.noise
noise
Definition: WriteCellNoiseToCool.py:380
LArMinBiasComplete::set
void set(const HWIdentifier &CellID, float vMinBiasRMS)
Definition: LArMinBiasComplete.cxx:18
LArNoiseMC.h
LArEM_Base_ID::is_em_endcap
bool is_em_endcap(const Identifier id) const
test if the id belongs to the EM Endcap
LArMinBiasAverageP::m_MinBiasAverage
float m_MinBiasAverage
Definition: LArMinBiasAverageP.h:20
LArOnlineID.h
ILArfSampl
Definition: ILArfSampl.h:14
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65
LArHEC_Base_ID::phi
int phi(const Identifier id) const
return phi[0,63] outer part [0,31] inner part
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
FixLArElecCalib::m_scell_idhelper
const CaloCell_SuperCell_ID * m_scell_idhelper
Definition: FixLArElecCalib.h:133
Identifier
Definition: IdentifierFieldParser.cxx:14