Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:25

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