Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:39

0001 #ifndef CondFormats_HcalObjects_HFPhase1PMTData_h
0002 #define CondFormats_HcalObjects_HFPhase1PMTData_h
0003 
0004 #include "boost/serialization/access.hpp"
0005 #include "boost/serialization/version.hpp"
0006 #include "boost/serialization/shared_ptr.hpp"
0007 #include "boost/version.hpp"
0008 #if BOOST_VERSION < 106400
0009 #include "boost/serialization/array.hpp"
0010 #else
0011 #include "boost/serialization/boost_array.hpp"
0012 #endif
0013 #include "CondFormats/HcalObjects/interface/AbsHcalFunctor.h"
0014 
0015 class HFPhase1PMTData {
0016 public:
0017   // Functor enum for the cut shapes
0018   enum {
0019     T_0_MIN = 0,  // Min time measurement allowed for the first anode,
0020                   //    depending on charge or energy
0021     T_0_MAX,      // Max time measurement allowed for the first anode
0022     T_1_MIN,      // Min time measurement allowed for the second anode
0023     T_1_MAX,      // Max time measurement allowed for the second anode
0024     ASYMM_MIN,    // Minimum allowed charge (or energy) asymmetry,
0025                   //    depending on charge (or energy)
0026     ASYMM_MAX,    // Maximum allowed asymmetry
0027     N_PMT_CUTS
0028   };
0029   typedef boost::array<std::shared_ptr<AbsHcalFunctor>, N_PMT_CUTS> Cuts;
0030 
0031   // Dummy constructor, to be used for deserialization only
0032   inline HFPhase1PMTData() : minCharge0_(0.0), minCharge1_(0.0), minChargeAsymm_(0.0) {}
0033 
0034   // Normal constructor
0035   inline HFPhase1PMTData(const Cuts& cutShapes, const float charge0, const float charge1, const float minQAsymm)
0036       : cuts_(cutShapes), minCharge0_(charge0), minCharge1_(charge1), minChargeAsymm_(minQAsymm) {}
0037 
0038   // Get the cut shape
0039   inline const AbsHcalFunctor& cut(const unsigned which) const { return *cuts_.at(which); }
0040 
0041   // Minimum charge on the first/second anode needed for
0042   // a reliable timing measurement. Setting this charge
0043   // to a very high value will disable timing measurements
0044   // on that anode.
0045   inline float minCharge0() const { return minCharge0_; }
0046   inline float minCharge1() const { return minCharge1_; }
0047 
0048   // Minimum total charge for applying the charge asymmetry cut
0049   inline float minChargeAsymm() const { return minChargeAsymm_; }
0050 
0051   // Deep comparison operators (useful for serialization tests)
0052   inline bool operator==(const HFPhase1PMTData& r) const {
0053     if (minCharge0_ != r.minCharge0_)
0054       return false;
0055     if (minCharge1_ != r.minCharge1_)
0056       return false;
0057     if (minChargeAsymm_ != r.minChargeAsymm_)
0058       return false;
0059     for (unsigned i = 0; i < N_PMT_CUTS; ++i)
0060       if (!(*cuts_[i] == *r.cuts_[i]))
0061         return false;
0062     return true;
0063   }
0064 
0065   inline bool operator!=(const HFPhase1PMTData& r) const { return !(*this == r); }
0066 
0067 private:
0068   Cuts cuts_;
0069   float minCharge0_;
0070   float minCharge1_;
0071   float minChargeAsymm_;
0072 
0073   friend class boost::serialization::access;
0074 
0075   template <class Archive>
0076   inline void serialize(Archive& ar, unsigned /* version */) {
0077     ar & cuts_ & minCharge0_ & minCharge1_ & minChargeAsymm_;
0078   }
0079 };
0080 
0081 BOOST_CLASS_VERSION(HFPhase1PMTData, 1)
0082 
0083 #endif  // CondFormats_HcalObjects_HFPhase1PMTData_h