9 #include "NovaDAQConventions/DAQConventions.h" 32 if (nPE_in < 0 || m < 0)
return 0.0;
35 if (m == 0)
return 1.0;
39 if (r < 0)
return 0.0;
41 double logProb =
log(nPE_in);
42 logProb += r*
log( (1-
fK)*(fGain-1)/fGain );
43 logProb += ((nPE_in+
fK*
r)/(1-
fK))*
log( (1+
fK*(fGain-1))/fGain );
44 logProb +=
lgamma( (nPE_in+r)/(1-
fK) );
45 logProb -=
log( nPE_in+
fK*r);
46 logProb -=
lgamma( r + 1 );
49 return fGain*
exp( logProb );
59 std::map<int, std::vector<double> >::iterator
it =
fPDFs.find(nPE);
62 const Double_t
u(flat->
fire());
64 const double xlo = (nPE - 7*sigma <0) ? 0.0 : nPE - 7*sigma;
67 const int nbins((xhi-xlo)/binw);
70 const Int_t
ibin = TMath::BinarySearch(nbins, &(it->second)[0],
u);
71 Double_t
x = xlo + ibin*binw;
72 if (
u > it->second[ibin]) x += binw*(
u - it->second[
ibin])/(it->second[ibin+1] - it->second[ibin]);
86 const double xlo = (nPE - 7*sigma < 0) ? 0.0 : nPE - 7*sigma;
89 const int nbins((xhi-xlo)/binw);
91 std::vector<double>
pdf(nbins);
93 double nPE_out = xlo +
i*binw;
99 pdf[
i] /= pdf[nbins-1];
102 std::pair<std::map<int, std::vector<double> >::iterator,
bool>
result =
fPDFs.insert(
make_pair(nPE, pdf) );
double fAPDExcessNoiseFactor
APD's "excess noise factor" (see .cxx for more)
double DrawSmearedPE(int nPE, CLHEP::RandFlat *flat)
fvar< T > lgamma(const fvar< T > &x)
double ExcessNoisePDF(int nPE_in, double nPE_out)
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Common configuration params for SimpleReadout, FPGAAlgorithms, NoiseMaker.
ExcessNoiseMaker(const fhicl::ParameterSet &pset)
fvar< T > exp(const fvar< T > &x)
double fGain
APD gain (electrons per photoelectron)
Can be used as either a member holding configurations, or a mix-in.
std::map< int, std::vector< double > >::iterator MakeTemplate(int nPE)
std::map< int, std::vector< double > > fPDFs