ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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, "CalibLineKey", "LArCalibLineMap", "calib line key"};
72 
73  IntegerProperty m_fixFlag{this, "FixFlag", 1, "which fix to apply"};
74  StringProperty m_g4Phys{this, "G4Phys", "", "which physics list to use"};
75  StringProperty m_infile{this, "InputFile", "", "name of inpput file"};
76 
77  StatusCode ReadFile(const std::string& filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar );
78  StatusCode ReadFileAll(const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar );
79 
80  StatusCode update_DAC2uA(const std::string& em_filename,const std::string& hec_filename);
81  // FIXME: for future round of developments:
82  // StatusCode update_uA2MeV(const std::string& em_filename,const std::string& hec_filename);
83  // StatusCode update_AC(const std::string& em_filename,const std::string& hec_filename);
84  //StatusCode update_Noise(const std::string& em_filename,const std::string& hec_filename);
85  //StatusCode update_Mphys(const std::string& em_filename,const std::string& hec_filename);
86  //StatusCode update_Ramp(const std::string& em_filename,const std::string& hec_filename);
87  //StatusCode update_Shape(const std::string& em_filename,const std::string& hec_filename);
88 
89  template <class T>
90  StatusCode update_EM_HEC ATLAS_NOT_THREAD_SAFE (const std::string& em_filename,const std::string& hec_filename, const LArOnOffIdMapping *cabling,
91  bool withGain, int nvar);
92  template <class T>
93  StatusCode update_All ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar);
94 
95  void print_object(const std::string& msg, const LArNoiseMC::LArCondObj& obj);
96  void set_object(LArNoiseMC::LArCondObj& obj, const std::vector<float>& v );
97 
98  void print_object(const std::string& msg, const LArAutoCorrMC::LArCondObj& obj);
99  void set_object(LArAutoCorrMC::LArCondObj& obj, const std::vector<float>& v );
100 
101  void print_object(const std::string& msg, const LArRampMC::LArCondObj& obj);
102  void set_object(LArRampMC::LArCondObj& obj, const std::vector<float>& v );
103 
104  //void print_object(const std::string& msg, const LAruA2MeVMC::LArCondObj& obj);
105  //void set_object(LAruA2MeVMC::LArCondObj& obj, std::vector<float>& v );
106 
107  void print_object(const std::string& msg, const LArShape32MC::LArCondObj& obj);
108  void set_object(LArShape32MC::LArCondObj& obj, const std::vector<float>& v );
109 
110  void print_object(const std::string& msg, const LArSingleFloatP& obj);
111  void set_object(LArSingleFloatP& obj, const std::vector<float>& v );
112 
113  // void print_object(const std::string& msg, const LArDAC2uAMC::LArCondObj& obj);
114  //void set_object(LArDAC2uAMC::LArCondObj& obj, std::vector<float>& v );
115 
116  StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling) ; // add new one with default for FCAL
117 
118  StatusCode fixDACuAMeV ATLAS_NOT_THREAD_SAFE () ; // remove -100000000
119 
120 
121  StatusCode updateEMfSampl ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
122  StatusCode updateMinBias ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
123  StatusCode updateEM_DACuAMeV ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
125 
134 
135 
136 
137 
138  typedef std::pair<HWIdentifier,std::vector<float> > ROW_t ;
139  typedef std::vector<ROW_t> VROW_t;
140 
142 
143 
144 };
145 
146 template <class T >
147  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)
148 {
149  // read in the file
150 
151  const T * container_c = nullptr;
152  ATH_CHECK( detStore()->retrieve(container_c) );
153 
154  T* container = const_cast<T*>(container_c);
155 
156  typedef typename T::LArCondObj CONDOBJ ;
157 
158  for (int i=0; i<2;++i)
159  { // EM and HEC
160  if( i==0 )
161  {
162  if ( em_filename == "") continue ;
163  bool EM=true;
164  ATH_CHECK( ReadFile(em_filename,cabling,EM,withGain,nvar) );
165  }
166  if( i==1 )
167  {
168  if ( hec_filename == "") continue ;
169  bool EM=false ;
170  ATH_CHECK( ReadFile(hec_filename,cabling,EM,withGain,nvar) );
171  }
172 
173 
174  int ngain=1;
175  if (withGain) ngain=3;
176  for (int igain = 0;igain<ngain;++igain){
177  VROW_t::iterator it = m_cache[igain].begin();
178  VROW_t::iterator it_e = m_cache[igain].end();
179 
180  int n=0;
181  for( ;it!=it_e;++it)
182  {
183  HWIdentifier hid = (*it).first;
184 
185  const CONDOBJ& u = container->get(hid,igain);
186 
187  if( u.isEmpty() )
188  {
189  ATH_MSG_WARNING(" No existing conditions data, adding new one " );
190  CONDOBJ t ;
191  set_object(t,(*it).second) ;
192  container->setPdata(hid,t,igain);
193  }
194  else
195  {
196  print_object(" Old object = ",u);
197 
198  CONDOBJ& u2 = const_cast<CONDOBJ&>(u);
199  set_object(u2,(*it).second) ;
200  }
201 
202  const CONDOBJ& u3 = container->get(hid,igain);
203  print_object(" New object = ",u3);
204 
205  ++n;
206  }
207  ATH_MSG_INFO( " done for gain ="<<igain<<" with "<<n<<" objects");
208 
209  }// gain
210  }// EM HEC
211 
212  ATH_MSG_INFO(" done with EM "<<em_filename<<" and HEC" <<hec_filename );
213  return StatusCode::SUCCESS;
214 }
215 
216 
217 template <class T >
218  StatusCode FixLArElecCalib::update_All ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
219 {
220  // read in the file
221 
222  const T * container_c = nullptr;
223  ATH_CHECK( detStore()->retrieve(container_c) );
224 
225  T* container = const_cast<T*>(container_c);
226 
227  typedef typename T::LArCondObj CONDOBJ ;
228 
229  if ( filename == "") { ATH_MSG_ERROR("No input filename "); return StatusCode::FAILURE; }
230  ATH_CHECK( ReadFileAll(filename, cabling, withGain,nvar) );
231 
232  int ngain=1;
233  if (withGain) ngain=3;
234  for (int igain = 0;igain<ngain;++igain){
235  VROW_t::iterator it = m_cache[igain].begin();
236  VROW_t::iterator it_e = m_cache[igain].end();
237 
238  int n=0;
239  for( ;it!=it_e;++it) {
240  HWIdentifier hid = (*it).first;
241 
242  if(!hid.is_valid()) {
243  ATH_MSG_WARNING(" Not valid hid: 0x" <<hid.getString() );
244  continue;
245  }
246 
247  const CONDOBJ& u = container->get(hid,igain);
248 
249  if( u.isEmpty() ) {
250  ATH_MSG_WARNING(" Not existing conditions data, adding new one " );
251  CONDOBJ t ;
252  set_object(t,(*it).second) ;
253  container->setPdata(hid,t,igain);
254  } else {
255  print_object(" Old object = ",u);
256 
257  CONDOBJ& u2 = const_cast<CONDOBJ&>(u);
258  set_object(u2,(*it).second) ;
259  }
260 
261  const CONDOBJ& u3 = container->get(hid,igain);
262  print_object(" New object = ",u3);
263 
264  ++n;
265  }
266  ATH_MSG_INFO( " done for gain ="<<igain<<" with "<<n<<" objects");
267 
268  }// gain
269 
270  ATH_MSG_INFO(" done with "<<filename );
271  return StatusCode::SUCCESS;
272 }
273 #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:1214
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::m_fixFlag
IntegerProperty m_fixFlag
Definition: FixLArElecCalib.h:73
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:126
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
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
skel.it
it
Definition: skel.GENtoEVGEN.py:407
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:147
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:132
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::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::m_g4Phys
StringProperty m_g4Phys
Definition: FixLArElecCalib.h:74
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:2072
AthAlgorithm
Definition: AthAlgorithm.h:47
LArNoiseP
Definition: LArNoiseP.h:12
ReadCondHandleKey.h
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:1290
FixLArElecCalib::execute
virtual StatusCode execute() override
Definition: FixLArElecCalib.cxx:144
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:240
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:1281
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)
SG::ReadCondHandleKey< LArOnOffIdMapping >
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:295
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:1733
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:2232
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
FixLArElecCalib::ROW_t
std::pair< HWIdentifier, std::vector< float > > ROW_t
Definition: FixLArElecCalib.h:138
FixLArElecCalib::VROW_t
std::vector< ROW_t > VROW_t
Definition: FixLArElecCalib.h:139
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
FixLArElecCalib::fix1
StatusCode fix1(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:219
FixLArElecCalib::ReadFile
StatusCode ReadFile(const std::string &filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar)
Definition: FixLArElecCalib.cxx:1142
PlotCalibFromCool.ngain
ngain
Definition: PlotCalibFromCool.py:565
FixLArElecCalib::addMphysOverMcal
StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling)
Definition: FixLArElecCalib.cxx:1424
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:2004
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
FixLArElecCalib::m_infile
StringProperty m_infile
Definition: FixLArElecCalib.h:75
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:133