ATLAS Offline Software
Loading...
Searching...
No Matches
CaloNoiseCompCondAlg.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11#ifndef CALOCONDPHYSALGS_CaloNoiseCompCondAlg_H
12#define CALOCONDPHYSALGS_CaloNoiseCompCondAlg_H
13
15#include "CaloDetDescr/CaloDetDescrManager.h" //read handle
16#include "CaloIdentifier/CaloCell_ID.h" //use of enum in namespace
17#include "CaloConditions/CaloNoise.h" //write handle
18#include "CaloIdentifier/CaloGain.h" //use of enum in namespace
19#include "LArCabling/LArOnOffIdMapping.h" //read handle
20#include "LArElecCalib/ILArShape.h" //read handle
21#include "LArElecCalib/ILArPedestal.h" //read handle
22#include "LArElecCalib/ILArfSampl.h" //read handle
23#include "LArElecCalib/ILArMinBias.h" //read handle
24#include "LArElecCalib/ILArAutoCorr.h" //read handle
25#include "LArRawConditions/LArADC2MeV.h" //read handle
26#include "LArRawConditions/LArOFC.h" //read handle
29
30class AtlasDetectorID;
31class CaloIdManager;
32class CaloCell;
33
34typedef std::vector< std::vector<float> > VectorContainer;
35typedef std::vector< float > SingleContainer;
36
41 ELECTRONICNOISE = 100, /* return the electronic noise */
42 ELECTRONICNOISE_HIGHESTGAIN = 101, /* same in highest gain */
43 PILEUPNOISE = 200, /* return the pileup noise */
44 PILEUPNOISE_HIGHESTGAIN = 201, /* return the pileup noise */
45 TOTALNOISE = 300, /* return the total noise */
46 TOTALNOISE_HIGHESTGAIN = 301, /* return the total noise */
47 JOBOPTION = 9999 /* defined by jobOptions */ };
48
50 ONLYRIGHTSIDEINTEGRATION = 0, /* integral pdf from E to infinity (or -infinity to E is E<0) */
51 ABSOLUTEENERGYVALUE = 1, /* integral pdf from abs(E) to infinity */
52 MAXSYMMETRYHANDLING = 9999 /* defined by jobOptions */ };
53
55 NCALOS = 4,
56 NGAINS = 3,};
57
58namespace CLHEP { class HepRandomEngine; }
59
61
62 public:
63
65 CaloNoiseCompCondAlg(const std::string& name, ISvcLocator* pSvcLocator);
67 virtual ~CaloNoiseCompCondAlg() = default;
68
70 virtual StatusCode initialize() override final;
72 virtual StatusCode execute(const EventContext& /*ctx*/) const override final {return StatusCode::SUCCESS;};
74 virtual StatusCode finalize() override final {return StatusCode::SUCCESS;};
75
76 // all the meat is here:
77 virtual StatusCode stop() override final;
78
79 //-------------- user interfaces ------------------------------------------
80 // Note on NMinBias : if you use the interface without it or if you take -1,
81 // the returned data will be the one calculated at the
82 // initialization with the default value (0) or the
83 // specified one (with the property m_Nminbias).
84 // In all cases, the NMinBias used to calculate the OFCs
85 // is NOT known by CaloNoiseCompCondAlg (CaloNoiseCompCondAlg always
86 // recomputes OFCs for its own needs)
87
88
89
90
91
92 //== ELECTRONIC NOISE ==
93
94 //''''''''' functions to use currently
95
96 float elecNoiseRMS(const CaloCell* caloCell);
97 //Returns the sigma of the electronic noise, finding itself the right gain
98 //from the energy of the given caloCell.
99
100
101 float elecNoiseRMS(const CaloDetDescrElement* caloDDE,
102 const CaloGain::CaloGain gain);
103 //Returns the sigma of the electronic noise for the given caloDDE, gain and
104 //the number of minimum bias events per bunch crossing.
105
106 std::vector<float>
108 //Returns a vector containing the sigma of the electronic noise for the
109 //given caloDDE, for each gain of the considered calorimeter
110 //(eg: vector of 3 sigma3 gains for LAr)
111
112
113
114 //== PILEUP NOISE ==
115
116 float pileupNoiseRMS(const CaloCell* caloCell,
117 const float Nminbias=-1);
119 const float Nminbias=-1);
120 //Nminbias is the number of minimum-bias events per bunch-crossing
121 // (default is 0 (set in the constructor) )
122
123 //== TOTAL NOISE ==
124
125 float totalNoiseRMS(const CaloCell* caloCell,
126 const float Nminbias=-1);
128 const CaloGain::CaloGain gain,
129 const float Nminbias=-1);
130 float totalNoiseRMSHighestGain(const CaloCell* caloCell,
131 const float Nminbias=-1);
133 const float Nminbias=-1);
134
135
136
137 //== GAIN ==
140 const CaloDetDescrElement* caloDDE);
142 const float &energy);
143
144 //== ADDITIONNAL STUFF ==
145 // these functions will be replaced soon by dedicated tools,
146 // so please AVOID TO USING THEM
147
148 //float eScale(const CaloDetDescrElement* caloDDE);
149 //Returns the scale between RawChannels and Cells, i.e
150 //what returns LArG3Escale
151
152 float adc2mev(const CaloDetDescrElement* caloDDE,
153 const CaloGain::CaloGain gain);
154 //Returns adc2mev factor for the given caloDDE and gain
155
157 //Returns adc2mev factor for the given ID and gain
158 //SHOULD NOT BE USED ANYMORE, prefer the one above with caloDDE
159
160 private:
161
163
164
165 //Constants
166 static constexpr int m_nCalos=NCALOS;// number of calorimeters
167 static constexpr int m_nGains=NGAINS;// number of gains
171
174 int m_nReason[5000][m_nGains]{};
176 int m_idHash[5000][m_nGains]{};
177 int m_reason[5000][10][m_nGains]{};
178
179 std::string m_reasonName[10];
180
181 //Identifiers
183
185
189
192
197
198
199
200 // Properties
201 IntegerProperty m_deltaBunch{this, "deltaBunch", 1};
202 UnsignedIntegerProperty m_firstSample{this, "firstSample", 0};
203 BooleanProperty m_UseSymmetry{this, "UseSymmetry", true};
204 BooleanProperty m_DiagnosticHG{this, "DiagnosticHG", false};
205 BooleanProperty m_DiagnosticMG{this, "DiagnosticMG", false};
206 BooleanProperty m_DiagnosticLG{this, "DiagnosticLG", false};
207 BooleanProperty m_DumpDatabaseHG{this, "DumpDatabaseHG", false};
208 BooleanProperty m_DumpDatabaseMG{this, "DumpDatabaseMG", false};
209 BooleanProperty m_DumpDatabaseLG{this, "DumpDatabaseLG", false};
210 FloatProperty m_Nminbias{this, "NMinBias", -1};
211 BooleanProperty m_isSC{this, "SuperCell", false};
212
213
214 //Database
215
220 float m_c[32][32]{};
224 float m_fSampl{};
225 double m_AdcPerMev{};
227
228 SG::ReadCondHandleKey<CaloDetDescrManager> m_caloMgrKey {this,"CaloDetDescrManager", "CaloDetDescrManager", "SG Key for CaloDetDescrManager in the Condition Store" };
229 SG::ReadCondHandleKey<CaloSuperCellDetDescrManager> m_caloSCMgrKey {this,"CaloSuperCellDetDescrManager", "CaloSuperCellDetDescrManager", "SG Key for CaloSuperCellDetDescrManager in the Condition Store" };
231
232 SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};
234
235 SG::ReadCondHandleKey<LArADC2MeV> m_adc2mevKey{this, "ADC2MeVKey", "LArADC2MeV", "SG Key of the LArADC2MeV CDO" };
236
237 SG::ReadCondHandleKey<ILArPedestal> m_pedestalKey{this,"PedestalKey","LArPedestal","SG Key of LArPedestal object"};
238 const ILArPedestal *m_ped=nullptr;
239
240 SG::ReadCondHandleKey<ILArNoise> m_noiseKey{this,"NoiseKey","","SG Key of LArNoise object"};
241 const ILArNoise *m_noise=nullptr;
242
243 SG::ReadCondHandleKey<ILArAutoCorr> m_acorrKey{this,"AutocorrKey","LArAutoCorrSym","SG Key of LArAutoCorr object"};
244 const ILArAutoCorr *m_acorr=nullptr;
245
246 SG::ReadCondHandleKey<ILArOFC> m_LArOFCObjKey{this, "OFKey","LArOFC", "SG Key of LAr OFCs"};
247 const ILArOFC *m_ofccond=nullptr;
248
249 SG::ReadCondHandleKey<ILArShape> m_shapeKey{this,"ShapeKey","LArShapeSym","SG Key of Shape conditions object"};
250 const ILArShape *m_shapecond=nullptr;
251
252 SG::ReadCondHandleKey<ILArfSampl> m_fSamplKey{this,"fSamplKey","LArfSamplSym","SG Key of LArfSampl object"};
253 const ILArfSampl *m_fsamplcond = nullptr;
254
255 SG::ReadCondHandleKey<ILArMinBias> m_LArMinBiasObjKey{this, "LArMinBiasKey", "LArMinBiasSym", "SG Key of LArMinBias"};
256 const ILArMinBias *m_minbias = nullptr;
257
258 // Output containers
259 SG::WriteCondHandleKey<CaloNoise> m_outputElecKey{this, "OutputElecKey", "elecNoise", "SG Key of resulting noise CDO"};
260 SG::WriteCondHandleKey<CaloNoise> m_outputPileupKey{this, "OutputPileupKey", "pileupNoise", "SG Key of resulting noise CDO"};
261
262
263 //Containers
264 std::vector<IdentifierHash> m_indexContainer;
265 // = vector indexed with all the hashids,
266 //containing which index (of container) should be used with a hashid
267 std::vector<IdentifierHash> m_idSymmCaloHashContainer;
268 //used only to initialize m_indexOfContainer
269
270
275
276
277 //Functions
278 StatusCode initContainers();
279 StatusCode initData(const LArADC2MeV *adc2mev);
280 StatusCode initIndex();
281 StatusCode initAdc2MeV(const LArADC2MeV *adc2mev);
282 StatusCode initElecNoise();
283 StatusCode initPileUpNoise();
284
285 bool checkIfConnected(const Identifier &id);
286 void commonCalculations(float & OFC_AC_OFC,float & OFC_OFC, int icase, unsigned int firstSample=0);
287 StatusCode retrieveCellDatabase(const IdentifierHash & idCaloHash,
288 const Identifier & id,int igain,
289 std::vector<bool> &retrieve);
290 StatusCode checkCellDatabase(const Identifier & id, int igain,
291 std::vector<bool> &retrieve);
292 void updateDiagnostic(int reason, const std::string &reason_name,int igain, bool &noiseOK);
293
294 std::vector<float>
295 calculateElecNoiseForLAR(const IdentifierHash &idCaloHash);
296
297 float
298 calculatePileUpNoise(const IdentifierHash &idCaloHash,
299 const float &Nminbias);
300
301 using AthCondAlgorithm::index;
302 int index(const IdentifierHash &idCaloHash);
303
305 bool isBadValue(float tested_value);
306
308 const CaloDetDescrElement* caloDDE,
309 const float &energy);
310
311
312
313};
314
315//------------------------------------------------------------
316
317inline bool
319{
320 if(tested_value<BADVALUE+1) return true;
321 return false;
322}
323
325
328{
329 return
330 static_cast<CaloCell_ID::SUBCALO>(m_calocell_id->sub_calo(idCaloHash));
331}
332
333#endif
334
Base class for conditions algorithms.
Definition of CaloDetDescrManager.
CalorimeterNoiseSymmetryHandling
@ ABSOLUTEENERGYVALUE
@ MAXSYMMETRYHANDLING
@ ONLYRIGHTSIDEINTEGRATION
@ BADVALUE_TO_RETURN
std::vector< std::vector< float > > VectorContainer
CalorimeterNoiseType
@ TOTALNOISE_HIGHESTGAIN
@ ELECTRONICNOISE
@ ELECTRONICNOISE_HIGHESTGAIN
@ PILEUPNOISE_HIGHESTGAIN
@ PILEUPNOISE
std::vector< float > SingleContainer
@ iSIGMANOISE
@ iMINBIASRMS
defines and typedefs for IOVSvc
#define NGAINS
Base class for conditions algorithms.
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Helper base class for offline cell identifiers.
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
Helper class for offline supercell identifiers.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class groups all DetDescr information related to a CaloCell.
This class initializes the Calo (LAr and Tile) offline identifiers.
virtual StatusCode stop() override final
CaloGain::CaloGain m_highestGain[m_nCalos]
void commonCalculations(float &OFC_AC_OFC, float &OFC_OFC, int icase, unsigned int firstSample=0)
StatusCode checkCellDatabase(const Identifier &id, int igain, std::vector< bool > &retrieve)
float adc2mev(const CaloDetDescrElement *caloDDE, const CaloGain::CaloGain gain)
float pileupNoiseRMS(const CaloCell *caloCell, const float Nminbias=-1)
virtual StatusCode initialize() override final
standard Athena-Algorithm method
StatusCode initData(const LArADC2MeV *adc2mev)
StatusCode retrieveCellDatabase(const IdentifierHash &idCaloHash, const Identifier &id, int igain, std::vector< bool > &retrieve)
int m_itReason[10][m_nGains]
const ILArPedestal * m_ped
std::vector< float > calculateElecNoiseForLAR(const IdentifierHash &idCaloHash)
CaloGain::CaloGain estimatedGain(const CaloCell *caloCell)
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSCMgrKey
std::vector< float > elecNoiseRMS3gains(const CaloDetDescrElement *caloDDE)
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
void updateDiagnostic(int reason, const std::string &reason_name, int igain, bool &noiseOK)
virtual StatusCode execute(const EventContext &) const override final
standard Athena-Algorithm method
int m_reason[5000][10][m_nGains]
float totalNoiseRMS(const CaloCell *caloCell, const float Nminbias=-1)
SG::WriteCondHandleKey< CaloNoise > m_outputPileupKey
int m_nReason[5000][m_nGains]
const ILArAutoCorr * m_acorr
VectorContainer m_elecNoiseCELLContainer
VectorContainer m_adc2mevContainer
float m_HighGainThresh[m_nCalos]
CaloGain::CaloGain estimatedLArGain(const CaloCell_ID::SUBCALO &iCalo, const CaloDetDescrElement *caloDDE, const float &energy)
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
BooleanProperty m_DumpDatabaseMG
SG::ReadCondHandleKey< ILArNoise > m_noiseKey
const ILArfSampl * m_fsamplcond
SG::ReadCondHandleKey< ILArAutoCorr > m_acorrKey
SG::ReadCondHandleKey< ILArShape > m_shapeKey
int m_idHash[5000][m_nGains]
BooleanProperty m_DumpDatabaseLG
const LArOnOffIdMapping * m_cabling
StatusCode initAdc2MeV(const LArADC2MeV *adc2mev)
std::vector< IdentifierHash > m_idSymmCaloHashContainer
VectorContainer m_elecNoiseRAWContainer
float m_LowGainThresh[m_nCalos]
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
UnsignedIntegerProperty m_firstSample
SG::ReadCondHandleKey< ILArOFC > m_LArOFCObjKey
const LArEM_Base_ID * m_lar_em_id
const AtlasDetectorID * m_atlas_id
const ILArMinBias * m_minbias
BooleanProperty m_DumpDatabaseHG
virtual StatusCode finalize() override final
standard Athena-Algorithm method
static constexpr int m_nGains
SingleContainer m_pileupNoiseContainer
SG::WriteCondHandleKey< CaloNoise > m_outputElecKey
CaloCell_ID::SUBCALO caloNum(const IdentifierHash idCaloHash)
CaloNoiseCompCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
const CaloIdManager * m_calo_id_man
const ILArShape * m_shapecond
const CaloDetDescrManager_Base * m_calo_dd_man
float totalNoiseRMSHighestGain(const CaloCell *caloCell, const float Nminbias=-1)
static constexpr int m_nCalos
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
SG::ReadCondHandleKey< ILArMinBias > m_LArMinBiasObjKey
const LArFCAL_Base_ID * m_lar_fcal_id
bool checkIfConnected(const Identifier &id)
bool isBadValue(float tested_value)
std::vector< IdentifierHash > m_indexContainer
const CaloCell_SuperCell_ID * m_calosupercell_id
const CaloCell_Base_ID * m_calocell_id
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
float calculatePileUpNoise(const IdentifierHash &idCaloHash, const float &Nminbias)
const LArHEC_Base_ID * m_lar_hec_id
virtual ~CaloNoiseCompCondAlg()=default
Default Destructor.
float elecNoiseRMS(const CaloCell *caloCell)
This class defines the interface for accessing AutoCorrelation parameters for each channel @stereotyp...
This is a "hash" representation of an Identifier.
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
This class factors out code common between LArEM_ID and LArEM_SuperCell_ID.
Proxy for accessing a range of float values like a vector.
Definition index.py:1
STL namespace.
#define private