Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 #ifndef HcalSimAlgos_HcalSiPM_h
0003 #define HcalSimAlgos_HcalSiPM_h
0004 
0005 /**
0006 
0007   \class HcalSiPM
0008 
0009   \brief A general implementation for the response of a SiPM.
0010 
0011 */
0012 #include <vector>
0013 #include <algorithm>
0014 #include <unordered_map>
0015 
0016 #include "CalibCalorimetry/HcalAlgos/interface/HcalSiPMnonlinearity.h"
0017 
0018 namespace CLHEP {
0019   class HepRandomEngine;
0020 }
0021 
0022 class HcalSiPM final {
0023 public:
0024   HcalSiPM(int nCells = 1, double tau = 15.);
0025 
0026   ~HcalSiPM();
0027 
0028   void resetSiPM() { std::fill(theSiPM.begin(), theSiPM.end(), -999.f); }
0029   double hitCells(CLHEP::HepRandomEngine*, unsigned int pes, double tempDiff = 0., double photonTime = 0.);
0030 
0031   double totalCharge() const { return totalCharge(theLastHitTime); }
0032   double totalCharge(double time) const;
0033 
0034   int getNCells() const { return theCellCount; }
0035   double getTau() const { return theTau; }
0036   double getCrossTalk() const { return theCrossTalk; }
0037   double getTempDep() const { return theTempDep; }
0038 
0039   void setNCells(int nCells);
0040   void setTau(double tau);
0041   void setCrossTalk(double xtalk);  //  Borel-Tanner "lambda"
0042   void setTemperatureDependence(double tempDep);
0043   void setSaturationPars(const std::vector<float>& pars);
0044 
0045 protected:
0046   typedef std::pair<unsigned int, std::vector<double> > cdfpair;
0047   typedef std::unordered_map<unsigned int, cdfpair> cdfmap;
0048 
0049   // void expRecover(double dt);
0050 
0051   double cellCharge(double deltaTime) const;
0052   unsigned int addCrossTalkCells(CLHEP::HepRandomEngine* engine, unsigned int in_pes);
0053 
0054   //numerical random generation from Borel-Tanner distribution
0055   const cdfpair& BorelCDF(unsigned int k);
0056 
0057   unsigned int theCellCount;
0058   std::vector<float> theSiPM;
0059   double theTau;
0060   double theTauInv;
0061   double theCrossTalk;
0062   double theTempDep;
0063   double theLastHitTime;
0064 
0065   HcalSiPMnonlinearity* nonlin;
0066 
0067   cdfmap borelcdfs;
0068 };
0069 
0070 #endif  //HcalSimAlgos_HcalSiPM_h