15 #include "CLHEP/Random/RandPoissonQ.h"
16 #include "CLHEP/Random/RandFlat.h"
23 CaloHitResponse(parameterMap, shapes), theSiPM(), theRecoveryTime(250.),
24 TIMEMULT(1), Y11RANGE(250), Y11MAX(0.04), Y11TIMETORISE(16.65), PreMixDigis(PreMix1) {
41 photonTimeMap::iterator channelPhotons;
46 channelPhotons->second,
50 const unsigned int size ( signal.
size() ) ;
52 for(
unsigned int i ( 0 ) ;
i !=
size ; ++
i ) {
53 keep = keep || signal[
i] > 1.e-7 ;
60 if (keep)
add(signal);
70 (*oldSignal) += signal;
81 unsigned int photons(signal + 0.5);
83 double time( hit.
time() );
89 std::pair<DetId, photonTimeHist >(
id,
91 pars.readoutFrameSize(), 0)
96 LogDebug(
"HcalSiPMHitResponse") << id;
97 LogDebug(
"HcalSiPMHitResponse") <<
" fCtoGeV: " << pars.fCtoGeV(
id)
98 <<
" samplingFactor: " << pars.samplingFactor(
id)
99 <<
" photoelectronsToAnalog: " << pars.photoelectronsToAnalog(
id)
100 <<
" simHitToPhotoelectrons: " << pars.simHitToPhotoelectrons(
id);
102 <<
" photons: " << photons
103 <<
" time: " << time;
104 LogDebug(
"HcalSiPMHitResponse") <<
" timePhase: " << pars.timePhase()
106 <<
" binOfMaximum: " << pars.binOfMaximum()
113 LogDebug(
"HcalSiPMHitResponse") <<
" corrected tzero: " << tzero_bin <<
'\n';
116 for (
unsigned int pe(0); pe<
photons; ++pe) {
120 <<
" t_bin: " << t_bin <<
'\n';
133 for(std::vector<DetId>::const_iterator idItr =
theDetIds->begin();
144 if (dc_pe_avg <= 0.)
continue;
148 unsigned int sumnoisePE(0);
149 double elapsedTime(0.);
150 for (
int tprecise(0); tprecise < nPreciseBins; ++tprecise) {
151 int noisepe = CLHEP::RandPoissonQ::shoot(engine, dc_pe_avg);
156 photons[tprecise] = noisepe;
158 (std::pair<DetId, photonTimeHist >(
id, photons ) );
163 sumnoisePE += noisepe;
169 LogDebug(
"HcalSiPMHitResponse") << id;
170 LogDebug(
"HcalSiPMHitResponse") <<
" total noise (PEs): " << sumnoisePE;
187 CLHEP::HepRandomEngine* engine)
const {
198 int sampleBin(0), preciseBin(0);
201 double hitPixels(0.), elapsedTime(0.);
202 unsigned int sumPE(0);
207 std::list< std::pair<double, double> > pulses;
208 std::list< std::pair<double, double> >::iterator pulse;
209 double timeDiff, pulseBit;
212 for (
unsigned int tbin(0); tbin < photonTimeBins.size(); ++tbin) {
213 pe = photonTimeBins[tbin];
219 sumHits += hitPixels;
220 LogDebug(
"HcalSiPMHitResponse") <<
" elapsedTime: " << elapsedTime
221 <<
" sampleBin: " << sampleBin
222 <<
" preciseBin: " << preciseBin
224 <<
" hitPixels: " << hitPixels ;
226 pulses.push_back( std::pair<double, double>(elapsedTime, hitPixels) );
228 signal[sampleBin] += hitPixels;
239 pulse = pulses.begin();
240 while (pulse != pulses.end()) {
241 timeDiff = elapsedTime - pulse->first;
242 pulseBit = sipmPulseShape(timeDiff)*pulse->second;
243 LogDebug(
"HcalSiPMHitResponse") <<
" pulse t: " << pulse->first
244 <<
" pulse A: " << pulse->second
245 <<
" timeDiff: " << timeDiff
246 <<
" pulseBit: " << pulseBit;
247 signal[sampleBin] += pulseBit;
250 if (timeDiff > 1 && sipmPulseShape(timeDiff) < 1
e-7)
251 pulse = pulses.erase(pulse);
265 result = CLHEP::RandFlat::shoot(engine,
Y11RANGE);
272 return exp(-0.0635-0.1518*t)*
pow(t, 2.528)/2485.9;
std::vector< float > sipmNonlinearity(const DetId &detId) const
A general implementation for the response of a SiPM.
const std::vector< DetId > * theDetIds
virtual void finalizeHits(CLHEP::HepRandomEngine *) override
Finalize hits.
void setSaturationPars(const std::vector< float > &pars)
virtual double photoelectronsToAnalog(const DetId &detId) const
double generatePhotonTime(CLHEP::HepRandomEngine *) const
virtual bool keepBlank() const
static double Y11TimePDF(double t)
int pixels(const DetId &detId) const
int preciseSize() const
get the size
Main class for Parameters in different subdetectors.
virtual void addPEnoise(CLHEP::HepRandomEngine *engine)
virtual CaloSamples makeSiPMSignal(DetId const &id, photonTimeHist const &photons, CLHEP::HepRandomEngine *) const
Creates electronics signals from hits.
virtual double hitCells(CLHEP::HepRandomEngine *, unsigned int pes, double tempDiff=0., double photonTime=0.)
unsigned int signalShape(const DetId &detId) const
void setNCells(int nCells)
bool doSiPMSmearing() const
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
virtual void add(const PCaloHit &hit, CLHEP::HepRandomEngine *) override
process a single SimHit
void setCrossTalk(double xtalk)
virtual void setDetIds(const std::vector< DetId > &detIds)
virtual bool accepts(const PCaloHit &hit) const =0
double timeOfFlight(const DetId &detId) const
int readoutFrameSize() const
for now, the LinearFrames and trhe digis will be one-to-one.
HcalTDCParameters theTDCParams
AnalogSignalMap theAnalogSignalMap
double analogSignalAmplitude(const DetId &id, float energy, const CaloSimParameters ¶meters, CLHEP::HepRandomEngine *) const
std::vector< unsigned int > photonTimeHist
virtual CaloSamples makeBlankSignal(const DetId &detId) const
float const Y11TIMETORISE
double sipmDarkCurrentuA(const DetId &detId) const
const CaloVSimParameterMap * theParameterMap
int size() const
get the size
virtual void initializeHits() override
Initialize hits.
CaloSamples * findSignal(const DetId &detId)
users can look for the signal for a given cell
float & preciseAtMod(int i)
mutable function to access precise samples
double sipmCrossTalk(const DetId &detId) const
static const double tzero[3]
const CaloVHitFilter * theHitFilter
DetId id() const
get the (generic) id
photonTimeMap precisionTimedPhotons
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
virtual ~HcalSiPMHitResponse()
HcalSiPMHitResponse(const CaloVSimParameterMap *parameterMap, const CaloShapes *shapes, bool PreMix1=false)