CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
HcalSiPM Class Referencefinal

A general implementation for the response of a SiPM. More...

#include <HcalSiPM.h>

Public Member Functions

double getCrossTalk () const
 
int getNCells () const
 
double getTau () const
 
double getTempDep () const
 
 HcalSiPM (int nCells=1, double tau=15.)
 
double hitCells (CLHEP::HepRandomEngine *, unsigned int pes, double tempDiff=0., double photonTime=0.)
 
void resetSiPM ()
 
void setCrossTalk (double xtalk)
 
void setNCells (int nCells)
 
void setSaturationPars (const std::vector< float > &pars)
 
void setTau (double tau)
 
void setTemperatureDependence (double tempDep)
 
double totalCharge () const
 
double totalCharge (double time) const
 
 ~HcalSiPM ()
 

Protected Types

typedef std::unordered_map< unsigned int, cdfpaircdfmap
 
typedef std::pair< unsigned int, std::vector< double > > cdfpair
 

Protected Member Functions

unsigned int addCrossTalkCells (CLHEP::HepRandomEngine *engine, unsigned int in_pes)
 
const cdfpairBorelCDF (unsigned int k)
 
double cellCharge (double deltaTime) const
 

Protected Attributes

cdfmap borelcdfs
 
HcalSiPMnonlinearitynonlin
 
unsigned int theCellCount
 
double theCrossTalk
 
double theLastHitTime
 
std::vector< float > theSiPM
 
double theTau
 
double theTauInv
 
double theTempDep
 

Detailed Description

A general implementation for the response of a SiPM.

Definition at line 22 of file HcalSiPM.h.

Member Typedef Documentation

◆ cdfmap

typedef std::unordered_map<unsigned int, cdfpair> HcalSiPM::cdfmap
protected

Definition at line 47 of file HcalSiPM.h.

◆ cdfpair

typedef std::pair<unsigned int, std::vector<double> > HcalSiPM::cdfpair
protected

Definition at line 46 of file HcalSiPM.h.

Constructor & Destructor Documentation

◆ HcalSiPM()

HcalSiPM::HcalSiPM ( int  nCells = 1,
double  tau = 15. 
)

Definition at line 14 of file HcalSiPM.cc.

References cms::cuda::assert(), setTau(), metsig::tau, and theCellCount.

16  theSiPM(nCells, -999.f),
17  theCrossTalk(0.),
18  theTempDep(0.),
19  theLastHitTime(-1.),
20  nonlin(nullptr) {
21  setTau(tau);
22  assert(theCellCount > 0);
23 }
double theTempDep
Definition: HcalSiPM.h:62
assert(be >=bs)
double theCrossTalk
Definition: HcalSiPM.h:61
void setTau(double tau)
Definition: HcalSiPM.cc:184
double theLastHitTime
Definition: HcalSiPM.h:63
double f[11][100]
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ nCells
std::vector< float > theSiPM
Definition: HcalSiPM.h:58
HcalSiPMnonlinearity * nonlin
Definition: HcalSiPM.h:65
unsigned int theCellCount
Definition: HcalSiPM.h:57

◆ ~HcalSiPM()

HcalSiPM::~HcalSiPM ( )

Definition at line 25 of file HcalSiPM.cc.

References nonlin.

25  {
26  if (nonlin)
27  delete nonlin;
28 }
HcalSiPMnonlinearity * nonlin
Definition: HcalSiPM.h:65

Member Function Documentation

◆ addCrossTalkCells()

unsigned int HcalSiPM::addCrossTalkCells ( CLHEP::HepRandomEngine *  engine,
unsigned int  in_pes 
)
protected

Definition at line 119 of file HcalSiPM.cc.

References BorelCDF(), LogDebug, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, mitigatedMETSequence_cff::U, and up.

Referenced by hitCells().

119  {
120  const cdfpair& cdf = BorelCDF(in_pes);
121 
122  double U = CLHEP::RandFlat::shoot(engine);
123  std::vector<double>::const_iterator up;
124  up = std::lower_bound(cdf.second.cbegin(), cdf.second.cend(), U);
125 
126  LogDebug("HcalSiPM") << "cdf size = " << cdf.second.size() << ", U = " << U << ", in_pes = " << in_pes
127  << ", 2ndary_pes = " << (up - cdf.second.cbegin() + cdf.first);
128 
129  // returns the number of secondary pes produced
130  return (up - cdf.second.cbegin() + cdf.first);
131 }
Definition: BitonicSort.h:7
const cdfpair & BorelCDF(unsigned int k)
Definition: HcalSiPM.cc:80
std::pair< unsigned int, std::vector< double > > cdfpair
Definition: HcalSiPM.h:46
#define LogDebug(id)

◆ BorelCDF()

const HcalSiPM::cdfpair & HcalSiPM::BorelCDF ( unsigned int  k)
protected

Definition at line 80 of file HcalSiPM.cc.

References borelcdfs, MillePedeFileConverter_cfg::e, kinem::EPSILON, dqmdumpme::first, mps_fire::i, dqmdumpme::k, and theCrossTalk.

Referenced by addCrossTalkCells(), and setCrossTalk().

80  {
81  // EPSILON determines the min and max # of xtalk cells that can be
82  // simulated.
83  constexpr double EPSILON = 1e-6;
84  constexpr uint32_t maxCDFsize = 170; // safe max to avoid factorial to be infinite
85  auto it = borelcdfs.find(k);
86  if (it == borelcdfs.end()) {
87  vector<double> cdf;
88  cdf.reserve(64);
89 
90  // Find the first n=k+i value for which cdf[i] > EPSILON
91  unsigned int i;
92  double sumb = 0.;
93  double iFact = 1.;
94  for (i = 0; i < maxCDFsize; i++) {
95  if (i > 0)
96  iFact *= double(i);
97  sumb += Borel(i, theCrossTalk, k, iFact);
98  if (sumb >= EPSILON)
99  break;
100  }
101 
102  cdf.push_back(sumb);
103  unsigned int borelstartn = i;
104 
105  // calculate cdf[i] limit to 170 to avoid iFact to become infinite
106  for (++i; i < maxCDFsize; ++i) {
107  iFact *= double(i);
108  sumb += Borel(i, theCrossTalk, k, iFact);
109  cdf.push_back(sumb);
110  if (1. - sumb < EPSILON)
111  break;
112  }
113  it = (borelcdfs.emplace(k, make_pair(borelstartn, cdf))).first;
114  }
115 
116  return it->second;
117 }
double theCrossTalk
Definition: HcalSiPM.h:61
cdfmap borelcdfs
Definition: HcalSiPM.h:67
const float EPSILON
Definition: AnglesUtil.h:22

◆ cellCharge()

double HcalSiPM::cellCharge ( double  deltaTime) const
protected

Definition at line 217 of file HcalSiPM.cc.

References JetChargeProducer_cfi::exp, mps_fire::result, and theTauInv.

Referenced by hitCells(), and totalCharge().

217  {
218  if (deltaTime <= 0.)
219  return 0.;
220  if (deltaTime * theTauInv > 10.)
221  return 1.;
222  double result(1. - std::exp(-deltaTime * theTauInv));
223  return (result > 0.99) ? 1.0 : result;
224 }
double theTauInv
Definition: HcalSiPM.h:60

◆ getCrossTalk()

double HcalSiPM::getCrossTalk ( ) const
inline

Definition at line 36 of file HcalSiPM.h.

References theCrossTalk.

36 { return theCrossTalk; }
double theCrossTalk
Definition: HcalSiPM.h:61

◆ getNCells()

int HcalSiPM::getNCells ( ) const
inline

Definition at line 34 of file HcalSiPM.h.

References theCellCount.

34 { return theCellCount; }
unsigned int theCellCount
Definition: HcalSiPM.h:57

◆ getTau()

double HcalSiPM::getTau ( ) const
inline

Definition at line 35 of file HcalSiPM.h.

References theTau.

35 { return theTau; }
double theTau
Definition: HcalSiPM.h:59

◆ getTempDep()

double HcalSiPM::getTempDep ( ) const
inline

Definition at line 37 of file HcalSiPM.h.

References theTempDep.

37 { return theTempDep; }
double theTempDep
Definition: HcalSiPM.h:62

◆ hitCells()

double HcalSiPM::hitCells ( CLHEP::HepRandomEngine *  engine,
unsigned int  pes,
double  tempDiff = 0.,
double  photonTime = 0. 
)

Definition at line 135 of file HcalSiPM.cc.

References addCrossTalkCells(), cellCharge(), muonClassificationByHits_cfi::pixel, theCellCount, theCrossTalk, theLastHitTime, theSiPM, theTau, and theTempDep.

Referenced by HcalSiPMHitResponse::makeSiPMSignal().

135  {
136  // response to light impulse with pes input photons. The return is the number
137  // of micro-pixels hit. If a fraction other than 0. is supplied then the
138  // micro-pixel doesn't fully discharge. The tempDiff is the temperature
139  // difference from nominal and is used to modify the relative strength of a
140  // hit pixel. Pixels which are fractionally charged return a fractional
141  // number of hit pixels.
142 
143  if ((theCrossTalk > 0.) && (theCrossTalk < 1.))
144  pes += addCrossTalkCells(engine, pes);
145 
146  // Account for saturation - disabled in lieu of recovery model below
147  //pes = nonlin->getPixelsFired(pes);
148 
149  //disable saturation/recovery model for bad tau values
150  if (theTau <= 0)
151  return pes;
152 
153  unsigned int pixel;
154  double sum(0.), hit(0.);
155  for (unsigned int pe(0); pe < pes; ++pe) {
156  pixel = CLHEP::RandFlat::shootInt(engine, theCellCount);
157  hit = (theSiPM[pixel] < 0.) ? 1.0 : (cellCharge(photonTime - theSiPM[pixel]));
158  sum += hit * (1 + (tempDiff * theTempDep));
159  theSiPM[pixel] = photonTime;
160  }
161 
162  theLastHitTime = photonTime;
163 
164  return sum;
165 }
double theTempDep
Definition: HcalSiPM.h:62
double theCrossTalk
Definition: HcalSiPM.h:61
double theLastHitTime
Definition: HcalSiPM.h:63
std::vector< float > theSiPM
Definition: HcalSiPM.h:58
unsigned int addCrossTalkCells(CLHEP::HepRandomEngine *engine, unsigned int in_pes)
Definition: HcalSiPM.cc:119
double theTau
Definition: HcalSiPM.h:59
unsigned int theCellCount
Definition: HcalSiPM.h:57
double cellCharge(double deltaTime) const
Definition: HcalSiPM.cc:217

◆ resetSiPM()

void HcalSiPM::resetSiPM ( )
inline

Definition at line 28 of file HcalSiPM.h.

References ntuplemaker::fill, and theSiPM.

Referenced by setNCells().

28 { std::fill(theSiPM.begin(), theSiPM.end(), -999.f); }
std::vector< float > theSiPM
Definition: HcalSiPM.h:58

◆ setCrossTalk()

void HcalSiPM::setCrossTalk ( double  xtalk)

Definition at line 192 of file HcalSiPM.cc.

References BorelCDF(), borelcdfs, dqmdumpme::k, theCrossTalk, and hgchebackDigitizer_cfi::xTalk.

Referenced by HcalSiPMHitResponse::makeSiPMSignal().

192  {
193  // set the cross-talk probability
194 
195  double oldCrossTalk = theCrossTalk;
196 
197  if ((xTalk < 0) || (xTalk >= 1)) {
198  theCrossTalk = 0.;
199  } else {
201  }
202 
203  // Recalculate the crosstalk CDFs
204  if (theCrossTalk != oldCrossTalk) {
205  borelcdfs.clear();
206  if (theCrossTalk > 0)
207  for (int k = 1; k <= 100; k++)
208  BorelCDF(k);
209  }
210 }
double theCrossTalk
Definition: HcalSiPM.h:61
const cdfpair & BorelCDF(unsigned int k)
Definition: HcalSiPM.cc:80
cdfmap borelcdfs
Definition: HcalSiPM.h:67

◆ setNCells()

void HcalSiPM::setNCells ( int  nCells)

Definition at line 178 of file HcalSiPM.cc.

References caHitNtupletGeneratorKernels::nCells, resetSiPM(), theCellCount, and theSiPM.

Referenced by HcalSiPMHitResponse::makeSiPMSignal().

178  {
180  theSiPM.resize(nCells);
181  resetSiPM();
182 }
void resetSiPM()
Definition: HcalSiPM.h:28
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ nCells
std::vector< float > theSiPM
Definition: HcalSiPM.h:58
unsigned int theCellCount
Definition: HcalSiPM.h:57

◆ setSaturationPars()

void HcalSiPM::setSaturationPars ( const std::vector< float > &  pars)

Definition at line 226 of file HcalSiPM.cc.

References nonlin.

Referenced by HcalSiPMHitResponse::makeSiPMSignal().

226  {
227  if (nonlin)
228  delete nonlin;
229 
230  nonlin = new HcalSiPMnonlinearity(pars);
231 }
HcalSiPMnonlinearity * nonlin
Definition: HcalSiPM.h:65

◆ setTau()

void HcalSiPM::setTau ( double  tau)

Definition at line 184 of file HcalSiPM.cc.

References metsig::tau, theTau, and theTauInv.

Referenced by HcalSiPM(), and HcalSiPMHitResponse::makeSiPMSignal().

184  {
185  theTau = tau;
186  if (theTau > 0)
187  theTauInv = 1. / theTau;
188  else
189  theTauInv = 0;
190 }
double theTauInv
Definition: HcalSiPM.h:60
double theTau
Definition: HcalSiPM.h:59

◆ setTemperatureDependence()

void HcalSiPM::setTemperatureDependence ( double  tempDep)

Definition at line 212 of file HcalSiPM.cc.

References theTempDep.

212  {
213  // set the temperature dependence
214  theTempDep = dTemp;
215 }
double theTempDep
Definition: HcalSiPM.h:62

◆ totalCharge() [1/2]

double HcalSiPM::totalCharge ( ) const
inline

Definition at line 31 of file HcalSiPM.h.

References theLastHitTime, and totalCharge().

Referenced by totalCharge().

31 { return totalCharge(theLastHitTime); }
double totalCharge() const
Definition: HcalSiPM.h:31
double theLastHitTime
Definition: HcalSiPM.h:63

◆ totalCharge() [2/2]

double HcalSiPM::totalCharge ( double  time) const

Definition at line 167 of file HcalSiPM.cc.

References cellCharge(), mps_fire::i, theCellCount, theSiPM, protons_cff::time, and compareTotals::tot.

167  {
168  // sum of the micro-pixels. NP is a fully charged device.
169  // 0 is a fullly depleted device.
170  double tot(0.), hit(0.);
171  for (unsigned int i = 0; i < theCellCount; ++i) {
172  hit = (theSiPM[i] < 0.) ? 1. : cellCharge(time - theSiPM[i]);
173  tot += hit;
174  }
175  return tot;
176 }
std::vector< float > theSiPM
Definition: HcalSiPM.h:58
unsigned int theCellCount
Definition: HcalSiPM.h:57
double cellCharge(double deltaTime) const
Definition: HcalSiPM.cc:217

Member Data Documentation

◆ borelcdfs

cdfmap HcalSiPM::borelcdfs
protected

Definition at line 67 of file HcalSiPM.h.

Referenced by BorelCDF(), and setCrossTalk().

◆ nonlin

HcalSiPMnonlinearity* HcalSiPM::nonlin
protected

Definition at line 65 of file HcalSiPM.h.

Referenced by setSaturationPars(), and ~HcalSiPM().

◆ theCellCount

unsigned int HcalSiPM::theCellCount
protected

Definition at line 57 of file HcalSiPM.h.

Referenced by getNCells(), HcalSiPM(), hitCells(), setNCells(), and totalCharge().

◆ theCrossTalk

double HcalSiPM::theCrossTalk
protected

Definition at line 61 of file HcalSiPM.h.

Referenced by BorelCDF(), getCrossTalk(), hitCells(), and setCrossTalk().

◆ theLastHitTime

double HcalSiPM::theLastHitTime
protected

Definition at line 63 of file HcalSiPM.h.

Referenced by hitCells(), and totalCharge().

◆ theSiPM

std::vector<float> HcalSiPM::theSiPM
protected

Definition at line 58 of file HcalSiPM.h.

Referenced by hitCells(), resetSiPM(), setNCells(), and totalCharge().

◆ theTau

double HcalSiPM::theTau
protected

Definition at line 59 of file HcalSiPM.h.

Referenced by getTau(), hitCells(), and setTau().

◆ theTauInv

double HcalSiPM::theTauInv
protected

Definition at line 60 of file HcalSiPM.h.

Referenced by cellCharge(), and setTau().

◆ theTempDep

double HcalSiPM::theTempDep
protected

Definition at line 62 of file HcalSiPM.h.

Referenced by getTempDep(), hitCells(), and setTemperatureDependence().