CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Attributes
HcalSiPMHitResponse Class Reference

#include <HcalSiPMHitResponse.h>

Inheritance diagram for HcalSiPMHitResponse:
CaloHitResponse

Public Types

typedef std::vector< unsigned int > photonTimeHist
 
typedef std::map< DetId,
photonTimeHist
photonTimeMap
 
- Public Types inherited from CaloHitResponse
enum  { BUNCHSPACE =25 }
 
typedef std::map< DetId,
CaloSamples
AnalogSignalMap
 

Public Member Functions

virtual void add (const PCaloHit &hit, CLHEP::HepRandomEngine *) override
 process a single SimHit More...
 
virtual void add (const CaloSamples &signal)
 
virtual void addPEnoise (CLHEP::HepRandomEngine *engine)
 
virtual void finalizeHits (CLHEP::HepRandomEngine *) override
 Finalize hits. More...
 
 HcalSiPMHitResponse (const CaloVSimParameterMap *parameterMap, const CaloShapes *shapes, bool PreMix1=false)
 
virtual void initializeHits () override
 Initialize hits. More...
 
virtual CaloSamples makeBlankSignal (const DetId &detId) const
 
virtual void setDetIds (const std::vector< DetId > &detIds)
 
virtual ~HcalSiPMHitResponse ()
 
- Public Member Functions inherited from CaloHitResponse
void add (const CaloSamples &signal)
 add a signal, in units of pe More...
 
void addHit (const PCaloHit *hit, CaloSamples &frame) const
 adds the amplitude for a single hit to the frame More...
 
double analogSignalAmplitude (const DetId &id, float energy, const CaloSimParameters &parameters, CLHEP::HepRandomEngine *) const
 
 CaloHitResponse (const CaloVSimParameterMap *parameterMap, const CaloVShape *shape)
 
 CaloHitResponse (const CaloVSimParameterMap *parameterMap, const CaloShapes *shapes)
 
void clear ()
 frees up memory More...
 
CaloSamplesfindSignal (const DetId &detId)
 users can look for the signal for a given cell More...
 
virtual bool keepBlank () const
 
virtual CaloSamples makeAnalogSignal (const PCaloHit &inputHit, CLHEP::HepRandomEngine *) const
 creates the signal corresponding to this hit More...
 
CaloSamples makeBlankSignal (const DetId &detId) const
 creates an empty signal for this DetId More...
 
int nSignals () const
 number of signals in the current cache More...
 
virtual void run (MixCollection< PCaloHit > &hits, CLHEP::HepRandomEngine *)
 Complete cell digitization. More...
 
void setBunchRange (int minBunch, int maxBunch)
 tells it which pileup bunches to do More...
 
void setGeometry (const CaloGeometry *geometry)
 geometry needed for time-of-flight More...
 
void setHitCorrection (const CaloVHitCorrection *hitCorrection)
 If you want to correct hits, for attenuation or delay, set this. More...
 
void setHitFilter (const CaloVHitFilter *filter)
 if you want to reject hits, for example, from a certain subdetector, set this More...
 
void setIgnoreGeantTime (bool gt)
 
void setPECorrection (const CaloVPECorrection *peCorrection)
 if you want to correct the photoelectrons More...
 
void setPhaseShift (const double &thePhaseShift)
 setting the phase shift for asynchronous trigger (e.g. test beams) More...
 
void setStorePrecise (bool sp)
 
double timeOfFlight (const DetId &detId) const
 
bool withinBunchRange (int bunchCrossing) const
 check if crossing is within bunch range: More...
 
virtual ~CaloHitResponse ()
 doesn't delete the pointers passed in More...
 

Protected Member Functions

virtual CaloSamples makeSiPMSignal (DetId const &id, photonTimeHist const &photons, CLHEP::HepRandomEngine *)
 

Private Attributes

double dt
 
double invdt
 
int nbins
 
photonTimeMap precisionTimedPhotons
 
bool PreMixDigis
 
const std::vector< DetId > * theDetIds
 
HcalSiPM theSiPM
 

Additional Inherited Members

- Protected Attributes inherited from CaloHitResponse
bool ignoreTime
 
bool storePrecise
 
AnalogSignalMap theAnalogSignalMap
 
const CaloGeometrytheGeometry
 
const CaloVHitCorrectiontheHitCorrection
 
const CaloVHitFiltertheHitFilter
 
int theMaxBunch
 
int theMinBunch
 
const CaloVSimParameterMaptheParameterMap
 
const CaloVPECorrectionthePECorrection
 
double thePhaseShift_
 
const CaloVShapetheShape
 
const CaloShapestheShapes
 

Detailed Description

Definition at line 24 of file HcalSiPMHitResponse.h.

Member Typedef Documentation

typedef std::vector<unsigned int> HcalSiPMHitResponse::photonTimeHist

Definition at line 32 of file HcalSiPMHitResponse.h.

Definition at line 33 of file HcalSiPMHitResponse.h.

Constructor & Destructor Documentation

HcalSiPMHitResponse::HcalSiPMHitResponse ( const CaloVSimParameterMap parameterMap,
const CaloShapes shapes,
bool  PreMix1 = false 
)

Definition at line 20 of file HcalSiPMHitResponse.cc.

21  :
22  CaloHitResponse(parameterMap, shapes), theSiPM(), PreMixDigis(PreMix1),
CaloHitResponse(const CaloVSimParameterMap *parameterMap, const CaloVShape *shape)
static constexpr float invDeltaTSiPM_
static constexpr float deltaTSiPM_
HcalSiPMHitResponse::~HcalSiPMHitResponse ( )
virtual

Definition at line 25 of file HcalSiPMHitResponse.cc.

25 {}

Member Function Documentation

void HcalSiPMHitResponse::add ( const PCaloHit hit,
CLHEP::HepRandomEngine *  engine 
)
overridevirtual

process a single SimHit

Reimplemented from CaloHitResponse.

Definition at line 68 of file HcalSiPMHitResponse.cc.

References CaloVHitFilter::accepts(), CaloHitResponse::analogSignalAmplitude(), CaloHitResponse::BUNCHSPACE, dt, PCaloHit::energy(), HcalPulseShapes::generatePhotonTime(), PCaloHit::id(), CaloHitResponse::ignoreTime, invdt, edm::isNotFinite(), LogDebug, nbins, interactiveExample::photons, precisionTimedPhotons, CaloVSimParameterMap::simParameters(), findQualityFiles::size, CaloHitResponse::theHitFilter, CaloHitResponse::theParameterMap, CaloHitResponse::thePhaseShift_, PCaloHit::time(), CaloHitResponse::timeOfFlight(), and tzero.

Referenced by finalizeHits(), and counter.Counter::register().

68  {
69  if (!edm::isNotFinite(hit.time()) &&
70  ((theHitFilter == 0) || (theHitFilter->accepts(hit)))) {
71  HcalDetId id(hit.id());
72  const HcalSimParameters& pars = dynamic_cast<const HcalSimParameters&>(theParameterMap->simParameters(id));
73  //divide out mean of crosstalk distribution 1/(1-lambda) = multiply by (1-lambda)
74  double signal(analogSignalAmplitude(id, hit.energy(), pars, engine)*(1-pars.sipmCrossTalk(id)));
75  unsigned int photons(signal + 0.5);
76  double tof( timeOfFlight(id) );
77  double time( hit.time() );
78  if(ignoreTime) time = tof;
79 
80  if (photons > 0)
81  if (precisionTimedPhotons.find(id)==precisionTimedPhotons.end()) {
82  precisionTimedPhotons.insert(
83  std::pair<DetId, photonTimeHist >(id,
84  photonTimeHist(nbins * pars.readoutFrameSize(), 0)
85  )
86  );
87  }
88 
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);
94  LogDebug("HcalSiPMHitResponse") << " energy: " << hit.energy()
95  << " photons: " << photons
96  << " time: " << time;
97  LogDebug("HcalSiPMHitResponse") << " timePhase: " << pars.timePhase()
98  << " tof: " << tof
99  << " binOfMaximum: " << pars.binOfMaximum()
100  << " phaseShift: " << thePhaseShift_;
101  double tzero(0.0 + pars.timePhase() -
102  (time - tof) -
103  BUNCHSPACE*( pars.binOfMaximum() - thePhaseShift_));
104  LogDebug("HcalSiPMHitResponse") << " tzero: " << tzero;
105  double tzero_bin(-tzero*invdt);
106  LogDebug("HcalSiPMHitResponse") << " corrected tzero: " << tzero_bin << '\n';
107  double t_pe(0.);
108  int t_bin(0);
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';
114  if ((t_bin >= 0) &&
115  (static_cast<unsigned int>(t_bin) < precisionTimedPhotons[id].size()))
116  precisionTimedPhotons[id][t_bin] += 1;
117  }
118  }
119 }
#define LogDebug(id)
double time() const
Definition: PCaloHit.h:36
double energy() const
Definition: PCaloHit.h:29
bool isNotFinite(T x)
Definition: isFinite.h:10
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
virtual bool accepts(const PCaloHit &hit) const =0
unsigned int id() const
Definition: PCaloHit.h:43
double timeOfFlight(const DetId &detId) const
static double generatePhotonTime(CLHEP::HepRandomEngine *engine)
double analogSignalAmplitude(const DetId &id, float energy, const CaloSimParameters &parameters, CLHEP::HepRandomEngine *) const
std::vector< unsigned int > photonTimeHist
const CaloVSimParameterMap * theParameterMap
static const double tzero[3]
const CaloVHitFilter * theHitFilter
photonTimeMap precisionTimedPhotons
tuple size
Write out results.
void HcalSiPMHitResponse::add ( const CaloSamples signal)
virtual

Definition at line 58 of file HcalSiPMHitResponse.cc.

References CaloHitResponse::findSignal(), CaloSamples::id(), and CaloHitResponse::theAnalogSignalMap.

Referenced by counter.Counter::register().

58  {
59  DetId id(signal.id());
60  CaloSamples * oldSignal = findSignal(id);
61  if (oldSignal == 0) {
62  theAnalogSignalMap[id] = signal;
63  } else {
64  (*oldSignal) += signal;
65  }
66 }
AnalogSignalMap theAnalogSignalMap
Definition: DetId.h:18
CaloSamples * findSignal(const DetId &detId)
users can look for the signal for a given cell
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
void HcalSiPMHitResponse::addPEnoise ( CLHEP::HepRandomEngine *  engine)
virtual

Definition at line 121 of file HcalSiPMHitResponse.cc.

References dt, LogDebug, nbins, HcalSimParameters::photoelectronsToAnalog(), interactiveExample::photons, precisionTimedPhotons, CaloSimParameters::readoutFrameSize(), CaloVSimParameterMap::simParameters(), HcalSimParameters::sipmDarkCurrentuA(), theDetIds, and CaloHitResponse::theParameterMap.

Referenced by finalizeHits().

122 {
123  // Add SiPM dark current noise to all cells
124  for(std::vector<DetId>::const_iterator idItr = theDetIds->begin();
125  idItr != theDetIds->end(); ++idItr) {
126  HcalDetId id(*idItr);
127  const HcalSimParameters& pars =
128  static_cast<const HcalSimParameters&>(theParameterMap->simParameters(id));
129 
130  // uA * ns / (fC/pe) = pe!
131  double dc_pe_avg =
132  pars.sipmDarkCurrentuA(id) * dt /
133  pars.photoelectronsToAnalog(id);
134 
135  if (dc_pe_avg <= 0.) continue;
136 
137  int nPreciseBins = nbins * pars.readoutFrameSize();
138 
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); // add dark current noise
143 
144  if (noisepe > 0) {
145  if (precisionTimedPhotons.find(id)==precisionTimedPhotons.end()) {
146  photonTimeHist photons(nPreciseBins, 0);
147  photons[tprecise] = noisepe;
148  precisionTimedPhotons.insert
149  (std::pair<DetId, photonTimeHist >(id, photons ) );
150  } else {
151  precisionTimedPhotons[id][tprecise] += noisepe;
152  }
153 
154  sumnoisePE += noisepe;
155  }
156  elapsedTime += dt;
157 
158  } // precise time loop
159 
160  LogDebug("HcalSiPMHitResponse") << id;
161  LogDebug("HcalSiPMHitResponse") << " total noise (PEs): " << sumnoisePE;
162 
163  } // detId loop
164 } // HcalSiPMHitResponse::addPEnoise()
#define LogDebug(id)
const std::vector< DetId > * theDetIds
virtual double photoelectronsToAnalog(const DetId &detId) const
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
int readoutFrameSize() const
for now, the LinearFrames and trhe digis will be one-to-one.
std::vector< unsigned int > photonTimeHist
double sipmDarkCurrentuA(const DetId &detId) const
const CaloVSimParameterMap * theParameterMap
photonTimeMap precisionTimedPhotons
void HcalSiPMHitResponse::finalizeHits ( CLHEP::HepRandomEngine *  )
overridevirtual

Finalize hits.

Reimplemented from CaloHitResponse.

Definition at line 31 of file HcalSiPMHitResponse.cc.

References add(), addPEnoise(), i, CaloSamples::id(), keep, CaloHitResponse::keepBlank(), LogDebug, makeSiPMSignal(), precisionTimedPhotons, PreMixDigis, CaloSamples::size(), and findQualityFiles::size.

31  {
32  //do not add PE noise for initial premix
33  if(!PreMixDigis) addPEnoise(engine);
34 
35  photonTimeMap::iterator channelPhotons;
36  for (channelPhotons = precisionTimedPhotons.begin();
37  channelPhotons != precisionTimedPhotons.end();
38  ++channelPhotons) {
39  CaloSamples signal(makeSiPMSignal(channelPhotons->first,
40  channelPhotons->second,
41  engine));
42  bool keep( keepBlank() );
43  if (!keep) {
44  const unsigned int size ( signal.size() ) ;
45  if( 0 != size ) {
46  for( unsigned int i ( 0 ) ; i != size ; ++i ) {
47  keep = keep || signal[i] > 1.e-7 ;
48  }
49  }
50  }
51 
52  LogDebug("HcalSiPMHitResponse") << HcalDetId(signal.id()) << ' ' << signal;
53 
54  if (keep) add(signal);
55  }
56 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
virtual bool keepBlank() const
virtual void addPEnoise(CLHEP::HepRandomEngine *engine)
const int keep
virtual void add(const PCaloHit &hit, CLHEP::HepRandomEngine *) override
process a single SimHit
virtual CaloSamples makeSiPMSignal(DetId const &id, photonTimeHist const &photons, CLHEP::HepRandomEngine *)
photonTimeMap precisionTimedPhotons
tuple size
Write out results.
void HcalSiPMHitResponse::initializeHits ( )
overridevirtual

Initialize hits.

Reimplemented from CaloHitResponse.

Definition at line 27 of file HcalSiPMHitResponse.cc.

References precisionTimedPhotons.

27  {
28  precisionTimedPhotons.clear();
29 }
photonTimeMap precisionTimedPhotons
CaloSamples HcalSiPMHitResponse::makeBlankSignal ( const DetId detId) const
virtual

Definition at line 166 of file HcalSiPMHitResponse.cc.

References CaloSimParameters::binOfMaximum(), dt, nbins, HLT_FULL_cff::parameters, CaloSimParameters::readoutFrameSize(), mps_fire::result, CaloVSimParameterMap::simParameters(), and CaloHitResponse::theParameterMap.

Referenced by makeSiPMSignal().

166  {
168  int preciseSize(parameters.readoutFrameSize() * nbins);
169  CaloSamples result(detId, parameters.readoutFrameSize(), preciseSize);
170  result.setPresamples(parameters.binOfMaximum()-1);
171  result.setPrecise(result.presamples() * nbins, dt);
172  return result;
173 }
Main class for Parameters in different subdetectors.
tuple result
Definition: mps_fire.py:84
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
int readoutFrameSize() const
for now, the LinearFrames and trhe digis will be one-to-one.
const CaloVSimParameterMap * theParameterMap
int binOfMaximum() const
CaloSamples HcalSiPMHitResponse::makeSiPMSignal ( DetId const &  id,
photonTimeHist const &  photons,
CLHEP::HepRandomEngine *  engine 
)
protectedvirtual

Definition at line 175 of file HcalSiPMHitResponse.cc.

References HcalSimParameters::doSiPMSmearing(), dt, alignCSCRings::e, HcalSiPM::hitCells(), invdt, LogDebug, makeBlankSignal(), nbins, HcalSimParameters::pixels(), CaloSamples::preciseAtMod(), CaloSamples::preciseSize(), CaloSamples::resetPrecise(), HcalSiPM::setCrossTalk(), HcalSiPM::setNCells(), HcalSiPM::setSaturationPars(), HcalSiPM::setTau(), HcalSimParameters::signalShape(), CaloVSimParameterMap::simParameters(), HcalSimParameters::sipmCrossTalk(), HcalSimParameters::sipmNonlinearity(), HcalSimParameters::sipmTau(), CaloHitResponse::theParameterMap, and theSiPM.

Referenced by finalizeHits().

177  {
178  const HcalSimParameters& pars = static_cast<const HcalSimParameters&>(theParameterMap->simParameters(id));
179  theSiPM.setNCells(pars.pixels(id));
180  theSiPM.setTau(pars.sipmTau());
183 
184  //use to make signal
185  CaloSamples signal( makeBlankSignal(id) );
186  int sampleBin(0), preciseBin(0);
187  signal.resetPrecise();
188  unsigned int pe(0);
189  double hitPixels(0.), elapsedTime(0.);
190  unsigned int sumPE(0);
191  double sumHits(0.);
192 
193  HcalSiPMShape sipmPulseShape(pars.signalShape(id));
194 
195  std::list< std::pair<double, double> > pulses;
196  std::list< std::pair<double, double> >::iterator pulse;
197  double timeDiff, pulseBit;
198  LogDebug("HcalSiPMHitResponse") << "makeSiPMSignal for " << HcalDetId(id);
199 
200  for (unsigned int tbin(0); tbin < photonTimeBins.size(); ++tbin) {
201  pe = photonTimeBins[tbin];
202  sumPE += pe;
203  preciseBin = tbin;
204  sampleBin = preciseBin/nbins;
205  if (pe > 0) {
206  hitPixels = theSiPM.hitCells(engine, pe, 0., elapsedTime);
207  sumHits += hitPixels;
208  LogDebug("HcalSiPMHitResponse") << " elapsedTime: " << elapsedTime
209  << " sampleBin: " << sampleBin
210  << " preciseBin: " << preciseBin
211  << " pe: " << pe
212  << " hitPixels: " << hitPixels ;
213  if (pars.doSiPMSmearing()) {
214  pulses.push_back( std::pair<double, double>(elapsedTime, hitPixels) );
215  } else {
216  signal[sampleBin] += hitPixels;
217  hitPixels *= invdt;
218  signal.preciseAtMod(preciseBin) += 0.6*hitPixels;
219  if (preciseBin > 0)
220  signal.preciseAtMod(preciseBin-1) += 0.2*hitPixels;
221  if (preciseBin < signal.preciseSize() -1)
222  signal.preciseAtMod(preciseBin+1) += 0.2*hitPixels;
223  }
224  }
225 
226  if (pars.doSiPMSmearing()) {
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;
236  signal.preciseAtMod(preciseBin) += pulseBit*invdt;
237 
238  if (timeDiff > 1 && sipmPulseShape(timeDiff) < 1e-7)
239  pulse = pulses.erase(pulse);
240  else
241  ++pulse;
242  }
243  }
244  elapsedTime += dt;
245  }
246 
247  return signal;
248 }
#define LogDebug(id)
std::vector< float > sipmNonlinearity(const DetId &detId) const
double sipmTau() const
void setSaturationPars(const std::vector< float > &pars)
Definition: HcalSiPM.cc:189
int pixels(const DetId &detId) const
virtual double hitCells(CLHEP::HepRandomEngine *, unsigned int pes, double tempDiff=0., double photonTime=0.)
Definition: HcalSiPM.cc:100
unsigned int signalShape(const DetId &detId) const
void setNCells(int nCells)
Definition: HcalSiPM.cc:144
void setTau(double tau)
Definition: HcalSiPM.cc:151
bool doSiPMSmearing() const
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
void setCrossTalk(double xtalk)
Definition: HcalSiPM.cc:157
virtual CaloSamples makeBlankSignal(const DetId &detId) const
const CaloVSimParameterMap * theParameterMap
double sipmCrossTalk(const DetId &detId) const
void HcalSiPMHitResponse::setDetIds ( const std::vector< DetId > &  detIds)
virtual

Definition at line 250 of file HcalSiPMHitResponse.cc.

References theDetIds.

250  {
251  theDetIds = &detIds;
252 }
const std::vector< DetId > * theDetIds

Member Data Documentation

double HcalSiPMHitResponse::dt
private

Definition at line 56 of file HcalSiPMHitResponse.h.

Referenced by add(), addPEnoise(), makeBlankSignal(), and makeSiPMSignal().

double HcalSiPMHitResponse::invdt
private

Definition at line 56 of file HcalSiPMHitResponse.h.

Referenced by add(), and makeSiPMSignal().

int HcalSiPMHitResponse::nbins
private

Definition at line 55 of file HcalSiPMHitResponse.h.

Referenced by add(), addPEnoise(), makeBlankSignal(), and makeSiPMSignal().

photonTimeMap HcalSiPMHitResponse::precisionTimedPhotons
private

Definition at line 58 of file HcalSiPMHitResponse.h.

Referenced by add(), addPEnoise(), finalizeHits(), and initializeHits().

bool HcalSiPMHitResponse::PreMixDigis
private

Definition at line 54 of file HcalSiPMHitResponse.h.

Referenced by finalizeHits().

const std::vector<DetId>* HcalSiPMHitResponse::theDetIds
private

Definition at line 60 of file HcalSiPMHitResponse.h.

Referenced by addPEnoise(), and setDetIds().

HcalSiPM HcalSiPMHitResponse::theSiPM
private

Definition at line 53 of file HcalSiPMHitResponse.h.

Referenced by makeSiPMSignal().