14 #include "CLHEP/Random/RandPoissonQ.h" 20 const CaloShapes * shapes,
bool PreMix1,
bool HighFidelity) :
21 CaloHitResponse(parameterMap, shapes), theSiPM(), PreMixDigis(PreMix1), HighFidelityPreMix(HighFidelity),
51 photonTimeMap::iterator channelPhotons;
56 channelPhotons->second,
60 const unsigned int size ( signal.
size() ) ;
62 for(
unsigned int i ( 0 ) ;
i !=
size ; ++
i ) {
63 keep = keep || signal[
i] > 1.e-7 ;
82 assert(photonTimeHistSize == signal.
size());
85 std::pair<DetId, photonTimeHist >(
id,
photonTimeHist(photonTimeHistSize, 0)
89 for(
int i = 0;
i < signal.
size(); ++
i){
90 unsigned int photons(signal[
i] + 0.5);
102 unsigned int photons(signal + 0.5);
110 std::pair<DetId, photonTimeHist >(
id,
117 LogDebug(
"HcalSiPMHitResponse") <<
" fCtoGeV: " << pars.fCtoGeV(
id)
118 <<
" samplingFactor: " << pars.samplingFactor(
id)
119 <<
" photoelectronsToAnalog: " << pars.photoelectronsToAnalog(
id)
120 <<
" simHitToPhotoelectrons: " << pars.simHitToPhotoelectrons(
id);
122 <<
" photons: " << photons
123 <<
" time: " <<
time;
124 LogDebug(
"HcalSiPMHitResponse") <<
" timePhase: " << pars.timePhase()
126 <<
" binOfMaximum: " << pars.binOfMaximum()
128 double tzero(0.0 + pars.timePhase() -
132 double tzero_bin(-tzero*
invdt);
133 LogDebug(
"HcalSiPMHitResponse") <<
" corrected tzero: " << tzero_bin <<
'\n';
136 for (
unsigned int pe(0); pe<
photons; ++pe) {
138 t_bin =
int(t_pe*invdt + tzero_bin + 0.5);
139 LogDebug(
"HcalSiPMHitResponse") <<
"t_pe: " << t_pe <<
" t_pe + tzero: " << (t_pe+tzero_bin*
dt)
140 <<
" t_bin: " << t_bin <<
'\n';
151 for(std::vector<DetId>::const_iterator idItr =
theDetIds->begin();
162 if (dc_pe_avg <= 0.)
continue;
166 unsigned int sumnoisePE(0);
167 double elapsedTime(0.);
168 for (
int tprecise(0); tprecise < nPreciseBins; ++tprecise) {
169 int noisepe = CLHEP::RandPoissonQ::shoot(engine, dc_pe_avg);
174 photons[tprecise] = noisepe;
176 (std::pair<DetId, photonTimeHist >(
id, photons ) );
181 sumnoisePE += noisepe;
188 LogDebug(
"HcalSiPMHitResponse") <<
" total noise (PEs): " << sumnoisePE;
196 int preciseSize(readoutFrameSize *
nbins);
205 CLHEP::HepRandomEngine* engine) {
214 int sampleBin(0), preciseBin(0);
217 double hitPixels(0.), elapsedTime(0.);
218 unsigned int sumPE(0);
223 std::list< std::pair<double, double> > pulses;
224 std::list< std::pair<double, double> >::iterator pulse;
225 double timeDiff, pulseBit;
228 for (
unsigned int tbin(0); tbin < photonTimeBins.size(); ++tbin) {
229 pe = photonTimeBins[tbin];
232 sampleBin = preciseBin/
nbins;
236 signal[sampleBin] += pe;
243 sumHits += hitPixels;
244 LogDebug(
"HcalSiPMHitResponse") <<
" elapsedTime: " << elapsedTime
245 <<
" sampleBin: " << sampleBin
246 <<
" preciseBin: " << preciseBin
248 <<
" hitPixels: " << hitPixels ;
250 pulses.push_back( std::pair<double, double>(elapsedTime, hitPixels) );
252 signal[sampleBin] += hitPixels;
263 pulse = pulses.begin();
264 while (pulse != pulses.end()) {
265 timeDiff = elapsedTime - pulse->first;
266 pulseBit = sipmPulseShape(timeDiff)*pulse->second;
267 LogDebug(
"HcalSiPMHitResponse") <<
" pulse t: " << pulse->first
268 <<
" pulse A: " << pulse->second
269 <<
" timeDiff: " << timeDiff
270 <<
" pulseBit: " << pulseBit;
271 signal[sampleBin] += pulseBit;
274 if (timeDiff > 1 && sipmPulseShape(timeDiff) < 1
e-7)
275 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
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
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)
double timeOfFlight(const DetId &detId) const
void setPresamples(int pre)
set presample information
static double generatePhotonTime(CLHEP::HepRandomEngine *engine)
int readoutFrameSize() const
for now, the LinearFrames and trhe digis will be one-to-one.
virtual int getReadoutFrameSize(const DetId &id) const
static constexpr float invDeltaTSiPM_
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 *)
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
virtual ~HcalSiPMHitResponse()