14 #include "CLHEP/Random/RandPoissonQ.h" 26 HighFidelityPreMix(HighFidelity),
56 photonTimeMap::iterator channelPhotons;
62 const unsigned int size(signal.
size());
64 for (
unsigned int i(0);
i !=
size; ++
i) {
65 keep = keep || signal[
i] > 1.e-7;
90 assert(photonTimeHistSize == signal.
size());
94 for (
int i = 0;
i < signal.
size(); ++
i) {
95 unsigned int photons(signal[
i] + 0.5);
106 unsigned int photons(signal + 0.5);
119 LogDebug(
"HcalSiPMHitResponse") <<
" fCtoGeV: " << pars.fCtoGeV(
id)
120 <<
" samplingFactor: " << pars.samplingFactor(
id)
121 <<
" photoelectronsToAnalog: " << pars.photoelectronsToAnalog(
id)
122 <<
" simHitToPhotoelectrons: " << pars.simHitToPhotoelectrons(
id);
123 LogDebug(
"HcalSiPMHitResponse") <<
" energy: " << hit.
energy() <<
" photons: " << photons <<
" time: " <<
time;
124 LogDebug(
"HcalSiPMHitResponse") <<
" timePhase: " << pars.timePhase() <<
" tof: " << tof
125 <<
" binOfMaximum: " << pars.binOfMaximum() <<
" phaseShift: " <<
thePhaseShift_;
128 double tzero_bin(-tzero *
invdt);
129 LogDebug(
"HcalSiPMHitResponse") <<
" corrected tzero: " << tzero_bin <<
'\n';
132 unsigned signalShape = pars.signalShape(
id);
133 for (
unsigned int pe(0); pe <
photons; ++pe) {
135 t_bin =
int(t_pe * invdt + tzero_bin + 0.5);
136 LogDebug(
"HcalSiPMHitResponse") <<
"t_pe: " << t_pe <<
" t_pe + tzero: " << (t_pe + tzero_bin *
dt)
137 <<
" t_bin: " << t_bin <<
'\n';
146 for (std::vector<DetId>::const_iterator idItr =
theDetIds->begin(); idItr !=
theDetIds->end(); ++idItr) {
158 unsigned int sumnoisePE(0);
159 double elapsedTime(0.);
160 for (
int tprecise(0); tprecise < nPreciseBins; ++tprecise) {
161 int noisepe = CLHEP::RandPoissonQ::shoot(engine, dc_pe_avg);
166 photons[tprecise] = noisepe;
172 sumnoisePE += noisepe;
179 LogDebug(
"HcalSiPMHitResponse") <<
" total noise (PEs): " << sumnoisePE;
187 int preciseSize(readoutFrameSize *
nbins);
196 CLHEP::HepRandomEngine* engine) {
205 int sampleBin(0), preciseBin(0);
208 double hitPixels(0.), elapsedTime(0.);
209 unsigned int sumPE(0);
214 std::list<std::pair<double, double> > pulses;
215 std::list<std::pair<double, double> >::iterator
pulse;
216 double timeDiff, pulseBit;
219 for (
unsigned int tbin(0); tbin < photonTimeBins.size(); ++tbin) {
220 pe = photonTimeBins[tbin];
223 sampleBin = preciseBin /
nbins;
227 signal[sampleBin] += pe;
234 sumHits += hitPixels;
235 LogDebug(
"HcalSiPMHitResponse") <<
" elapsedTime: " << elapsedTime <<
" sampleBin: " << sampleBin
236 <<
" preciseBin: " << preciseBin <<
" pe: " << pe <<
" hitPixels: " << hitPixels;
238 pulses.push_back(std::pair<double, double>(elapsedTime, hitPixels));
240 signal[sampleBin] += hitPixels;
251 pulse = pulses.begin();
252 while (pulse != pulses.end()) {
253 timeDiff = elapsedTime - pulse->first;
254 pulseBit = sipmPulseShape(timeDiff) * pulse->second;
255 LogDebug(
"HcalSiPMHitResponse") <<
" pulse t: " << pulse->first <<
" pulse A: " << pulse->second
256 <<
" timeDiff: " << timeDiff <<
" pulseBit: " << pulseBit;
257 signal[sampleBin] += pulseBit;
260 if (timeDiff > 1 && sipmPulseShape(timeDiff) < 1
e-7)
261 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)
std::map< int, HcalSiPMShape > shapeMap
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
void setPreciseSize(unsigned int size)