CMS 3D CMS Logo

rawEnergy.h
Go to the documentation of this file.
1 #include <cstdint>
2 #ifndef RecoLocalCalo_HcalRecAlgos_rawEnergy_h
3 #define RecoLocalCalo_HcalRecAlgos_rawEnergy_h
4 
5 namespace HcalRecAlgosPrivate {
6  template <typename T>
7  class IsClassType {
8  typedef char One;
9  typedef struct {
10  char a[2];
11  } Two;
12  template <typename C>
13  static One test(int C::*);
14  template <typename C>
15  static Two test(...);
16 
17  public:
18  enum { value = sizeof(IsClassType<T>::template test<T>(nullptr)) == 1 };
19  };
20 
21  template <typename T>
23  private:
24  template <void (T::*)(float)>
25  struct tester;
26  typedef char One;
27  typedef struct {
28  char a[2];
29  } Two;
30  template <typename C>
32  template <typename C>
33  static Two test(...);
34 
35  public:
36  enum { value = sizeof(HasRawEnergySetterHelper<T>::template test<T>(nullptr)) == 1 };
37  };
38 
41  enum { value = false };
42  };
43 
44  template <typename T>
47  };
48 
49  template <typename T, bool>
50  struct RawEnergySetter {
51  inline static void setRawEnergy(T&, float) {}
52  };
53 
54  template <typename T>
55  struct RawEnergySetter<T, true> {
56  inline static void setRawEnergy(T& h, float e) { h.setRawEnergy(e); }
57  };
58 
59  template <typename T>
61  private:
62  template <float (T::*)() const>
63  struct tester;
64  typedef char One;
65  typedef struct {
66  char a[2];
67  } Two;
68  template <typename C>
69  static One test(tester<&C::eraw>*);
70  template <typename C>
71  static Two test(...);
72 
73  public:
74  enum { value = sizeof(HasRawEnergyGetterHelper<T>::template test<T>(0)) == 1 };
75  };
76 
79  enum { value = false };
80  };
81 
82  template <typename T>
85  };
86 
87  template <typename T, bool>
88  struct RawEnergyGetter {
89  inline static float getRawEnergy(const T&, float v) { return v; }
90  };
91 
92  template <typename T>
93  struct RawEnergyGetter<T, true> {
94  inline static float getRawEnergy(const T& h, float) { return h.eraw(); }
95  };
96 
97  template <typename T>
99  private:
100  template <void (T::*)(float)>
101  struct tester;
102  typedef char One;
103  typedef struct {
104  char a[2];
105  } Two;
106  template <typename C>
108  template <typename C>
109  static Two test(...);
110 
111  public:
112  enum { value = sizeof(HasAuxEnergySetterHelper<T>::template test<T>(nullptr)) == 1 };
113  };
114 
117  enum { value = false };
118  };
119 
120  template <typename T>
123  };
124 
125  template <typename T, bool>
127  inline static void setAuxEnergy(T&, float) {}
128  };
129 
130  template <typename T>
131  struct AuxEnergySetter<T, true> {
132  inline static void setAuxEnergy(T& h, float e) { h.setAuxEnergy(e); }
133  };
134 
135  template <typename T>
137  private:
138  template <float (T::*)() const>
139  struct tester;
140  typedef char One;
141  typedef struct {
142  char a[2];
143  } Two;
144  template <typename C>
145  static One test(tester<&C::eaux>*);
146  template <typename C>
147  static Two test(...);
148 
149  public:
150  enum { value = sizeof(HasAuxEnergyGetterHelper<T>::template test<T>(0)) == 1 };
151  };
152 
155  enum { value = false };
156  };
157 
158  template <typename T>
161  };
162 
163  template <typename T, bool>
165  inline static float getAuxEnergy(const T&, float v) { return v; }
166  };
167 
168  template <typename T>
169  struct AuxEnergyGetter<T, true> {
170  inline static float getAuxEnergy(const T& h, float) { return h.eaux(); }
171  };
172 
173  template <typename T>
175  private:
176  template <uint32_t (T::*)() const>
177  struct tester;
178  typedef char One;
179  typedef struct {
180  char a[2];
181  } Two;
182  template <typename C>
183  static One test(tester<&C::auxHBHE>*);
184  template <typename C>
185  static Two test(...);
186 
187  public:
188  enum { value = sizeof(HasAuxRecHitGetterHelper<T>::template test<T>(0)) == 1 };
189  };
190 
193  enum { value = false };
194  };
195 
196  template <typename T>
199  };
200 
201  template <typename T, bool>
203  inline static uint32_t getAuxRecHit(const T&, uint32_t v) { return v; }
204  };
205 
206  template <typename T>
207  struct AuxRecHitGetter<T, true> {
208  inline static uint32_t getAuxRecHit(const T& h, uint32_t) { return h.auxHBHE(); }
209  };
210 } // namespace HcalRecAlgosPrivate
211 
212 // Function for setting the raw energy in a code templated
213 // upon the rechit type. The function call will be ignored
214 // in case the HcalRecHit type does not have a member function
215 // "void setRawEnergy(float)".
216 template <typename HcalRecHit>
217 inline void setRawEnergy(HcalRecHit& h, float e) {
220 }
221 
222 // Function for getting the raw energy in a code templated
223 // upon the rechit type. This function will return "valueIfNoSuchMember"
224 // in case the HcalRecHit type does not have a member function
225 // "float eraw() const".
226 template <typename HcalRecHit>
227 inline float getRawEnergy(const HcalRecHit& h, float valueIfNoSuchMember = -1.0e20) {
229  getRawEnergy(h, valueIfNoSuchMember);
230 }
231 
232 // Similar functions for aux energy
233 template <typename HcalRecHit>
234 inline void setAuxEnergy(HcalRecHit& h, float e) {
237 }
238 
239 template <typename HcalRecHit>
240 inline float getAuxEnergy(const HcalRecHit& h, float valueIfNoSuchMember = -1.0e20) {
242  getAuxEnergy(h, valueIfNoSuchMember);
243 }
244 
245 // Function for getting the auxiliary word in a code templated
246 // upon the rechit type. This function will return "valueIfNoSuchMember"
247 // in case the HcalRecHit type does not have a member function
248 // "uint32_t auxHBHE() const".
249 template <typename HcalRecHit>
250 inline uint32_t getAuxRecHitWord(const HcalRecHit& h, uint32_t valueIfNoSuchMember = 4294967295U) {
252  getAuxRecHit(h, valueIfNoSuchMember);
253 }
254 
255 #endif // RecoLocalCalo_HcalRecAlgos_rawEnergy_h
HcalRecAlgosPrivate::AuxRecHitGetter::getAuxRecHit
static uint32_t getAuxRecHit(const T &, uint32_t v)
Definition: rawEnergy.h:203
setAuxEnergy
void setAuxEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:234
getAuxEnergy
float getAuxEnergy(const HcalRecHit &h, float valueIfNoSuchMember=-1.0e20)
Definition: rawEnergy.h:240
HcalRecAlgosPrivate::HasRawEnergySetterHelper::Two
Definition: rawEnergy.h:27
HcalRecAlgosPrivate::HasAuxEnergySetterHelper
Definition: rawEnergy.h:98
HcalRecAlgosPrivate::RawEnergyGetter< T, true >::getRawEnergy
static float getRawEnergy(const T &h, float)
Definition: rawEnergy.h:94
HcalRecAlgosPrivate::HasAuxEnergyGetterHelper
Definition: rawEnergy.h:136
HcalRecAlgosPrivate::HasAuxEnergyGetter
Definition: rawEnergy.h:154
HcalRecAlgosPrivate::RawEnergyGetter::getRawEnergy
static float getRawEnergy(const T &, float v)
Definition: rawEnergy.h:89
HcalRecAlgosPrivate::AuxEnergySetter< T, true >::setAuxEnergy
static void setAuxEnergy(T &h, float e)
Definition: rawEnergy.h:132
findQualityFiles.v
v
Definition: findQualityFiles.py:179
HcalRecAlgosPrivate::HasAuxEnergySetterHelper::One
char One
Definition: rawEnergy.h:101
HcalRecAlgosPrivate
Definition: rawEnergy.h:5
getRawEnergy
float getRawEnergy(const HcalRecHit &h, float valueIfNoSuchMember=-1.0e20)
Definition: rawEnergy.h:227
HcalRecAlgosPrivate::AuxEnergySetter
Definition: rawEnergy.h:126
HcalRecAlgosPrivate::HasAuxEnergyGetterHelper::One
char One
Definition: rawEnergy.h:139
HcalRecAlgosPrivate::HasRawEnergyGetter
Definition: rawEnergy.h:78
HcalRecAlgosPrivate::HasAuxRecHitGetterHelper
Definition: rawEnergy.h:174
HcalRecAlgosPrivate::HasRawEnergySetter
Definition: rawEnergy.h:40
HcalRecAlgosPrivate::HasAuxRecHitGetterHelper::tester
Definition: rawEnergy.h:177
HcalRecAlgosPrivate::HasRawEnergyGetterHelper
Definition: rawEnergy.h:60
HcalRecAlgosPrivate::HasRawEnergySetterHelper::test
static One test(tester<&C::setRawEnergy > *)
HcalRecAlgosPrivate::RawEnergyGetter
Definition: rawEnergy.h:88
HcalRecAlgosPrivate::RawEnergySetter< T, true >::setRawEnergy
static void setRawEnergy(T &h, float e)
Definition: rawEnergy.h:56
HcalRecAlgosPrivate::AuxEnergyGetter< T, true >::getAuxEnergy
static float getAuxEnergy(const T &h, float)
Definition: rawEnergy.h:170
HcalRecAlgosPrivate::AuxEnergyGetter
Definition: rawEnergy.h:164
HcalRecAlgosPrivate::HasAuxEnergyGetterHelper::test
static One test(tester<&C::eaux > *)
h
HcalRecAlgosPrivate::HasAuxEnergySetterHelper::test
static One test(tester<&C::setAuxEnergy > *)
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
funct::true
true
Definition: Factorize.h:173
HcalRecAlgosPrivate::HasAuxRecHitGetterHelper::One
char One
Definition: rawEnergy.h:177
a
double a
Definition: hdecay.h:119
HcalRecAlgosPrivate::AuxRecHitGetter
Definition: rawEnergy.h:202
HcalRecAlgosPrivate::HasAuxEnergySetterHelper::tester
Definition: rawEnergy.h:101
HcalRecAlgosPrivate::HasAuxRecHitGetter
Definition: rawEnergy.h:192
HcalRecAlgosPrivate::HasRawEnergyGetterHelper::Two
Definition: rawEnergy.h:65
HcalRecAlgosPrivate::HasAuxEnergyGetterHelper::tester
Definition: rawEnergy.h:139
HcalRecAlgosPrivate::HasRawEnergySetterHelper::tester
Definition: rawEnergy.h:25
value
Definition: value.py:1
getAuxRecHitWord
uint32_t getAuxRecHitWord(const HcalRecHit &h, uint32_t valueIfNoSuchMember=4294967295U)
Definition: rawEnergy.h:250
HcalRecAlgosPrivate::HasRawEnergySetterHelper::One
char One
Definition: rawEnergy.h:25
HcalRecAlgosPrivate::RawEnergySetter::setRawEnergy
static void setRawEnergy(T &, float)
Definition: rawEnergy.h:51
HcalRecAlgosPrivate::IsClassType
Definition: rawEnergy.h:7
HcalRecAlgosPrivate::HasAuxRecHitGetterHelper::test
static One test(tester<&C::auxHBHE > *)
HcalRecAlgosPrivate::HasRawEnergyGetterHelper::tester
Definition: rawEnergy.h:63
HcalRecAlgosPrivate::AuxEnergySetter::setAuxEnergy
static void setAuxEnergy(T &, float)
Definition: rawEnergy.h:127
HcalRecAlgosPrivate::AuxEnergyGetter::getAuxEnergy
static float getAuxEnergy(const T &, float v)
Definition: rawEnergy.h:165
gen::C
C
Definition: PomwigHadronizer.cc:76
HcalRecAlgosPrivate::HasAuxEnergySetter
Definition: rawEnergy.h:116
HcalRecAlgosPrivate::HasRawEnergySetterHelper
Definition: rawEnergy.h:22
T
long double T
Definition: Basic3DVectorLD.h:48
HcalRecAlgosPrivate::HasRawEnergyGetterHelper::test
static One test(tester<&C::eraw > *)
relativeConstraints.value
value
Definition: relativeConstraints.py:53
HcalRecAlgosPrivate::IsClassType::One
char One
Definition: rawEnergy.h:8
setRawEnergy
void setRawEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:217
HcalRecAlgosPrivate::IsClassType::Two
Definition: rawEnergy.h:9
HcalRecAlgosPrivate::HasAuxEnergyGetterHelper::Two
Definition: rawEnergy.h:141
HcalRecAlgosPrivate::HasRawEnergyGetterHelper::One
char One
Definition: rawEnergy.h:63
HcalRecAlgosPrivate::HasAuxEnergySetterHelper::Two
Definition: rawEnergy.h:103
HcalRecAlgosPrivate::IsClassType::test
static One test(int C::*)
HcalRecAlgosPrivate::RawEnergySetter
Definition: rawEnergy.h:50
HcalRecAlgosPrivate::AuxRecHitGetter< T, true >::getAuxRecHit
static uint32_t getAuxRecHit(const T &h, uint32_t)
Definition: rawEnergy.h:208
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HcalRecAlgosPrivate::HasAuxRecHitGetterHelper::Two
Definition: rawEnergy.h:179