ATLAS Offline Software
FixLArIdMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
181 #include "GaudiKernel/Algorithm.h"
182 #include "GaudiKernel/MsgStream.h"
183 #include "Gaudi/Property.h"
184 #include "GaudiKernel/IToolSvc.h"
185 
186 #include "StoreGate/StoreGateSvc.h"
187 #include "LArCabling/LArCablingService.h"
189 #include "LArTools/LArOnOffIdMap.h"
190 #include "LArTools/LArFebRodMap.h"
192 
193 #include <fstream>
194 
195 FixLArIdMap::FixLArIdMap(const std::string& name, ISvcLocator* pSvcLocator) :
196  AthAlgorithm(name,pSvcLocator) ,m_fixFlag(0), m_dumpIds(false)
197 {
198 
199  declareProperty("FixFlag", m_fixFlag);
200  declareProperty("FEBtoRODMap", m_febToRodMap);
201  declareProperty("DumpIds", m_dumpIds);
202 
203  //std::cout<<" In FixLArIdMap constructor"<<std::endl;
204 }
205 
207 { }
208 
210  return StatusCode::SUCCESS;
211 }
212 
214 {
215  ATH_MSG_DEBUG(" in execute, fix = "<<m_fixFlag );
216  return StatusCode::SUCCESS;
217 }
218 
220 {
221  ATH_MSG_INFO(" in finalize, fix = "<<m_fixFlag );
222 
223  if(m_dumpIds) dumpId();
224 
225  if(m_fixFlag==1)
226  return fix1();
227 
228  if(m_fixFlag==2)
229  return fix2();
230 
231  if(m_fixFlag==3)
232  return fix3();
233 
234  if(m_fixFlag==4)
235  return fix4();
236 
237  if(m_fixFlag==5)
238  return fix5();
239 
240  if(m_fixFlag==6)
241  return fix6();
242 
243  if(m_fixFlag==7)
244  return fix7();
245 
246  if(m_fixFlag==8)
247  return fix8();
248 
249  if(m_fixFlag==9)
250  return fix9();
251 
252  if(m_fixFlag==10)
253  return fix10();
254 
255  if(m_fixFlag==11)
256  return fix11();
257 
258  if(m_fixFlag==12)
259  return fix12();
260 
261  return StatusCode::SUCCESS;
262 
263 }
264 
266 {
267  // Fix the FCal Map.
268  // The jobs should be run with LAr IdDict for the new Identifier
269  // definition, i.e., No slot=8 for FCAL (1-7, 9-15).
270 
271  // fix calibLine for Strip eta=0 in barrel
272 
273  // LArOnOffIdMap
274  const LArOnOffIdMap * onOffIdMap_c;
275  sc=detStore()->retrieve(onOffIdMap_c);
276  if(sc!=StatusCode::SUCCESS){
277  ATH_MSG_ERROR(" Can not find LArOnOffIdMap" );
278  // return sc;
279  }
280  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
281 
282  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
283 
284  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
285 
286 
287  VONOFF::const_iterator it = onOffId_P->m_v.begin();
288  VONOFF::const_iterator it_e = onOffId_P->m_v.end();
289 
290  ATH_MSG_DEBUG(" Dump of OnOffIdMap" );
291  ATH_MSG_DEBUG(" Persistent LArOnOffId_P version = "<<onOffId_P->m_version );
292  for (; it!=it_e;++it)
293  {
294  const LArOnOffId_P::LArOnOffId_P_t& t = *it;
295  ATH_MSG_DEBUG(" det="<<t.det
296  <<" pn="<<t.pn
297  <<" sample="<<t.sample
298  <<" region="<<t.region
299  <<" eta="<<t.eta
300  <<" phi="<<t.phi
301  <<" ft="<<t.ft_num
302  <<" slot="<<t.feb_slot
303  <<" chan="<<t.feb_chan
304  <<" calib_slot="<<t.calib_slot
305  <<" calib_line="<<t.calib_line );
306  }
307 
308 
309  // LArFebRodMap
310 
311  const LArFebRodMap * febRodMap_c;
312  sc=detStore->retrieve(febRodMap_c);
313  if(sc!=StatusCode::SUCCESS){
314  ATH_MSG_ERROR(" Can not find LArFebRodMap" );
315  // return sc;
316  }
317 
318  LArFebRodMap* febRodMap=const_cast<LArFebRodMap*>(febRodMap_c);
319 
320  LArFebRod_P* febRod_P = febRodMap->getP();
321 
322  typedef std::vector<LArFebRod_P::LArFebRod_P_t> VFEBROD;
323 
324 
325  VFEBROD::const_iterator it2 = febRod_P->m_v.begin();
326  VFEBROD::const_iterator it2_e = febRod_P->m_v.end();
327 
328  ATH_MSG_DEBUG(" Dump of LArFebRodMap" );
329  ATH_MSG_DEBUG(" Persistent LArFebRod_P version = "<< febRod_P->m_version );
330 
331  for (; it2!=it2_e;++it2)
332  {
333  const LArFebRod_P::LArFebRod_P_t& t = *it2;
334  ATH_MSG_DEBUG(" hashid="<<t.hashid
335  <<" det="<<t.det
336  <<" rosfrag="<<t.rosfrag
337  <<" robfrag="<<t.robfrag
338  <<" rodfrag="<<t.rodfrag
339  <<" rodcrate="<<t.rodcrate
340  <<" rodslot="<<t.rodslot
341  <<" ft_det="<<t.ft_det
342  <<" ft_pn="<<t.ft_pn
343  <<" ft_num="<<t.ft_num
344  <<" ft_slot="<<t.ft_slot );
345  }
346 
347  return;
348 
349 }
350 
352 
353 
354  // Fix the FCal Map.
355  // The jobs should be run with LAr IdDict for the new Identifier
356  // definition, i.e., No slot=8 for FCAL (1-7, 9-15).
357 
358  // fix calibLine for Strip eta=0 in barrel
359 
360 /*
361  // retrieve LArOnlineID
362  LArOnlineID* onlineID;
363  sc = detStore()->retrieve(onlineID);
364  if (sc.isFailure()) {
365  log << MSG::ERROR
366  << "Unable to retrieve pointer to LArOnlineID "
367  << endmsg;
368  return sc;
369  }
370  log << MSG::DEBUG << "Retrieved LArOnlineID" << endmsg;
371 
372  // retrieve DetDescrManager and LArCablingService
373  IToolSvc* toolSvc;
374  if( service("ToolSvc", toolSvc) != StatusCode::SUCCESS){
375  log<< MSG::ERROR <<" Failed to get ToolSvc" <<endmsg;
376  // return StatusCode::FAILURE ;
377  return;
378  }
379 
380 
381  if(StatusCode::SUCCESS != toolSvc->retrieveTool("LArCablingService",m_cablingSvc) ) {
382  log<< MSG::ERROR <<" Failed to get LArCablingService" <<endmsg;
383  // return StatusCode::FAILURE ;
384  return;
385  }
386 */
387 
388  // LArOnOffIdMap
389  const LArOnOffIdMap * onOffIdMap_c;
390  sc=detStore()->retrieve(onOffIdMap_c);
391  if(sc!=StatusCode::SUCCESS){
392  ATH_MSG_ERROR(" Can not find LArOnOffIdMap" );
393  // return sc;
394  }
395  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
396 
397  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
398 
399  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
400 
401 
402  if( onOffId_P->m_version!=0){
403  ATH_MSG_ERROR(" The FCAL Fix should only be done toversion=0" );
404  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
405  return StatusCode::FAILURE;
406  }
407 
408  VONOFF::iterator it = onOffId_P->m_v.begin();
409  VONOFF::iterator it_e = onOffId_P->m_v.end();
410 
411  // set the version to 1.
412  onOffId_P->m_version = 1 ;
413  for (; it!=it_e;++it)
414  {
415  LArOnOffId_P::LArOnOffId_P_t& t = *it;
416  if( t.det == 2 // FCAL connected channels
417  || t.det == 7 // FCAL disconnected channels
418  ){
419  unsigned int feb = t.feb_slot ;
420  if(feb>=8) {
421  ATH_MSG_INFO(" Fixing this FCAL channel, before and after" );
422 
423  ATH_MSG_DEBUG(" det="<<t.det
424  <<" pn="<<t.pn
425  <<" sample="<<t.sample
426  <<" region="<<t.region
427  <<" eta="<<t.eta
428  <<" phi="<<t.phi
429  <<" ft="<<t.ft_num
430  <<" slot="<<t.feb_slot
431  <<" chan="<<t.feb_chan
432  <<" calib_slot="<<t.calib_slot
433  <<" calib_line="<<t.calib_line );
434 
435  // The fix. shift it by one.
436  t.feb_slot=t.feb_slot+1;
437 
438  ATH_MSG_DEBUG(" det="<<t.det
439  <<" pn="<<t.pn
440  <<" sample="<<t.sample
441  <<" region="<<t.region
442  <<" eta="<<t.eta
443  <<" phi="<<t.phi
444  <<" ft="<<t.ft_num
445  <<" slot="<<t.feb_slot
446  <<" chan="<<t.feb_chan
447  <<" calib_slot="<<t.calib_slot
448  <<" calib_line="<<t.calib_line );
449 
450  }
451  } // FCAL
452 
453  if( t.det==9 && abs(t.pn)==1 && t.sample==1 && t.region==0 && t.eta==0 ) {
454 
455  ATH_MSG_INFO(" Fixing this Barrel Strip channel, before and after" );
456 
457  ATH_MSG_DEBUG(" det="<<t.det
458  <<" pn="<<t.pn
459  <<" sample="<<t.sample
460  <<" region="<<t.region
461  <<" eta="<<t.eta
462  <<" phi="<<t.phi
463  <<" ft="<<t.ft_num
464  <<" slot="<<t.feb_slot
465  <<" chan="<<t.feb_chan
466  <<" calib_slot="<<t.calib_slot
467  <<" calib_line="<<t.calib_line );
468 
469  // this disconnected channel is pulsed .
470  t.calib_slot=15;
471  t.calib_line=0;
472 
473  ATH_MSG_DEBUG(" det="<<t.det
474  <<" pn="<<t.pn
475  <<" sample="<<t.sample
476  <<" region="<<t.region
477  <<" eta="<<t.eta
478  <<" phi="<<t.phi
479  <<" ft="<<t.ft_num
480  <<" slot="<<t.feb_slot
481  <<" chan="<<t.feb_chan
482  <<" calib_slot="<<t.calib_slot
483  <<" calib_line="<<t.calib_line );
484 
485  } // barrel strip
486 
487 
488  } // channel loop
489 
490 
491  // LArFebRodMap
492  const LArFebRodMap * febRodMap_c;
493  sc=detStore()->retrieve(febRodMap_c);
494  if(sc!=StatusCode::SUCCESS){
495  ATH_MSG_ERROR(" Can not find LArFebRodMap" );
496  // return sc;
497  }
498 
499  LArFebRodMap* febRodMap=const_cast<LArFebRodMap*>(febRodMap_c);
500 
501  LArFebRod_P* febRod_P = febRodMap->getP();
502 
503  typedef std::vector<LArFebRod_P::LArFebRod_P_t> VFEBROD;
504 
505  VFEBROD::iterator it2 = febRod_P->m_v.begin();
506  VFEBROD::iterator it2_e = febRod_P->m_v.end();
507 
508  if(febRod_P->m_version!=0){
509 
510  ATH_MSG_ERROR(" wrong Persistent LArFebRod_P version = "<< febRod_P->m_version );
511  ATH_MSG_ERROR(" this fix should only fix version 0 " );
512  return StatusCode::FAILURE;
513  }
514 
515 
516  // increment the version
517  febRod_P->m_version = 1;
518 
519  for (; it2!=it2_e;++it2)
520  {
521  LArFebRod_P::LArFebRod_P_t& t = *it2;
522 
523  if( (t.det ==71 || t.det ==72 ) && t.ft_slot>=8 )
524  {
525 
526  ATH_MSG_INFO( " Fixing FEB slot number, before and after " );
527 
528  ATH_MSG_DEBUG(" hashid="<<t.hashid
529  <<" det="<<t.det
530  <<" rosfrag="<<t.rosfrag
531  <<" robfrag="<<t.robfrag
532  <<" rodfrag="<<t.rodfrag
533  <<" rodcrate="<<t.rodcrate
534  <<" rodslot="<<t.rodslot
535  <<" ft_det="<<t.ft_det
536  <<" ft_pn="<<t.ft_pn
537  <<" ft_num="<<t.ft_num
538  <<" ft_slot="<<t.ft_slot );
539 
540  t.ft_slot=t.ft_slot+1;
541  ATH_MSG_DEBUG(" hashid="<<t.hashid
542  <<" det="<<t.det
543  <<" rosfrag="<<t.rosfrag
544  <<" robfrag="<<t.robfrag
545  <<" rodfrag="<<t.rodfrag
546  <<" rodcrate="<<t.rodcrate
547  <<" rodslot="<<t.rodslot
548  <<" ft_det="<<t.ft_det
549  <<" ft_pn="<<t.ft_pn
550  <<" ft_num="<<t.ft_num
551  <<" ft_slot="<<t.ft_slot );
552  }
553 
554  }
555 
556 
557 
558  return StatusCode::SUCCESS;
559 }
560 
561 
562 
563 
565  // Fix the EMEC mapping
566  // both calibration channel, and signal.
567 
568 /*
569  // retrieve LArOnlineID
570  LArOnlineID* onlineID;
571  sc = detStore()->retrieve(onlineID);
572  if (sc.isFailure()) {
573  log << MSG::ERROR
574  << "Unable to retrieve pointer to LArOnlineID "
575  << endmsg;
576  return sc;
577  }
578  log << MSG::DEBUG << "Retrieved LArOnlineID" << endmsg;
579 
580  // retrieve DetDescrManager and LArCablingService
581  IToolSvc* toolSvc;
582  if( service("ToolSvc", toolSvc) != StatusCode::SUCCESS){
583  log<< MSG::ERROR <<" Failed to get ToolSvc" <<endmsg;
584  // return StatusCode::FAILURE ;
585  return;
586  }
587 
588 
589  if(StatusCode::SUCCESS != toolSvc->retrieveTool("LArCablingService",m_cablingSvc) ) {
590  log<< MSG::ERROR <<" Failed to get LArCablingService" <<endmsg;
591  // return StatusCode::FAILURE ;
592  return;
593  }
594 */
595 
596  // LArOnOffIdMap
597  const LArOnOffIdMap * onOffIdMap_c;
598  sc=detStore()->retrieve(onOffIdMap_c);
599  std::vector<int> nfixes;
600  nfixes.resize(30,0);
601 
602  if(sc!=StatusCode::SUCCESS){
603  ATH_MSG_ERROR(" Can not find LArOnOffIdMap" );
604  // return sc;
605  }
606  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
607 
608  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
609 
610  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
611 
612 
613  if( onOffId_P->m_version!=1){
614  ATH_MSG_ERROR(" This should only fix map with version=1" );
615  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
616  return StatusCode::FAILURE;
617  }
618 
619  VONOFF::iterator it = onOffId_P->m_v.begin();
620  VONOFF::iterator it_e = onOffId_P->m_v.end();
621 
622  // set the version to 2.
623  onOffId_P->m_version = 2 ;
624  for (; it!=it_e;++it)
625  {
626  LArOnOffId_P::LArOnOffId_P_t& t = *it;
627  int ifix = 0;
628  if( t.det == 0 ) // for EM (emec, actually)
629  {
630  if(t.pn==-2 || t.pn==-3) // Endcap-C
631  {
632 // FT3R Calib. ch : 2->60, 3->61 pn=-2, ft=7
633 // FT3L Calib. ch : 68->124 ,69->125 pn=-2, ft=8
634 // FT8L Calib. ch : 72->124, 73->125 pn=-2, ft=24
635  if(t.ft_num==7){
636  if( t.calib_line==2) {
637  t.calib_line=60;
638  ifix = 1;
639  }
640  if( t.calib_line==3) {
641  t.calib_line=61;
642  ifix = 2;
643  }
644  }
645  if(t.ft_num==8){
646  if( t.calib_line==68){
647  t.calib_line=124;
648  ifix = 3;
649  }
650  if( t.calib_line==69) {
651  t.calib_line=125;
652  ifix=4;
653  }
654 
655  }
656  if(t.ft_num==24){
657  if( t.calib_line==72) {
658  t.calib_line=124;
659  ifix = 5;
660  }
661 
662  if( t.calib_line==73) {
663  t.calib_line=125;
664  ifix = 6;
665  }
666  }
667 
668  }
669 
670  if(t.pn==2 || t.pn==3 ) // Endcap-A
671  {
672 // FT2L Calib. ch (slot CAL1): 0->108, 1->109 pn=2, ft=2
673 // (CalibModule is in FT2L, but the signal channels are in FT2R)
674 // FT9L Signal ch (ATI02, Slot L2): 122->124 pn=2, ft=16,slot=2
675 // FT11L Calib. ch : 64->60, 65->61, 66->124, 67->125 pn=2, ft=20
676 // FT13R Signal ch (ATI04, Slot FRT2): 88->64, 89->65, 90->66, 91->67,
677 // 92->68, 93->69, 94->70, 95->71 pn=2, ft=23,slot=4
678 
679 // calib line fix
680  if(t.ft_num==2){
681  if( t.calib_slot==4 && t.calib_line==0) {
682  t.calib_line=108;
683  ifix = 7;
684  }
685  if( t.calib_slot==4 && t.calib_line==1) {
686  t.calib_line=109;
687  ifix = 8;
688  }
689  }
690 
691 
692  if(t.ft_num==20){
693  if( t.calib_line==64) {
694  t.calib_line=60;
695  ifix = 9;
696  }
697  if( t.calib_line==65) {
698  t.calib_line=61;
699  ifix = 10;
700  }
701  if( t.calib_line==66) {
702  t.calib_line=124;
703  ifix = 11;
704  }
705  if( t.calib_line==67) {
706  t.calib_line=125;
707  ifix = 12;
708  }
709  }
710 
711 // signal channel
712 
713  if(t.ft_num==16 && t.feb_slot==2){
714  if(t.feb_chan==122){
715  t.feb_chan=124 ;
716  ifix = 13;
717  }
718  }
719 
720  if(t.ft_num==23 && t.feb_slot==4){
721  if(t.feb_chan>=64 && t.feb_chan<=71){
722  // 64-->88, etc
723  ifix = 14+ (t.feb_chan-64) ;
724  t.feb_chan= t.feb_chan+24 ;
725  }
726  }
727 
728  }
729  } //
730 
731  // disconnected channel
732  if( t.det == 9 ) // for EM disconnected (emec, actually)
733  {
734 
735  if(t.pn==2 || t.pn==3) // Endcap-C
736  {
737  if(t.ft_num==16 && t.feb_slot==2){
738  if(t.feb_chan==124){
739  t.feb_chan=122 ;
740  ifix = 22;
741  }
742  }
743  if(t.ft_num==23 && t.feb_slot==4){
744  if(t.feb_chan>=88 && t.feb_chan<=95){
745  // 64-->88, etc
746  ifix = 23+ (t.feb_chan-88) ;
747  t.feb_chan= t.feb_chan-24 ;
748  }
749  }
750  }
751 
752  }
753 
754  if(ifix != 0) {
755  nfixes[ifix-1] +=1;
756 
757  ATH_MSG_INFO(" Fix number " << ifix );
758 
759  ATH_MSG_DEBUG(" det="<<t.det
760  <<" pn="<<t.pn
761  <<" sample="<<t.sample
762  <<" region="<<t.region
763  <<" eta="<<t.eta
764  <<" phi="<<t.phi
765  <<" ft="<<t.ft_num
766  <<" slot="<<t.feb_slot
767  <<" chan="<<t.feb_chan
768  <<" calib_slot="<<t.calib_slot
769  <<" calib_line="<<t.calib_line );
770  }
771 
772 
773  } // channel loop
774 
775 
776  for(unsigned int i=0;i<30;++i){
777  ATH_MSG_INFO( nfixes[i] << " fixes for " << i+1 );
778  }
779 
780  return StatusCode::SUCCESS;
781 }
782 
784 
785  // Fix the EMEC inner wheel channel swapping
786 
787  // LArOnOffIdMap
788  const LArOnOffIdMap * onOffIdMap_c;
789  sc=detStore()->retrieve(onOffIdMap_c);
790  std::vector<int> nfixes;
791  nfixes.resize(16,0);
792 
793  if(sc!=StatusCode::SUCCESS){
794  ATH_MSG_ERROR(" Can not find LArOnOffIdMap" );
795  // return sc;
796  }
797  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
798 
799  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
800 
801  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
802 
803 
804  if( onOffId_P->m_version!=2){
805  ATH_MSG_ERROR(" This should only fix map with version=2" );
806  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
807  return StatusCode::FAILURE;
808  }
809 
810  VONOFF::iterator it = onOffId_P->m_v.begin();
811  VONOFF::iterator it_e = onOffId_P->m_v.end();
812 
813  // set the version to 3.
814  onOffId_P->m_version = 3 ;
815  for (; it!=it_e;++it)
816  {
817  int ifix = -1;
818  LArOnOffId_P::LArOnOffId_P_t& t = *it;
819  if( t.det == 0 || t.det==9 ) // for EM (emec, actually)
820  { // connected or disconnected.
821  if(t.pn==-3 || t.pn==3) // Inner wheel
822  {
823 
824 
825 // ft=10,3,22,16
826 // slot = 1, 2
827 // Channels:
828 // 26<->28, 27<->29, 58<->60, 59<->61,
829 // 90<->92, 91<->93, 122<->124, 123<->125.
830 
831  if(t.ft_num==3 || t.ft_num==10 || t.ft_num==16 || t.ft_num==22){
832  if( t.feb_slot==1 || t.feb_slot==2 ) {
833 
834  bool special = t.pn==3 && t.ft_num==16 && t.feb_slot==2;
835 
836  if(t.feb_chan==26)
837  { t.feb_chan=28 ;
838  ifix = 0;
839  }else
840  if(t.feb_chan==28)
841  { t.feb_chan=26 ;
842  ifix = 1;
843  }else
844  if(t.feb_chan==27)
845  { t.feb_chan=29 ;
846  ifix = 2;
847  }else
848  if(t.feb_chan==29)
849  { t.feb_chan=27 ;
850  ifix = 3;
851  }else
852  if(t.feb_chan==58)
853  { t.feb_chan=60 ;
854  ifix = 4;
855  }else
856  if(t.feb_chan==60)
857  { t.feb_chan=58 ;
858  ifix = 5;
859  }else
860  if(t.feb_chan==59)
861  { t.feb_chan=61 ;
862  ifix = 6;
863  }else
864  if(t.feb_chan==61)
865  { t.feb_chan=59 ;
866  ifix = 7;
867  }else
868  if(t.feb_chan==90)
869  { t.feb_chan=92 ;
870  ifix = 8;
871  }else
872  if(t.feb_chan==92)
873  { t.feb_chan=90 ;
874  ifix = 9;
875  }else
876  if(t.feb_chan==91)
877  { t.feb_chan=93 ;
878  ifix = 10;
879  }else
880  if(t.feb_chan==93)
881  { t.feb_chan=91 ;
882  ifix = 11;
883  }else
884  if(t.feb_chan==122 && !special)
885  { t.feb_chan=124 ;
886  ifix = 12;
887  }else
888  if(t.feb_chan==124 && !special)
889  { t.feb_chan=122 ;
890  ifix = 13;
891  }else
892  if(t.feb_chan==123)
893  { t.feb_chan=125 ;
894  ifix = 14;
895  }else
896  if(t.feb_chan==125)
897  { t.feb_chan=123 ;
898  ifix = 15;
899  }
900 
901  }
902  }
903 
904  }
905  }
906 
907  if(ifix != -1) {
908  nfixes[ifix] +=1;
909 
910  ATH_MSG_INFO(" Fix number " << ifix );
911 
912  ATH_MSG_DEBUG(" det="<<t.det
913  <<" pn="<<t.pn
914  <<" sample="<<t.sample
915  <<" region="<<t.region
916  <<" eta="<<t.eta
917  <<" phi="<<t.phi
918  <<" ft="<<t.ft_num
919  <<" slot="<<t.feb_slot
920  <<" chan="<<t.feb_chan
921  <<" calib_slot="<<t.calib_slot
922  <<" calib_line="<<t.calib_line );
923  }
924 
925 
926  }//channel loop
927 
928  for(unsigned int i=0;i<nfixes.size();++i){
929  ATH_MSG_INFO( nfixes[i] << " fixes for " << i );
930  }
931 
932  return StatusCode::SUCCESS;
933 }
934 
936 
937  // Fix the FCAL mapping
938 
939 
940  // LArOnOffIdMap
941  const LArOnOffIdMap * onOffIdMap_c;
942  sc=detStore()->retrieve(onOffIdMap_c);
943  std::vector<int> nfixes;
944  nfixes.resize(8,0);
945 
946  if(sc!=StatusCode::SUCCESS){
947  ATH_MSG_ERROR(" Can not find LArOnOffIdMap" );
948  // return sc;
949  }
950  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
951 
952  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
953 
954  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
955 
956  if( onOffId_P->m_version!=3){
957  ATH_MSG_ERROR(" This should only fix map with version=3" );
958  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
959  return StatusCode::FAILURE;
960  }
961 
962  VONOFF::iterator it = onOffId_P->m_v.begin();
963  VONOFF::iterator it_e = onOffId_P->m_v.end();
964 
965  // set the version to 3.
966  onOffId_P->m_version = onOffId_P->m_version+1 ;
967  for (; it!=it_e;++it)
968  {
969  int ifix = -1;
970  LArOnOffId_P::LArOnOffId_P_t& t = *it;
971 
972  //negative side
973  if( t.det == 7 && t.pn==-2 && t.ft_num==6 &&
974  t.feb_slot==14 && t.feb_chan==95 )
975  { // [4.4.1.0.6.14.95] disconnected
976  t.det=2 ; // make it connected
977  t.calib_slot=16 ;
978  t.calib_line=t.feb_chan;
979  ifix=0 ;
980  }else
981  if( t.det == 7 && t.pn==-2 && t.ft_num==6 &&
982  t.feb_slot==15 && t.feb_chan==95 )
983  { // [4.4.1.0.6.15.95] disconnected
984  t.det=2 ; // make it connected
985  t.calib_slot=16 ;
986  t.calib_line=t.feb_chan;
987  ifix=1 ;
988  }else
989  if( t.det == 2 && t.pn==-2 && t.ft_num==6 &&
990  t.feb_slot==14 && t.feb_chan==47 )
991  { // [4.4.1.0.6.14.47] connected
992  t.det=7 ; // make it disconnected
993  t.calib_slot=0 ;
994  t.calib_line=0 ;
995  ifix=2 ;
996  }else
997  if( t.det == 2 && t.pn==-2 && t.ft_num==6 &&
998  t.feb_slot==15 && t.feb_chan==47 )
999  { // [4.4.1.0.6.15.47] connected
1000  t.det=7 ; // make it discconnected
1001  t.calib_slot=0 ;
1002  t.calib_line=0 ;
1003  ifix=3 ;
1004  }else
1005  // positive side
1006  if( t.det == 7 && t.pn==2 && t.ft_num==6 &&
1007  t.feb_slot==14 && t.feb_chan==47 )
1008  { // [4.4.1.1.6.14.47] disconnected
1009  t.det=2 ; // make it connected
1010  t.calib_slot=16 ;
1011  t.calib_line=t.feb_chan;
1012  ifix=4 ;
1013  }else
1014  if( t.det == 7 && t.pn==2 && t.ft_num==6 &&
1015  t.feb_slot==15 && t.feb_chan==47 )
1016  { // [4.4.1.1.6.15.47] disconnected
1017  t.det=2 ; // make it connected
1018  t.calib_slot=16 ;
1019  t.calib_line=t.feb_chan;
1020  ifix=5 ;
1021  }else
1022  if( t.det == 2 && t.pn==2 && t.ft_num==6 &&
1023  t.feb_slot==14 && t.feb_chan==95 )
1024  { // [4.4.1.1.6.14.95] connected
1025  t.det=7 ; // make it disconnected
1026  t.calib_slot=0 ;
1027  t.calib_line=0 ;
1028  ifix=6 ;
1029  }else
1030  if( t.det == 2 && t.pn==2 && t.ft_num==6 &&
1031  t.feb_slot==15 && t.feb_chan==95 )
1032  { // [4.4.1.1.6.15.95] connected
1033  t.det=7 ; // make it discconnected
1034  t.calib_slot=0 ;
1035  t.calib_line=0 ;
1036  ifix=7 ;
1037  }
1038 
1039  if(ifix != -1) {
1040  nfixes[ifix] +=1;
1041 
1042  ATH_MSG_INFO(" Fix number " << ifix );
1043 
1044  ATH_MSG_DEBUG(" det="<<t.det
1045  <<" pn="<<t.pn
1046  <<" sample="<<t.sample
1047  <<" region="<<t.region
1048  <<" eta="<<t.eta
1049  <<" phi="<<t.phi
1050  <<" ft="<<t.ft_num
1051  <<" slot="<<t.feb_slot
1052  <<" chan="<<t.feb_chan
1053  <<" calib_slot="<<t.calib_slot
1054  <<" calib_line="<<t.calib_line );
1055  }
1056 
1057 
1058  }//channel loop
1059 
1060  for(unsigned int i=0;i<nfixes.size();++i){
1061  ATH_MSG_INFO( nfixes[i] << " fixes for " << i );
1062  }
1063 
1064  return StatusCode::SUCCESS;
1065 }
1066 
1067 
1069 
1070  // Fix the FCAL mapping
1071 
1072  // LArOnOffIdMap
1073  const LArOnOffIdMap * onOffIdMap_c;
1074  sc=detStore()->retrieve(onOffIdMap_c);
1075  int nfixes = 0;
1076 
1077  if(sc!=StatusCode::SUCCESS){
1078  ATH_MSG_ERROR(" Can not find LArOnOffIdMap" );
1079  // return sc;
1080  }
1081  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
1082 
1083  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
1084 
1085  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
1086 
1087  if( onOffId_P->m_version!=3){
1088  ATH_MSG_ERROR(" This should only fix map with version=3" );
1089  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
1090  return StatusCode::FAILURE;
1091  }
1092 
1093  VONOFF::iterator it = onOffId_P->m_v.begin();
1094  VONOFF::iterator it_e = onOffId_P->m_v.end();
1095 
1096  // set the version to .
1097  onOffId_P->m_version = 5 ;
1098  for (; it!=it_e;++it)
1099  {
1100  LArOnOffId_P::LArOnOffId_P_t& t = *it;
1101 
1102  //negative side
1103  if( t.det == 7 || t.det == 2)
1104  {
1105  // FCAL, connected or disconnected
1106  t.calib_slot = 16;
1107  ++nfixes ;
1108  int q = t.feb_chan/32 ;
1109  if (q==0 || q==2){
1110  int r = t.feb_chan%2 ;
1111  if (r==0) t.calib_line = t.feb_chan+1;
1112  else t.calib_line = t.feb_chan-1;
1113  }
1114  else
1115  {
1116  t.calib_line = t.feb_chan;
1117  }
1118 
1119  }// FCAL
1120  }//channel loop
1121 
1122  ATH_MSG_INFO( " Number of fixes:" << nfixes );
1123 
1124  return StatusCode::SUCCESS;
1125 }
1126 
1127 
1128 
1130 
1131  // Fix the HEC Calib mapping
1132 
1133  // LArOnOffIdMap
1134  const LArOnOffIdMap * onOffIdMap_c;
1135  sc=detStore()->retrieve(onOffIdMap_c);
1136  std::vector<int> nfixes;
1137  nfixes.resize(44,0);
1138 
1139 
1140  int nentries=44;
1141  int hec_calib_fix[ ] = {
1142  9 , 100 , 55 , 56,
1143  9 , 101 , 54 , 56,
1144  10 , 100 , 119 , 120,
1145  10 , 101 , 118 , 120,
1146  7 , 36 , 13 , 12,
1147  7 , 37 , 13 , 11,
1148  7 , 37 , 14 , 12,
1149  7 , 38 , 3 , 5,
1150  7 , 39 , 3 , 5,
1151  7 , 44 , 29 , 28,
1152  7 , 45 , 29 , 27,
1153  7 , 45 , 30 , 28,
1154  7 , 46 , 19 , 21,
1155  7 , 47 , 19 , 21,
1156  7 , 100 , 45 , 44,
1157  7 , 101 , 45 , 43,
1158  7 , 101 , 46 , 44,
1159  7 , 102 , 35 , 37,
1160  7 , 103 , 35 , 37,
1161  7 , 108 , 61 , 60,
1162  7 , 109 , 61 , 59,
1163  7 , 109 , 62 , 60,
1164  7 , 110 , 51 , 53,
1165  7 , 111 , 51 , 53,
1166  8 , 36 , 77 , 76,
1167  8 , 37 , 77 , 75,
1168  8 , 37 , 78 , 76,
1169  8 , 38 , 67 , 69,
1170  8 , 39 , 67 , 69,
1171  8 , 44 , 93 , 92,
1172  8 , 45 , 93 , 91,
1173  8 , 45 , 94 , 92,
1174  8 , 46 , 83 , 85,
1175  8 , 47 , 83 , 85,
1176  8 , 100 , 109 , 108,
1177  8 , 101 , 109 , 107,
1178  8 , 101 , 110 , 108,
1179  8 , 102 , 99 , 101,
1180  8 , 103 , 99 , 101,
1181  8 , 108 , 125 , 124,
1182  8 , 109 , 125 , 123,
1183  8 , 109 , 126 , 124,
1184  8 , 110 , 115 , 117,
1185  8 , 111 , 115 , 117 };
1186 
1187  if(sc!=StatusCode::SUCCESS){
1188  ATH_MSG_ERROR(" Can not find LArOnOffIdMap" );
1189  // return sc;
1190  }
1191  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
1192 
1193  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
1194 
1195  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
1196 
1197  if( onOffId_P->m_version!=5){
1198  ATH_MSG_ERROR(" This should only fix map with version 5" );
1199  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
1200  return StatusCode::FAILURE;
1201  }
1202 
1203  VONOFF::iterator it = onOffId_P->m_v.begin();
1204  VONOFF::iterator it_e = onOffId_P->m_v.end();
1205 
1206  // set the version to .
1207  onOffId_P->m_version = 6 ;
1208  int ifix=-1;
1209  for (; it!=it_e;++it)
1210  {
1211  LArOnOffId_P::LArOnOffId_P_t& t = *it;
1212 
1213  //negative side
1214  if( t.det == 1 ) //HEC
1215  {
1216  if( t.ft_num==3 || t.ft_num==10 ||t.ft_num==16 ||t.ft_num==22)
1217  {
1218  ifix=-1;
1219  for( int i = 0;i<nentries;++i)
1220  {
1221  int j = 4*i;
1222  int slot = hec_calib_fix[j+0];
1223  int chan = hec_calib_fix[j+1];
1224  int line_old = hec_calib_fix[j+2];
1225  int line_new = hec_calib_fix[j+3];
1226  if (t.feb_slot == slot)
1227  {
1228  if (t.feb_chan == chan )
1229  {
1230  if(t.calib_line==line_old)
1231  {
1232  ifix=i;
1233  t.calib_line = line_new;
1234  break;
1235  }
1236  }
1237  }
1238  }
1239 
1240  if(ifix != -1) {
1241  nfixes[ifix] +=1;
1242 
1243  ATH_MSG_INFO(" Fix number " << ifix );
1244 
1245  ATH_MSG_DEBUG(" det="<<t.det
1246  <<" pn="<<t.pn
1247  <<" sample="<<t.sample
1248  <<" region="<<t.region
1249  <<" eta="<<t.eta
1250  <<" phi="<<t.phi
1251  <<" ft="<<t.ft_num
1252  <<" slot="<<t.feb_slot
1253  <<" chan="<<t.feb_chan
1254  <<" calib_slot="<<t.calib_slot
1255  <<" calib_line="<<t.calib_line );
1256  }
1257  }
1258  } //HEC
1259  }//channel loop
1260 
1261  for(int i=0;i<nentries;++i){
1262  ATH_MSG_INFO( nfixes[i] << " fixes for " << i+1 );
1263  }
1264 
1265  return StatusCode::SUCCESS;
1266 }
1267 
1268 
1270 
1271  // Fix the FCAL mapping
1272 
1273 
1274  const LArFCAL_ID* fcal_id ;
1275  ATH_CHECK( detStore()->retrieve(fcal_id) );
1276 
1277  // read in the map from file
1278  std::ifstream fcal_map("FCal-online-map-disc.txt");
1279 
1280  // skip two lines
1281  char buffer[128];
1282  fcal_map.getline(buffer,128,'\n');
1283  fcal_map.getline(buffer,128,'\n');
1284  std::string side;
1285  int module,phi,eta,slot,chan;
1286  std::string group ;
1287  int trig_eta;
1288  std::string trig_phi;
1289 
1290  LArOnOffId_P::LArOnOffId_P_t tt = {0,0,0,0,0,0,0,0,0,0,0};
1291  tt.ft_num = 6 ;
1292 
1293  std::set<LArOnOffId_P::LArOnOffId_P_t> t_set ;
1294  int nread_disc=0 ;
1295  int nread=0 ;
1296  while ( fcal_map>>side>>module>>phi>>eta>>slot>>chan>> group >>trig_eta>>trig_phi)
1297  {
1298  ATH_MSG_DEBUG("side="<<side<< "module= "<<module
1299  << " phi "<<phi
1300  << " eta "<<eta
1301  << " slot "<<slot
1302  << " chan "<<chan
1303  << " group "<<group
1304  << " trig_eta "<<trig_eta
1305  << " trig_phi "<<trig_phi );
1306 
1307  if(side=="A"){
1308  tt.pn= 2;
1309  } else
1310  if(side=="C") {
1311  tt.pn= -2;
1312  } else {
1313  ATH_MSG_WARNING(" unknown side "<<side );
1314  return StatusCode::FAILURE ;
1315  }
1316 
1317  try{
1318  /*Identifier id = */fcal_id->channel_id(tt.pn,tt.sample,tt.eta,tt.phi);
1319  } catch (LArID_Exception& ex)
1320  {
1321  ATH_MSG_DEBUG( " LArID_Exception" << ex.message() );
1322  }
1323  tt.region=module;
1324  tt.sample=module;
1325  tt.eta=eta;
1326  tt.phi=phi;
1327  tt.feb_slot=slot;
1328  tt.feb_chan=chan;
1329 
1330  tt.calib_slot = 16;
1331  int q = tt.feb_chan/32 ;
1332  if (q==0 || q==2){
1333  int r = tt.feb_chan%2 ;
1334  if (r==0) tt.calib_line = tt.feb_chan+1;
1335  else tt.calib_line = tt.feb_chan-1;
1336  }
1337  else
1338  {
1339  tt.calib_line = tt.feb_chan;
1340  }
1341 
1342  if(trig_eta<0){ // disconnected channels
1343  tt.det=7 ;
1344  ++nread_disc;
1345  } else // connected channels
1346  {
1347  tt.det=2 ;
1348  }
1349 
1350  t_set.insert(tt);
1351  ++nread ;
1352 
1353  }
1354 
1355  ATH_MSG_DEBUG(" read number of entries " << nread
1356  <<" number of disconnected channels= " << nread_disc
1357  <<" number of unique=" << t_set.size() );
1358 
1359 
1360  // LArOnOffIdMap
1361  const LArOnOffIdMap * onOffIdMap_c;
1362  ATH_CHECK( detStore()->retrieve(onOffIdMap_c) );
1363 
1364  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
1365 
1366  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
1367 
1368  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
1369 
1370  if( onOffId_P->m_version!=6){
1371  ATH_MSG_ERROR(" This should only fix map with version 6" );
1372  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
1373  return StatusCode::FAILURE;
1374  }
1375 
1376  VONOFF::iterator it = onOffId_P->m_v.begin();
1377  VONOFF::iterator it_e = onOffId_P->m_v.end();
1378 
1379  // set the version to .
1380  onOffId_P->m_version = 7 ;
1381 
1382  // remove all the current FCAL entries.
1383  int n_conn=0;
1384  int n_disc=0;
1385 
1386  VONOFF new_v;
1387 
1388  for (; it!=it_e;++it)
1389  {
1390  LArOnOffId_P::LArOnOffId_P_t& t = *it;
1391 
1392  //negative side
1393  if( t.det == 2 || t.det == 7 ) //FCAL
1394  {
1395  if (t.det==2) ++n_conn;
1396  if (t.det==7) ++n_disc;
1397 
1398  ATH_MSG_DEBUG(" Dropping FCAL det="<<t.det
1399  <<" pn="<<t.pn
1400  <<" sample="<<t.sample
1401  <<" region="<<t.region
1402  <<" eta="<<t.eta
1403  <<" phi="<<t.phi
1404  <<" ft="<<t.ft_num
1405  <<" slot="<<t.feb_slot
1406  <<" chan="<<t.feb_chan
1407  <<" calib_slot="<<t.calib_slot
1408  <<" calib_line="<<t.calib_line );
1409 
1410  } else
1411  new_v.push_back(t);
1412 
1413  }
1414  ATH_MSG_INFO(" Number of connected channels removed"<<n_conn );
1415  ATH_MSG_INFO(" Number of disconnected channels removed"<<n_disc );
1416 
1417  std::set<LArOnOffId_P::LArOnOffId_P_t>::const_iterator it2 =t_set.begin();
1418  std::set<LArOnOffId_P::LArOnOffId_P_t>::const_iterator it2_e =t_set.end();
1419 
1420  for ( ; it2!=it2_e;++it2){
1421  new_v.push_back(*it2);
1422  }
1423 
1424  ATH_MSG_INFO(" number of old channels "<<onOffId_P->m_v.size() );
1425 
1426  onOffId_P->m_v = new_v;
1427  ATH_MSG_INFO(" number of new channels "<<onOffId_P->m_v.size() );
1428 
1429  return StatusCode::SUCCESS;
1430 }
1431 
1432 
1433 bool operator < (const LArOnOffId_P::LArOnOffId_P_t & t1,
1434  const LArOnOffId_P::LArOnOffId_P_t & t2)
1435  {
1436  if (t1.det<t2.det) return true ;
1437  else
1438  if( t1.det>t2.det) return false;
1439 
1440  if (t1.pn<t2.pn) return true ;
1441  else
1442  if (t1.pn>t2.pn) return false;
1443 
1444  if (t1.sample<t2.sample) return true ;
1445  else
1446  if( t1.sample>t2.sample) return false;
1447 
1448  if (t1.region<t2.region) return true ;
1449  else
1450  if( t1.region>t2.region) return false;
1451 
1452  if (t1.eta<t2.eta) return true ;
1453  else
1454  if( t1.eta>t2.eta) return false;
1455 
1456  if (t1.phi<t2.phi) return true ;
1457  else
1458  if( t1.phi>t2.phi) return false;
1459 
1460  if (t1.ft_num<t2.ft_num) return true ;
1461  else
1462  if( t1.ft_num>t2.ft_num) return false;
1463 
1464  if (t1.feb_slot<t2.feb_slot) return true ;
1465  else
1466  if( t1.feb_slot>t2.feb_slot) return false;
1467 
1468  if (t1.feb_chan<t2.feb_chan) return true ;
1469  else
1470  if( t1.feb_chan>t2.feb_chan) return false;
1471 
1472  if (t1.calib_slot<t2.calib_slot) return true ;
1473  else
1474  if( t1.calib_slot>t2.calib_slot) return false;
1475 
1476  if (t1.calib_line<t2.calib_line) return true ;
1477  else
1478  if( t1.calib_line>t2.calib_line) return false;
1479 
1480  return false;
1481  }
1482 
1483 
1484 
1486 {
1487  // Import new FEB ROD map
1488 
1489  ATH_MSG_INFO(" In fix8()" );
1490 
1491  // retrieve DetDescrManager and LArCablingService
1492  IToolSvc* toolSvc = nullptr;
1493  ATH_CHECK( service("ToolSvc", toolSvc) );
1494 
1495  LArCablingService* cablingSvc = nullptr;
1496  ATH_CHECK( toolSvc->retrieveTool("LArCablingService",cablingSvc) );
1497 
1498  // WARNING: LArFebRodMap should not have been retrieved before this call.
1499  // so far it will be created by LArCablingService from file.
1500  if (m_febToRodMap.empty()) {
1501 
1502  ATH_MSG_ERROR(" FEBtoRODMap filename is empty. Please specify through jobOpt" );
1503  return StatusCode::FAILURE ;
1504 
1505  }
1506 
1507  ATH_MSG_DEBUG(" FEBtoRODMap filename is " << m_febToRodMap );
1508 
1509  int flag = cablingSvc->fillFEB_RODmap(m_febToRodMap) ;
1510 
1511  if (flag!=0) {
1512  ATH_MSG_ERROR(" Fail load the map file" );
1513  return StatusCode::FAILURE ;
1514  }
1515 
1516  // LArFebRodMap
1517  LArFebRodMap * febRodMap = nullptr;
1518  ATH_CHECK( detStore()->retrieve(febRodMap,"LArFebRodMapAtlas") );
1519 
1520  LArFebRod_P* febRod_P = febRodMap->getP();
1521  febRod_P->m_version = 4;
1522 
1523  ATH_MSG_INFO(" Number of entries in new map"<< febRod_P->m_v.size() );
1524  ATH_MSG_INFO(" Set LArFebRodMap version to "<<febRod_P->m_version );
1525 
1526  return StatusCode::SUCCESS ;
1527 }
1528 
1529 
1530 
1532 {
1533  // Import new FEB ROD map
1534 
1535  ATH_MSG_INFO(" In fix9() Barrel Cabling Fix" );
1536 
1537  // LArOnOffIdMap
1538  const LArOnOffIdMap * onOffIdMap_c = nullptr;
1539  ATH_CHECK( detStore()->retrieve(onOffIdMap_c) );
1540 
1541  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
1542 
1543  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
1544 
1545 
1546  unsigned int ntype=4 ;
1547  std::vector<int> nfixes;
1548  nfixes.resize(ntype);
1549 
1550  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
1551 
1552  ATH_MSG_INFO(" LArOnOffIdMap version "<<onOffId_P->m_version );
1553 
1554  if( onOffId_P->m_version!=7){
1555  ATH_MSG_ERROR(" This should only fix map with version 7" );
1556  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
1557  return StatusCode::FAILURE;
1558  }
1559 
1560  VONOFF::iterator it = onOffId_P->m_v.begin();
1561  VONOFF::iterator it_e = onOffId_P->m_v.end();
1562 
1563  // set the version to .
1564  onOffId_P->m_version = 8 ;
1565 
1566  for (; it!=it_e;++it)
1567  {
1568  LArOnOffId_P::LArOnOffId_P_t& t = *it;
1569 
1570  if( t.det == 0 || t.det==9 ) //EM
1571  {
1572  if( t.pn== -1 ) // Barrel C
1573  {
1574 
1575  // type 0
1576  if ( (t.ft_num==5 && t.feb_slot== 6) ||
1577  (t.ft_num==29 && t.feb_slot==5) ||
1578  (t.ft_num==29 && t.feb_slot==7)
1579  ){
1580  // channel (1-63)<-> (64-127)
1581  if( t.feb_chan<64) {
1582  t.feb_chan= t.feb_chan+64;
1583  }else{
1584  t.feb_chan= t.feb_chan-64;
1585  }
1586  nfixes[0]+=1;
1587  }
1588 
1589  // type 1 in Barrel-C
1590  if ( t.ft_num==0 && t.feb_slot== 8 ) {
1591  if ( t.feb_chan>=32 && t.feb_chan<=39 ){
1592  t.feb_chan = t.feb_chan+8 ;
1593  nfixes[1]+=1;
1594  }
1595  else
1596  if( t.feb_chan>=40 && t.feb_chan<=47 ){
1597  t.feb_chan = t.feb_chan-8 ;
1598  nfixes[1]+=1;
1599  }
1600  }
1601  }
1602  else if( t.pn== 1 ) // Barrel A
1603  {
1604  // type 2
1605  if( (t.ft_num==6 && t.feb_slot==2 )|| (t.ft_num==17 && t.feb_slot==3 ))
1606  {
1607 
1608  if ( t.feb_chan>=112 && t.feb_chan<=119 ){
1609  t.feb_chan = t.feb_chan+8 ;
1610  nfixes[2]+=1;
1611  }
1612  else if( t.feb_chan>=120 && t.feb_chan<=127 ){
1613  t.feb_chan = t.feb_chan-8 ;
1614  nfixes[2]+=1;
1615  }
1616  }
1617 
1618  if( (t.ft_num==22 && t.feb_slot==7 ) )
1619  {
1620  if ( t.feb_chan>=32 && t.feb_chan<=39 ){
1621  t.feb_chan = t.feb_chan+8 ;
1622  nfixes[3]+=1;
1623  }
1624  else if( t.feb_chan>=40 && t.feb_chan<=47 ){
1625  t.feb_chan = t.feb_chan-8 ;
1626  nfixes[3]+=1;
1627  }
1628  }
1629 
1630  }
1631  } // EM
1632 
1633  }//channel loop
1634 
1635  for(unsigned int i=0;i<ntype;++i){
1636  ATH_MSG_INFO( nfixes[i] << " fixes for type " << i );
1637  }
1638 
1639  return StatusCode::SUCCESS;
1640 }
1641 
1642 
1644 {
1645  // Fix HEC FEB Swapping run 0-56450
1646 
1647  ATH_MSG_INFO(" In fix10() HEC-C Cabling Fix" );
1648 
1649  // LArOnOffIdMap
1650  const LArOnOffIdMap * onOffIdMap_c = nullptr;
1651  ATH_CHECK( detStore()->retrieve(onOffIdMap_c) );
1652 
1653  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
1654 
1655  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
1656 
1657 
1658  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
1659 
1660  ATH_MSG_INFO(" LArOnOffIdMap version "<<onOffId_P->m_version );
1661 
1662  if( onOffId_P->m_version!=8){
1663  ATH_MSG_ERROR(" This should only fix map with version 8" );
1664  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
1665  return StatusCode::FAILURE;
1666  }
1667 
1668  // set the version to .
1669  onOffId_P->m_version = 9 ;
1670 
1671  /*
1672  VONOFF::iterator it = onOffId_P->m_v.begin();
1673  VONOFF::iterator it_e = onOffId_P->m_v.end();
1674 
1675 
1676  typedef std::map<unsigned short,LArOnOffId_P> MAPCHAN;
1677  typedef std::map<unsigned short,MAPCHAN> MAPFEB;
1678  typedef std::map<unsigned short,MAPFEB> MAPFT;
1679 
1680  MAPFT map_ft ;
1681 
1682  int n = 0;
1683  for (; it!=it_e;++it)
1684  {
1685  LArOnOffId_P::LArOnOffId_P_t& t = *it;
1686 
1687 
1688  if( t.det == 1 || t.det==8 ) // HEC
1689  {
1690  if( t.pn== -2 ) // HEC-C
1691  {
1692  ++n ;
1693  map_ft[t.ft_num][t.feb_slot][t.feb_chan]=t ;
1694  }
1695 
1696  }
1697  }
1698 
1699  log<<MSG::INFO<" number of HEC-C channels"<<n<<endmsg;
1700 
1701  */
1702  std::map<int,int> nfixes ;
1703 
1704  VONOFF::iterator it = onOffId_P->m_v.begin();
1705  VONOFF::iterator it_e = onOffId_P->m_v.end();
1706 
1707  for (; it!=it_e;++it)
1708  {
1709  LArOnOffId_P::LArOnOffId_P_t& t = *it;
1710 
1711  if( t.det == 1 || t.det==8 ) // HEC
1712  {
1713  if( t.pn== -2 ) // HEC-C
1714  {
1715  if( t.ft_num== 3 || t.ft_num== 10 || t.ft_num== 16 || t.ft_num== 22 )
1716  {
1717  unsigned short islot = 100;
1718  if (t.feb_slot==5) islot=6;
1719  else if(t.feb_slot==6) islot=5;
1720  else if(t.feb_slot==7) islot=8;
1721  else if(t.feb_slot==8) islot=7;
1722  else if(t.feb_slot==9) islot=10;
1723  else if(t.feb_slot==10) islot=9;
1724 
1725  if(islot!=100){
1726  t.feb_slot = islot ;
1727  nfixes[islot] +=1 ;
1728  }
1729 
1730  }
1731 
1732  }
1733  }
1734  }
1735 
1736  std::map<int,int>::const_iterator map_it=nfixes.begin();
1737  std::map<int,int>::const_iterator map_it_e=nfixes.end();
1738  for (;map_it!=map_it_e;++map_it){
1739  log<<" slot and nfixes "<<(*map_it).first<<" " <<(*map_it).second <<endmsg;
1740  }
1741 
1742  return StatusCode::SUCCESS;
1743 
1744 }
1745 
1747 {
1748  // Fix EMEC-C Cabling
1749 
1750  ATH_MSG_INFO(" In fix11() EMEC Cabling Fix" );
1751 
1752  // LArOnOffIdMap
1753  const LArOnOffIdMap * onOffIdMap_c = nullptr;
1754  ATH_CHECK( detStore->retrieve(onOffIdMap_c) );
1755 
1756  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
1757 
1758  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
1759 
1760  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
1761 
1762  log<<MSG::INFO<<" LArOnOffIdMap version "<<onOffId_P->m_version<< endmsg;
1763 
1764  if( onOffId_P->m_version!=9){
1765  ATH_MSG_ERROR(" This should only fix map with version 9" );
1766  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
1767  return StatusCode::FAILURE;
1768  }
1769 
1770 
1771  VONOFF::iterator it = onOffId_P->m_v.begin();
1772  VONOFF::iterator it_e = onOffId_P->m_v.end();
1773 
1774  // set the version to .
1775  onOffId_P->m_version = 10 ;
1776  std::map<int,int> nfixes ;
1777 
1778  for (; it!=it_e;++it)
1779  {
1780  LArOnOffId_P::LArOnOffId_P_t& t = *it;
1781 
1782  if( t.det == 0 || t.det==9 ) // EM
1783  {
1784  if( t.pn== -2 ) // EMEC-C
1785  {
1786  if( t.ft_num== 21 )
1787  {
1788  unsigned short islot = 100;
1789  if (t.feb_slot==5) islot=8;
1790  else if(t.feb_slot==8) islot=5;
1791 
1792  if(islot!=100){
1793  t.feb_slot = islot ;
1794  nfixes[islot] +=1 ;
1795  }
1796 
1797  }
1798 
1799  }
1800  }
1801  }
1802 
1803  std::map<int,int>::const_iterator map_it=nfixes.begin();
1804  std::map<int,int>::const_iterator map_it_e=nfixes.end();
1805  for (;map_it!=map_it_e;++map_it){
1806  ATH_MSG_VERBOSE(" slot and nfixes "<<(*map_it).first<<" "<< (*map_it).second );
1807  }
1808 
1809 
1810  // Fix FEB ROD map
1811 
1812  // LArFebRodMap
1813  const LArFebRodMap * febRodMap_c = nullptr;
1814  sc=detStore->retrieve(febRodMap_c);
1815  if(sc!=StatusCode::SUCCESS){
1816  ATH_MSG_ERROR(" Can not find LArFebRodMap" );
1817  // return sc;
1818  }
1819 
1820  LArFebRodMap* febRodMap=const_cast<LArFebRodMap*>(febRodMap_c);
1821 
1822  LArFebRod_P* febRod_P = febRodMap->getP();
1823 
1824  typedef std::vector<LArFebRod_P::LArFebRod_P_t> VFEBROD;
1825 
1826  VFEBROD::iterator it2 = febRod_P->m_v.begin();
1827  VFEBROD::iterator it2_e = febRod_P->m_v.end();
1828 
1829  if(febRod_P->m_version!=2){
1830 
1831  ATH_MSG_ERROR(" wrong Persistent LArFebRod_P version = "<< febRod_P->m_version );
1832  ATH_MSG_ERROR(" this fix should only fix version 2 " );
1833  return StatusCode::FAILURE;
1834  }
1835 
1836 
1837  // increment the version
1838  febRod_P->m_version = 3;
1839 
1840  int nfix = 0;
1841  for (; it2!=it2_e;++it2)
1842  {
1843  LArFebRod_P::LArFebRod_P_t& t = *it2;
1844 
1845  bool fixed = false ;
1846  if( t.det ==68 && t.ft_det==1 && t.ft_pn==0 && t.ft_num==21 && t.ft_slot==5 )
1847  {
1848  fixed=true;
1849  t.ft_slot=8;
1850  }else
1851  if( t.det ==68 && t.ft_det==1 && t.ft_pn==0 && t.ft_num==21 && t.ft_slot==8 )
1852  {
1853  fixed=true;
1854  t.ft_slot=5;
1855  }
1856  ATH_MSG_INFO( " Fixing FEB slot number, before and after " );
1857 
1858  if(fixed) {
1859  ++nfix;
1860  ATH_MSG_DEBUG(" fixed: hashid="<<t.hashid
1861  <<" det="<<t.det
1862  <<" rosfrag="<<t.rosfrag
1863  <<" robfrag="<<t.robfrag
1864  <<" rodfrag="<<t.rodfrag
1865  <<" rodcrate="<<t.rodcrate
1866  <<" rodslot="<<t.rodslot
1867  <<" ft_det="<<t.ft_det
1868  <<" ft_pn="<<t.ft_pn
1869  <<" ft_num="<<t.ft_num
1870  <<" ft_slot="<<t.ft_slot );
1871 
1872  }
1873 
1874  }
1875 
1876  return StatusCode::SUCCESS;
1877 }
1878 
1880 {
1881  // Fix EMEC-A Cabling
1882 
1883  ATH_MSG_INFO(" In fix12() EMEC Cabling Fix" );
1884 
1885  // LArOnOffIdMap
1886  const LArOnOffIdMap * onOffIdMap_c = nullptr;
1887  ATH_CHECK( detStore()->retrieve(onOffIdMap_c) );
1888 
1889  LArOnOffIdMap* onOffIdMap=const_cast<LArOnOffIdMap*>(onOffIdMap_c);
1890 
1891  LArOnOffId_P* onOffId_P = onOffIdMap->getP();
1892 
1893  typedef std::vector<LArOnOffId_P::LArOnOffId_P_t> VONOFF;
1894 
1895  ATH_MSG_INFO(" LArOnOffIdMap version "<<onOffId_P->m_version );
1896  if( onOffId_P->m_version!=10){
1897  ATH_MSG_ERROR(" This should only fix map with version 10" );
1898  ATH_MSG_ERROR(" This LArOnOffId_P's version is "<<onOffId_P->m_version );
1899  return StatusCode::FAILURE;
1900  }
1901 
1902 
1903  VONOFF::iterator it = onOffId_P->m_v.begin();
1904  VONOFF::iterator it_e = onOffId_P->m_v.end();
1905 
1906  // set the version to .
1907  onOffId_P->m_version = 11 ;
1908  std::map<int,int> nfixes ;
1909 
1910  for (; it!=it_e;++it)
1911  {
1912  LArOnOffId_P::LArOnOffId_P_t& t = *it;
1913 
1914  if( t.det == 0 || t.det==9 ) // EM
1915  {
1916  if( t.pn== 2 ) // EMEC-A
1917  {
1918  if( t.ft_num== 9 )
1919  {
1920  unsigned short islot = 100;
1921  if (t.feb_slot==7) islot=8;
1922  else if(t.feb_slot==8) islot=7;
1923 
1924  if(islot!=100){
1925  t.feb_slot = islot ;
1926  nfixes[islot] +=1 ;
1927  }
1928 
1929  }
1930 
1931  }
1932  }
1933  }
1934 
1935  std::map<int,int>::const_iterator map_it=nfixes.begin();
1936  std::map<int,int>::const_iterator map_it_e=nfixes.end();
1937  for (;map_it!=map_it_e;++map_it){
1938  ATH_MSG_VERBOSE(" slot and nfixes "<<(*map_it).first<<" "<< (*map_it).second );
1939  }
1940 
1941  return StatusCode::SUCCESS;
1942 
1943 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
beamspotman.r
def r
Definition: beamspotman.py:676
FixLArIdMap::finalize
StatusCode finalize()
Definition: FixLArIdMap.cxx:219
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FixLArIdMap::fix8
StatusCode fix8()
Definition: FixLArIdMap.cxx:1485
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
FixLArIdMap::fix5
StatusCode fix5()
Definition: FixLArIdMap.cxx:1068
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
FixLArIdMap::fix4
StatusCode fix4()
Definition: FixLArIdMap.cxx:935
skel.it
it
Definition: skel.GENtoEVGEN.py:396
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
FixLArIdMap::dumpId
void dumpId()
Definition: FixLArIdMap.cxx:265
FixLArIdMap::fix7
StatusCode fix7()
Definition: FixLArIdMap.cxx:1269
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
FixLArIdMap::~FixLArIdMap
virtual ~FixLArIdMap()
Definition: FixLArIdMap.cxx:206
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
TRT::Hit::side
@ side
Definition: HitInfo.h:83
python.PyAthena.module
module
Definition: PyAthena.py:131
PlotCalibFromCool.nentries
nentries
Definition: PlotCalibFromCool.py:798
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
FixLArIdMap::fix2
StatusCode fix2()
Definition: FixLArIdMap.cxx:564
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
FixLArIdMap::fix3
StatusCode fix3()
Definition: FixLArIdMap.cxx:783
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
FixLArIdMap::initialize
StatusCode initialize()
Definition: FixLArIdMap.cxx:209
LArFCAL_Base_ID::channel_id
Identifier channel_id(const ExpandedIdentifier &exp_id) const
cell identifier for a channel from ExpandedIdentifier
FixLArIdMap::fix9
StatusCode fix9()
Definition: FixLArIdMap.cxx:1531
master.flag
bool flag
Definition: master.py:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
FixLArIdMap::m_febToRodMap
std::string m_febToRodMap
Definition: FixLArIdMap.h:41
FixLArIdMap.h
AthAlgorithm
Definition: AthAlgorithm.h:47
FixLArIdMap::m_dumpIds
bool m_dumpIds
Definition: FixLArIdMap.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArID_Exception::message
void message(const std::string &l_message)
set error message
Definition: LArID_Exception.h:36
LArFCAL_ID.h
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
FixLArIdMap::m_fixFlag
int m_fixFlag
Definition: FixLArIdMap.h:39
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
FixLArIdMap::fix11
StatusCode fix11()
Definition: FixLArIdMap.cxx:1746
FixLArIdMap::fix6
StatusCode fix6()
Definition: FixLArIdMap.cxx:1129
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
operator<
bool operator<(const LArOnOffId_P::LArOnOffId_P_t &t1, const LArOnOffId_P::LArOnOffId_P_t &t2)
Definition: FixLArIdMap.cxx:1433
extractSporadic.q
list q
Definition: extractSporadic.py:98
FixLArIdMap::fix1
StatusCode fix1()
Definition: FixLArIdMap.cxx:351
FixLArIdMap::fix10
StatusCode fix10()
Definition: FixLArIdMap.cxx:1643
FixLArIdMap::execute
StatusCode execute()
Definition: FixLArIdMap.cxx:213
LArFCAL_ID
Helper class for LArFCAL offline identifiers.
Definition: LArFCAL_ID.h:60
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
FixLArIdMap::fix12
StatusCode fix12()
Definition: FixLArIdMap.cxx:1879
StoreGateSvc.h
LArID_Exception
Exception class for LAr Identifiers.
Definition: LArID_Exception.h:20
LArOnlineID.h
FixLArIdMap::FixLArIdMap
FixLArIdMap(const std::string &name, ISvcLocator *pSvcLocator)
Author Hong Ma hma@bnl.gov
Definition: FixLArIdMap.cxx:195