Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:31

0001 #ifndef EcalSimAlgos_EBHitResponse_h
0002 #define EcalSimAlgos_EBHitResponse_h
0003 
0004 #include "CalibFormats/CaloObjects/interface/CaloTSamples.h"
0005 #include "SimCalorimetry/EcalSimAlgos/interface/EcalHitResponse.h"
0006 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h"
0007 #include "DataFormats/EcalDigi/interface/EcalConstants.h"
0008 
0009 class APDSimParameters;
0010 
0011 namespace CLHEP {
0012   class HepRandomEngine;
0013 }
0014 
0015 template <class constset>
0016 class EBHitResponseImpl : public EcalHitResponse {
0017 public:
0018   typedef CaloTSamples<float, constset::sampleSize> EBSamples;
0019 
0020   typedef std::vector<double> VecD;
0021 
0022   static constexpr size_t kNOffsets = constset::kNOffsets;
0023 
0024   static constexpr double kSamplePeriod = constset::Samp_Period;
0025 
0026   EBHitResponseImpl(const CaloVSimParameterMap* parameterMap,
0027                     const CaloVShape* shape,
0028                     bool apdOnly,
0029                     const APDSimParameters* apdPars = nullptr,
0030                     const CaloVShape* apdShape = nullptr);
0031 
0032   ~EBHitResponseImpl() override;
0033 
0034   void initialize(CLHEP::HepRandomEngine*);
0035 
0036   virtual bool keepBlank() const { return false; }
0037 
0038   void setIntercal(const EcalIntercalibConstantsMC* ical);
0039 
0040   void add(const PCaloHit& hit, CLHEP::HepRandomEngine*) override;
0041 
0042   void initializeHits() override;
0043 
0044   void finalizeHits() override;
0045 
0046   void run(MixCollection<PCaloHit>& hits, CLHEP::HepRandomEngine*) override;
0047 
0048   unsigned int samplesSize() const override;
0049 
0050   EcalSamples* operator[](unsigned int i) override;
0051 
0052   const EcalSamples* operator[](unsigned int i) const override;
0053 
0054 protected:
0055   unsigned int samplesSizeAll() const override;
0056 
0057   EcalSamples* vSamAll(unsigned int i) override;
0058 
0059   const EcalSamples* vSamAll(unsigned int i) const override;
0060 
0061   EcalSamples* vSam(unsigned int i) override;
0062 
0063   void putAPDSignal(const DetId& detId, double npe, double time);
0064 
0065   void putAnalogSignal(const PCaloHit& inputHit, CLHEP::HepRandomEngine*) override;
0066 
0067 private:
0068   const VecD& offsets() const { return m_timeOffVec; }
0069 
0070   const double nonlFunc(double enr) const {
0071     return (pelo > enr ? pext : (pehi > enr ? nonlFunc1(enr) : pfac * atan(log10(enr - pehi + 0.00001)) + poff));
0072   }
0073 
0074   const double nonlFunc1(double energy) const {
0075     const double enr(log10(energy));
0076     const double enr2(enr * enr);
0077     const double enr3(enr2 * enr);
0078     return (pcub * enr3 + pqua * enr2 + plin * enr + pcon);
0079   }
0080 
0081   const APDSimParameters* apdParameters() const;
0082   const CaloVShape* apdShape() const;
0083 
0084   double apdSignalAmplitude(const PCaloHit& hit, CLHEP::HepRandomEngine*) const;
0085 
0086   void findIntercalibConstant(const DetId& detId, double& icalconst) const;
0087 
0088   const bool m_apdOnly;
0089   const APDSimParameters* m_apdPars;
0090   const CaloVShape* m_apdShape;
0091   const EcalIntercalibConstantsMC* m_intercal;
0092 
0093   std::vector<double> m_timeOffVec;
0094 
0095   std::vector<double> m_apdNpeVec;
0096   std::vector<double> m_apdTimeVec;
0097 
0098   const double pcub, pqua, plin, pcon, pelo, pehi, pasy, pext, poff, pfac;
0099 
0100   std::vector<EBSamples> m_vSam;
0101 
0102   bool m_isInitialized;
0103 };
0104 
0105 typedef EBHitResponseImpl<ecalPh1> EBHitResponse;
0106 typedef EBHitResponseImpl<ecalPh2> EBHitResponse_Ph2;
0107 #include "EBHitResponse.icc"
0108 #endif