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
CaloHitRespoNew Class Reference

Creates electronics signals from hits. More...

#include <CaloHitRespoNew.h>

Inheritance diagram for CaloHitRespoNew:
EBHitResponse

Public Types

enum  { BUNCHSPACE =25 }
 
typedef std::vector< unsigned int > VecInd
 
typedef std::vector< CaloSamplesVecSam
 

Public Member Functions

 CaloHitRespoNew (const CaloVSimParameterMap *parameterMap, const CaloVShape *shape)
 
const CaloSamplesoperator[] (unsigned int i) const
 
virtual void run (MixCollection< PCaloHit > &hits)
 
unsigned int samplesSize () const
 
void setBunchRange (int minBunch, int maxBunch)
 
void setGeometry (const CaloSubdetectorGeometry *geometry)
 
void setHitCorrection (const CaloVHitCorrection *hitCorrection)
 
void setHitFilter (const CaloVHitFilter *filter)
 
void setPECorrection (const CaloVPECorrection *peCorrection)
 
void setPhaseShift (double phaseShift)
 
virtual void setRandomEngine (CLHEP::HepRandomEngine &engine) const
 
virtual ~CaloHitRespoNew ()
 

Protected Member Functions

double analogSignalAmplitude (const PCaloHit &hit) const
 
void blankOutUsedSamples ()
 
CaloSamplesfindSignal (const DetId &detId)
 
const CaloSubdetectorGeometrygeometry () const
 
const CaloSimParametersparams (const DetId &detId) const
 
double phaseShift () const
 
virtual void putAnalogSignal (const PCaloHit &inputHit)
 
CLHEP::RandGaussQ * ranGauss () const
 
CLHEP::RandPoissonQ * ranPois () const
 
void setupSamples (const DetId &detId)
 
const CaloVShapeshape () const
 
double timeOfFlight (const DetId &detId) const
 

Private Attributes

const CaloSubdetectorGeometrym_geometry
 
const CaloVHitCorrectionm_hitCorrection
 
const CaloVHitFilterm_hitFilter
 
VecInd m_index
 
int m_maxBunch
 
int m_minBunch
 
const CaloVSimParameterMapm_parameterMap
 
const CaloVPECorrectionm_PECorrection
 
double m_phaseShift
 
CLHEP::RandGaussQ * m_RandGauss
 
CLHEP::RandPoissonQ * m_RandPoisson
 
bool m_setup
 
const CaloVShapem_shape
 
VecSam m_vSamp
 

Detailed Description

Creates electronics signals from hits.

Definition at line 34 of file CaloHitRespoNew.h.

Member Typedef Documentation

typedef std::vector< unsigned int > CaloHitRespoNew::VecInd

Definition at line 39 of file CaloHitRespoNew.h.

typedef std::vector< CaloSamples > CaloHitRespoNew::VecSam

Definition at line 38 of file CaloHitRespoNew.h.

Member Enumeration Documentation

anonymous enum
Enumerator
BUNCHSPACE 

Definition at line 41 of file CaloHitRespoNew.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file CaloHitRespoNew.cc.

24  :
25  m_parameterMap ( parameterMap ) ,
26  m_shape ( shape ) ,
27  m_hitCorrection ( 0 ) ,
28  m_PECorrection ( 0 ) ,
29  m_hitFilter ( 0 ) ,
30  m_geometry ( 0 ) ,
31  m_RandPoisson ( 0 ) ,
32  m_RandGauss ( 0 ) ,
33  m_minBunch ( -10 ) ,
34  m_maxBunch ( 10 ) ,
35  m_phaseShift ( 1 ) ,
36  m_setup ( false )
37 {
38 }
CLHEP::RandPoissonQ * m_RandPoisson
const CaloVPECorrection * m_PECorrection
CLHEP::RandGaussQ * m_RandGauss
const CaloVSimParameterMap * m_parameterMap
const CaloSubdetectorGeometry * m_geometry
const CaloVShape * m_shape
const CaloVHitCorrection * m_hitCorrection
const CaloVHitFilter * m_hitFilter
CaloHitRespoNew::~CaloHitRespoNew ( )
virtual

Definition at line 40 of file CaloHitRespoNew.cc.

References m_RandGauss, and m_RandPoisson.

41 {
42  delete m_RandPoisson ;
43  delete m_RandGauss ;
44 }
CLHEP::RandPoissonQ * m_RandPoisson
CLHEP::RandGaussQ * m_RandGauss

Member Function Documentation

double CaloHitRespoNew::analogSignalAmplitude ( const PCaloHit hit) const
protected

Definition at line 264 of file CaloHitRespoNew.cc.

References CaloVPECorrection::correctPE(), PCaloHit::energy(), PCaloHit::id(), m_PECorrection, Parameters::parameters, params(), and ranPois().

Referenced by putAnalogSignal().

265 {
266  const DetId& detId ( hit.id() ) ;
267 
268  const CaloSimParameters& parameters ( *params( detId ) ) ;
269 
270  // OK, the "energy" in the hit could be a real energy, deposited energy,
271  // or pe count. This factor converts to photoelectrons
272 
273  double npe ( hit.energy()*parameters.simHitToPhotoelectrons( detId ) ) ;
274 
275  // do we need to doPoisson statistics for the photoelectrons?
276  if( parameters.doPhotostatistics() ) npe = ranPois()->fire( npe ) ;
277 
278  if( 0 != m_PECorrection ) npe = m_PECorrection->correctPE( detId, npe ) ;
279 
280  return npe ;
281 }
dictionary parameters
Definition: Parameters.py:2
const CaloVPECorrection * m_PECorrection
double energy() const
Definition: PCaloHit.h:29
Main class for Parameters in different subdetectors.
unsigned int id() const
Definition: PCaloHit.h:40
Definition: DetId.h:20
const CaloSimParameters * params(const DetId &detId) const
CLHEP::RandPoissonQ * ranPois() const
virtual double correctPE(const DetId &detId, double npe) const =0
void CaloHitRespoNew::blankOutUsedSamples ( )
protected

Definition at line 189 of file CaloHitRespoNew.cc.

References i, m_index, m_vSamp, and findQualityFiles::size.

Referenced by run().

190 {
191  const unsigned int size ( m_index.size() ) ;
192 
193  for( unsigned int i ( 0 ) ; i != size ; ++i )
194  {
195  m_vSamp[ m_index[i] ].setBlank() ;
196  }
197  m_index.erase( m_index.begin() , // done and make ready to start over
198  m_index.end() ) ;
199 }
int i
Definition: DBlmapReader.cc:9
tuple size
Write out results.
CaloSamples * CaloHitRespoNew::findSignal ( const DetId detId)
protected

Definition at line 256 of file CaloHitRespoNew.cc.

References CaloSamples::isBlank(), m_index, m_vSamp, and query::result.

Referenced by EBHitResponse::putAnalogSignal(), and putAnalogSignal().

257 {
258  CaloSamples& result ( m_vSamp[ CaloGenericDetId( detId ).denseIndex() ] ) ;
259  if( result.isBlank() ) m_index.push_back( &result - &m_vSamp.front() ) ;
260  return &result ;
261 }
tuple result
Definition: query.py:137
const CaloSubdetectorGeometry * CaloHitRespoNew::geometry ( ) const
protected

Definition at line 97 of file CaloHitRespoNew.cc.

References m_geometry.

Referenced by python.Vispa.Gui.ConnectableWidget.ConnectableWidget::leaveEvent(), setGeometry(), and timeOfFlight().

98 {
99  assert( 0 != m_geometry ) ;
100  return m_geometry ;
101 }
const CaloSubdetectorGeometry * m_geometry
const CaloSamples & CaloHitRespoNew::operator[] ( unsigned int  i) const

Definition at line 155 of file CaloHitRespoNew.cc.

References i, and m_vSamp.

156 {
157  assert( i < m_vSamp.size() ) ;
158  return m_vSamp[ i ] ;
159 }
int i
Definition: DBlmapReader.cc:9
const CaloSimParameters * CaloHitRespoNew::params ( const DetId detId) const
protected

Definition at line 83 of file CaloHitRespoNew.cc.

References m_parameterMap, and CaloVSimParameterMap::simParameters().

Referenced by analogSignalAmplitude(), EBHitResponse::putAnalogSignal(), putAnalogSignal(), and setupSamples().

84 {
85  assert( 0 != m_parameterMap ) ;
86  return &m_parameterMap->simParameters( detId ) ;
87 }
const CaloVSimParameterMap * m_parameterMap
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
double CaloHitRespoNew::phaseShift ( ) const
protected

Definition at line 124 of file CaloHitRespoNew.cc.

References m_phaseShift.

Referenced by EBHitResponse::putAnalogSignal(), and setPhaseShift().

125 {
126  return m_phaseShift ;
127 }
void CaloHitRespoNew::putAnalogSignal ( const PCaloHit inputHit)
protectedvirtual

Reimplemented in EBHitResponse.

Definition at line 223 of file CaloHitRespoNew.cc.

References analogSignalAmplitude(), newFWLiteAna::bin, BUNCHSPACE, CaloVHitCorrection::correct(), findSignal(), PCaloHit::id(), m_hitCorrection, m_phaseShift, Parameters::parameters, params(), query::result, shape(), CaloSamples::size(), PCaloHit::time(), timeOfFlight(), CaloVShape::timeToRise(), and tzero.

Referenced by EBHitResponse::putAnalogSignal(), and run().

224 {
225  PCaloHit hit ( inputHit ) ;
226 
227  if( 0 != m_hitCorrection ) m_hitCorrection->correct( hit ) ;
228 
229  const DetId detId ( hit.id() ) ;
230 
231  const CaloSimParameters* parameters ( params( detId ) ) ;
232 
233  const double signal ( analogSignalAmplitude( hit ) ) ;
234 
235  const double jitter ( hit.time() - timeOfFlight( detId ) ) ;
236 
237  const double tzero = ( shape()->timeToRise()
238  + parameters->timePhase()
239  - jitter
240  - BUNCHSPACE*( parameters->binOfMaximum()
241  - m_phaseShift ) ) ;
242  double binTime ( tzero ) ;
243 
244  CaloSamples& result ( *findSignal( detId ) ) ;
245 
246  const unsigned int rsize ( result.size() ) ;
247 
248  for( unsigned int bin ( 0 ) ; bin != rsize ; ++bin )
249  {
250  result[ bin ] += (*shape())( binTime )*signal ;
251  binTime += BUNCHSPACE;
252  }
253 }
dictionary parameters
Definition: Parameters.py:2
double timeOfFlight(const DetId &detId) const
const CaloVShape * shape() const
Main class for Parameters in different subdetectors.
CaloSamples * findSignal(const DetId &detId)
virtual void correct(PCaloHit &hit) const =0
tuple result
Definition: query.py:137
virtual double timeToRise() const =0
double analogSignalAmplitude(const PCaloHit &hit) const
unsigned int id
Definition: DetId.h:20
const CaloSimParameters * params(const DetId &detId) const
static const double tzero[3]
const CaloVHitCorrection * m_hitCorrection
CLHEP::RandGaussQ * CaloHitRespoNew::ranGauss ( ) const
protected

Definition at line 65 of file CaloHitRespoNew.cc.

References edm::hlt::Exception, edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), and m_RandGauss.

Referenced by EBHitResponse::EBHitResponse().

66 {
67  if( 0 == m_RandGauss )
68  {
70  if ( !rng.isAvailable() )
71  {
72  throw cms::Exception("Configuration")
73  << "CaloHitRespoNew requires the RandomNumberGeneratorService\n"
74  "which is not present in the configuration file. You must add the service\n"
75  "in the configuration file or remove the modules that require it.";
76  }
77  m_RandGauss = new CLHEP::RandGaussQ( rng->getEngine() );
78  }
79  return m_RandGauss ;
80 }
CLHEP::RandGaussQ * m_RandGauss
bool isAvailable() const
Definition: Service.h:47
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
CLHEP::RandPoissonQ * CaloHitRespoNew::ranPois ( ) const
protected

Definition at line 47 of file CaloHitRespoNew.cc.

References edm::hlt::Exception, edm::RandomNumberGenerator::getEngine(), edm::Service< T >::isAvailable(), and m_RandPoisson.

Referenced by analogSignalAmplitude(), and EBHitResponse::apdSignalAmplitude().

48 {
49  if( 0 == m_RandPoisson )
50  {
52  if ( !rng.isAvailable() )
53  {
54  throw cms::Exception("Configuration")
55  << "CaloHitRespoNew requires the RandomNumberGeneratorService\n"
56  "which is not present in the configuration file. You must add the service\n"
57  "in the configuration file or remove the modules that require it.";
58  }
59  m_RandPoisson = new CLHEP::RandPoissonQ( rng->getEngine() );
60  }
61  return m_RandPoisson ;
62 }
CLHEP::RandPoissonQ * m_RandPoisson
bool isAvailable() const
Definition: Service.h:47
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
void CaloHitRespoNew::run ( MixCollection< PCaloHit > &  hits)
virtual

Definition at line 202 of file CaloHitRespoNew.cc.

References CaloVHitFilter::accepts(), MixCollection< T >::begin(), blankOutUsedSamples(), MixCollection< T >::end(), edm::detail::isnan(), m_hitFilter, m_index, m_maxBunch, m_minBunch, m_setup, putAnalogSignal(), setupSamples(), MixCollection< T >::size(), and PCaloHit::time().

203 {
204  if( !m_setup &&
205  0 < hits.size() ) setupSamples( hits.begin()->id() ) ;
206 
207  if( 0 != m_index.size() ) blankOutUsedSamples() ;
208 
209  for( MixCollection<PCaloHit>::MixItr hitItr ( hits.begin() ) ;
210  hitItr != hits.end() ; ++hitItr )
211  {
212  const PCaloHit& hit ( *hitItr ) ;
213  const int bunch ( hitItr.bunch() ) ;
214  if( m_minBunch <= bunch &&
215  m_maxBunch >= bunch &&
216  !isnan( hit.time() ) &&
217  ( 0 == m_hitFilter ||
219  }
220 }
void setupSamples(const DetId &detId)
int size() const
Definition: MixCollection.h:23
iterator end()
virtual void putAnalogSignal(const PCaloHit &inputHit)
bool isnan(float x)
Definition: math.h:13
virtual bool accepts(const PCaloHit &hit) const =0
iterator begin()
const CaloVHitFilter * m_hitFilter
unsigned int CaloHitRespoNew::samplesSize ( ) const

Definition at line 162 of file CaloHitRespoNew.cc.

References m_vSamp.

163 {
164  return m_vSamp.size() ;
165 }
void CaloHitRespoNew::setBunchRange ( int  minBunch,
int  maxBunch 
)

Definition at line 104 of file CaloHitRespoNew.cc.

References m_maxBunch, and m_minBunch.

106 {
107  m_minBunch = minBunch ;
108  m_maxBunch = maxBunch ;
109 }
void CaloHitRespoNew::setGeometry ( const CaloSubdetectorGeometry geometry)

Definition at line 112 of file CaloHitRespoNew.cc.

References geometry(), and m_geometry.

Referenced by EcalTBDigiProducer::produce(), and EcalDigiProducer::updateGeometry().

113 {
114  m_geometry = geometry ;
115 }
const CaloSubdetectorGeometry * geometry() const
const CaloSubdetectorGeometry * m_geometry
void CaloHitRespoNew::setHitCorrection ( const CaloVHitCorrection hitCorrection)

Definition at line 136 of file CaloHitRespoNew.cc.

References m_hitCorrection.

137 {
138  m_hitCorrection = hitCorrection ;
139 }
const CaloVHitCorrection * m_hitCorrection
void CaloHitRespoNew::setHitFilter ( const CaloVHitFilter filter)

Definition at line 130 of file CaloHitRespoNew.cc.

References align_tpl::filter, and m_hitFilter.

131 {
132  m_hitFilter = filter ;
133 }
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 * m_hitFilter
void CaloHitRespoNew::setPECorrection ( const CaloVPECorrection peCorrection)

Definition at line 142 of file CaloHitRespoNew.cc.

References m_PECorrection.

143 {
144  m_PECorrection = peCorrection ;
145 }
const CaloVPECorrection * m_PECorrection
void CaloHitRespoNew::setPhaseShift ( double  phaseShift)

Definition at line 118 of file CaloHitRespoNew.cc.

References m_phaseShift, and phaseShift().

Referenced by EcalDigiProducer::EcalDigiProducer(), and EcalTBDigiProducer::setPhaseShift().

119 {
121 }
double phaseShift() const
void CaloHitRespoNew::setRandomEngine ( CLHEP::HepRandomEngine &  engine) const
virtual

Definition at line 148 of file CaloHitRespoNew.cc.

References m_RandGauss, and m_RandPoisson.

149 {
150  m_RandPoisson = new CLHEP::RandPoissonQ( engine ) ;
151  m_RandGauss = new CLHEP::RandGaussQ( engine ) ;
152 }
CLHEP::RandPoissonQ * m_RandPoisson
CLHEP::RandGaussQ * m_RandGauss
void CaloHitRespoNew::setupSamples ( const DetId detId)
protected

Definition at line 168 of file CaloHitRespoNew.cc.

References CaloSimParameters::binOfMaximum(), DetId::det(), i, m_setup, m_vSamp, Parameters::parameters, params(), CaloSimParameters::readoutFrameSize(), findQualityFiles::size, DetId::subdetId(), and funct::true.

Referenced by run().

169 {
170  const CaloSimParameters& parameters ( *params( detId ) ) ;
171 
172  const unsigned int rSize ( parameters.readoutFrameSize() ) ;
173  const unsigned int nPre ( parameters.binOfMaximum() - 1 ) ;
174 
175  m_vSamp = VecSam( CaloGenericDetId( detId ).sizeForDenseIndexing() ) ;
176 
177  const unsigned int size ( m_vSamp.size() ) ;
178 
179  for( unsigned int i ( 0 ) ; i != size ; ++i )
180  {
181  m_vSamp[ i ].setDetId( CaloGenericDetId( detId.det(), detId.subdetId(), i ) ) ;
182  m_vSamp[ i ].setSize( rSize ) ;
183  m_vSamp[ i ].setPresamples( nPre ) ;
184  }
185  m_setup = true ;
186 }
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
Main class for Parameters in different subdetectors.
std::vector< CaloSamples > VecSam
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
const CaloSimParameters * params(const DetId &detId) const
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
tuple size
Write out results.
const CaloVShape * CaloHitRespoNew::shape ( ) const
protected

Definition at line 90 of file CaloHitRespoNew.cc.

References m_shape.

Referenced by putAnalogSignal().

91 {
92  assert( 0 != m_shape ) ;
93  return m_shape ;
94 }
const CaloVShape * m_shape
double CaloHitRespoNew::timeOfFlight ( const DetId detId) const
protected

Definition at line 284 of file CaloHitRespoNew.cc.

References geometry(), CaloCellGeometry::getPosition(), and PV3DBase< T, PVType, FrameType >::mag().

Referenced by EBHitResponse::putAnalogSignal(), and putAnalogSignal().

285 {
286  const CaloCellGeometry* cellGeometry ( geometry()->getGeometry( detId ) ) ;
287  assert( 0 != cellGeometry ) ;
288  return cellGeometry->getPosition().mag()*cm/c_light ; // Units of c_light: mm/ns
289 }
const CaloSubdetectorGeometry * geometry() const

Member Data Documentation

const CaloSubdetectorGeometry* CaloHitRespoNew::m_geometry
private

Definition at line 102 of file CaloHitRespoNew.h.

Referenced by geometry(), and setGeometry().

const CaloVHitCorrection* CaloHitRespoNew::m_hitCorrection
private

Definition at line 99 of file CaloHitRespoNew.h.

Referenced by putAnalogSignal(), and setHitCorrection().

const CaloVHitFilter* CaloHitRespoNew::m_hitFilter
private

Definition at line 101 of file CaloHitRespoNew.h.

Referenced by run(), and setHitFilter().

VecInd CaloHitRespoNew::m_index
private

Definition at line 114 of file CaloHitRespoNew.h.

Referenced by blankOutUsedSamples(), findSignal(), and run().

int CaloHitRespoNew::m_maxBunch
private

Definition at line 109 of file CaloHitRespoNew.h.

Referenced by run(), and setBunchRange().

int CaloHitRespoNew::m_minBunch
private

Definition at line 108 of file CaloHitRespoNew.h.

Referenced by run(), and setBunchRange().

const CaloVSimParameterMap* CaloHitRespoNew::m_parameterMap
private

Definition at line 97 of file CaloHitRespoNew.h.

Referenced by params().

const CaloVPECorrection* CaloHitRespoNew::m_PECorrection
private

Definition at line 100 of file CaloHitRespoNew.h.

Referenced by analogSignalAmplitude(), and setPECorrection().

double CaloHitRespoNew::m_phaseShift
private

Definition at line 110 of file CaloHitRespoNew.h.

Referenced by phaseShift(), putAnalogSignal(), and setPhaseShift().

CLHEP::RandGaussQ* CaloHitRespoNew::m_RandGauss
mutableprivate

Definition at line 106 of file CaloHitRespoNew.h.

Referenced by ranGauss(), setRandomEngine(), and ~CaloHitRespoNew().

CLHEP::RandPoissonQ* CaloHitRespoNew::m_RandPoisson
mutableprivate

Definition at line 104 of file CaloHitRespoNew.h.

Referenced by ranPois(), setRandomEngine(), and ~CaloHitRespoNew().

bool CaloHitRespoNew::m_setup
private

Definition at line 111 of file CaloHitRespoNew.h.

Referenced by run(), and setupSamples().

const CaloVShape* CaloHitRespoNew::m_shape
private

Definition at line 98 of file CaloHitRespoNew.h.

Referenced by shape().

VecSam CaloHitRespoNew::m_vSamp
private