15 #include "CLHEP/Random/RandFlat.h"
22 CaloHitResponse(parameterMap, shapes), theSiPM(), theRecoveryTime(250.),
23 TIMEMULT(1), Y11RANGE(80.), Y11MAX(0.04), Y11TIMETORISE(16.65) {
38 photonTimeMap::iterator channelPhotons;
43 channelPhotons->second,
47 const unsigned int size ( signal.
size() ) ;
49 for(
unsigned int i ( 0 ) ;
i !=
size ; ++
i ) {
50 keep = keep || signal[
i] > 1.e-7 ;
57 if (keep)
add(signal);
67 (*oldSignal) += signal;
77 unsigned int photons(signal + 0.5);
83 std::pair<DetId, photonTimeHist >(
id,
85 pars.readoutFrameSize(), 0)
90 LogDebug(
"HcalSiPMHitResponse") << id;
91 LogDebug(
"HcalSiPMHitResponse") <<
" fCtoGeV: " << pars.fCtoGeV(
id)
92 <<
" samplingFactor: " << pars.samplingFactor(
id)
93 <<
" photoelectronsToAnalog: " << pars.photoelectronsToAnalog(
id)
94 <<
" simHitToPhotoelectrons: " << pars.simHitToPhotoelectrons(
id);
96 <<
" photons: " << photons
100 LogDebug(
"HcalSiPMHitResponse") <<
" corrected time: " <<
time;
101 LogDebug(
"HcalSiPMHitResponse") <<
" timePhase: " << pars.timePhase()
103 <<
" binOfMaximum: " << pars.binOfMaximum()
111 tzero +=
BUNCHSPACE*pars.binOfMaximum() + 50.;
112 LogDebug(
"HcalSiPMHitResponse") <<
" corrected tzero: " << tzero <<
'\n';
115 for (
unsigned int pe(0); pe<
photons; ++pe) {
118 LogDebug(
"HcalSiPMHitResponse") <<
"t_pe: " << t_pe <<
" t_pe + tzero: " << (t_pe+
tzero)
119 <<
" t_bin: " << t_bin <<
'\n';
128 typedef std::multiset <const PCaloHit *, PCaloHitCompareTimes>
SortedHitSet;
130 std::map< DetId, SortedHitSet > sortedhits;
132 hitItr != hits.
end(); ++hitItr) {
136 DetId id(hitItr->id());
137 if (sortedhits.find(
id)==sortedhits.end())
138 sortedhits.insert(std::pair<DetId, SortedHitSet>(
id, SortedHitSet()));
139 sortedhits[id].insert(&(*hitItr));
142 int pixelIntegral, oldIntegral;
144 for (std::map<DetId, SortedHitSet>::iterator
i = sortedhits.begin();
145 i!=sortedhits.end(); ++
i) {
147 for (SortedHitSet::iterator itr =
i->second.begin();
148 itr !=
i->second.end(); ++itr) {
151 oldIntegral = pixelIntegral;
172 CLHEP::HepRandomEngine* engine)
const {
183 int photons =
static_cast<int>(signal + 0.5);
186 signal = double(pixels);
197 double binTime =
tzero;
200 result[
bin] += (*shape)(binTime)*signal;
210 CLHEP::HepRandomEngine* engine)
const {
218 int sampleBin(0), preciseBin(0);
221 double hitPixels(0.), elapsedTime(0.);
222 unsigned int sumPE(0);
227 std::list< std::pair<double, double> > pulses;
228 std::list< std::pair<double, double> >::iterator pulse;
229 double timeDiff, pulseBit;
231 for (
unsigned int pt(0);
pt < photons.size(); ++
pt) {
238 sumHits += hitPixels;
246 pulses.push_back( std::pair<double, double>(elapsedTime, hitPixels) );
248 signal[sampleBin] += hitPixels;
259 pulse = pulses.begin();
260 while (pulse != pulses.end()) {
261 timeDiff = elapsedTime - pulse->first;
262 pulseBit = sipmPulseShape(timeDiff)*pulse->second;
268 signal[sampleBin] += pulseBit;
270 if (sipmPulseShape(timeDiff) < 1
e-6)
271 pulse = pulses.erase(pulse);
289 double diffNorm)
const {
301 result = CLHEP::RandFlat::shoot(engine,
Y11RANGE);
308 return exp(-0.0635-0.1518*t)*
pow(t, 2.528)/2485.9;
virtual void initializeHits()
Initialize hits.
A general implementation for the response of a SiPM.
virtual void finalizeHits(CLHEP::HepRandomEngine *) override
Finalize hits.
virtual CaloSamples makeSiPMSignal(const DetId &id, const PCaloHit &hit, int &integral, CLHEP::HepRandomEngine *) const
double generatePhotonTime(CLHEP::HepRandomEngine *) const
virtual bool keepBlank() const
Electronic response of the preamp.
std::multiset< PCaloHit, PCaloHitCompareTimes > SortedHitSet
static double Y11TimePDF(double t)
int preciseSize() const
get the size
Main class for Parameters in different subdetectors.
double timePhase() const
the adjustment you need to apply to get the signal where you want it
int getIntegral(double time)
Creates electronics signals from hits.
virtual void differentiatePreciseSamples(CaloSamples &samples, double diffNorm=1.0) 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
virtual bool accepts(const PCaloHit &hit) const =0
double timeOfFlight(const DetId &detId) const
float preciseDeltaT() const
int readoutFrameSize() const
for now, the LinearFrames and trhe digis will be one-to-one.
const CaloVHitCorrection * theHitCorrection
Integral< F, X >::type integral(const F &f)
virtual double delay(const PCaloHit &hit, CLHEP::HepRandomEngine *) const =0
HcalTDCParameters theTDCParams
AnalogSignalMap theAnalogSignalMap
double analogSignalAmplitude(const DetId &id, float energy, const CaloSimParameters ¶meters, CLHEP::HepRandomEngine *) const
std::vector< unsigned int > photonTimeHist
virtual void run(MixCollection< PCaloHit > &hits, CLHEP::HepRandomEngine *) override
Complete cell digitization.
virtual CaloSamples makeBlankSignal(const DetId &detId) const
float const Y11TIMETORISE
const CaloShapes * theShapes
const CaloVSimParameterMap * theParameterMap
int size() const
get the size
HcalSiPMHitResponse(const CaloVSimParameterMap *parameterMap, const CaloShapes *shapes)
virtual int hitCells(CLHEP::HepRandomEngine *, unsigned int photons, unsigned int integral=0) const
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
static const double tzero[3]
const CaloVHitFilter * theHitFilter
DetId id() const
get the (generic) id
photonTimeMap precisionTimedPhotons
void addToHistory(double time, int pixels)
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
virtual const CaloVShape * shape(const DetId &detId) const
virtual ~HcalSiPMHitResponse()