Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparing to include Method 3 result into HBHERecHit #11213

Merged
merged 1 commit into from Sep 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions DataFormats/HcalRecHit/interface/HBHERecHit.h
Expand Up @@ -25,12 +25,16 @@ class HBHERecHit : public CaloRecHit {
inline void setRawEnergy(const float en) {rawEnergy_ = en;}
inline float eraw() const {return rawEnergy_;}

inline void setAuxEnergy(const float en) {auxEnergy_ = en;}
inline float eaux() const {return auxEnergy_;}

inline void setAuxHBHE(const uint32_t aux) { auxHBHE_ = aux;}
inline uint32_t auxHBHE() const {return auxHBHE_;}

private:
float timeFalling_;
float rawEnergy_;
float auxEnergy_;
uint32_t auxHBHE_;
};

Expand Down
8 changes: 6 additions & 2 deletions DataFormats/HcalRecHit/src/HBHERecHit.cc
@@ -1,13 +1,14 @@
#include "DataFormats/HcalRecHit/interface/HBHERecHit.h"


HBHERecHit::HBHERecHit() : CaloRecHit(), rawEnergy_(-1.0e21) {
HBHERecHit::HBHERecHit() : CaloRecHit(), rawEnergy_(-1.0e21), auxEnergy_(-1.0e21) {
}

HBHERecHit::HBHERecHit(const HcalDetId& id, float energy, float timeRising, float timeFalling) :
CaloRecHit(id,energy,timeRising),
timeFalling_(timeFalling),
rawEnergy_(-1.0e21)
rawEnergy_(-1.0e21),
auxEnergy_(-1.0e21)
{
}

Expand All @@ -16,6 +17,9 @@ std::ostream& operator<<(std::ostream& s, const HBHERecHit& hit) {
if (hit.eraw() > -0.9e21) {
s << ", eraw=" << hit.eraw() << " GeV";
}
if (hit.eaux() > -0.9e21) {
s << ", eaux=" << hit.eaux() << " GeV";
}
if(hit.time() > -998) {
s << ", t= " << hit.time() << " to " << hit.timeFalling() << " ns";
}
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/HcalRecHit/src/classes_def.xml
@@ -1,5 +1,6 @@
<lcgdict>
<class name="HBHERecHit" ClassVersion="15">
<class name="HBHERecHit" ClassVersion="16">
<version ClassVersion="16" checksum="2359330573"/>
<version ClassVersion="15" checksum="3086172316"/>
<version ClassVersion="14" checksum="525320376"/>
<version ClassVersion="13" checksum="1684878064"/>
Expand Down
89 changes: 89 additions & 0 deletions RecoLocalCalo/HcalRecAlgos/interface/rawEnergy.h
Expand Up @@ -92,6 +92,82 @@ namespace HcalRecAlgosPrivate {
inline static float getRawEnergy(const T& h, float) {return h.eraw();}
};

template <typename T>
class HasAuxEnergySetterHelper
{
private:
template<void (T::*)(float)> struct tester;
typedef char One;
typedef struct {char a[2];} Two;
template<typename C> static One test(tester<&C::setAuxEnergy>*);
template<typename C> static Two test(...);

public:
enum {value = sizeof(HasAuxEnergySetterHelper<T>::template test<T>(0)) == 1};
};

template<typename T, bool is_class_type=IsClassType<T>::value>
struct HasAuxEnergySetter
{
enum {value = false};
};

template<typename T>
struct HasAuxEnergySetter<T, true>
{
enum {value = HasAuxEnergySetterHelper<T>::value};
};

template<typename T, bool>
struct AuxEnergySetter
{
inline static void setAuxEnergy(T&, float) {}
};

template<typename T>
struct AuxEnergySetter<T, true>
{
inline static void setAuxEnergy(T& h, float e) {h.setAuxEnergy(e);}
};

template <typename T>
class HasAuxEnergyGetterHelper
{
private:
template<float (T::*)() const> struct tester;
typedef char One;
typedef struct {char a[2];} Two;
template<typename C> static One test(tester<&C::eaux>*);
template<typename C> static Two test(...);

public:
enum {value = sizeof(HasAuxEnergyGetterHelper<T>::template test<T>(0)) == 1};
};

template<typename T, bool is_class_type=IsClassType<T>::value>
struct HasAuxEnergyGetter
{
enum {value = false};
};

template<typename T>
struct HasAuxEnergyGetter<T, true>
{
enum {value = HasAuxEnergyGetterHelper<T>::value};
};

template<typename T, bool>
struct AuxEnergyGetter
{
inline static float getAuxEnergy(const T&, float v) {return v;}
};

template<typename T>
struct AuxEnergyGetter<T, true>
{
inline static float getAuxEnergy(const T& h, float) {return h.eaux();}
};

template <typename T>
class HasAuxRecHitGetterHelper
{
Expand Down Expand Up @@ -151,6 +227,19 @@ inline float getRawEnergy(const HcalRecHit& h, float valueIfNoSuchMember=-1.0e20
return HcalRecAlgosPrivate::RawEnergyGetter<HcalRecHit,HcalRecAlgosPrivate::HasRawEnergyGetter<HcalRecHit>::value>::getRawEnergy(h, valueIfNoSuchMember);
}

// Similar functions for aux energy
template <typename HcalRecHit>
inline void setAuxEnergy(HcalRecHit& h, float e)
{
HcalRecAlgosPrivate::AuxEnergySetter<HcalRecHit,HcalRecAlgosPrivate::HasAuxEnergySetter<HcalRecHit>::value>::setAuxEnergy(h, e);
}

template <typename HcalRecHit>
inline float getAuxEnergy(const HcalRecHit& h, float valueIfNoSuchMember=-1.0e20)
{
return HcalRecAlgosPrivate::AuxEnergyGetter<HcalRecHit,HcalRecAlgosPrivate::HasAuxEnergyGetter<HcalRecHit>::value>::getAuxEnergy(h, valueIfNoSuchMember);
}

// Function for getting the auxiliary word in a code templated
// upon the rechit type. This function will return "valueIfNoSuchMember"
// in case the HcalRecHit type does not have a member function
Expand Down