15 #include "CLHEP/Random/RandPoissonQ.h"
35 photonTimeMap::iterator channelPhotons;
40 channelPhotons->second,
44 const unsigned int size ( signal.
size() ) ;
46 for(
unsigned int i ( 0 ) ;
i !=
size ; ++
i ) {
47 keep = keep || signal[
i] > 1.e-7 ;
54 if (keep)
add(signal);
64 (*oldSignal) += signal;
75 unsigned int photons(signal + 0.5);
77 double time( hit.
time() );
83 std::pair<DetId, photonTimeHist >(
id,
89 LogDebug(
"HcalSiPMHitResponse") << id;
90 LogDebug(
"HcalSiPMHitResponse") <<
" fCtoGeV: " << pars.fCtoGeV(
id)
91 <<
" samplingFactor: " << pars.samplingFactor(
id)
92 <<
" photoelectronsToAnalog: " << pars.photoelectronsToAnalog(
id)
93 <<
" simHitToPhotoelectrons: " << pars.simHitToPhotoelectrons(
id);
95 <<
" photons: " << photons
97 LogDebug(
"HcalSiPMHitResponse") <<
" timePhase: " << pars.timePhase()
99 <<
" binOfMaximum: " << pars.binOfMaximum()
101 double tzero(0.0 + pars.timePhase() -
105 double tzero_bin(-tzero*
invdt);
106 LogDebug(
"HcalSiPMHitResponse") <<
" corrected tzero: " << tzero_bin <<
'\n';
109 for (
unsigned int pe(0); pe<
photons; ++pe) {
111 t_bin = int(t_pe*invdt + tzero_bin + 0.5);
112 LogDebug(
"HcalSiPMHitResponse") <<
"t_pe: " << t_pe <<
" t_pe + tzero: " << (t_pe+tzero_bin*
dt)
113 <<
" t_bin: " << t_bin <<
'\n';
124 for(std::vector<DetId>::const_iterator idItr =
theDetIds->begin();
135 if (dc_pe_avg <= 0.)
continue;
139 unsigned int sumnoisePE(0);
140 double elapsedTime(0.);
141 for (
int tprecise(0); tprecise < nPreciseBins; ++tprecise) {
142 int noisepe = CLHEP::RandPoissonQ::shoot(engine, dc_pe_avg);
147 photons[tprecise] = noisepe;
149 (std::pair<DetId, photonTimeHist >(
id, photons ) );
154 sumnoisePE += noisepe;
160 LogDebug(
"HcalSiPMHitResponse") << id;
161 LogDebug(
"HcalSiPMHitResponse") <<
" total noise (PEs): " << sumnoisePE;
177 CLHEP::HepRandomEngine* engine) {
186 int sampleBin(0), preciseBin(0);
189 double hitPixels(0.), elapsedTime(0.);
190 unsigned int sumPE(0);
195 std::list< std::pair<double, double> > pulses;
196 std::list< std::pair<double, double> >::iterator pulse;
197 double timeDiff, pulseBit;
200 for (
unsigned int tbin(0); tbin < photonTimeBins.size(); ++tbin) {
201 pe = photonTimeBins[tbin];
204 sampleBin = preciseBin/
nbins;
207 sumHits += hitPixels;
208 LogDebug(
"HcalSiPMHitResponse") <<
" elapsedTime: " << elapsedTime
209 <<
" sampleBin: " << sampleBin
210 <<
" preciseBin: " << preciseBin
212 <<
" hitPixels: " << hitPixels ;
214 pulses.push_back( std::pair<double, double>(elapsedTime, hitPixels) );
216 signal[sampleBin] += hitPixels;
227 pulse = pulses.begin();
228 while (pulse != pulses.end()) {
229 timeDiff = elapsedTime - pulse->first;
230 pulseBit = sipmPulseShape(timeDiff)*pulse->second;
231 LogDebug(
"HcalSiPMHitResponse") <<
" pulse t: " << pulse->first
232 <<
" pulse A: " << pulse->second
233 <<
" timeDiff: " << timeDiff
234 <<
" pulseBit: " << pulseBit;
235 signal[sampleBin] += pulseBit;
238 if (timeDiff > 1 && sipmPulseShape(timeDiff) < 1
e-7)
239 pulse = pulses.erase(pulse);
std::vector< float > sipmNonlinearity(const DetId &detId) const
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
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)
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
static double generatePhotonTime(CLHEP::HepRandomEngine *engine)
int readoutFrameSize() const
for now, the LinearFrames and trhe digis will be one-to-one.
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
double sipmDarkCurrentuA(const DetId &detId) const
const CaloVSimParameterMap * theParameterMap
int size() const
get the size
virtual void initializeHits() override
Initialize hits.
virtual CaloSamples makeSiPMSignal(DetId const &id, photonTimeHist const &photons, CLHEP::HepRandomEngine *)
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.
virtual ~HcalSiPMHitResponse()
HcalSiPMHitResponse(const CaloVSimParameterMap *parameterMap, const CaloShapes *shapes, bool PreMix1=false)