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 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,
CaloSamples
AnalogSignalMap
 

Public Member Functions

virtual void add (const PCaloHit &hit)
 process a single SimHit More...
 
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 PCaloHit &hit, const CaloSimParameters &parameters) 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) 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)
 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 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...
 
virtual void setRandomEngine (CLHEP::HepRandomEngine &engine)
 
double timeOfFlight (const DetId &detId) const
 
virtual ~CaloHitResponse ()
 doesn't delete the pointers passed in More...
 

Protected Attributes

AnalogSignalMap theAnalogSignalMap
 
const CaloGeometrytheGeometry
 
const CaloVHitCorrectiontheHitCorrection
 
const CaloVHitFiltertheHitFilter
 
int theMaxBunch
 
int theMinBunch
 
const CaloVSimParameterMaptheParameterMap
 
const CaloVPECorrectionthePECorrection
 
double thePhaseShift_
 
CLHEP::RandPoissonQ * theRandPoisson
 
const CaloVShapetheShape
 
const CaloShapestheShapes
 

Detailed Description

Creates electronics signals from hits.

Definition at line 31 of file CaloHitResponse.h.

Member Typedef Documentation

Definition at line 34 of file CaloHitResponse.h.

Member Enumeration Documentation

anonymous enum
Enumerator
BUNCHSPACE 

Definition at line 36 of file CaloHitResponse.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file CaloHitResponse.cc.

26  theParameterMap(parametersMap),
27  theShapes(0),
28  theShape(shape),
30  thePECorrection(0),
31  theHitFilter(0),
32  theGeometry(0),
33  theRandPoisson(0),
34  theMinBunch(-10),
35  theMaxBunch(10),
36  thePhaseShift_(1.)
37 {
38 }
CLHEP::RandPoissonQ * theRandPoisson
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 41 of file CaloHitResponse.cc.

44  theParameterMap(parametersMap),
45  theShapes(shapes),
46  theShape(0),
48  thePECorrection(0),
49  theHitFilter(0),
50  theGeometry(0),
51  theRandPoisson(0),
52  theMinBunch(-10),
53  theMaxBunch(10),
54  thePhaseShift_(1.)
55 {
56 }
CLHEP::RandPoissonQ * theRandPoisson
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 59 of file CaloHitResponse.cc.

References theRandPoisson.

60 {
61  delete theRandPoisson;
62 }
CLHEP::RandPoissonQ * theRandPoisson

Member Function Documentation

void CaloHitResponse::add ( const PCaloHit hit)
virtual

process a single SimHit

Definition at line 92 of file CaloHitResponse.cc.

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

Referenced by CaloTDigitizer< Traits >::addNoiseHits(), CaloTDigitizer< Traits >::addNoiseSignals(), HcalSiPMHitResponse::run(), and run().

93 {
94  // check the hit time makes sense
95  if ( isnan(hit.time()) ) { return; }
96 
97  // maybe it's not from this subdetector
98  if(theHitFilter == 0 || theHitFilter->accepts(hit)) {
99  LogDebug("CaloHitResponse") << hit;
100  CaloSamples signal( makeAnalogSignal( hit ) ) ;
101 
102  bool keep ( keepBlank() ) ; // here we check for blank signal if not keeping them
103  if( !keep )
104  {
105  const unsigned int size ( signal.size() ) ;
106  if( 0 != size )
107  {
108  for( unsigned int i ( 0 ) ; i != size ; ++i )
109  {
110  keep = keep || signal[i] > 1.e-7 ;
111  }
112  }
113  }
114  LogDebug("CaloHitResponse") << signal;
115  if( keep ) add(signal);
116  }
117 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
double time() const
Definition: PCaloHit.h:34
virtual CaloSamples makeAnalogSignal(const PCaloHit &inputHit) const
creates the signal corresponding to this hit
virtual bool keepBlank() const
const int keep
bool isnan(float x)
Definition: math.h:13
virtual void add(const PCaloHit &hit)
process a single SimHit
virtual bool accepts(const PCaloHit &hit) const =0
const CaloVHitFilter * theHitFilter
tuple size
Write out results.
void CaloHitResponse::add ( const CaloSamples signal)

add a signal, in units of pe

Definition at line 120 of file CaloHitResponse.cc.

References findSignal(), i, CaloSamples::id(), errorMatrix2Lands_multiChannel::id, CaloSamples::presamples(), CaloSamples::size(), and theAnalogSignalMap.

121 {
122  DetId id(signal.id());
123  CaloSamples * oldSignal = findSignal(id);
124  if (oldSignal == 0) {
125  theAnalogSignalMap[id] = signal;
126  } else {
127  // need a "+=" to CaloSamples
128  int sampleSize = oldSignal->size();
129  assert(sampleSize == signal.size());
130  assert(signal.presamples() == oldSignal->presamples());
131 
132  for(int i = 0; i < sampleSize; ++i) {
133  (*oldSignal)[i] += signal[i];
134  }
135  }
136 }
int i
Definition: DBlmapReader.cc:9
int presamples() const
access presample information
Definition: CaloSamples.h:31
AnalogSignalMap theAnalogSignalMap
Definition: DetId.h:20
int size() const
get the size
Definition: CaloSamples.h:24
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 PCaloHit hit,
const CaloSimParameters parameters 
) const

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

Definition at line 177 of file CaloHitResponse.cc.

References CaloVPECorrection::correctPE(), CaloSimParameters::doPhotostatistics(), PCaloHit::energy(), edm::hlt::Exception, edm::RandomNumberGenerator::getEngine(), PCaloHit::id(), edm::Service< T >::isAvailable(), CaloSimParameters::simHitToPhotoelectrons(), thePECorrection, and theRandPoisson.

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

177  {
178 
179  if(!theRandPoisson)
180  {
182  if ( ! rng.isAvailable()) {
183  throw cms::Exception("Configuration")
184  << "CaloHitResponse requires the RandomNumberGeneratorService\n"
185  "which is not present in the configuration file. You must add the service\n"
186  "in the configuration file or remove the modules that require it.";
187  }
188  theRandPoisson = new CLHEP::RandPoissonQ(rng->getEngine());
189  }
190 
191  // OK, the "energy" in the hit could be a real energy, deposited energy,
192  // or pe count. This factor converts to photoelectrons
193  DetId detId(hit.id());
194  double npe = hit.energy() * parameters.simHitToPhotoelectrons(detId);
195  // do we need to doPoisson statistics for the photoelectrons?
196  if(parameters.doPhotostatistics()) {
197  npe = theRandPoisson->fire(npe);
198  }
199  if(thePECorrection) npe = thePECorrection->correctPE(detId, npe);
200  return npe;
201 }
CLHEP::RandPoissonQ * theRandPoisson
double energy() const
Definition: PCaloHit.h:29
bool doPhotostatistics() const
whether or not to apply Poisson statistics to photoelectrons
const CaloVPECorrection * thePECorrection
bool isAvailable() const
Definition: Service.h:47
double simHitToPhotoelectrons() const
unsigned int id() const
Definition: PCaloHit.h:40
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
Definition: DetId.h:20
virtual double correctPE(const DetId &detId, double npe) const =0
void CaloHitResponse::clear ( void  )
inline

frees up memory

Definition at line 81 of file CaloHitResponse.h.

References theAnalogSignalMap.

Referenced by EcalMixingModuleValidation::computeSDBunchDigi(), and CaloTDigitizer< Traits >::run().

81 {theAnalogSignalMap.clear();}
AnalogSignalMap theAnalogSignalMap
CaloSamples * CaloHitResponse::findSignal ( const DetId detId)

users can look for the signal for a given cell

Definition at line 204 of file CaloHitResponse.cc.

References query::result, and theAnalogSignalMap.

Referenced by add(), EcalMixingModuleValidation::computeSDBunchDigi(), and CaloTDigitizer< Traits >::run().

204  {
205  CaloSamples * result = 0;
206  AnalogSignalMap::iterator signalItr = theAnalogSignalMap.find(detId);
207  if(signalItr == theAnalogSignalMap.end()) {
208  result = 0;
209  }
210  else {
211  result = &(signalItr->second);
212  }
213  return result;
214 }
tuple result
Definition: query.py:137
AnalogSignalMap theAnalogSignalMap
virtual bool CaloHitResponse::keepBlank ( ) const
inlinevirtual

Definition at line 52 of file CaloHitResponse.h.

References funct::true.

Referenced by add().

52 { return true ; }
CaloSamples CaloHitResponse::makeAnalogSignal ( const PCaloHit inputHit) const
virtual

creates the signal corresponding to this hit

Definition at line 139 of file CaloHitResponse.cc.

References analogSignalAmplitude(), newFWLiteAna::bin, BUNCHSPACE, CaloVHitCorrection::correct(), PCaloHit::id(), makeBlankSignal(), Parameters::parameters, query::result, CaloShapes::shape(), CaloVSimParameterMap::simParameters(), CaloSamples::size(), theHitCorrection, theParameterMap, thePhaseShift_, theShape, theShapes, PCaloHit::time(), timeOfFlight(), CaloVShape::timeToRise(), and tzero.

Referenced by add().

139  {
140 
141  // see if we need to correct the hit
142  PCaloHit hit = inputHit;
143 
144  if(theHitCorrection != 0) {
146  }
147 
148  DetId detId(hit.id());
150 
151  double signal = analogSignalAmplitude(hit, parameters);
152 
153  double jitter = hit.time() - timeOfFlight(detId);
154 
155  const CaloVShape * shape = theShape;
156  if(!shape) {
157  shape = theShapes->shape(detId);
158  }
159  // assume bins count from zero, go for center of bin
160  const double tzero = ( shape->timeToRise()
161  + parameters.timePhase()
162  - jitter
163  - BUNCHSPACE*( parameters.binOfMaximum()
164  - thePhaseShift_ ) ) ;
165  double binTime = tzero;
166 
168 
169  for(int bin = 0; bin < result.size(); bin++) {
170  result[bin] += (*shape)(binTime)* signal;
171  binTime += BUNCHSPACE;
172  }
173  return result;
174 }
dictionary parameters
Definition: Parameters.py:2
CaloSamples makeBlankSignal(const DetId &detId) const
creates an empty signal for this DetId
double time() const
Definition: PCaloHit.h:34
Electronic response of the preamp.
Definition: CaloVShape.h:11
Main class for Parameters in different subdetectors.
virtual void correct(PCaloHit &hit) const =0
tuple result
Definition: query.py:137
virtual double timeToRise() const =0
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
unsigned int id() const
Definition: PCaloHit.h:40
double timeOfFlight(const DetId &detId) const
const CaloVHitCorrection * theHitCorrection
Definition: DetId.h:20
double analogSignalAmplitude(const PCaloHit &hit, const CaloSimParameters &parameters) const
const CaloShapes * theShapes
const CaloVSimParameterMap * theParameterMap
static const double tzero[3]
const CaloVShape * theShape
virtual const CaloVShape * shape(const DetId &detId) const
Definition: CaloShapes.h:15
CaloSamples CaloHitResponse::makeBlankSignal ( const DetId detId) const

creates an empty signal for this DetId

Definition at line 217 of file CaloHitResponse.cc.

References CaloSimParameters::binOfMaximum(), Parameters::parameters, CaloSimParameters::readoutFrameSize(), query::result, CaloVSimParameterMap::simParameters(), and theParameterMap.

Referenced by makeAnalogSignal(), HcalSiPMHitResponse::makeSiPMSignal(), and CaloTDigitizer< Traits >::run().

217  {
219  CaloSamples result(detId, parameters.readoutFrameSize());
220  result.setPresamples(parameters.binOfMaximum()-1);
221  return result;
222 }
dictionary parameters
Definition: Parameters.py:2
Main class for Parameters in different subdetectors.
tuple result
Definition: query.py:137
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 97 of file CaloHitResponse.h.

References theAnalogSignalMap.

Referenced by CaloTDigitizer< Traits >::run().

97 {return theAnalogSignalMap.size();}
AnalogSignalMap theAnalogSignalMap
void CaloHitResponse::run ( MixCollection< PCaloHit > &  hits)
virtual

Complete cell digitization.

Reimplemented in HcalSiPMHitResponse.

Definition at line 77 of file CaloHitResponse.cc.

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

Referenced by EcalMixingModuleValidation::computeSDBunchDigi(), and CaloTDigitizer< Traits >::run().

77  {
78 
79  for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
80  hitItr != hits.end(); ++hitItr)
81  {
82  // check the bunch crossing range
83  if ( hitItr.bunch() < theMinBunch || hitItr.bunch() > theMaxBunch )
84  { continue; }
85 
86  add(*hitItr);
87  } // loop over hits
88 }
iterator end()
virtual void add(const PCaloHit &hit)
process a single SimHit
iterator begin()
void CaloHitResponse::setBunchRange ( int  minBunch,
int  maxBunch 
)

tells it which pileup bunches to do

Definition at line 65 of file CaloHitResponse.cc.

References theMaxBunch, and theMinBunch.

Referenced by EcalMixingModuleValidation::computeSDBunchDigi().

65  {
66  theMinBunch = minBunch;
67  theMaxBunch = maxBunch;
68 }
void CaloHitResponse::setGeometry ( const CaloGeometry geometry)
inline

geometry needed for time-of-flight

Definition at line 49 of file CaloHitResponse.h.

References geometry, and theGeometry.

Referenced by CastorDigiProducer::checkGeometry(), EcalMixingModuleValidation::computeSDBunchDigi(), HcalTBDigiProducer::updateGeometry(), HcalDigitizer::updateGeometry(), and EcalDigiProducer::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 69 of file CaloHitResponse.h.

References theHitCorrection.

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

69  {
70  theHitCorrection = hitCorrection;
71  }
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 64 of file CaloHitResponse.h.

References alcazmumu_cfi::filter, and theHitFilter.

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

64  {
66  }
const CaloVHitFilter * theHitFilter
void CaloHitResponse::setPECorrection ( const CaloVPECorrection peCorrection)
inline

if you want to correct the photoelectrons

Definition at line 74 of file CaloHitResponse.h.

References thePECorrection.

Referenced by HcalDigitizer::HcalDigitizer().

74  {
75  thePECorrection = peCorrection;
76  }
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.

References thePhaseShift_.

Referenced by HcalTBDigiProducer::setPhaseShift().

108 { thePhaseShift_ = thePhaseShift; }
void CaloHitResponse::setRandomEngine ( CLHEP::HepRandomEngine &  engine)
virtual

Reimplemented in HcalSiPMHitResponse.

Definition at line 71 of file CaloHitResponse.cc.

References theRandPoisson.

Referenced by HcalSiPMHitResponse::setRandomEngine(), and CaloTDigitizer< Traits >::setRandomEngine().

72 {
73  theRandPoisson = new CLHEP::RandPoissonQ(engine);
74 }
CLHEP::RandPoissonQ * theRandPoisson
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 225 of file CaloHitResponse.cc.

References CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), PV3DBase< T, PVType, FrameType >::mag(), DetId::rawId(), query::result, and theGeometry.

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

225  {
226  // not going to assume there's one of these per subdetector.
227  // Take the whole CaloGeometry and find the right subdet
228  double result = 0.;
229  if(theGeometry == 0) {
230  edm::LogWarning("CaloHitResponse") << "No Calo Geometry set, so no time of flight correction";
231  }
232  else {
233  const CaloCellGeometry* cellGeometry = theGeometry->getSubdetectorGeometry(detId)->getGeometry(detId);
234  if(cellGeometry == 0) {
235  edm::LogWarning("CaloHitResponse") << "No Calo cell found for ID"
236  << detId.rawId() << " so no time-of-flight subtraction will be done";
237  }
238  else {
239  double distance = cellGeometry->getPosition().mag();
240  result = distance * cm / c_light; // Units of c_light: mm/ns
241  }
242  }
243  return result;
244 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
const CaloGeometry * theGeometry
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
T mag() const
Definition: PV3DBase.h:66
tuple result
Definition: query.py:137

Member Data Documentation

AnalogSignalMap CaloHitResponse::theAnalogSignalMap
protected

Definition at line 112 of file CaloHitResponse.h.

Referenced by add(), clear(), findSignal(), and nSignals().

const CaloGeometry* CaloHitResponse::theGeometry
protected

Definition at line 121 of file CaloHitResponse.h.

Referenced by setGeometry(), and timeOfFlight().

const CaloVHitCorrection* CaloHitResponse::theHitCorrection
protected
const CaloVHitFilter* CaloHitResponse::theHitFilter
protected

Definition at line 119 of file CaloHitResponse.h.

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

int CaloHitResponse::theMaxBunch
protected

Definition at line 126 of file CaloHitResponse.h.

Referenced by HcalSiPMHitResponse::run(), run(), and setBunchRange().

int CaloHitResponse::theMinBunch
protected

Definition at line 125 of file CaloHitResponse.h.

Referenced by HcalSiPMHitResponse::run(), run(), and setBunchRange().

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

Definition at line 118 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude(), and setPECorrection().

double CaloHitResponse::thePhaseShift_
protected
CLHEP::RandPoissonQ* CaloHitResponse::theRandPoisson
mutableprotected

Definition at line 123 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude(), setRandomEngine(), and ~CaloHitResponse().

const CaloVShape* CaloHitResponse::theShape
protected

Definition at line 116 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().

const CaloShapes* CaloHitResponse::theShapes
protected

Definition at line 115 of file CaloHitResponse.h.

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