Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:12

0001 #ifndef CondFormats_HcalObjects_AbsOOTPileupCorrection_h
0002 #define CondFormats_HcalObjects_AbsOOTPileupCorrection_h
0003 
0004 #include <typeinfo>
0005 
0006 #include "boost/serialization/base_object.hpp"
0007 #include "boost/serialization/export.hpp"
0008 
0009 // Archive headers are needed here for the serialization registration to work.
0010 // <cassert> is needed for the archive headers to work.
0011 #if !defined(__GCCXML__)
0012 #include <cassert>
0013 #include "CondFormats/Serialization/interface/eos/portable_iarchive.hpp"
0014 #include "CondFormats/Serialization/interface/eos/portable_oarchive.hpp"
0015 #endif /* #if !defined(__GCCXML__) */
0016 
0017 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0018 
0019 // The contents of the "BunchXParameter" class are not well
0020 // defined yet. Potentially, they could be as simple as 0/1 flag
0021 // for beam gap/normal bunch crossing or they can include bunch
0022 // crossing lumi data. We need to figure out how to get this
0023 // information.
0024 class BunchXParameter;
0025 
0026 class AbsOOTPileupCorrection {
0027 public:
0028   inline virtual ~AbsOOTPileupCorrection() {}
0029 
0030   // Main correction application method to be implemented by
0031   // derived classes. Arguments are as follows:
0032   //
0033   //  id              -- HCAL detector id.
0034   //
0035   //  inputCharge     -- This array contains pedestal-subtracted input
0036   //                     charge. Gain factors converting charge into
0037   //                     energy might already be applied by the caller.
0038   //                     The caler should collaborate with this class
0039   //                     providing the right arguments here, depending on
0040   //                     what "inputIsEnergy" method returns.
0041   //
0042   //  lenInputCharge  -- Length of the "inputCharge" array.
0043   //
0044   //  bcParams        -- Information about bunch crossings, in the order
0045   //                     corresponding to "inputCharge".
0046   //
0047   //  lenBcParams     -- Length of the "bunchParams" array. Must not be
0048   //                     less than lenInputCharge.
0049   //
0050   //  firstTimeSlice  -- The first time slice that will be used for energy
0051   //                     reconstruction.
0052   //
0053   //  nTimeSlices     -- Number of time slices that will be used for energy
0054   //                     reconstruction. The sum firstTimeSlice + nTimeSlices
0055   //                     must not exceed lenInputCharge.
0056   //
0057   //  correctedCharge -- Array of corrected charges (or energies), to be
0058   //                     filled on output.
0059   //
0060   //  lenCorrectedCharge -- Length of the "correctedCharge" array. Must not
0061   //                     be less than lenInputCharge.
0062   //
0063   //  pulseShapeCorrApplied -- *pulseShapeCorrApplied should be set "true"
0064   //                     if the algorithm effectively performs the phase-based
0065   //                     amplitude correction, so that additional correction
0066   //                     of this type is not needed. If additional correction
0067   //                     has to be applied, this flag should be set "false".
0068   //
0069   //  leakCorrApplied -- *leakCorrApplied should be set "true" if the
0070   //                     algorithm effectively performs a correction for
0071   //                     charge leakage into the time slice before the
0072   //                     first one used for energy reconstruction. If not,
0073   //                     this flag should be set "false".
0074   //
0075   //  readjustTiming  -- *readjustTiming should be set "true" if one should
0076   //                     use OOT pileup corrected energies to derive hit time.
0077   //                     To use the original, uncorrected energies set this
0078   //                     to "false".
0079   //
0080   // Some of the input arguments may be ignored by derived classes.
0081   //
0082   virtual void apply(const HcalDetId& id,
0083                      const double* inputCharge,
0084                      unsigned lenInputCharge,
0085                      const BunchXParameter* bcParams,
0086                      unsigned lenBcParams,
0087                      unsigned firstTimeSlice,
0088                      unsigned nTimeSlices,
0089                      double* correctedCharge,
0090                      unsigned lenCorrectedCharge,
0091                      bool* pulseShapeCorrApplied,
0092                      bool* leakCorrApplied,
0093                      bool* readjustTiming) const = 0;
0094 
0095   // Another method to be overriden by derived classes. This method
0096   // tells whether fC -> GeV conversion should be performed before
0097   // calling the "apply" method or after. If "true" is returned,
0098   // it is assumed that the input is in GeV (this also takes into
0099   // account potentially different gains per cap id).
0100   virtual bool inputIsEnergy() const = 0;
0101 
0102   // Comparison operators. Note that they are not virtual and should
0103   // not be overriden by derived classes. These operators are very
0104   // useful for I/O testing.
0105   inline bool operator==(const AbsOOTPileupCorrection& r) const {
0106     return (typeid(*this) == typeid(r)) && this->isEqual(r);
0107   }
0108   inline bool operator!=(const AbsOOTPileupCorrection& r) const { return !(*this == r); }
0109 
0110 protected:
0111   // Method needed to compare objects for equality.
0112   // Must be implemented by derived classes.
0113   virtual bool isEqual(const AbsOOTPileupCorrection&) const = 0;
0114 
0115 private:
0116   friend class boost::serialization::access;
0117   template <typename Ar>
0118   inline void serialize(Ar& ar, unsigned /* version */) {}
0119 };
0120 
0121 BOOST_CLASS_EXPORT_KEY(AbsOOTPileupCorrection)
0122 
0123 #endif  // CondFormats_HcalObjects_AbsOOTPileupCorrection_h