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)
 
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
 

Detailed Description

Creates electronics signals from hits.

Definition at line 30 of file CaloHitResponse.h.

Member Typedef Documentation

Definition at line 33 of file CaloHitResponse.h.

Member Enumeration Documentation

anonymous enum
Enumerator
BUNCHSPACE 

Definition at line 35 of file CaloHitResponse.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file CaloHitResponse.cc.

25  theParameterMap(parametersMap),
26  theShape(shape),
28  thePECorrection(0),
29  theHitFilter(0),
30  theGeometry(0),
31  theRandPoisson(0),
32  theMinBunch(-10),
33  theMaxBunch(10),
34  thePhaseShift_(1.)
35 {
36 }
CLHEP::RandPoissonQ * theRandPoisson
const CaloGeometry * theGeometry
const CaloVPECorrection * thePECorrection
const CaloVHitCorrection * theHitCorrection
AnalogSignalMap theAnalogSignalMap
const CaloVSimParameterMap * theParameterMap
const CaloVHitFilter * theHitFilter
const CaloVShape * theShape
CaloHitResponse::~CaloHitResponse ( )
virtual

doesn't delete the pointers passed in

Definition at line 39 of file CaloHitResponse.cc.

References theRandPoisson.

40 {
41  delete theRandPoisson;
42 }
CLHEP::RandPoissonQ * theRandPoisson

Member Function Documentation

void CaloHitResponse::add ( const PCaloHit hit)
virtual

process a single SimHit

Definition at line 72 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(), ESFastTDigitizer::addNoiseHits(), CaloTDigitizer< Traits >::addNoiseSignals(), HcalSiPMHitResponse::run(), and run().

73 {
74  // check the hit time makes sense
75  if ( isnan(hit.time()) ) { return; }
76 
77  // maybe it's not from this subdetector
78  if(theHitFilter == 0 || theHitFilter->accepts(hit)) {
79  LogDebug("CaloHitResponse") << hit;
80  CaloSamples signal( makeAnalogSignal( hit ) ) ;
81 
82  bool keep ( keepBlank() ) ; // here we check for blank signal if not keeping them
83  if( !keep )
84  {
85  const unsigned int size ( signal.size() ) ;
86  if( 0 != size )
87  {
88  for( unsigned int i ( 0 ) ; i != size ; ++i )
89  {
90  keep = keep || signal[i] > 1.e-7 ;
91  }
92  }
93  }
94  LogDebug("CaloHitResponse") << signal;
95  if( keep ) add(signal);
96  }
97 }
#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 100 of file CaloHitResponse.cc.

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

101 {
102  DetId id(signal.id());
103  CaloSamples * oldSignal = findSignal(id);
104  if (oldSignal == 0) {
105  theAnalogSignalMap[id] = signal;
106  } else {
107  // need a "+=" to CaloSamples
108  int sampleSize = oldSignal->size();
109  assert(sampleSize == signal.size());
110  assert(signal.presamples() == oldSignal->presamples());
111 
112  for(int i = 0; i < sampleSize; ++i) {
113  (*oldSignal)[i] += signal[i];
114  }
115  }
116 }
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 153 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().

153  {
154 
155  if(!theRandPoisson)
156  {
158  if ( ! rng.isAvailable()) {
159  throw cms::Exception("Configuration")
160  << "CaloHitResponse requires the RandomNumberGeneratorService\n"
161  "which is not present in the configuration file. You must add the service\n"
162  "in the configuration file or remove the modules that require it.";
163  }
164  theRandPoisson = new CLHEP::RandPoissonQ(rng->getEngine());
165  }
166 
167  // OK, the "energy" in the hit could be a real energy, deposited energy,
168  // or pe count. This factor converts to photoelectrons
169  DetId detId(hit.id());
170  double npe = hit.energy() * parameters.simHitToPhotoelectrons(detId);
171  // do we need to doPoisson statistics for the photoelectrons?
172  if(parameters.doPhotostatistics()) {
173  npe = theRandPoisson->fire(npe);
174  }
175  if(thePECorrection) npe = thePECorrection->correctPE(detId, npe);
176  return npe;
177 }
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
CaloSamples * CaloHitResponse::findSignal ( const DetId detId)

users can look for the signal for a given cell

Definition at line 180 of file CaloHitResponse.cc.

References query::result, and theAnalogSignalMap.

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

180  {
181  CaloSamples * result = 0;
182  AnalogSignalMap::iterator signalItr = theAnalogSignalMap.find(detId);
183  if(signalItr == theAnalogSignalMap.end()) {
184  result = 0;
185  }
186  else {
187  result = &(signalItr->second);
188  }
189  return result;
190 }
tuple result
Definition: query.py:137
AnalogSignalMap theAnalogSignalMap
virtual bool CaloHitResponse::keepBlank ( ) const
inlinevirtual

Definition at line 49 of file CaloHitResponse.h.

References funct::true.

Referenced by add().

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

creates the signal corresponding to this hit

Definition at line 119 of file CaloHitResponse.cc.

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

Referenced by add().

119  {
120 
121  // see if we need to correct the hit
122  PCaloHit hit = inputHit;
123 
124  if(theHitCorrection != 0) {
126  }
127 
128  DetId detId(hit.id());
130 
131  double signal = analogSignalAmplitude(hit, parameters);
132 
133  double jitter = hit.time() - timeOfFlight(detId);
134 
135  // assume bins count from zero, go for center of bin
136  const double tzero = ( theShape->timeToRise()
137  + parameters.timePhase()
138  - jitter
139  - BUNCHSPACE*( parameters.binOfMaximum()
140  - thePhaseShift_ ) ) ;
141  double binTime = tzero;
142 
144 
145  for(int bin = 0; bin < result.size(); bin++) {
146  result[bin] += (*theShape)(binTime)* signal;
147  binTime += BUNCHSPACE;
148  }
149  return result;
150 }
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
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 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 193 of file CaloHitResponse.cc.

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

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

193  {
195  CaloSamples result(detId, parameters.readoutFrameSize());
196  result.setPresamples(parameters.binOfMaximum()-1);
197  return result;
198 }
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 94 of file CaloHitResponse.h.

References theAnalogSignalMap.

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

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

Complete cell digitization.

Reimplemented in HcalSiPMHitResponse.

Definition at line 57 of file CaloHitResponse.cc.

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

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

57  {
58 
59  for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
60  hitItr != hits.end(); ++hitItr)
61  {
62  // check the bunch crossing range
63  if ( hitItr.bunch() < theMinBunch || hitItr.bunch() > theMaxBunch )
64  { continue; }
65 
66  add(*hitItr);
67  } // loop over hits
68 }
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 45 of file CaloHitResponse.cc.

References theMaxBunch, and theMinBunch.

Referenced by EcalMixingModuleValidation::computeSDBunchDigi().

45  {
46  theMinBunch = minBunch;
47  theMaxBunch = maxBunch;
48 }
void CaloHitResponse::setGeometry ( const CaloGeometry geometry)
inline

geometry needed for time-of-flight

Definition at line 46 of file CaloHitResponse.h.

References geometry, and theGeometry.

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

46 { 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 66 of file CaloHitResponse.h.

References theHitCorrection.

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

66  {
67  theHitCorrection = hitCorrection;
68  }
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 61 of file CaloHitResponse.h.

References align_tpl::filter, and theHitFilter.

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

61  {
63  }
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
Definition: align_tpl.py:86
const CaloVHitFilter * theHitFilter
void CaloHitResponse::setPECorrection ( const CaloVPECorrection peCorrection)
inline

if you want to correct the photoelectrons

Definition at line 71 of file CaloHitResponse.h.

References thePECorrection.

Referenced by HcalDigitizer::HcalDigitizer().

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

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

Definition at line 105 of file CaloHitResponse.h.

References thePhaseShift_.

Referenced by HcalTBDigiProducer::setPhaseShift().

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

Reimplemented in HcalSiPMHitResponse.

Definition at line 51 of file CaloHitResponse.cc.

References theRandPoisson.

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

52 {
53  theRandPoisson = new CLHEP::RandPoissonQ(engine);
54 }
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 201 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().

201  {
202  // not going to assume there's one of these per subdetector.
203  // Take the whole CaloGeometry and find the right subdet
204  double result = 0.;
205  if(theGeometry == 0) {
206  edm::LogWarning("CaloHitResponse") << "No Calo Geometry set, so no time of flight correction";
207  }
208  else {
209  const CaloCellGeometry* cellGeometry = theGeometry->getSubdetectorGeometry(detId)->getGeometry(detId);
210  if(cellGeometry == 0) {
211  edm::LogWarning("CaloHitResponse") << "No Calo cell found for ID"
212  << detId.rawId() << " so no time-of-flight subtraction will be done";
213  }
214  else {
215  double distance = cellGeometry->getPosition().mag();
216  result = distance * cm / c_light; // Units of c_light: mm/ns
217  }
218  }
219  return result;
220 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
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:61
tuple result
Definition: query.py:137
const GlobalPoint & getPosition() const

Member Data Documentation

AnalogSignalMap CaloHitResponse::theAnalogSignalMap
protected

Definition at line 109 of file CaloHitResponse.h.

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

const CaloGeometry* CaloHitResponse::theGeometry
protected

Definition at line 117 of file CaloHitResponse.h.

Referenced by setGeometry(), and timeOfFlight().

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

Definition at line 115 of file CaloHitResponse.h.

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

int CaloHitResponse::theMaxBunch
protected

Definition at line 122 of file CaloHitResponse.h.

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

int CaloHitResponse::theMinBunch
protected

Definition at line 121 of file CaloHitResponse.h.

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

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

Definition at line 114 of file CaloHitResponse.h.

Referenced by analogSignalAmplitude(), and setPECorrection().

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

Definition at line 119 of file CaloHitResponse.h.

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

const CaloVShape* CaloHitResponse::theShape
protected

Definition at line 112 of file CaloHitResponse.h.

Referenced by makeAnalogSignal().