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
28
29class AtlasDetectorID;
30class CaloIdManager;
31class CaloCell;
32
33typedef std::vector< std::vector<float> > VectorContainer;
34typedef std::vector< float > SingleContainer;
35
40 ELECTRONICNOISE = 100, /* return the electronic noise */
41 ELECTRONICNOISE_HIGHESTGAIN = 101, /* same in highest gain */
42 PILEUPNOISE = 200, /* return the pileup noise */
43 PILEUPNOISE_HIGHESTGAIN = 201, /* return the pileup noise */
44 TOTALNOISE = 300, /* return the total noise */
45 TOTALNOISE_HIGHESTGAIN = 301, /* return the total noise */
46 JOBOPTION = 9999 /* defined by jobOptions */ };
47
49 ONLYRIGHTSIDEINTEGRATION = 0, /* integral pdf from E to infinity (or -infinity to E is E<0) */
50 ABSOLUTEENERGYVALUE = 1, /* integral pdf from abs(E) to infinity */
51 MAXSYMMETRYHANDLING = 9999 /* defined by jobOptions */ };
52
54 NCALOS = 4,
55 NGAINS = 3,};
56
57namespace CLHEP { class HepRandomEngine; }
58
60
61 public:
62
64 CaloNoiseCompCondAlg(const std::string& name, ISvcLocator* pSvcLocator);
66 virtual ~CaloNoiseCompCondAlg() = default;
67
69 virtual StatusCode initialize() override final;
71 virtual StatusCode execute(const EventContext& /*ctx*/) const override final {return StatusCode::SUCCESS;};
73 virtual StatusCode finalize() override final {return StatusCode::SUCCESS;};
74
75 // all the meat is here:
76 virtual StatusCode stop() override final;
77
78 //-------------- user interfaces ------------------------------------------
79 // Note on NMinBias : if you use the interface without it or if you take -1,
80 // the returned data will be the one calculated at the
81 // initialization with the default value (0) or the
82 // specified one (with the property m_Nminbias).
83 // In all cases, the NMinBias used to calculate the OFCs
84 // is NOT known by CaloNoiseCompCondAlg (CaloNoiseCompCondAlg always
85 // recomputes OFCs for its own needs)
86
87
88
89
90
91 //== ELECTRONIC NOISE ==
92
93 //''''''''' functions to use currently
94
95 float elecNoiseRMS(const CaloCell* caloCell);
96 //Returns the sigma of the electronic noise, finding itself the right gain
97 //from the energy of the given caloCell.
98
99
100 float elecNoiseRMS(const CaloDetDescrElement* caloDDE,
101 const CaloGain::CaloGain gain);
102 //Returns the sigma of the electronic noise for the given caloDDE, gain and
103 //the number of minimum bias events per bunch crossing.
104
105 std::vector<float>
107 //Returns a vector containing the sigma of the electronic noise for the
108 //given caloDDE, for each gain of the considered calorimeter
109 //(eg: vector of 3 sigma3 gains for LAr)
110
111
112
113 //== PILEUP NOISE ==
114
115 float pileupNoiseRMS(const CaloCell* caloCell,
116 const float Nminbias=-1);
118 const float Nminbias=-1);
119 //Nminbias is the number of minimum-bias events per bunch-crossing
120 // (default is 0 (set in the constructor) )
121
122 //== TOTAL NOISE ==
123
124 float totalNoiseRMS(const CaloCell* caloCell,
125 const float Nminbias=-1);
127 const CaloGain::CaloGain gain,
128 const float Nminbias=-1);
129 float totalNoiseRMSHighestGain(const CaloCell* caloCell,
130 const float Nminbias=-1);
132 const float Nminbias=-1);
133
134
135
136 //== GAIN ==
139 const CaloDetDescrElement* caloDDE);
141 const float &energy);
142
143 //== ADDITIONNAL STUFF ==
144 // these functions will be replaced soon by dedicated tools,
145 // so please AVOID TO USING THEM
146
147 //float eScale(const CaloDetDescrElement* caloDDE);
148 //Returns the scale between RawChannels and Cells, i.e
149 //what returns LArG3Escale
150
151 float adc2mev(const CaloDetDescrElement* caloDDE,
152 const CaloGain::CaloGain gain);
153 //Returns adc2mev factor for the given caloDDE and gain
154
156 //Returns adc2mev factor for the given ID and gain
157 //SHOULD NOT BE USED ANYMORE, prefer the one above with caloDDE
158
159 private:
160
162
163
164 //Constants
165 static constexpr int m_nCalos=NCALOS;// number of calorimeters
166 static constexpr int m_nGains=NGAINS;// number of gains
170
173 int m_nReason[5000][m_nGains]{};
175 int m_idHash[5000][m_nGains]{};
176 int m_reason[5000][10][m_nGains]{};
177
178 std::string m_reasonName[10];
179
180 //Identifiers
182
184
188
191
196
197
198
199 // Properties
200 IntegerProperty m_deltaBunch{this, "deltaBunch", 1};
201 UnsignedIntegerProperty m_firstSample{this, "firstSample", 0};
202 BooleanProperty m_UseSymmetry{this, "UseSymmetry", true};
203 BooleanProperty m_DiagnosticHG{this, "DiagnosticHG", false};
204 BooleanProperty m_DiagnosticMG{this, "DiagnosticMG", false};
205 BooleanProperty m_DiagnosticLG{this, "DiagnosticLG", false};
206 BooleanProperty m_DumpDatabaseHG{this, "DumpDatabaseHG", false};
207 BooleanProperty m_DumpDatabaseMG{this, "DumpDatabaseMG", false};
208 BooleanProperty m_DumpDatabaseLG{this, "DumpDatabaseLG", false};
209 FloatProperty m_Nminbias{this, "NMinBias", -1};
210 BooleanProperty m_isSC{this, "SuperCell", false};
211
212
213 //Database
214
219 float m_c[32][32]{};
223 float m_fSampl{};
224 double m_AdcPerMev{};
226
227 SG::ReadCondHandleKey<CaloDetDescrManager> m_caloMgrKey {this,"CaloDetDescrManager", "CaloDetDescrManager", "SG Key for CaloDetDescrManager in the Condition Store" };
228 SG::ReadCondHandleKey<CaloSuperCellDetDescrManager> m_caloSCMgrKey {this,"CaloSuperCellDetDescrManager", "CaloSuperCellDetDescrManager", "SG Key for CaloSuperCellDetDescrManager in the Condition Store" };
230
231 SG::ReadCondHandleKey<LArOnOffIdMapping> m_cablingKey{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};
233
234 SG::ReadCondHandleKey<LArADC2MeV> m_adc2mevKey{this, "ADC2MeVKey", "LArADC2MeV", "SG Key of the LArADC2MeV CDO" };
235
236 SG::ReadCondHandleKey<ILArPedestal> m_pedestalKey{this,"PedestalKey","LArPedestal","SG Key of LArPedestal object"};
237 const ILArPedestal *m_ped=nullptr;
238
239 SG::ReadCondHandleKey<ILArNoise> m_noiseKey{this,"NoiseKey","","SG Key of LArNoise object"};
240 const ILArNoise *m_noise=nullptr;
241
242 SG::ReadCondHandleKey<ILArAutoCorr> m_acorrKey{this,"AutocorrKey","LArAutoCorrSym","SG Key of LArAutoCorr object"};
243 const ILArAutoCorr *m_acorr=nullptr;
244
245 SG::ReadCondHandleKey<ILArOFC> m_LArOFCObjKey{this, "OFKey","LArOFC", "SG Key of LAr OFCs"};
246 const ILArOFC *m_ofccond=nullptr;
247
248 SG::ReadCondHandleKey<ILArShape> m_shapeKey{this,"ShapeKey","LArShapeSym","SG Key of Shape conditions object"};
249 const ILArShape *m_shapecond=nullptr;
250
251 SG::ReadCondHandleKey<ILArfSampl> m_fSamplKey{this,"fSamplKey","LArfSamplSym","SG Key of LArfSampl object"};
252 const ILArfSampl *m_fsamplcond = nullptr;
253
254 SG::ReadCondHandleKey<ILArMinBias> m_LArMinBiasObjKey{this, "LArMinBiasKey", "LArMinBiasSym", "SG Key of LArMinBias"};
255 const ILArMinBias *m_minbias = nullptr;
256
257 // Output containers
258 SG::WriteCondHandleKey<CaloNoise> m_outputElecKey{this, "OutputElecKey", "elecNoise", "SG Key of resulting noise CDO"};
259 SG::WriteCondHandleKey<CaloNoise> m_outputPileupKey{this, "OutputPileupKey", "pileupNoise", "SG Key of resulting noise CDO"};
260
261
262 //Containers
263 std::vector<IdentifierHash> m_indexContainer;
264 // = vector indexed with all the hashids,
265 //containing which index (of container) should be used with a hashid
266 std::vector<IdentifierHash> m_idSymmCaloHashContainer;
267 //used only to initialize m_indexOfContainer
268
269
274
275
276 //Functions
277 StatusCode initContainers();
278 StatusCode initData(const LArADC2MeV *adc2mev);
279 StatusCode initIndex();
280 StatusCode initAdc2MeV(const LArADC2MeV *adc2mev);
281 StatusCode initElecNoise();
282 StatusCode initPileUpNoise();
283
284 bool checkIfConnected(const Identifier &id);
285 void commonCalculations(float & OFC_AC_OFC,float & OFC_OFC, int icase, unsigned int firstSample=0);
286 StatusCode retrieveCellDatabase(const IdentifierHash & idCaloHash,
287 const Identifier & id,int igain,
288 std::vector<bool> &retrieve);
289 StatusCode checkCellDatabase(const Identifier & id, int igain,
290 std::vector<bool> &retrieve);
291 void updateDiagnostic(int reason, const std::string &reason_name,int igain, bool &noiseOK);
292
293 std::vector<float>
294 calculateElecNoiseForLAR(const IdentifierHash &idCaloHash);
295
296 float
297 calculatePileUpNoise(const IdentifierHash &idCaloHash,
298 const float &Nminbias);
299
300 using AthCondAlgorithm::index;
301 int index(const IdentifierHash &idCaloHash);
302
304 bool isBadValue(float tested_value);
305
307 const CaloDetDescrElement* caloDDE,
308 const float &energy);
309
310
311
312};
313
314//------------------------------------------------------------
315
316inline bool
318{
319 if(tested_value<BADVALUE+1) return true;
320 return false;
321}
322
324
327{
328 return
329 static_cast<CaloCell_ID::SUBCALO>(m_calocell_id->sub_calo(idCaloHash));
330}
331
332#endif
333
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
#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