ATLAS Offline Software
Normalizations.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: Normalizations.h 704615 2015-10-29 18:50:12Z wsfreund $
6 #ifndef RINGERSELECTORTOOLS_PROCEDURES_NORMALIZATIONS_H
7 #define RINGERSELECTORTOOLS_PROCEDURES_NORMALIZATIONS_H
8 
9 //#undef NDEBUG
10 
11 // STL includes:
12 #include <vector>
13 #include <stdexcept>
14 #include <string>
15 #include <cmath>
16 #include <iostream>
17 
18 // Gaudi includes:
19 #if !defined(XAOD_STANDALONE) && !defined(RINGER_STANDALONE)
20 # include "GaudiKernel/SystemOfUnits.h"
21 #endif
22 
23 
24 // Local includes:
28 
32 namespace Ringer
33 {
34 
38 namespace PreProcessing
39 {
40 
44 namespace Norm {
45 
48 class Norm1 : virtual public IPreProcessor,
49  public RedirectMsgStream
50 {
51 
53 
54  public:
55  Norm1(){;}
56 
57  virtual void execute(std::vector<float> &inputSpace) const final override;
58 
59  private:
61 
63  //ClassDef(Norm1,1)
64 };
65 
67 
68 class Norm2 : public virtual IPreProcessor,
69  public RedirectMsgStream
70 {
71 
73 
74  public:
75  Norm2(){;}
76 
77  virtual void execute(std::vector<float> &inputSpace) const final override;
78 
79  private:
81 
83  //ClassDef(Norm2,0)
84 };
85 
87 
88 class Sqrt : public virtual IPreProcessor,
89  public RedirectMsgStream
90 {
91 
93 
94  public:
95  Sqrt(){};
96 
97  virtual void execute(std::vector<float> &inputSpace) const final override;
98 
99  private:
100  Sqrt(Sqrt&&);
101 
103  //ClassDef(Sqrt,0)
104 };
105 
107 
108 class ConstantValue : public virtual IPreProcessor,
109  public RedirectMsgStream
110 {
111 
113 
114  public:
115 
117  : m_constantInv(1){;}
119  const float constantValue)
120  : m_constantInv(1/constantValue)
121  {
122  if (!m_constantInv) {
123  throw std::runtime_error(
124  std::string("Initialized ConstantValueVarDep norm with zero constant"));
125  }
126  }
127 
128  virtual void execute(std::vector<float> &inputSpace) const final override;
129 
130  private:
134 
136  //ClassDef(ConstantValue,0)
137 };
138 
140 
141 class Sequential : public virtual IPreProcessor,
142  public RedirectMsgStream
143 {
145 
146  public:
147 
149  : m_stopEnergy(0),
150  m_energyThres(0){;}
151 
153  const float stopEnergy,
154  const float energyThres)
155  : m_stopEnergy(stopEnergy),
156  m_energyThres(energyThres){;}
157 
158  virtual void execute(std::vector<float> &inputSpace) const final override;
159 
160  private:
166 
168  //ClassDef(Sequential,0)
169 };
170 
172 
173 class Spherization : public virtual IPreProcessor,
174  public RedirectMsgStream
175 {
177 
178  public:
179 
181  : m_dim(0){;}
182 
184  const std::vector<float> &dataMean,
185  const std::vector<float> &dataStd);
186 
187  virtual void execute(std::vector<float> &inputSpace) const final override;
188 
189  private:
192  std::vector<float> m_deslocation;
194  std::vector<float> m_normInv;
196  size_t m_dim;
197 
199  //ClassDef(Spherization,0)
200 };
201 
203 
204 class MinMax : public virtual IPreProcessor,
205  public RedirectMsgStream
206 {
208 
209  public:
211  : m_dim(0){;}
212 
214  const std::vector<float>& min,
215  const std::vector<float>& max);
216 
217  virtual void execute(std::vector<float> &inputSpace) const final override;
218 
219  private:
222  std::vector<float> m_deslocation;
224  std::vector<float> m_normInv;
226  size_t m_dim;
227 
229  //ClassDef(MinMax,0)
230 };
232 
233 
236 class ExtraPatternsNorm : public virtual IPreProcessor,
237  public RedirectMsgStream,
239 {
240 
242 
243  public:
244 
245  ExtraPatternsNorm( const float etMin = 0., const float etMax = 1.
246  , const float etaMin = 0., const float etaMax = 1.
247  , const float pileupEstimationMax = 1. ):
248  m_etMin{etMin}, m_etMax{etMax},
249  m_etaMin{etaMin}, m_etaMax{etaMax},
250  m_pileupEstimationMax{pileupEstimationMax}
251  {;}
252 
256  ExtraPatternsNorm& setEtNormParams( float min, float max ) { m_etMin = min; m_etMax = max; return *this; }
257 
261  ExtraPatternsNorm& setEtaNormParams( float min, float max ) { m_etaMin = min; m_etaMax = max; return *this; }
262 
266  ExtraPatternsNorm& setPileupEstimationParams( float max ) { m_pileupEstimationMax = max; return *this; }
267 
271  float normEta(float eta) const;
272 
276  float normEt(float et) const;
277 
281  float normPileupEstimation(float pileupEstimation) const;
282 
283 
284  private:
286  float m_etMin, m_etMax;
288  float m_etaMin, m_etaMax;
291 
296  virtual void execute(std::vector<float> &inputSpace) const final override;
298  //ClassDef(ExtraDescriptionPatterns,0)
299 };
301 
302 
306 
309 class Norm1VarDep : virtual public IPreProcessorVarDep,
310  public RingerIOVarDepObj < Norm1VarDep >,
311  public Norm1
312 {
314 
315  public:
316 
318 
320  //ClassDef(Norm1VarDep,1)
321 };
322 
326 class Norm2VarDep : virtual public IPreProcessorVarDep,
327  public RingerIOVarDepObj < Norm2VarDep >,
328  public Norm2
329 {
330 
332 
333  public:
334 
336 
338  //ClassDef(Norm2VarDep,1)
339 };
340 
344 class SqrtVarDep : virtual public IPreProcessorVarDep,
345  public RingerIOVarDepObj < SqrtVarDep >,
346  public Sqrt
347 {
348 
350 
351  public:
352 
354 
356  //ClassDef(SqrtVarDep,1)
357 };
358 
363  public RingerIOVarDepObj < ConstantValueVarDep >,
364  public ConstantValue
365 {
366 
368 
369  public:
370 
372 
373  ConstantValueVarDep(const float constantValue)
374  : ConstantValue(constantValue){;}
375 
377  //ClassDef(ConstantValueVarDep,1)
378 };
379 
383 class MevToGevVarDep: virtual public IPreProcessorVarDep,
384  public RingerIOVarDepObj < MevToGevVarDep >,
385  public ConstantValue
386 {
387 
389 
390  public:
391 
392  // Normalization is the inverse of the Units transformation (MeV -> GeV)
393 #if !defined(XAOD_STANDALONE) && !defined(RINGER_STANDALONE)
395  : ConstantValue( (Gaudi::Units::GeV) / (Gaudi::Units::MeV) ){;}
396 #else // We suppose that we are working with MeV as reference unit.
398  : ConstantValue( 1000 / 1 ){;}
399 #endif
400 
402  //ClassDef(MevToGevVarDep,1)
403 };
404 
412 class SequentialVarDep : virtual public IPreProcessorVarDep,
413  public RingerIOVarDepObj < SequentialVarDep >,
414  public Sequential
415 {
416 
418 
419  public:
420 
422 
424  const float stopEnergy,
425  const float energyThres):
426  Sequential(stopEnergy,energyThres){;}
427 
429  //ClassDef(SequentialVarDep,1)
430 };
431 
436  public RingerIOVarDepObj < SpherizationVarDep >,
437  public Spherization
438 {
439 
441 
442  public:
443 
445 
447  const std::vector<float> &dataMean,
448  const std::vector<float> &dataStd):
449  Spherization(dataMean,dataStd){;}
450 
452  //ClassDef(SpherizationVarDep,1)
453 };
454 
458 class MinMaxVarDep : virtual public IPreProcessorVarDep,
459  public RingerIOVarDepObj < MinMaxVarDep >,
460  public MinMax
461 {
463 
464  public:
465 
467 
469  const std::vector<float> &min,
470  const std::vector<float> &max):
471  MinMax(min,max){;}
472 
474  //ClassDef(MinMaxVarDep,1)
475 };
476 
481  public RingerIOVarDepObj < ExtraPatternsNormVarDep >,
482  public ExtraPatternsNorm
483 {
485 
486 };
488 
489 } // Norm namespace;
490 } // Pre-processing namespace;
491 } // Ringer namespace
492 
493 
494 #endif // RINGERSELECTORTOOLS_PROCEDURES_NORMALIZATIONS_H
495 
496 // Include inline and template declarations:
497 #ifndef INCLUDE_HEADER_ONLY // Protect against circular includes
498 #include "Normalizations.icc"
499 #endif // INCLUDE_HEADER_ONLY
Ringer::PreProcessing::Norm::ExtraPatternsNorm::normEta
float normEta(float eta) const
Retrieve normalized eta.
et
Extra patterns decribing particle interation process.
Ringer::PreProcessing::Norm::Norm1VarDep
@ Usable normalizations:
Definition: Normalizations.h:312
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
max
#define max(a, b)
Definition: cfImp.cxx:41
Ringer::PreProcessing::Norm::ExtraPatternsNorm::setPileupEstimationParams
ExtraPatternsNorm & setPileupEstimationParams(float max)
Set eta normalization params.
Definition: Normalizations.h:266
Ringer::PreProcessing::Norm::MevToGevVarDep::MevToGevVarDep
MevToGevVarDep()
Definition: Normalizations.h:394
Ringer::PreProcessing::Norm::SqrtVarDep::SqrtVarDep
SqrtVarDep()
Definition: Normalizations.h:353
Ringer::PreProcessing::Norm::ExtraPatternsNormVarDep
Normalize data to be bounded within [-1,1] range.
Definition: Normalizations.h:483
Ringer::PreProcessing::Norm::Sequential::Sequential
Sequential()
Definition: Normalizations.h:148
Ringer::PreProcessing::Norm::ExtraPatternsNorm::execute
virtual void execute(std::vector< float > &inputSpace) const final override
This normalization does not applies to the input space, but rather to special components of the input...
VariableDependency.h
Ringer::PreProcessing::Norm::ExtraPatternsNorm::m_etaMin
float m_etaMin
Min and Max eta normalization factors.
Definition: Normalizations.h:288
Ringer::PreProcessing::Norm::ExtraPatternsNorm
Special case for the extra patterns normalization.
Definition: Normalizations.h:239
Ringer::PreProcessing::Norm::Norm2::Norm2
Norm2(Norm2 &&)
Ringer::PreProcessing::Norm::Sqrt::Sqrt
Sqrt(Sqrt &&)
Ringer::PreProcessing::Norm::Norm2::execute
virtual void execute(std::vector< float > &inputSpace) const final override
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
RINGER_IO_VARDEP_OBJ
#define RINGER_IO_VARDEP_OBJ(self, base)
Add necessary information to RingerIOVarDepObj.
Definition: RingerIOVarDepObj.h:134
Ringer::PreProcessing::Norm::Norm1VarDep::Norm1VarDep
Norm1VarDep()
Definition: Normalizations.h:317
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
Ringer::PreProcessing::Norm::ExtraPatternsNorm::setEtNormParams
ExtraPatternsNorm & setEtNormParams(float min, float max)
Set eta normalization params.
Definition: Normalizations.h:256
Ringer::PreProcessing::Norm::ExtraPatternsNorm::m_pileupEstimationMax
float m_pileupEstimationMax
Min and Max eta normalization factors.
Definition: Normalizations.h:290
Ringer::PreProcessing::Norm::MinMax
Definition: Normalizations.h:206
Ringer::PreProcessing::Norm::Spherization::m_normInv
std::vector< float > m_normInv
The inverse of the training sample data standard deviation.
Definition: Normalizations.h:194
Ringer::PreProcessing::Norm::MinMax::execute
virtual void execute(std::vector< float > &inputSpace) const final override
Ringer::PreProcessing::Norm::SpherizationVarDep::SpherizationVarDep
SpherizationVarDep()
Definition: Normalizations.h:444
Ringer::PreProcessing::Norm::Norm1::execute
virtual void execute(std::vector< float > &inputSpace) const final override
Ringer::PreProcessing::Norm::Spherization::Spherization
Spherization(const std::vector< float > &dataMean, const std::vector< float > &dataStd)
Ringer::PreProcessing::Norm::MinMax::m_deslocation
std::vector< float > m_deslocation
The training sample data min.
Definition: Normalizations.h:222
Ringer::PreProcessing::Norm::ConstantValueVarDep
Use constant value as rings normalization factor.
Definition: Normalizations.h:365
Ringer::PreProcessing::Norm::ExtraPatternsNorm::m_etMin
float m_etMin
Min and Max et normalization factors.
Definition: Normalizations.h:286
Ringer::PreProcessing::Norm::SequentialVarDep::SequentialVarDep
SequentialVarDep()
Definition: Normalizations.h:421
Ringer::PreProcessing::Norm::MevToGevVarDep
Scale rings energy to GeV.
Definition: Normalizations.h:386
Ringer::PreProcessing::IPreProcessorVarDep
PreProcessor interface to be used by Ringer Wrapper.
Definition: IRingerProcedure.h:269
Ringer::PreProcessing::IPreProcessor
PreProcessing interface to be inherited by PreProcessing procedures.
Definition: IRingerProcedure.h:250
Ringer::PreProcessing::Norm::ConstantValue::m_constantInv
float m_constantInv
Inverse value of the constant value normalization.
Definition: Normalizations.h:133
Ringer::PreProcessing::Norm::ConstantValueVarDep::ConstantValueVarDep
ConstantValueVarDep()
Definition: Normalizations.h:371
Ringer::PreProcessing::Norm::Sequential::m_stopEnergy
float m_stopEnergy
The stop energy threshold for increasing noise.
Definition: Normalizations.h:163
JetVoronoiDiagramHelpers::Norm
Point Norm(const Point &a)
Definition: JetVoronoiDiagramHelpers.cxx:79
Ringer::PreProcessing::Norm::SequentialVarDep::SequentialVarDep
SequentialVarDep(const float stopEnergy, const float energyThres)
Definition: Normalizations.h:423
Ringer::PreProcessing::Norm::SequentialVarDep
Use sequential normalization.
Definition: Normalizations.h:415
Ringer::PreProcessing::Norm::Spherization
Definition: Normalizations.h:175
Normalizations.icc
Ringer::PreProcessing::Norm::Sqrt::execute
virtual void execute(std::vector< float > &inputSpace) const final override
Ringer::PreProcessing::Norm::ConstantValue::execute
virtual void execute(std::vector< float > &inputSpace) const final override
Ringer::PreProcessing::Norm::MinMax::MinMax
MinMax()
Definition: Normalizations.h:210
Ringer::PreProcessing::Norm::Sequential
Definition: Normalizations.h:143
Ringer::PreProcessing::Norm::SpherizationVarDep::SpherizationVarDep
SpherizationVarDep(const std::vector< float > &dataMean, const std::vector< float > &dataStd)
Definition: Normalizations.h:446
Ringer::PreProcessing::Norm::Spherization::Spherization
Spherization(Spherization &&)
min
#define min(a, b)
Definition: cfImp.cxx:40
RINGER_IO_VARDEP_BASE_NOMEMBER
#define RINGER_IO_VARDEP_BASE_NOMEMBER(self)
Same as RINGER_IO_VARDEP_BASE, but when class has no member.
Definition: RingerIOVarDepObj.h:113
Ringer::PreProcessing::Norm::MinMax::m_dim
size_t m_dim
Input dimension (transient variable)
Definition: Normalizations.h:226
Ringer::PreProcessing::Norm::MinMax::m_normInv
std::vector< float > m_normInv
The inverse of sample delta(max,min)
Definition: Normalizations.h:224
Ringer::PreProcessing::Norm::Spherization::m_dim
size_t m_dim
Input dimension (transient variable)
Definition: Normalizations.h:196
Athena::Units
Definition: Units.h:45
Ringer::PreProcessing::Norm::Spherization::execute
virtual void execute(std::vector< float > &inputSpace) const final override
RingerIOVarDepObj.h
Ringer::PreProcessing::Norm::Spherization::Spherization
Spherization()
Definition: Normalizations.h:180
Ringer::PreProcessing::Norm::ConstantValue::ConstantValue
ConstantValue(ConstantValue &&)
Ringer::PreProcessing::Norm::ExtraPatternsNorm::normPileupEstimation
float normPileupEstimation(float pileupEstimation) const
Retrieve normalized pile-up estimation.
Ringer::PreProcessing::Norm::ConstantValue
Definition: Normalizations.h:110
Ringer::PreProcessing::Norm::ExtraPatternsNorm::ExtraPatternsNorm
ExtraPatternsNorm(const float etMin=0., const float etMax=1., const float etaMin=0., const float etaMax=1., const float pileupEstimationMax=1.)
Definition: Normalizations.h:245
Ringer::PreProcessing::Norm::ExtraPatternsNorm::setEtaNormParams
ExtraPatternsNorm & setEtaNormParams(float min, float max)
Set eta normalization params.
Definition: Normalizations.h:261
Ringer::PreProcessing::Norm::Sequential::Sequential
Sequential(Sequential &&)
Ringer::PreProcessing::Norm::Norm2::Norm2
Norm2()
Definition: Normalizations.h:75
Ringer::PreProcessing::Norm::SpherizationVarDep
Normalize data to have zero mean and unitary standard deviation.
Definition: Normalizations.h:438
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
Ringer::PreProcessing::Norm::ConstantValue::ConstantValue
ConstantValue(const float constantValue)
Definition: Normalizations.h:118
Ringer::PreProcessing::Norm::Norm1
Normalization base classes:
Definition: Normalizations.h:50
Ringer::PreProcessing::Norm::Norm1::Norm1
Norm1(Norm1 &&)
Ringer::PreProcessing::Norm::ExtraPatternsNorm::normEt
float normEt(float et) const
Retrieve normalized et.
Ringer::PreProcessing::Norm::SqrtVarDep
Use SqrtVarDep of norm-1 as rings normalization factor.
Definition: Normalizations.h:347
Ringer::PreProcessing::Norm::Spherization::m_deslocation
std::vector< float > m_deslocation
The training sample data mean.
Definition: Normalizations.h:192
Ringer::PreProcessing::Norm::MinMaxVarDep::MinMaxVarDep
MinMaxVarDep()
Definition: Normalizations.h:466
RINGER_IO_VARDEP_BASE
#define RINGER_IO_VARDEP_BASE(self)
Create RingerIOVarDepObj base object prototype methods.
Definition: RingerIOVarDepObj.h:98
Ringer::PreProcessing::Norm::Sqrt::Sqrt
Sqrt()
Definition: Normalizations.h:95
Ringer::PreProcessing::Norm::Sequential::m_energyThres
float m_energyThres
The energy threshold for choosing.
Definition: Normalizations.h:165
Ringer::PreProcessing::Norm::Sequential::execute
virtual void execute(std::vector< float > &inputSpace) const final override
Ringer::PreProcessing::Norm::Norm2VarDep
Use norm-2 as rings normalization factor.
Definition: Normalizations.h:329
Ringer::PreProcessing::Norm::MinMax::MinMax
MinMax(const std::vector< float > &min, const std::vector< float > &max)
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
Ringer::PreProcessing::Norm::MinMaxVarDep::MinMaxVarDep
MinMaxVarDep(const std::vector< float > &min, const std::vector< float > &max)
Definition: Normalizations.h:468
RINGER_DEFINE_PROCEDURE_DEFAULT_METHODS
#define RINGER_DEFINE_PROCEDURE_DEFAULT_METHODS(self)
This macro should be defined for every Ringer Procedure defined after the class is defined,...
Definition: IRingerProcedure.h:117
Ringer::RingerIOVarDepObj
Objects that can be recorded/read into/from configuration files.
Definition: RingerIOVarDepObj.h:195
Ringer::PreProcessing::Norm::MinMaxVarDep
Normalize data to be bounded within [-1,1] range.
Definition: Normalizations.h:461
IRingerProcedure.h
Ringer::PreProcessing::Norm::Norm2VarDep::Norm2VarDep
Norm2VarDep()
Definition: Normalizations.h:335
Ringer::PreProcessing::Norm::ConstantValueVarDep::ConstantValueVarDep
ConstantValueVarDep(const float constantValue)
Definition: Normalizations.h:373
Ringer::PreProcessing::Norm::MinMax::MinMax
MinMax(MinMax &&)
Ringer::PreProcessing::Norm::Sqrt
Definition: Normalizations.h:90
Ringer::PreProcessing::Norm::Sequential::Sequential
Sequential(const float stopEnergy, const float energyThres)
Definition: Normalizations.h:152
Ringer::PreProcessing::Norm::ConstantValue::ConstantValue
ConstantValue()
Definition: Normalizations.h:116
Ringer
Namespace dedicated for Ringer utilities.
Definition: CaloRingsDefs.h:9
Ringer::PreProcessing::Norm::Norm2
Definition: Normalizations.h:70
Ringer::PreProcessing::Norm::Norm1::Norm1
Norm1()
Definition: Normalizations.h:55