ATLAS Offline Software
FixLArElecCalib.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef FIXLARELECCALIB_H
6 #define FIXLARELECCALIB_H
7 
11 #include "StoreGate/StoreGateSvc.h"
15 #include <string>
16 
17 class LArEM_ID ;
18 class LArHEC_ID;
19 class LArFCAL_ID;
20 class LArOnlineID;
23 class LArOnOffIdMapping;
24 
34 
35 // this class is collection of various fixes, applied to LAr conditions,
36 // when some bug was found.
37 // should serve mainly as example, in case yet another problem will need a fix
39 {
40  public:
41  FixLArElecCalib(const std::string& name,ISvcLocator* pSvcLocator);
42  virtual ~FixLArElecCalib() = default;
43 
44  virtual StatusCode initialize() override;
45  virtual StatusCode execute() override;
46  virtual StatusCode finalize() override {return StatusCode::SUCCESS;}
47  virtual StatusCode stop ATLAS_NOT_THREAD_SAFE () override;
48 
66  StatusCode fix18(const LArCalibLineMapping *clmap);
67 
68  private:
69 
70  SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};
71  SG::ReadCondHandleKey<LArCalibLineMapping> m_CLKey{this, "SCCalibLineKey", "LArCalibLineMap", "SG calib line key"};
72 
73  StatusCode ReadFile(const std::string& filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar );
74  StatusCode ReadFileAll(const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar );
75 
76  StatusCode update_DAC2uA(const std::string& em_filename,const std::string& hec_filename);
77  // FIXME: for future round of developments:
78  // StatusCode update_uA2MeV(const std::string& em_filename,const std::string& hec_filename);
79  // StatusCode update_AC(const std::string& em_filename,const std::string& hec_filename);
80  //StatusCode update_Noise(const std::string& em_filename,const std::string& hec_filename);
81  //StatusCode update_Mphys(const std::string& em_filename,const std::string& hec_filename);
82  //StatusCode update_Ramp(const std::string& em_filename,const std::string& hec_filename);
83  //StatusCode update_Shape(const std::string& em_filename,const std::string& hec_filename);
84 
85  template <class T>
86  StatusCode update_EM_HEC ATLAS_NOT_THREAD_SAFE (const std::string& em_filename,const std::string& hec_filename, const LArOnOffIdMapping *cabling,
87  bool withGain, int nvar);
88  template <class T>
89  StatusCode update_All ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar);
90 
91  void print_object(const std::string& msg, const LArNoiseMC::LArCondObj& obj);
92  void set_object(LArNoiseMC::LArCondObj& obj, const std::vector<float>& v );
93 
94  void print_object(const std::string& msg, const LArAutoCorrMC::LArCondObj& obj);
95  void set_object(LArAutoCorrMC::LArCondObj& obj, const std::vector<float>& v );
96 
97  void print_object(const std::string& msg, const LArRampMC::LArCondObj& obj);
98  void set_object(LArRampMC::LArCondObj& obj, const std::vector<float>& v );
99 
100  //void print_object(const std::string& msg, const LAruA2MeVMC::LArCondObj& obj);
101  //void set_object(LAruA2MeVMC::LArCondObj& obj, std::vector<float>& v );
102 
103  void print_object(const std::string& msg, const LArShape32MC::LArCondObj& obj);
104  void set_object(LArShape32MC::LArCondObj& obj, const std::vector<float>& v );
105 
106  void print_object(const std::string& msg, const LArSingleFloatP& obj);
107  void set_object(LArSingleFloatP& obj, const std::vector<float>& v );
108 
109  // void print_object(const std::string& msg, const LArDAC2uAMC::LArCondObj& obj);
110  //void set_object(LArDAC2uAMC::LArCondObj& obj, std::vector<float>& v );
111 
112  StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling) ; // add new one with default for FCAL
113 
114  StatusCode fixDACuAMeV ATLAS_NOT_THREAD_SAFE () ; // remove -100000000
115 
116 
117  StatusCode updateEMfSampl ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
118  StatusCode updateMinBias ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
119  StatusCode updateEM_DACuAMeV ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
121 
122  int m_fixFlag ;
123  std::string m_g4Phys;
124  std::string m_infile;
125 
135 
136 
137 
138 
139  typedef std::pair<HWIdentifier,std::vector<float> > ROW_t ;
140  typedef std::vector<ROW_t> VROW_t;
141 
143 
144 
145 };
146 
147 template <class T >
148  StatusCode FixLArElecCalib::update_EM_HEC ATLAS_NOT_THREAD_SAFE (const std::string& em_filename,const std::string& hec_filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
149 {
150  // read in the file
151 
152  const T * container_c = nullptr;
153  ATH_CHECK( detStore()->retrieve(container_c) );
154 
155  T* container = const_cast<T*>(container_c);
156 
157  typedef typename T::LArCondObj CONDOBJ ;
158 
159  for (int i=0; i<2;++i)
160  { // EM and HEC
161  if( i==0 )
162  {
163  if ( em_filename == "") continue ;
164  bool EM=true;
165  ATH_CHECK( ReadFile(em_filename,cabling,EM,withGain,nvar) );
166  }
167  if( i==1 )
168  {
169  if ( hec_filename == "") continue ;
170  bool EM=false ;
171  ATH_CHECK( ReadFile(hec_filename,cabling,EM,withGain,nvar) );
172  }
173 
174 
175  int ngain=1;
176  if (withGain) ngain=3;
177  for (int igain = 0;igain<ngain;++igain){
178  VROW_t::iterator it = m_cache[igain].begin();
179  VROW_t::iterator it_e = m_cache[igain].end();
180 
181  int n=0;
182  for( ;it!=it_e;++it)
183  {
184  HWIdentifier hid = (*it).first;
185 
186  const CONDOBJ& u = container->get(hid,igain);
187 
188  if( u.isEmpty() )
189  {
190  ATH_MSG_WARNING(" No existing conditions data, adding new one " );
191  CONDOBJ t ;
192  set_object(t,(*it).second) ;
193  container->setPdata(hid,t,igain);
194  }
195  else
196  {
197  print_object(" Old object = ",u);
198 
199  CONDOBJ& u2 = const_cast<CONDOBJ&>(u);
200  set_object(u2,(*it).second) ;
201  }
202 
203  const CONDOBJ& u3 = container->get(hid,igain);
204  print_object(" New object = ",u3);
205 
206  ++n;
207  }
208  ATH_MSG_INFO( " done for gain ="<<igain<<" with "<<n<<" objects");
209 
210  }// gain
211  }// EM HEC
212 
213  ATH_MSG_INFO(" done with EM "<<em_filename<<" and HEC" <<hec_filename );
214  return StatusCode::SUCCESS;
215 }
216 
217 
218 template <class T >
219  StatusCode FixLArElecCalib::update_All ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
220 {
221  // read in the file
222 
223  const T * container_c = nullptr;
224  ATH_CHECK( detStore()->retrieve(container_c) );
225 
226  T* container = const_cast<T*>(container_c);
227 
228  typedef typename T::LArCondObj CONDOBJ ;
229 
230  if ( filename == "") { ATH_MSG_ERROR("No input filename "); return StatusCode::FAILURE; }
231  ATH_CHECK( ReadFileAll(filename, cabling, withGain,nvar) );
232 
233  int ngain=1;
234  if (withGain) ngain=3;
235  for (int igain = 0;igain<ngain;++igain){
236  VROW_t::iterator it = m_cache[igain].begin();
237  VROW_t::iterator it_e = m_cache[igain].end();
238 
239  int n=0;
240  for( ;it!=it_e;++it) {
241  HWIdentifier hid = (*it).first;
242 
243  if(!hid.is_valid()) {
244  ATH_MSG_WARNING(" Not valid hid: 0x" <<hid.getString() );
245  continue;
246  }
247 
248  const CONDOBJ& u = container->get(hid,igain);
249 
250  if( u.isEmpty() ) {
251  ATH_MSG_WARNING(" Not existing conditions data, adding new one " );
252  CONDOBJ t ;
253  set_object(t,(*it).second) ;
254  container->setPdata(hid,t,igain);
255  } else {
256  print_object(" Old object = ",u);
257 
258  CONDOBJ& u2 = const_cast<CONDOBJ&>(u);
259  set_object(u2,(*it).second) ;
260  }
261 
262  const CONDOBJ& u3 = container->get(hid,igain);
263  print_object(" New object = ",u3);
264 
265  ++n;
266  }
267  ATH_MSG_INFO( " done for gain ="<<igain<<" with "<<n<<" objects");
268 
269  }// gain
270 
271  ATH_MSG_INFO(" done with "<<filename );
272  return StatusCode::SUCCESS;
273 }
274 #endif // FixLArElecCalib
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix6 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
FixLArElecCalib::finalize
virtual StatusCode finalize() override
Definition: FixLArElecCalib.h:46
FixLArElecCalib::ReadFileAll
StatusCode ReadFileAll(const std::string &filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
Definition: FixLArElecCalib.cxx:1220
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix9 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix17 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode updateMinBias ATLAS_NOT_THREAD_SAFE(const std::string &filename, const LArOnOffIdMapping *cabling)
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix7 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix16 ATLAS_NOT_THREAD_SAFE()
FixLArElecCalib::initialize
virtual StatusCode initialize() override
Definition: FixLArElecCalib.cxx:131
LAruA2MeVMC.h
LArMinBiasMC.h
LArSingleFloatP
Definition: LArSingleFloatP.h:11
LArRampP1
Persistent data for LArRamp Copied from LAr.
Definition: LArRampP1.h:24
LArCalibLineMapping
Definition: LArCalibLineMapping.h:17
LArFCAL_SuperCell_ID
Helper class for LArFCAL offline identifiers for supercells.
Definition: LArFCAL_SuperCell_ID.h:48
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArAutoCorrP1
c-struct reproducing the structure of the persistent data
Definition: LArAutoCorrP1.h:25
ATLAS_NOT_THREAD_SAFE
StatusCode FixLArElecCalib::update_EM_HEC ATLAS_NOT_THREAD_SAFE(const std::string &em_filename, const std::string &hec_filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
Definition: FixLArElecCalib.h:148
LArMphysOverMcalMC.h
LArDAC2uAMC.h
LArHEC_ID
Helper class for LArHEC offline identifiers.
Definition: LArHEC_ID.h:85
FixLArElecCalib::~FixLArElecCalib
virtual ~FixLArElecCalib()=default
FixLArElecCalib::m_sonline_idhelper
const LArOnline_SuperCellID * m_sonline_idhelper
Definition: FixLArElecCalib.h:133
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix10 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
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
HWIdentifier
Definition: HWIdentifier.h:13
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
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
FixLArElecCalib::m_sfcal_idhelper
const LArFCAL_SuperCell_ID * m_sfcal_idhelper
Definition: FixLArElecCalib.h:132
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode updateEMfSampl ATLAS_NOT_THREAD_SAFE(const std::string &filename, const LArOnOffIdMapping *cabling)
AthAlgorithm.h
LArEM_SuperCell_ID
Helper class for LArEM offline identifiers for supercells.
Definition: LArEM_SuperCell_ID.h:122
FixLArElecCalib
fix electronic calibration constants for MC.
Definition: FixLArElecCalib.h:39
LArOnOffIdMapping.h
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode updateHADfSampl ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Ringer::EM
@ EM
Definition: CaloRingsDefs.h:19
FixLArElecCalib::m_em_idhelper
const LArEM_ID * m_em_idhelper
Definition: FixLArElecCalib.h:126
CaloCell_SuperCell_ID
Helper class for offline supercell identifiers.
Definition: CaloCell_SuperCell_ID.h:48
FixLArElecCalib::m_sem_idhelper
const LArEM_SuperCell_ID * m_sem_idhelper
Definition: FixLArElecCalib.h:130
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArRampMC.h
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArShapeP1
c-struct reproducing the structure of the persistent data
Definition: LArShapeP1.h:16
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix5 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix4 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
FixLArElecCalib::m_online_idhelper
const LArOnlineID * m_online_idhelper
Definition: FixLArElecCalib.h:129
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArfSamplMC.h
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix15 ATLAS_NOT_THREAD_SAFE()
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode updateEM_DACuAMeV ATLAS_NOT_THREAD_SAFE(const std::string &filename, const LArOnOffIdMapping *cabling)
FixLArElecCalib::fix14
StatusCode fix14(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:2078
AthAlgorithm
Definition: AthAlgorithm.h:47
LArNoiseP
Definition: LArNoiseP.h:12
ReadCondHandleKey.h
FixLArElecCalib::m_g4Phys
std::string m_g4Phys
Definition: FixLArElecCalib.h:123
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
FixLArElecCalib::set_object
void set_object(LArNoiseMC::LArCondObj &obj, const std::vector< float > &v)
Definition: FixLArElecCalib.cxx:1296
FixLArElecCalib::execute
virtual StatusCode execute() override
Definition: FixLArElecCalib.cxx:150
HWIdentifier.h
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix11 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArAutoCorrMC.h
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode update_EM_HEC ATLAS_NOT_THREAD_SAFE(const std::string &em_filename, const std::string &hec_filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
LArOnlineID
Definition: LArOnlineID.h:20
FixLArElecCalib::print_object
void print_object(const std::string &msg, const LArNoiseMC::LArCondObj &obj)
Definition: FixLArElecCalib.cxx:1287
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
FixLArElecCalib::FixLArElecCalib
FixLArElecCalib(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FixLArElecCalib.cxx:111
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
virtual StatusCode stop ATLAS_NOT_THREAD_SAFE() override
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix3 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
FixLArElecCalib::m_fixFlag
int m_fixFlag
Definition: FixLArElecCalib.h:122
SG::ReadCondHandleKey< LArOnOffIdMapping >
python.PyAthena.v
v
Definition: PyAthena.py:154
FixLArElecCalib::m_cache
VROW_t m_cache[3]
Definition: FixLArElecCalib.h:142
FixLArElecCalib::fix2
StatusCode fix2(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:301
FixLArElecCalib::m_infile
std::string m_infile
Definition: FixLArElecCalib.h:124
Identifier::getString
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Definition: Identifier.cxx:25
FixLArElecCalib::fix13
StatusCode fix13(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:1739
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArShape32MC.h
LArHEC_SuperCell_ID
Helper class for LArHEC offline identifiers for supercells.
Definition: LArHEC_SuperCell_ID.h:59
FixLArElecCalib::fix18
StatusCode fix18(const LArCalibLineMapping *clmap)
Definition: FixLArElecCalib.cxx:2238
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
FixLArElecCalib::ROW_t
std::pair< HWIdentifier, std::vector< float > > ROW_t
Definition: FixLArElecCalib.h:139
FixLArElecCalib::VROW_t
std::vector< ROW_t > VROW_t
Definition: FixLArElecCalib.h:140
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
FixLArElecCalib::fix1
StatusCode fix1(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:225
FixLArElecCalib::ReadFile
StatusCode ReadFile(const std::string &filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar)
Definition: FixLArElecCalib.cxx:1148
PlotCalibFromCool.ngain
ngain
Definition: PlotCalibFromCool.py:565
FixLArElecCalib::addMphysOverMcal
StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:1430
FixLArElecCalib::update_DAC2uA
StatusCode update_DAC2uA(const std::string &em_filename, const std::string &hec_filename)
LArEM_ID
Helper class for LArEM offline identifiers.
Definition: LArEM_ID.h:118
FixLArElecCalib::fix12
StatusCode fix12(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:2010
FixLArElecCalib::m_CLKey
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
Definition: FixLArElecCalib.h:71
checker_macros.h
Define macros for attributes used to control the static checker.
python.PyAthena.obj
obj
Definition: PyAthena.py:132
LArFCAL_ID
Helper class for LArFCAL offline identifiers.
Definition: LArFCAL_ID.h:60
LArCalibLineMapping.h
StoreGateSvc.h
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fixDACuAMeV ATLAS_NOT_THREAD_SAFE()
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
LArNoiseMC.h
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode update_All ATLAS_NOT_THREAD_SAFE(const std::string &filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
FixLArElecCalib::ATLAS_NOT_THREAD_SAFE
StatusCode fix8 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
FixLArElecCalib::m_scell_idhelper
const CaloCell_SuperCell_ID * m_scell_idhelper
Definition: FixLArElecCalib.h:134