CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
HcalSiPM Class Reference

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.)
 
virtual int hitCells (unsigned int photons, unsigned int integral=0) const
 
virtual double hitCells (unsigned int pes, double tempDiff=0., double photonTime=0.)
 
void initRandomEngine (CLHEP::HepRandomEngine &engine)
 
void resetSiPM ()
 
void setCrossTalk (double xtalk)
 
void setNCells (int nCells)
 
void setTau (double tau)
 
void setTemperatureDependence (double tempDep)
 
virtual double totalCharge () const
 
virtual double totalCharge (double time) const
 
virtual ~HcalSiPM ()
 

Protected Member Functions

double cellCharge (double deltaTime) const
 

Protected Attributes

unsigned int theCellCount
 
double theCrossTalk
 
double theLastHitTime
 
CLHEP::RandFlat * theRndFlat
 
CLHEP::RandGaussQ * theRndGauss
 
CLHEP::RandPoissonQ * theRndPoisson
 
std::vector< double > theSiPM
 
double theTauInv
 
double theTempDep
 

Detailed Description

A general implementation for the response of a SiPM.

Definition at line 20 of file HcalSiPM.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file HcalSiPM.cc.

References resetSiPM(), and theCellCount.

9  :
10  theCellCount(nCells), theSiPM(nCells,1.), theTauInv(1.0/tau),
11  theCrossTalk(0.), theTempDep(0.), theLastHitTime(-1.),
13 
14  assert(theCellCount>0);
15  resetSiPM();
16 }
double theTempDep
Definition: HcalSiPM.h:59
double theTauInv
Definition: HcalSiPM.h:57
void resetSiPM()
Definition: HcalSiPM.h:26
CLHEP::RandGaussQ * theRndGauss
Definition: HcalSiPM.h:62
double theCrossTalk
Definition: HcalSiPM.h:58
std::vector< double > theSiPM
Definition: HcalSiPM.h:56
double theLastHitTime
Definition: HcalSiPM.h:60
CLHEP::RandFlat * theRndFlat
Definition: HcalSiPM.h:64
CLHEP::RandPoissonQ * theRndPoisson
Definition: HcalSiPM.h:63
unsigned int theCellCount
Definition: HcalSiPM.h:55
HcalSiPM::~HcalSiPM ( )
virtual

Definition at line 18 of file HcalSiPM.cc.

References theRndFlat, theRndGauss, and theRndPoisson.

18  {
19  delete theRndGauss;
20  delete theRndPoisson;
21  delete theRndFlat;
22 }
CLHEP::RandGaussQ * theRndGauss
Definition: HcalSiPM.h:62
CLHEP::RandFlat * theRndFlat
Definition: HcalSiPM.h:64
CLHEP::RandPoissonQ * theRndPoisson
Definition: HcalSiPM.h:63

Member Function Documentation

double HcalSiPM::cellCharge ( double  deltaTime) const
protected

Definition at line 180 of file HcalSiPM.cc.

References create_public_lumi_plots::exp, query::result, and theTauInv.

Referenced by hitCells(), and totalCharge().

180  {
181  if (deltaTime <= 0.) return 0.;
182  if (deltaTime > 10./theTauInv) return 1.;
183  double result(1. - std::exp(-deltaTime*theTauInv));
184  return (result > 0.99) ? 1.0 : result;
185 }
double theTauInv
Definition: HcalSiPM.h:57
tuple result
Definition: query.py:137
double HcalSiPM::getCrossTalk ( ) const
inline

Definition at line 38 of file HcalSiPM.h.

References theCrossTalk.

38 { return theCrossTalk; }
double theCrossTalk
Definition: HcalSiPM.h:58
int HcalSiPM::getNCells ( ) const
inline

Definition at line 36 of file HcalSiPM.h.

References theCellCount.

36 { return theCellCount; }
unsigned int theCellCount
Definition: HcalSiPM.h:55
double HcalSiPM::getTau ( ) const
inline

Definition at line 37 of file HcalSiPM.h.

References theTauInv.

37 { return 1.0/theTauInv; }
double theTauInv
Definition: HcalSiPM.h:57
double HcalSiPM::getTempDep ( ) const
inline

Definition at line 39 of file HcalSiPM.h.

References theTempDep.

39 { return theTempDep; }
double theTempDep
Definition: HcalSiPM.h:59
int HcalSiPM::hitCells ( unsigned int  photons,
unsigned int  integral = 0 
) const
virtual

Definition at line 24 of file HcalSiPM.cc.

References edm::hlt::Exception, create_public_lumi_plots::exp, edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), timingPdfMaker::mean, mathSSE::sqrt(), theCellCount, theCrossTalk, theRndFlat, theRndGauss, theRndPoisson, and x.

Referenced by HcalSiPMHitResponse::makeSiPMSignal().

24  {
25  //don't need to do zero or negative photons.
26  if (photons < 1) return 0;
27  if (integral >= theCellCount) return 0;
28 
29  if (theRndGauss == 0) {
30  //random number generator setup
32  if ( ! rng.isAvailable()) {
33  throw cms::Exception("Configuration")
34  << "HcalSiPM requires the RandomNumberGeneratorService\n"
35  "which is not present in the configuration file. "
36  "You must add the service\n"
37  "in the configuration file or remove the modules that require it.";
38  }
39 
40  CLHEP::HepRandomEngine& engine = rng->getEngine();
41  theRndGauss = new CLHEP::RandGaussQ(engine);
42  theRndPoisson = new CLHEP::RandPoissonQ(engine);
43  theRndFlat = new CLHEP::RandFlat(engine);
44  }
45 
46  //normalize by theCellCount to remove dependency on SiPM size and pixel density.
47  if ((theCrossTalk > 0.) && (theCrossTalk < 1.))
49  double x(photons/double(theCellCount));
50  double prehit(integral/double(theCellCount));
51 
52  //calculate the width and mean of the distribution for a given x
53  double mean(1. - std::exp(-x));
54  double width2(std::exp(-x)*(1-(1+x)*std::exp(-x)));
55 
56  //you can't hit more than everything.
57  if (mean > 1.) mean = 1.;
58 
59  //convert back to absolute pixels
60  mean *= (1-prehit)*theCellCount;
61  width2 *= (1-prehit)*theCellCount;
62 
63  double npe;
64  while (true) {
65  npe = theRndGauss->fire(mean, std::sqrt(width2 + (mean*prehit)));
66  if ((npe > -0.5) && (npe <= theCellCount-integral))
67  return int(npe + 0.5);
68  }
69 }
CLHEP::RandGaussQ * theRndGauss
Definition: HcalSiPM.h:62
double theCrossTalk
Definition: HcalSiPM.h:58
T sqrt(T t)
Definition: SSEVec.h:48
bool isAvailable() const
Definition: Service.h:46
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69
CLHEP::RandFlat * theRndFlat
Definition: HcalSiPM.h:64
CLHEP::RandPoissonQ * theRndPoisson
Definition: HcalSiPM.h:63
unsigned int theCellCount
Definition: HcalSiPM.h:55
Definition: DDAxes.h:10
double HcalSiPM::hitCells ( unsigned int  pes,
double  tempDiff = 0.,
double  photonTime = 0. 
)
virtual

Definition at line 71 of file HcalSiPM.cc.

References cellCharge(), edm::hlt::Exception, edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), theCellCount, theCrossTalk, theLastHitTime, theRndFlat, theRndGauss, theRndPoisson, theSiPM, and theTempDep.

72  {
73  // response to light impulse with pes input photons. The return is the number
74  // of micro-pixels hit. If a fraction other than 0. is supplied then the
75  // micro-pixel doesn't fully discharge. The tempDiff is the temperature
76  // difference from nominal and is used to modify the relative strength of a
77  // hit pixel. Pixels which are fractionally charged return a fractional
78  // number of hit pixels.
79 
80  if (theRndGauss == 0) {
81  //random number generator setup
83  if ( ! rng.isAvailable()) {
84  throw cms::Exception("Configuration")
85  << "HcalSiPM requires the RandomNumberGeneratorService\n"
86  "which is not present in the configuration file. "
87  "You must add the service\n"
88  "in the configuration file or remove the modules that require it.";
89  }
90 
91  CLHEP::HepRandomEngine& engine = rng->getEngine();
92  theRndGauss = new CLHEP::RandGaussQ(engine);
93  theRndPoisson = new CLHEP::RandPoissonQ(engine);
94  theRndFlat = new CLHEP::RandFlat(engine);
95  }
96 
97  if ((theCrossTalk > 0.) && (theCrossTalk < 1.))
98  pes += theRndPoisson->fire(pes/(1. - theCrossTalk) - pes);
99 
100  unsigned int pixel;
101  double sum(0.), hit(0.);
102  for (unsigned int pe(0); pe < pes; ++pe) {
103  pixel = theRndFlat->fireInt(theCellCount);
104  hit = (theSiPM[pixel] < 0.) ? 1.0 :
105  (cellCharge(photonTime - theSiPM[pixel]));
106  sum += hit*(1 + (tempDiff*theTempDep));
107  theSiPM[pixel] = photonTime;
108  }
109 
110  theLastHitTime = photonTime;
111 
112  return sum;
113 }
double theTempDep
Definition: HcalSiPM.h:59
double cellCharge(double deltaTime) const
Definition: HcalSiPM.cc:180
CLHEP::RandGaussQ * theRndGauss
Definition: HcalSiPM.h:62
double theCrossTalk
Definition: HcalSiPM.h:58
std::vector< double > theSiPM
Definition: HcalSiPM.h:56
bool isAvailable() const
Definition: Service.h:46
double theLastHitTime
Definition: HcalSiPM.h:60
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
CLHEP::RandFlat * theRndFlat
Definition: HcalSiPM.h:64
CLHEP::RandPoissonQ * theRndPoisson
Definition: HcalSiPM.h:63
unsigned int theCellCount
Definition: HcalSiPM.h:55
void HcalSiPM::initRandomEngine ( CLHEP::HepRandomEngine &  engine)

Definition at line 159 of file HcalSiPM.cc.

References theRndFlat, theRndGauss, and theRndPoisson.

Referenced by HcalSiPMHitResponse::setRandomEngine().

159  {
160  if(theRndGauss) delete theRndGauss;
161  theRndGauss = new CLHEP::RandGaussQ(engine);
162  if(theRndPoisson) delete theRndPoisson;
163  theRndPoisson = new CLHEP::RandPoissonQ(engine);
164  if(theRndFlat) delete theRndFlat;
165  theRndFlat = new CLHEP::RandFlat(engine);
166 }
CLHEP::RandGaussQ * theRndGauss
Definition: HcalSiPM.h:62
CLHEP::RandFlat * theRndFlat
Definition: HcalSiPM.h:64
CLHEP::RandPoissonQ * theRndPoisson
Definition: HcalSiPM.h:63
void HcalSiPM::resetSiPM ( )
inline

Definition at line 26 of file HcalSiPM.h.

References lumiContext::fill, and theSiPM.

Referenced by HcalSiPM(), and setNCells().

26 { std::fill(theSiPM.begin(), theSiPM.end(), -999.); }
string fill
Definition: lumiContext.py:319
std::vector< double > theSiPM
Definition: HcalSiPM.h:56
void HcalSiPM::setCrossTalk ( double  xtalk)

Definition at line 143 of file HcalSiPM.cc.

References theCrossTalk.

143  {
144  // set the cross-talk probability
145 
146  if((xTalk < 0) || (xTalk >= 1)) {
147  theCrossTalk = 0.;
148  } else {
149  theCrossTalk = xTalk;
150  }
151 
152 }
double theCrossTalk
Definition: HcalSiPM.h:58
void HcalSiPM::setNCells ( int  nCells)

Definition at line 136 of file HcalSiPM.cc.

References resetSiPM(), theCellCount, and theSiPM.

Referenced by HcalSiPMHitResponse::makeSiPMSignal().

136  {
137  assert(nCells>0);
138  theCellCount = nCells;
139  theSiPM.resize(nCells);
140  resetSiPM();
141 }
void resetSiPM()
Definition: HcalSiPM.h:26
std::vector< double > theSiPM
Definition: HcalSiPM.h:56
unsigned int theCellCount
Definition: HcalSiPM.h:55
void HcalSiPM::setTau ( double  tau)
inline

Definition at line 42 of file HcalSiPM.h.

References metsig::tau, and theTauInv.

Referenced by HcalSiPMHitResponse::makeSiPMSignal().

42 {theTauInv=1.0/tau;}
double theTauInv
Definition: HcalSiPM.h:57
void HcalSiPM::setTemperatureDependence ( double  tempDep)

Definition at line 154 of file HcalSiPM.cc.

References theTempDep.

154  {
155  // set the temperature dependence
156  theTempDep = dTemp;
157 }
double theTempDep
Definition: HcalSiPM.h:59
virtual double HcalSiPM::totalCharge ( ) const
inlinevirtual

Definition at line 32 of file HcalSiPM.h.

References theLastHitTime, and totalCharge().

Referenced by totalCharge().

32 { return totalCharge(theLastHitTime); }
virtual double totalCharge() const
Definition: HcalSiPM.h:32
double theLastHitTime
Definition: HcalSiPM.h:60
double HcalSiPM::totalCharge ( double  time) const
virtual

Definition at line 115 of file HcalSiPM.cc.

References cellCharge(), i, theCellCount, and theSiPM.

115  {
116  // sum of the micro-pixels. NP is a fully charged device.
117  // 0 is a fullly depleted device.
118  double tot(0.), hit(0.);
119  for(unsigned int i=0; i<theCellCount; ++i) {
120  hit = (theSiPM[i] < 0.) ? 1. : cellCharge(time - theSiPM[i]);
121  tot += hit;
122  }
123  return tot;
124 }
int i
Definition: DBlmapReader.cc:9
double cellCharge(double deltaTime) const
Definition: HcalSiPM.cc:180
std::vector< double > theSiPM
Definition: HcalSiPM.h:56
unsigned int theCellCount
Definition: HcalSiPM.h:55

Member Data Documentation

unsigned int HcalSiPM::theCellCount
protected

Definition at line 55 of file HcalSiPM.h.

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

double HcalSiPM::theCrossTalk
protected

Definition at line 58 of file HcalSiPM.h.

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

double HcalSiPM::theLastHitTime
protected

Definition at line 60 of file HcalSiPM.h.

Referenced by hitCells(), and totalCharge().

CLHEP::RandFlat* HcalSiPM::theRndFlat
mutableprotected

Definition at line 64 of file HcalSiPM.h.

Referenced by hitCells(), initRandomEngine(), and ~HcalSiPM().

CLHEP::RandGaussQ* HcalSiPM::theRndGauss
mutableprotected

Definition at line 62 of file HcalSiPM.h.

Referenced by hitCells(), initRandomEngine(), and ~HcalSiPM().

CLHEP::RandPoissonQ* HcalSiPM::theRndPoisson
mutableprotected

Definition at line 63 of file HcalSiPM.h.

Referenced by hitCells(), initRandomEngine(), and ~HcalSiPM().

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

Definition at line 56 of file HcalSiPM.h.

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

double HcalSiPM::theTauInv
protected

Definition at line 57 of file HcalSiPM.h.

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

double HcalSiPM::theTempDep
protected

Definition at line 59 of file HcalSiPM.h.

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