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)
 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 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 36 of file CaloHitResponse.h.

Member Enumeration Documentation

anonymous enum
Enumerator
BUNCHSPACE 

Definition at line 38 of file CaloHitResponse.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file CaloHitResponse.cc.

24  theParameterMap(parametersMap),
25  theShapes(nullptr),
26  theShape(shape),
27  theHitCorrection(nullptr),
28  thePECorrection(nullptr),
29  theHitFilter(nullptr),
30  theGeometry(nullptr),
31  theMinBunch(-10),
32  theMaxBunch(10),
33  thePhaseShift_(1.),
34  storePrecise(false),
35  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 37 of file CaloHitResponse.cc.

40  theParameterMap(parametersMap),
41  theShapes(shapes),
42  theShape(nullptr),
43  theHitCorrection(nullptr),
44  thePECorrection(nullptr),
45  theHitFilter(nullptr),
46  theGeometry(nullptr),
47  theMinBunch(-10),
48  theMaxBunch(10),
49  thePhaseShift_(1.),
50  storePrecise(false),
51  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 53 of file CaloHitResponse.cc.

53  {
54 }

Member Function Documentation

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

process a single SimHit

Reimplemented in HcalSiPMHitResponse.

Definition at line 71 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().

71  {
72  // check the hit time makes sense
73  if ( edm::isNotFinite(hit.time()) ) { return; }
74 
75  // maybe it's not from this subdetector
76  if(theHitFilter == nullptr || theHitFilter->accepts(hit)) {
77  LogDebug("CaloHitResponse") << hit;
78  CaloSamples signal( makeAnalogSignal( hit, engine ) ) ;
79  bool keep ( keepBlank() ) ; // here we check for blank signal if not keeping them
80  if( !keep )
81  {
82  const unsigned int size ( signal.size() ) ;
83  if( 0 != size )
84  {
85  for( unsigned int i ( 0 ) ; i != size ; ++i )
86  {
87  keep = keep || signal[i] > 1.e-7 ;
88  }
89  }
90  }
91 
92  if( keep ) add(signal);
93  }
94 }
#define LogDebug(id)
size
Write out results.
double time() const
Definition: PCaloHit.h:36
virtual bool keepBlank() const
const int keep
virtual bool accepts(const PCaloHit &hit) const =0
bool isNotFinite(T x)
Definition: isFinite.h:10
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 97 of file CaloHitResponse.cc.

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

Referenced by counter.Counter::register().

98 {
99  DetId id(signal.id());
100  CaloSamples * oldSignal = findSignal(id);
101  if (oldSignal == nullptr) {
102  theAnalogSignalMap[id] = signal;
103 
104  } else {
105  (*oldSignal) += signal;
106  }
107 }
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 159 of file CaloHitResponse.cc.

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

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

159  {
160 
161  // OK, the "energy" in the hit could be a real energy, deposited energy,
162  // or pe count. This factor converts to photoelectrons
163  //GMA Smeared in photon production it self
164  double npe = energy * parameters.simHitToPhotoelectrons(detId);
165  // do we need to doPoisson statistics for the photoelectrons?
166  if(parameters.doPhotostatistics()) {
167  npe = CLHEP::RandPoissonQ::shoot(engine,npe);
168  }
169  if(thePECorrection) npe = thePECorrection->correctPE(detId, npe, engine);
170  return npe;
171 }
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 85 of file CaloHitResponse.h.

Referenced by EcalMixingModuleValidation::computeSDBunchDigi().

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

Finalize hits.

Reimplemented in HcalSiPMHitResponse.

Definition at line 58 of file CaloHitResponse.h.

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

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

users can look for the signal for a given cell

Definition at line 174 of file CaloHitResponse.cc.

References mps_fire::result, and theAnalogSignalMap.

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

174  {
175  CaloSamples * result = nullptr;
176  AnalogSignalMap::iterator signalItr = theAnalogSignalMap.find(detId);
177  if(signalItr == theAnalogSignalMap.end()) {
178  result = nullptr;
179  } else {
180  result = &(signalItr->second);
181  }
182  return result;
183 }
AnalogSignalMap theAnalogSignalMap
virtual void CaloHitResponse::initializeHits ( )
inlinevirtual

Initialize hits.

Reimplemented in HcalSiPMHitResponse.

Definition at line 55 of file CaloHitResponse.h.

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

Definition at line 52 of file CaloHitResponse.h.

References funct::true.

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

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

creates the signal corresponding to this hit

Definition at line 110 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().

110  {
111 
112  DetId detId(hit.id());
114  double signal = analogSignalAmplitude(detId, hit.energy(), parameters, engine);
115 
116  double time = hit.time();
117  double tof = timeOfFlight(detId);
118  if(ignoreTime) time = tof;
119  if(theHitCorrection != nullptr) {
120  time += theHitCorrection->delay(hit, engine);
121  }
122  double jitter = time - tof;
123 
124  const CaloVShape * shape = theShape;
125  if(!shape) {
126  shape = theShapes->shape(detId,storePrecise);
127  }
128  // assume bins count from zero, go for center of bin
129  const double tzero = ( shape->timeToRise()
130  + parameters.timePhase()
131  - jitter
132  - BUNCHSPACE*( parameters.binOfMaximum()
133  - thePhaseShift_ ) ) ;
134  double binTime = tzero;
135 
137 
138  if(storePrecise){
139  result.resetPrecise();
140  int sampleBin(0);
141  //use 1ns binning for precise sample
142  for(int bin = 0; bin < result.size()*BUNCHSPACE; bin++) {
143  sampleBin = bin/BUNCHSPACE;
144  double pulseBit = (*shape)(binTime)* signal;
145  result[sampleBin] += pulseBit;
146  result.preciseAtMod(bin) += pulseBit;
147  binTime += 1.0;
148  }
149  }
150  else {
151  for(int bin = 0; bin < result.size(); bin++) {
152  result[bin] += (*shape)(binTime)* signal;
153  binTime += BUNCHSPACE;
154  }
155  }
156  return result;
157 }
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:15
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 186 of file CaloHitResponse.cc.

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

Referenced by makeAnalogSignal().

186  {
188  int preciseSize(storePrecise ? parameters.readoutFrameSize()*BUNCHSPACE : 0);
189  CaloSamples result(detId, parameters.readoutFrameSize(),preciseSize);
190  result.setPresamples(parameters.binOfMaximum()-1);
191  if(storePrecise) result.setPrecise(result.presamples()*BUNCHSPACE,1.0);
192  return result;
193 }
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 101 of file CaloHitResponse.h.

References spr::timeOfFlight().

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

Complete cell digitization.

Definition at line 61 of file CaloHitResponse.cc.

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

Referenced by EcalMixingModuleValidation::computeSDBunchDigi().

61  {
62 
63  for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
64  hitItr != hits.end(); ++hitItr) {
65  if(withinBunchRange(hitItr.bunch())) {
66  add(*hitItr, engine);
67  } // loop over hits
68  }
69 }
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 50 of file CaloHitResponse.h.

References geometry.

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

50 { 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 75 of file CaloHitResponse.h.

Referenced by CastorDigiProducer::CastorDigiProducer().

75  {
76  theHitCorrection = hitCorrection;
77  }
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(), HcalDigitizer::HcalDigitizer(), and HcalTBDigiProducer::HcalTBDigiProducer().

70  {
72  }
const CaloVHitFilter * theHitFilter
void CaloHitResponse::setIgnoreGeantTime ( bool  gt)
inline

Definition at line 124 of file CaloHitResponse.h.

Referenced by HcalDigitizer::HcalDigitizer().

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

if you want to correct the photoelectrons

Definition at line 80 of file CaloHitResponse.h.

Referenced by HcalDigitizer::HcalDigitizer().

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

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

Definition at line 112 of file CaloHitResponse.h.

Referenced by HcalTBDigiProducer::setPhaseShift().

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

Definition at line 120 of file CaloHitResponse.h.

120  {
121  storePrecise = sp;
122  }
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 196 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().

196  {
197  // not going to assume there's one of these per subdetector.
198  // Take the whole CaloGeometry and find the right subdet
199  double result = 0.;
200  if(theGeometry == nullptr) {
201  edm::LogWarning("CaloHitResponse") << "No Calo Geometry set, so no time of flight correction";
202  }
203  else {
204  auto cellGeometry = theGeometry->getSubdetectorGeometry(detId)->getGeometry(detId);
205  if(cellGeometry == nullptr) {
206  edm::LogWarning("CaloHitResponse") << "No Calo cell found for ID"
207  << detId.rawId() << " so no time-of-flight subtraction will be done";
208  }
209  else {
210  double distance = cellGeometry->getPosition().mag();
211  result = distance * cm / c_light; // Units of c_light: mm/ns
212  }
213  }
214  return result;
215 }
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:47
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 116 of file CaloHitResponse.h.

Referenced by run().

116  {
117  return(bunchCrossing >= theMinBunch && bunchCrossing <= theMaxBunch);
118  }

Member Data Documentation

bool CaloHitResponse::ignoreTime
protected

Definition at line 146 of file CaloHitResponse.h.

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

bool CaloHitResponse::storePrecise
protected

Definition at line 145 of file CaloHitResponse.h.

Referenced by makeAnalogSignal(), and makeBlankSignal().

AnalogSignalMap CaloHitResponse::theAnalogSignalMap
protected

Definition at line 130 of file CaloHitResponse.h.

Referenced by add(), and findSignal().

const CaloGeometry* CaloHitResponse::theGeometry
protected

Definition at line 139 of file CaloHitResponse.h.

Referenced by timeOfFlight().

const CaloVHitCorrection* CaloHitResponse::theHitCorrection
protected

Definition at line 135 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().

const CaloVHitFilter* CaloHitResponse::theHitFilter
protected

Definition at line 137 of file CaloHitResponse.h.

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

int CaloHitResponse::theMaxBunch
protected

Definition at line 142 of file CaloHitResponse.h.

Referenced by setBunchRange().

int CaloHitResponse::theMinBunch
protected

Definition at line 141 of file CaloHitResponse.h.

Referenced by setBunchRange().

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

Definition at line 136 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude().

double CaloHitResponse::thePhaseShift_
protected

Definition at line 144 of file CaloHitResponse.h.

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

const CaloVShape* CaloHitResponse::theShape
protected

Definition at line 134 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().

const CaloShapes* CaloHitResponse::theShapes
protected

Definition at line 133 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().