CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
static void setAuxEnergy(T &h, float e)
Definition: rawEnergy.h:132
uint32_t getAuxRecHitWord(const HcalRecHit &h, uint32_t valueIfNoSuchMember=4294967295U)
Definition: rawEnergy.h:250
static uint32_t getAuxRecHit(const T &h, uint32_t)
Definition: rawEnergy.h:208
static void setRawEnergy(T &, float)
Definition: rawEnergy.h:51
void setRawEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:217
static One test(tester<&C::setRawEnergy > *)
static One test(tester<&C::eaux > *)
static One test(tester<&C::setAuxEnergy > *)
static void setRawEnergy(T &h, float e)
Definition: rawEnergy.h:56
float getAuxEnergy(const HcalRecHit &h, float valueIfNoSuchMember=-1.0e20)
Definition: rawEnergy.h:240
static One test(tester<&C::auxHBHE > *)
static void setAuxEnergy(T &, float)
Definition: rawEnergy.h:127
static float getAuxEnergy(const T &, float v)
Definition: rawEnergy.h:165
static One test(tester<&C::eraw > *)
double a
Definition: hdecay.h:119
static float getRawEnergy(const T &h, float)
Definition: rawEnergy.h:94
static float getAuxEnergy(const T &h, float)
Definition: rawEnergy.h:170
static uint32_t getAuxRecHit(const T &, uint32_t v)
Definition: rawEnergy.h:203
float getRawEnergy(const HcalRecHit &h, float valueIfNoSuchMember=-1.0e20)
Definition: rawEnergy.h:227
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
long double T
void setAuxEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:234
static float getRawEnergy(const T &, float v)
Definition: rawEnergy.h:89