CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
CaloHitResponse Class Reference

Creates electronics signals from hits. More...

#include <CaloHitResponse.h>

Inheritance diagram for CaloHitResponse:
HcalSiPMHitResponse

Public Types

enum  { BUNCHSPACE = 25 }
 
typedef std::map< DetId, CaloSamplesAnalogSignalMap
 

Public Member Functions

virtual void add (const PCaloHit &hit, CLHEP::HepRandomEngine *)
 process a single SimHit More...
 
virtual 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...
 
virtual void finalizeHits (CLHEP::HepRandomEngine *)
 Finalize hits. More...
 
CaloSamplesfindSignal (const DetId &detId)
 users can look for the signal for a given cell More...
 
virtual void initializeHits ()
 Initialize hits. 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 (const 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)
 
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 Attributes

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

Creates electronics signals from hits.

Definition at line 33 of file CaloHitResponse.h.

Member Typedef Documentation

Definition at line 35 of file CaloHitResponse.h.

Member Enumeration Documentation

anonymous enum
Enumerator
BUNCHSPACE 

Definition at line 37 of file CaloHitResponse.h.

Constructor & Destructor Documentation

CaloHitResponse::CaloHitResponse ( const CaloVSimParameterMap parameterMap,
const CaloVShape shape 
)

Definition at line 21 of file CaloHitResponse.cc.

23  theParameterMap(parametersMap),
24  theShapes(nullptr),
25  theShape(shape),
26  theHitCorrection(nullptr),
27  thePECorrection(nullptr),
28  theHitFilter(nullptr),
29  theGeometry(nullptr),
30  theMinBunch(-10),
31  theMaxBunch(10),
32  thePhaseShift_(1.),
33  storePrecise(false),
34  ignoreTime(false) {}
const CaloGeometry * theGeometry
const CaloVPECorrection * thePECorrection
const CaloVHitCorrection * theHitCorrection
AnalogSignalMap theAnalogSignalMap
const CaloShapes * theShapes
const CaloVSimParameterMap * theParameterMap
const CaloVHitFilter * theHitFilter
const CaloVShape * theShape
CaloHitResponse::CaloHitResponse ( const CaloVSimParameterMap parameterMap,
const CaloShapes shapes 
)

Definition at line 36 of file CaloHitResponse.cc.

38  theParameterMap(parametersMap),
39  theShapes(shapes),
40  theShape(nullptr),
41  theHitCorrection(nullptr),
42  thePECorrection(nullptr),
43  theHitFilter(nullptr),
44  theGeometry(nullptr),
45  theMinBunch(-10),
46  theMaxBunch(10),
47  thePhaseShift_(1.),
48  storePrecise(false),
49  ignoreTime(false) {}
const CaloGeometry * theGeometry
const CaloVPECorrection * thePECorrection
const CaloVHitCorrection * theHitCorrection
AnalogSignalMap theAnalogSignalMap
const CaloShapes * theShapes
const CaloVSimParameterMap * theParameterMap
const CaloVHitFilter * theHitFilter
const CaloVShape * theShape
CaloHitResponse::~CaloHitResponse ( )
virtual

doesn't delete the pointers passed in

Definition at line 51 of file CaloHitResponse.cc.

51 {}

Member Function Documentation

void CaloHitResponse::add ( const PCaloHit hit,
CLHEP::HepRandomEngine *  engine 
)
virtual

process a single SimHit

Reimplemented in HcalSiPMHitResponse.

Definition at line 66 of file CaloHitResponse.cc.

References CaloVHitFilter::accepts(), mps_fire::i, edm::isNotFinite(), keep, keepBlank(), LogDebug, makeAnalogSignal(), CaloSamples::size(), findQualityFiles::size, theHitFilter, and PCaloHit::time().

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

66  {
67  // check the hit time makes sense
68  if (edm::isNotFinite(hit.time())) {
69  return;
70  }
71 
72  // maybe it's not from this subdetector
73  if (theHitFilter == nullptr || theHitFilter->accepts(hit)) {
74  LogDebug("CaloHitResponse") << hit;
75  CaloSamples signal(makeAnalogSignal(hit, engine));
76  bool keep(keepBlank()); // here we check for blank signal if not keeping them
77  if (!keep) {
78  const unsigned int size(signal.size());
79  if (0 != size) {
80  for (unsigned int i(0); i != size; ++i) {
81  keep = keep || signal[i] > 1.e-7;
82  }
83  }
84  }
85 
86  if (keep)
87  add(signal);
88  }
89 }
#define LogDebug(id)
size
Write out results.
double time() const
Definition: PCaloHit.h:30
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
virtual bool keepBlank() const
const int keep
virtual bool accepts(const PCaloHit &hit) const =0
virtual CaloSamples makeAnalogSignal(const PCaloHit &inputHit, CLHEP::HepRandomEngine *) const
creates the signal corresponding to this hit
virtual void add(const PCaloHit &hit, CLHEP::HepRandomEngine *)
process a single SimHit
const CaloVHitFilter * theHitFilter
void CaloHitResponse::add ( const CaloSamples signal)
virtual

add a signal, in units of pe

Reimplemented in HcalSiPMHitResponse.

Definition at line 91 of file CaloHitResponse.cc.

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

Referenced by counter.Counter::register().

91  {
92  DetId id(signal.id());
93  CaloSamples *oldSignal = findSignal(id);
94  if (oldSignal == nullptr) {
95  theAnalogSignalMap[id] = signal;
96 
97  } else {
98  (*oldSignal) += signal;
99  }
100 }
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 CaloHitResponse::addHit ( const PCaloHit hit,
CaloSamples frame 
) const

adds the amplitude for a single hit to the frame

double CaloHitResponse::analogSignalAmplitude ( const DetId id,
float  energy,
const CaloSimParameters parameters,
CLHEP::HepRandomEngine *  engine 
) const

finds the amplitude contribution from this hit, applying photostatistics, if needed. Results are in photoelectrons

Definition at line 147 of file CaloHitResponse.cc.

References CaloVPECorrection::correctPE(), CaloSimParameters::doPhotostatistics(), CaloSimParameters::simHitToPhotoelectrons(), and thePECorrection.

Referenced by HcalSiPMHitResponse::add(), and makeAnalogSignal().

150  {
151  // OK, the "energy" in the hit could be a real energy, deposited energy,
152  // or pe count. This factor converts to photoelectrons
153  // GMA Smeared in photon production it self
154  double npe = energy * parameters.simHitToPhotoelectrons(detId);
155  // do we need to doPoisson statistics for the photoelectrons?
156  if (parameters.doPhotostatistics()) {
157  npe = CLHEP::RandPoissonQ::shoot(engine, npe);
158  }
159  if (thePECorrection)
160  npe = thePECorrection->correctPE(detId, npe, engine);
161  return npe;
162 }
bool doPhotostatistics() const
whether or not to apply Poisson statistics to photoelectrons
const CaloVPECorrection * thePECorrection
double simHitToPhotoelectrons() const
virtual double correctPE(const DetId &detId, double npe, CLHEP::HepRandomEngine *) const =0
void CaloHitResponse::clear ( void  )
inline

frees up memory

Definition at line 79 of file CaloHitResponse.h.

Referenced by EcalMixingModuleValidation::computeSDBunchDigi().

79 { theAnalogSignalMap.clear(); }
AnalogSignalMap theAnalogSignalMap
virtual void CaloHitResponse::finalizeHits ( CLHEP::HepRandomEngine *  )
inlinevirtual

Finalize hits.

Reimplemented in HcalSiPMHitResponse.

Definition at line 57 of file CaloHitResponse.h.

References PVValHelper::add(), hfClusterShapes_cfi::hits, and writedatasetfile::run.

57 {}
CaloSamples * CaloHitResponse::findSignal ( const DetId detId)

users can look for the signal for a given cell

Definition at line 164 of file CaloHitResponse.cc.

References mps_fire::result, and theAnalogSignalMap.

Referenced by add(), and EcalMixingModuleValidation::computeSDBunchDigi().

164  {
165  CaloSamples *result = nullptr;
166  AnalogSignalMap::iterator signalItr = theAnalogSignalMap.find(detId);
167  if (signalItr == theAnalogSignalMap.end()) {
168  result = nullptr;
169  } else {
170  result = &(signalItr->second);
171  }
172  return result;
173 }
AnalogSignalMap theAnalogSignalMap
virtual void CaloHitResponse::initializeHits ( )
inlinevirtual

Initialize hits.

Reimplemented in HcalSiPMHitResponse.

Definition at line 54 of file CaloHitResponse.h.

54 {}
virtual bool CaloHitResponse::keepBlank ( ) const
inlinevirtual

Definition at line 51 of file CaloHitResponse.h.

Referenced by add(), and HcalSiPMHitResponse::finalizeHits().

51 { return true; }
CaloSamples CaloHitResponse::makeAnalogSignal ( const PCaloHit inputHit,
CLHEP::HepRandomEngine *  engine 
) const
virtual

creates the signal corresponding to this hit

Definition at line 102 of file CaloHitResponse.cc.

References analogSignalAmplitude(), stringResolutionProvider_cfi::bin, BUNCHSPACE, CaloVHitCorrection::delay(), PCaloHit::energy(), PCaloHit::id(), ignoreTime, makeBlankSignal(), CaloSamples::preciseAtMod(), CaloSamples::resetPrecise(), mps_fire::result, CaloShapes::shape(), CaloVSimParameterMap::simParameters(), CaloSamples::size(), storePrecise, theHitCorrection, theParameterMap, thePhaseShift_, theShape, theShapes, PCaloHit::time(), ntuplemaker::time, timeOfFlight(), CaloVShape::timeToRise(), and tzero.

Referenced by add().

102  {
103  DetId detId(hit.id());
105  double signal = analogSignalAmplitude(detId, hit.energy(), parameters, engine);
106 
107  double time = hit.time();
108  double tof = timeOfFlight(detId);
109  if (ignoreTime)
110  time = tof;
111  if (theHitCorrection != nullptr) {
112  time += theHitCorrection->delay(hit, engine);
113  }
114  double jitter = time - tof;
115 
116  const CaloVShape *shape = theShape;
117  if (!shape) {
118  shape = theShapes->shape(detId, storePrecise);
119  }
120  // assume bins count from zero, go for center of bin
121  const double tzero = (shape->timeToRise() + parameters.timePhase() - jitter -
122  BUNCHSPACE * (parameters.binOfMaximum() - thePhaseShift_));
123  double binTime = tzero;
124 
126 
127  if (storePrecise) {
128  result.resetPrecise();
129  int sampleBin(0);
130  // use 1ns binning for precise sample
131  for (int bin = 0; bin < result.size() * BUNCHSPACE; bin++) {
132  sampleBin = bin / BUNCHSPACE;
133  double pulseBit = (*shape)(binTime)*signal;
134  result[sampleBin] += pulseBit;
135  result.preciseAtMod(bin) += pulseBit;
136  binTime += 1.0;
137  }
138  } else {
139  for (int bin = 0; bin < result.size(); bin++) {
140  result[bin] += (*shape)(binTime)*signal;
141  binTime += BUNCHSPACE;
142  }
143  }
144  return result;
145 }
CaloSamples makeBlankSignal(const DetId &detId) const
creates an empty signal for this DetId
virtual const CaloVShape * shape(const DetId &detId, bool precise=false) const
Definition: CaloShapes.h:14
virtual double delay(const PCaloHit &hit, CLHEP::HepRandomEngine *) const =0
Electronic response of the preamp.
Definition: CaloVShape.h:11
Main class for Parameters in different subdetectors.
virtual double timeToRise() const =0
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
double timeOfFlight(const DetId &detId) const
const CaloVHitCorrection * theHitCorrection
bin
set the eta bin as selection string.
unsigned int id
Definition: DetId.h:18
double analogSignalAmplitude(const DetId &id, float energy, const CaloSimParameters &parameters, CLHEP::HepRandomEngine *) const
const CaloShapes * theShapes
const CaloVSimParameterMap * theParameterMap
static const double tzero[3]
const CaloVShape * theShape
CaloSamples CaloHitResponse::makeBlankSignal ( const DetId detId) const

creates an empty signal for this DetId

Definition at line 175 of file CaloHitResponse.cc.

References CaloSimParameters::binOfMaximum(), BUNCHSPACE, CaloSimParameters::readoutFrameSize(), mps_fire::result, CaloVSimParameterMap::simParameters(), storePrecise, and theParameterMap.

Referenced by makeAnalogSignal().

175  {
177  int preciseSize(storePrecise ? parameters.readoutFrameSize() * BUNCHSPACE : 0);
178  CaloSamples result(detId, parameters.readoutFrameSize(), preciseSize);
179  result.setPresamples(parameters.binOfMaximum() - 1);
180  if (storePrecise)
181  result.setPrecise(result.presamples() * BUNCHSPACE, 1.0);
182  return result;
183 }
Main class for Parameters in different subdetectors.
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
int CaloHitResponse::nSignals ( ) const
inline

number of signals in the current cache

Definition at line 98 of file CaloHitResponse.h.

References spr::timeOfFlight().

98 { return theAnalogSignalMap.size(); }
AnalogSignalMap theAnalogSignalMap
void CaloHitResponse::run ( const MixCollection< PCaloHit > &  hits,
CLHEP::HepRandomEngine *  engine 
)
virtual

Complete cell digitization.

Definition at line 58 of file CaloHitResponse.cc.

References add(), MixCollection< T >::begin(), MixCollection< T >::end(), and withinBunchRange().

Referenced by EcalMixingModuleValidation::computeSDBunchDigi().

58  {
59  for (MixCollection<PCaloHit>::MixItr hitItr = hits.begin(); hitItr != hits.end(); ++hitItr) {
60  if (withinBunchRange(hitItr.bunch())) {
61  add(*hitItr, engine);
62  } // loop over hits
63  }
64 }
bool withinBunchRange(int bunchCrossing) const
check if crossing is within bunch range:
iterator end() const
virtual void add(const PCaloHit &hit, CLHEP::HepRandomEngine *)
process a single SimHit
iterator begin() const
void CaloHitResponse::setBunchRange ( int  minBunch,
int  maxBunch 
)
void CaloHitResponse::setGeometry ( const CaloGeometry geometry)
inline

geometry needed for time-of-flight

Definition at line 49 of file CaloHitResponse.h.

References geometry.

Referenced by CastorDigiProducer::checkGeometry(), EcalMixingModuleValidation::computeSDBunchDigi(), and HcalTBDigiProducer::updateGeometry().

49 { theGeometry = geometry; }
const CaloGeometry * theGeometry
ESHandle< TrackerGeometry > geometry
void CaloHitResponse::setHitCorrection ( const CaloVHitCorrection hitCorrection)
inline

If you want to correct hits, for attenuation or delay, set this.

Definition at line 73 of file CaloHitResponse.h.

Referenced by CastorDigiProducer::CastorDigiProducer().

73 { theHitCorrection = hitCorrection; }
const CaloVHitCorrection * theHitCorrection
void CaloHitResponse::setHitFilter ( const CaloVHitFilter filter)
inline

if you want to reject hits, for example, from a certain subdetector, set this

Definition at line 70 of file CaloHitResponse.h.

References ALCARECOTkAlBeamHalo_cff::filter.

Referenced by CastorDigiProducer::CastorDigiProducer(), and HcalTBDigiProducer::HcalTBDigiProducer().

void CaloHitResponse::setIgnoreGeantTime ( bool  gt)
inline

Definition at line 118 of file CaloHitResponse.h.

118 { ignoreTime = gt; }
void CaloHitResponse::setPECorrection ( const CaloVPECorrection peCorrection)
inline

if you want to correct the photoelectrons

Definition at line 76 of file CaloHitResponse.h.

76 { thePECorrection = peCorrection; }
const CaloVPECorrection * thePECorrection
void CaloHitResponse::setPhaseShift ( const double &  thePhaseShift)
inline

setting the phase shift for asynchronous trigger (e.g. test beams)

Definition at line 108 of file CaloHitResponse.h.

Referenced by HcalTBDigiProducer::setPhaseShift().

108 { thePhaseShift_ = thePhaseShift; }
void CaloHitResponse::setStorePrecise ( bool  sp)
inline

Definition at line 116 of file CaloHitResponse.h.

116 { storePrecise = sp; }
double CaloHitResponse::timeOfFlight ( const DetId detId) const

time-of-flight, in ns, to get to this cell returns 0 if no geometry has been set

Definition at line 185 of file CaloHitResponse.cc.

References SoftLeptonByDistance_cfi::distance, CaloSubdetectorGeometry::getGeometry(), CaloGeometry::getSubdetectorGeometry(), DetId::rawId(), mps_fire::result, and theGeometry.

Referenced by HcalSiPMHitResponse::add(), and makeAnalogSignal().

185  {
186  // not going to assume there's one of these per subdetector.
187  // Take the whole CaloGeometry and find the right subdet
188  double result = 0.;
189  if (theGeometry == nullptr) {
190  edm::LogWarning("CaloHitResponse") << "No Calo Geometry set, so no time of flight correction";
191  } else {
192  auto cellGeometry = theGeometry->getSubdetectorGeometry(detId)->getGeometry(detId);
193  if (cellGeometry == nullptr) {
194  edm::LogWarning("CaloHitResponse") << "No Calo cell found for ID" << detId.rawId()
195  << " so no time-of-flight subtraction will be done";
196  } else {
197  double distance = cellGeometry->getPosition().mag();
198  result = distance * cm / c_light; // Units of c_light: mm/ns
199  }
200  }
201  return result;
202 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
const CaloGeometry * theGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
bool CaloHitResponse::withinBunchRange ( int  bunchCrossing) const
inline

check if crossing is within bunch range:

Definition at line 112 of file CaloHitResponse.h.

Referenced by run().

112  {
113  return (bunchCrossing >= theMinBunch && bunchCrossing <= theMaxBunch);
114  }

Member Data Documentation

bool CaloHitResponse::ignoreTime
protected

Definition at line 137 of file CaloHitResponse.h.

Referenced by HcalSiPMHitResponse::add(), and makeAnalogSignal().

bool CaloHitResponse::storePrecise
protected

Definition at line 136 of file CaloHitResponse.h.

Referenced by makeAnalogSignal(), and makeBlankSignal().

AnalogSignalMap CaloHitResponse::theAnalogSignalMap
protected

Definition at line 121 of file CaloHitResponse.h.

Referenced by add(), and findSignal().

const CaloGeometry* CaloHitResponse::theGeometry
protected

Definition at line 130 of file CaloHitResponse.h.

Referenced by timeOfFlight().

const CaloVHitCorrection* CaloHitResponse::theHitCorrection
protected

Definition at line 126 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().

const CaloVHitFilter* CaloHitResponse::theHitFilter
protected

Definition at line 128 of file CaloHitResponse.h.

Referenced by HcalSiPMHitResponse::add(), and add().

int CaloHitResponse::theMaxBunch
protected

Definition at line 133 of file CaloHitResponse.h.

Referenced by setBunchRange().

int CaloHitResponse::theMinBunch
protected

Definition at line 132 of file CaloHitResponse.h.

Referenced by setBunchRange().

const CaloVSimParameterMap* CaloHitResponse::theParameterMap
protected
const CaloVPECorrection* CaloHitResponse::thePECorrection
protected

Definition at line 127 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude().

double CaloHitResponse::thePhaseShift_
protected

Definition at line 135 of file CaloHitResponse.h.

Referenced by HcalSiPMHitResponse::add(), and makeAnalogSignal().

const CaloVShape* CaloHitResponse::theShape
protected

Definition at line 125 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().

const CaloShapes* CaloHitResponse::theShapes
protected

Definition at line 124 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().