14 #include "CLHEP/Random/RandPoissonQ.h" 20 const CaloShapes * shapes,
bool PreMix1,
bool HighFidelity) :
21 CaloHitResponse(parameterMap, shapes), theSiPM(), PreMixDigis(PreMix1), HighFidelityPreMix(HighFidelity),
52 photonTimeMap::iterator channelPhotons;
57 channelPhotons->second,
61 const unsigned int size ( signal.
size() ) ;
63 for(
unsigned int i ( 0 ) ;
i !=
size ; ++
i ) {
64 keep = keep || signal[
i] > 1.e-7 ;
88 assert(photonTimeHistSize == signal.
size());
91 std::pair<DetId, photonTimeHist >(
id,
photonTimeHist(photonTimeHistSize, 0)
95 for(
int i = 0;
i < signal.
size(); ++
i){
96 unsigned int photons(signal[
i] + 0.5);
108 unsigned int photons(signal + 0.5);
116 std::pair<DetId, photonTimeHist >(
id,
123 LogDebug(
"HcalSiPMHitResponse") <<
" fCtoGeV: " << pars.fCtoGeV(
id)
124 <<
" samplingFactor: " << pars.samplingFactor(
id)
125 <<
" photoelectronsToAnalog: " << pars.photoelectronsToAnalog(
id)
126 <<
" simHitToPhotoelectrons: " << pars.simHitToPhotoelectrons(
id);
128 <<
" photons: " << photons
129 <<
" time: " <<
time;
130 LogDebug(
"HcalSiPMHitResponse") <<
" timePhase: " << pars.timePhase()
132 <<
" binOfMaximum: " << pars.binOfMaximum()
134 double tzero(0.0 + pars.timePhase() -
138 double tzero_bin(-tzero*
invdt);
139 LogDebug(
"HcalSiPMHitResponse") <<
" corrected tzero: " << tzero_bin <<
'\n';
142 unsigned signalShape = pars.signalShape(
id);
143 for (
unsigned int pe(0); pe<
photons; ++pe) {
145 t_bin =
int(t_pe*invdt + tzero_bin + 0.5);
146 LogDebug(
"HcalSiPMHitResponse") <<
"t_pe: " << t_pe <<
" t_pe + tzero: " << (t_pe+tzero_bin*
dt)
147 <<
" t_bin: " << t_bin <<
'\n';
158 for(std::vector<DetId>::const_iterator idItr =
theDetIds->begin();
169 if (dc_pe_avg <= 0.)
continue;
173 unsigned int sumnoisePE(0);
174 double elapsedTime(0.);
175 for (
int tprecise(0); tprecise < nPreciseBins; ++tprecise) {
176 int noisepe = CLHEP::RandPoissonQ::shoot(engine, dc_pe_avg);
181 photons[tprecise] = noisepe;
183 (std::pair<DetId, photonTimeHist >(
id, photons ) );
188 sumnoisePE += noisepe;
195 LogDebug(
"HcalSiPMHitResponse") <<
" total noise (PEs): " << sumnoisePE;
203 int preciseSize(readoutFrameSize *
nbins);
212 CLHEP::HepRandomEngine* engine) {
221 int sampleBin(0), preciseBin(0);
224 double hitPixels(0.), elapsedTime(0.);
225 unsigned int sumPE(0);
230 std::list< std::pair<double, double> > pulses;
231 std::list< std::pair<double, double> >::iterator
pulse;
232 double timeDiff, pulseBit;
235 for (
unsigned int tbin(0); tbin < photonTimeBins.size(); ++tbin) {
236 pe = photonTimeBins[tbin];
239 sampleBin = preciseBin/
nbins;
243 signal[sampleBin] += pe;
250 sumHits += hitPixels;
251 LogDebug(
"HcalSiPMHitResponse") <<
" elapsedTime: " << elapsedTime
252 <<
" sampleBin: " << sampleBin
253 <<
" preciseBin: " << preciseBin
255 <<
" hitPixels: " << hitPixels ;
257 pulses.push_back( std::pair<double, double>(elapsedTime, hitPixels) );
259 signal[sampleBin] += hitPixels;
270 pulse = pulses.begin();
271 while (pulse != pulses.end()) {
272 timeDiff = elapsedTime - pulse->first;
273 pulseBit = sipmPulseShape(timeDiff)*pulse->second;
274 LogDebug(
"HcalSiPMHitResponse") <<
" pulse t: " << pulse->first
275 <<
" pulse A: " << pulse->second
276 <<
" timeDiff: " << timeDiff
277 <<
" pulseBit: " << pulseBit;
278 signal[sampleBin] += pulseBit;
281 if (timeDiff > 1 && sipmPulseShape(timeDiff) < 1
e-7)
282 pulse = pulses.erase(pulse);
std::vector< float > sipmNonlinearity(const DetId &detId) const
const std::vector< DetId > * theDetIds
void finalizeHits(CLHEP::HepRandomEngine *) override
Finalize hits.
void setSaturationPars(const std::vector< float > &pars)
constexpr bool isNotFinite(T x)
double photoelectronsToAnalog(const DetId &detId) const override
int presamples() const
access presample information
virtual bool keepBlank() const
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 bool accepts(const PCaloHit &hit) const =0
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
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
void setNCells(int nCells)
bool doSiPMSmearing() const
void add(const PCaloHit &hit, CLHEP::HepRandomEngine *) override
process a single SimHit
void setCrossTalk(double xtalk)
virtual void setDetIds(const std::vector< DetId > &detIds)
double timeOfFlight(const DetId &detId) const
void setPresamples(int pre)
set presample information
int readoutFrameSize() const
for now, the LinearFrames and trhe digis will be one-to-one.
static float invDeltaTSiPM_
virtual int getReadoutFrameSize(const DetId &id) const
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
double sipmDarkCurrentuA(const DetId &detId) const
double pulse(double x, double y, double z, double t)
~HcalSiPMHitResponse() override
const CaloVSimParameterMap * theParameterMap
int size() const
get the size
static double generatePhotonTime(CLHEP::HepRandomEngine *engine, unsigned int signalShape)
void initializeHits() override
Initialize hits.
virtual CaloSamples makeSiPMSignal(DetId const &id, photonTimeHist const &photons, CLHEP::HepRandomEngine *)
float & preciseAtMod(int i)
mutable function to access precise samples
virtual void add(const PCaloHit &hit, CLHEP::HepRandomEngine *)
process a single SimHit
double sipmCrossTalk(const DetId &detId) const
void setPrecise(int precisePresamples, float deltaT)
static const double tzero[3]
HcalSiPMHitResponse(const CaloVSimParameterMap *parameterMap, const CaloShapes *shapes, bool PreMix1=false, bool HighFidelity=true)
const CaloVHitFilter * theHitFilter
DetId id() const
get the (generic) id
photonTimeMap precisionTimedPhotons
std::map< int, HcalSiPMShape > shapeMap
void setPreciseSize(unsigned int size)