ATLAS Offline Software
Loading...
Searching...
No Matches
FixLArElecCalib.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef FIXLARELECCALIB_H
6#define FIXLARELECCALIB_H
7
12#include "LArCabling/LArOnOffIdMapping.h" //template argument
13#include "LArRecConditions/LArCalibLineMapping.h" //template argument
14#include "LArRawConditions/LArMphysOverMcalMC.h" //template argument
15#include "LArRawConditions/LArShape32MC.h" //typedef
16#include "LArRawConditions/LArNoiseMC.h" //typedef
17#include "LArRawConditions/LArRampMC.h" //typedef
18#include "LArRawConditions/LArAutoCorrMC.h" //typedef
19#include <string>
20#include <string_view>
21#include <utility> //std::pair
22#include <vector>
23
24
25class LArSingleFloatP;
26class LArEM_ID ;
27class LArHEC_ID;
28class LArFCAL_ID;
29class LArOnlineID;
32
33// this class is collection of various fixes, applied to LAr conditions,
34// when some bug was found.
35// should serve mainly as example, in case yet another problem will need a fix
37{
38 public:
39 FixLArElecCalib(const std::string& name,ISvcLocator* pSvcLocator);
40 virtual ~FixLArElecCalib() = default;
41
42 virtual StatusCode initialize() override;
43 virtual StatusCode execute() override;
44 virtual StatusCode finalize() override {return StatusCode::SUCCESS;}
45 virtual StatusCode stop ATLAS_NOT_THREAD_SAFE () override;
46
47 StatusCode fix1(const LArOnOffIdMapping *cabling);
48 StatusCode fix2(const LArOnOffIdMapping *cabling);
49 StatusCode fix3 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
50 StatusCode fix4 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
51 StatusCode fix5 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
52 StatusCode fix6 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
53 StatusCode fix7 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
54 StatusCode fix8 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
55 StatusCode fix9 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
56 StatusCode fix10 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
57 StatusCode fix11 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
58 StatusCode fix12(const LArOnOffIdMapping *cabling);
59 StatusCode fix13(const LArOnOffIdMapping *cabling);
60 StatusCode fix14(const LArOnOffIdMapping *cabling);
61 StatusCode fix15 ATLAS_NOT_THREAD_SAFE ();
62 StatusCode fix16 ATLAS_NOT_THREAD_SAFE ();
63 StatusCode fix17 ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
64 StatusCode fix18(const LArCalibLineMapping *clmap);
65
66 private:
67
68 SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};
69 SG::ReadCondHandleKey<LArCalibLineMapping> m_CLKey{this, "CalibLineKey", "LArCalibLineMap", "calib line key"};
70
71 IntegerProperty m_fixFlag{this, "FixFlag", 1, "which fix to apply"};
72 StringProperty m_g4Phys{this, "G4Phys", "", "which physics list to use"};
73 StringProperty m_infile{this, "InputFile", "", "name of inpput file"};
74
75 StatusCode ReadFile(const std::string& filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar );
76 StatusCode ReadFileAll(const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar );
77
78 StatusCode update_DAC2uA(const std::string& em_filename,const std::string& hec_filename);
79 // FIXME: for future round of developments:
80 // StatusCode update_uA2MeV(const std::string& em_filename,const std::string& hec_filename);
81 // StatusCode update_AC(const std::string& em_filename,const std::string& hec_filename);
82 //StatusCode update_Noise(const std::string& em_filename,const std::string& hec_filename);
83 //StatusCode update_Mphys(const std::string& em_filename,const std::string& hec_filename);
84 //StatusCode update_Ramp(const std::string& em_filename,const std::string& hec_filename);
85 //StatusCode update_Shape(const std::string& em_filename,const std::string& hec_filename);
86
87 template <class T>
88 StatusCode update_EM_HEC ATLAS_NOT_THREAD_SAFE (const std::string& em_filename,const std::string& hec_filename, const LArOnOffIdMapping *cabling,
89 bool withGain, int nvar);
90 template <class T>
91 StatusCode update_All ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar);
92
93 void print_object(std::string_view msg, const LArNoiseMC::LArCondObj& obj);
94 void set_object(LArNoiseMC::LArCondObj& obj, const std::vector<float>& v );
95
96 void print_object(std::string_view msg, const LArAutoCorrMC::LArCondObj& obj);
97 void set_object(LArAutoCorrMC::LArCondObj& obj, const std::vector<float>& v );
98
99 void print_object(std::string_view, const LArRampMC::LArCondObj& obj);
100 void set_object(LArRampMC::LArCondObj& obj, const std::vector<float>& v );
101
102 void print_object(std::string_view msg, const LArShape32MC::LArCondObj& obj);
103 void set_object(LArShape32MC::LArCondObj& obj, const std::vector<float>& v );
104
105 void print_object(std::string_view msg, const LArSingleFloatP& obj);
106 void set_object(LArSingleFloatP& obj, const std::vector<float>& v );
107
108 StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling) ; // add new one with default for FCAL
109
110 StatusCode fixDACuAMeV ATLAS_NOT_THREAD_SAFE () ; // remove -100000000
111
112
113 StatusCode updateEMfSampl ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
114 StatusCode updateMinBias ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
115 StatusCode updateEM_DACuAMeV ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling);
116 StatusCode updateHADfSampl ATLAS_NOT_THREAD_SAFE (const LArOnOffIdMapping *cabling);
117
126
127 typedef std::pair<HWIdentifier,std::vector<float> > ROW_t ;
128 typedef std::vector<ROW_t> VROW_t;
129
131
132
133};
134
135template <class T >
136 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)
137{
138 // read in the file
139
140 const T * container_c = nullptr;
141 ATH_CHECK( detStore()->retrieve(container_c) );
142
143 T* container = const_cast<T*>(container_c);
144
145 typedef typename T::LArCondObj CONDOBJ ;
146
147 for (int i=0; i<2;++i)
148 { // EM and HEC
149 if( i==0 )
150 {
151 if ( em_filename == "") continue ;
152 bool EM=true;
153 ATH_CHECK( ReadFile(em_filename,cabling,EM,withGain,nvar) );
154 }
155 if( i==1 )
156 {
157 if ( hec_filename == "") continue ;
158 bool EM=false ;
159 ATH_CHECK( ReadFile(hec_filename,cabling,EM,withGain,nvar) );
160 }
161
162
163 int ngain=1;
164 if (withGain) ngain=3;
165 for (int igain = 0;igain<ngain;++igain){
166 VROW_t::iterator it = m_cache[igain].begin();
167 VROW_t::iterator it_e = m_cache[igain].end();
168
169 int n=0;
170 for( ;it!=it_e;++it)
171 {
172 HWIdentifier hid = (*it).first;
173
174 const CONDOBJ& u = container->get(hid,igain);
175
176 if( u.isEmpty() )
177 {
178 ATH_MSG_WARNING(" No existing conditions data, adding new one " );
179 CONDOBJ t ;
180 set_object(t,(*it).second) ;
181 container->setPdata(hid,t,igain);
182 }
183 else
184 {
185 print_object(" Old object = ",u);
186
187 CONDOBJ& u2 = const_cast<CONDOBJ&>(u);
188 set_object(u2,(*it).second) ;
189 }
190
191 const CONDOBJ& u3 = container->get(hid,igain);
192 print_object(" New object = ",u3);
193
194 ++n;
195 }
196 ATH_MSG_INFO( " done for gain ="<<igain<<" with "<<n<<" objects");
197
198 }// gain
199 }// EM HEC
200
201 ATH_MSG_INFO(" done with EM "<<em_filename<<" and HEC" <<hec_filename );
202 return StatusCode::SUCCESS;
203}
204
205
206template <class T >
207 StatusCode FixLArElecCalib::update_All ATLAS_NOT_THREAD_SAFE (const std::string& filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
208{
209 // read in the file
210
211 const T * container_c = nullptr;
212 ATH_CHECK( detStore()->retrieve(container_c) );
213
214 T* container = const_cast<T*>(container_c);
215
216 typedef typename T::LArCondObj CONDOBJ ;
217
218 if ( filename == "") { ATH_MSG_ERROR("No input filename "); return StatusCode::FAILURE; }
219 ATH_CHECK( ReadFileAll(filename, cabling, withGain,nvar) );
220
221 int ngain=1;
222 if (withGain) ngain=3;
223 for (int igain = 0;igain<ngain;++igain){
224 VROW_t::iterator it = m_cache[igain].begin();
225 VROW_t::iterator it_e = m_cache[igain].end();
226
227 int n=0;
228 for( ;it!=it_e;++it) {
229 HWIdentifier hid = (*it).first;
230
231 if(!hid.is_valid()) {
232 ATH_MSG_WARNING(" Not valid hid: 0x" <<hid.getString() );
233 continue;
234 }
235
236 const CONDOBJ& u = container->get(hid,igain);
237
238 if( u.isEmpty() ) {
239 ATH_MSG_WARNING(" Not existing conditions data, adding new one " );
240 CONDOBJ t ;
241 set_object(t,(*it).second) ;
242 container->setPdata(hid,t,igain);
243 } else {
244 print_object(" Old object = ",u);
245
246 CONDOBJ& u2 = const_cast<CONDOBJ&>(u);
247 set_object(u2,(*it).second) ;
248 }
249
250 const CONDOBJ& u3 = container->get(hid,igain);
251 print_object(" New object = ",u3);
252
253 ++n;
254 }
255 ATH_MSG_INFO( " done for gain ="<<igain<<" with "<<n<<" objects");
256
257 }// gain
258
259 ATH_MSG_INFO(" done with "<<filename );
260 return StatusCode::SUCCESS;
261}
262#endif // FixLArElecCalib
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
Define macros for attributes used to control the static checker.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
MsgStream & msg() const
Helper class for offline supercell identifiers.
StatusCode fix3 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
StatusCode fix13(const LArOnOffIdMapping *cabling)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
StatusCode fix12(const LArOnOffIdMapping *cabling)
StatusCode fix9 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
void set_object(LArNoiseMC::LArCondObj &obj, const std::vector< float > &v)
StatusCode ReadFile(const std::string &filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar)
const LArOnline_SuperCellID * m_sonline_idhelper
virtual StatusCode initialize() override
StatusCode fix6 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
virtual ~FixLArElecCalib()=default
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)
StatusCode fix2(const LArOnOffIdMapping *cabling)
virtual StatusCode finalize() override
StatusCode updateHADfSampl ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
const LArEM_SuperCell_ID * m_sem_idhelper
StringProperty m_infile
StatusCode fix10 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
StatusCode fix1(const LArOnOffIdMapping *cabling)
StatusCode update_All ATLAS_NOT_THREAD_SAFE(const std::string &filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
StatusCode updateMinBias ATLAS_NOT_THREAD_SAFE(const std::string &filename, const LArOnOffIdMapping *cabling)
std::vector< ROW_t > VROW_t
virtual StatusCode execute() override
StatusCode updateEMfSampl ATLAS_NOT_THREAD_SAFE(const std::string &filename, const LArOnOffIdMapping *cabling)
StatusCode fix18(const LArCalibLineMapping *clmap)
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
StringProperty m_g4Phys
StatusCode update_DAC2uA(const std::string &em_filename, const std::string &hec_filename)
StatusCode fix8 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
StatusCode fixDACuAMeV ATLAS_NOT_THREAD_SAFE()
StatusCode fix11 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
StatusCode fix15 ATLAS_NOT_THREAD_SAFE()
const LArHEC_ID * m_hec_idhelper
IntegerProperty m_fixFlag
StatusCode fix7 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
const LArOnlineID * m_online_idhelper
virtual StatusCode stop ATLAS_NOT_THREAD_SAFE() override
void print_object(std::string_view msg, const LArNoiseMC::LArCondObj &obj)
const LArFCAL_ID * m_fcal_idhelper
StatusCode fix17 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
const CaloCell_SuperCell_ID * m_scell_idhelper
const LArEM_ID * m_em_idhelper
StatusCode fix4 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
std::pair< HWIdentifier, std::vector< float > > ROW_t
StatusCode fix14(const LArOnOffIdMapping *cabling)
StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling)
const LArHEC_SuperCell_ID * m_shec_idhelper
StatusCode updateEM_DACuAMeV ATLAS_NOT_THREAD_SAFE(const std::string &filename, const LArOnOffIdMapping *cabling)
StatusCode ReadFileAll(const std::string &filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
StatusCode fix16 ATLAS_NOT_THREAD_SAFE()
StatusCode fix5 ATLAS_NOT_THREAD_SAFE(const LArOnOffIdMapping *cabling)
FixLArElecCalib(const std::string &name, ISvcLocator *pSvcLocator)
std::string getString() const
Provide a string form of the identifier - hexadecimal.
bool is_valid() const
Check if id is in a valid state.
Helper class for LArEM offline identifiers.
Definition LArEM_ID.h:111
Helper class for LArEM offline identifiers for supercells.
Helper class for LArFCAL offline identifiers.
Definition LArFCAL_ID.h:49
Helper class for LArHEC offline identifiers.
Definition LArHEC_ID.h:76
Helper class for LArHEC offline identifiers for supercells.