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>

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 DetId detId)
 
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 CaloVHitFilterhitFilter () const
 
VecIndindex ()
 
int maxBunch () const
 
int minBunch () 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
 
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,
const DetId  detId 
)

Definition at line 23 of file CaloHitRespoNew.cc.

References setupSamples().

25  :
26  m_parameterMap ( parameterMap ) ,
27  m_shape ( shape ) ,
28  m_hitCorrection ( 0 ) ,
29  m_PECorrection ( 0 ) ,
30  m_hitFilter ( 0 ) ,
31  m_geometry ( 0 ) ,
32  m_RandPoisson ( 0 ) ,
33  m_RandGauss ( 0 ) ,
34  m_minBunch ( -10 ) ,
35  m_maxBunch ( 10 ) ,
36  m_phaseShift ( 1 )
37 {
38  setupSamples( detId ) ;
39 }
void setupSamples(const DetId &detId)
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 41 of file CaloHitRespoNew.cc.

References m_RandGauss, and m_RandPoisson.

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

Member Function Documentation

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

Definition at line 261 of file CaloHitRespoNew.cc.

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

Referenced by putAnalogSignal().

262 {
263  const DetId& detId ( hit.id() ) ;
264 
265  const CaloSimParameters& parameters ( *params( detId ) ) ;
266 
267  // OK, the "energy" in the hit could be a real energy, deposited energy,
268  // or pe count. This factor converts to photoelectrons
269 
270  double npe ( hit.energy()*parameters.simHitToPhotoelectrons( detId ) ) ;
271 
272  // do we need to doPoisson statistics for the photoelectrons?
273  if( parameters.doPhotostatistics() ) npe = ranPois()->fire( npe ) ;
274 
275  if( 0 != m_PECorrection ) npe = m_PECorrection->correctPE( detId, npe ) ;
276 
277  return npe ;
278 }
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 253 of file CaloHitRespoNew.cc.

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

Referenced by putAnalogSignal().

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

Definition at line 98 of file CaloHitRespoNew.cc.

References m_geometry.

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

99 {
100  assert( 0 != m_geometry ) ;
101  return m_geometry ;
102 }
const CaloSubdetectorGeometry * m_geometry
const CaloVHitFilter* CaloHitRespoNew::hitFilter ( ) const
inlineprotected

Definition at line 102 of file CaloHitRespoNew.h.

References m_hitFilter.

102 { return m_hitFilter ; }
const CaloVHitFilter * m_hitFilter
VecInd& CaloHitRespoNew::index ( )
inlineprotected

Definition at line 100 of file CaloHitRespoNew.h.

References m_index.

Referenced by BeautifulSoup.PageElement::_invert().

100 { return m_index ; }
int CaloHitRespoNew::maxBunch ( ) const
inlineprotected

Definition at line 98 of file CaloHitRespoNew.h.

References m_maxBunch.

Referenced by setBunchRange().

98 { return m_maxBunch ; }
int CaloHitRespoNew::minBunch ( ) const
inlineprotected

Definition at line 96 of file CaloHitRespoNew.h.

References m_minBunch.

Referenced by setBunchRange().

96 { return m_minBunch ; }
const CaloSamples & CaloHitRespoNew::operator[] ( unsigned int  i) const

Definition at line 156 of file CaloHitRespoNew.cc.

References i, and m_vSamp.

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

Definition at line 84 of file CaloHitRespoNew.cc.

References m_parameterMap, and CaloVSimParameterMap::simParameters().

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

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

Definition at line 125 of file CaloHitRespoNew.cc.

References m_phaseShift.

Referenced by setPhaseShift().

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

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

221 {
222  PCaloHit hit ( inputHit ) ;
223 
224  if( 0 != m_hitCorrection ) m_hitCorrection->correct( hit ) ;
225 
226  const DetId detId ( hit.id() ) ;
227 
228  const CaloSimParameters* parameters ( params( detId ) ) ;
229 
230  const double signal ( analogSignalAmplitude( hit ) ) ;
231 
232  const double jitter ( hit.time() - timeOfFlight( detId ) ) ;
233 
234  const double tzero = ( shape()->timeToRise()
235  + parameters->timePhase()
236  - jitter
237  - BUNCHSPACE*( parameters->binOfMaximum()
238  - m_phaseShift ) ) ;
239  double binTime ( tzero ) ;
240 
241  CaloSamples& result ( *findSignal( detId ) ) ;
242 
243  const unsigned int rsize ( result.size() ) ;
244 
245  for( unsigned int bin ( 0 ) ; bin != rsize ; ++bin )
246  {
247  result[ bin ] += (*shape())( binTime )*signal ;
248  binTime += BUNCHSPACE;
249  }
250 }
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 66 of file CaloHitRespoNew.cc.

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

67 {
68  if( 0 == m_RandGauss )
69  {
71  if ( !rng.isAvailable() )
72  {
73  throw cms::Exception("Configuration")
74  << "CaloHitRespoNew requires the RandomNumberGeneratorService\n"
75  "which is not present in the configuration file. You must add the service\n"
76  "in the configuration file or remove the modules that require it.";
77  }
78  m_RandGauss = new CLHEP::RandGaussQ( rng->getEngine() );
79  }
80  return m_RandGauss ;
81 }
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 48 of file CaloHitRespoNew.cc.

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

Referenced by analogSignalAmplitude().

49 {
50  if( 0 == m_RandPoisson )
51  {
53  if ( !rng.isAvailable() )
54  {
55  throw cms::Exception("Configuration")
56  << "CaloHitRespoNew requires the RandomNumberGeneratorService\n"
57  "which is not present in the configuration file. You must add the service\n"
58  "in the configuration file or remove the modules that require it.";
59  }
60  m_RandPoisson = new CLHEP::RandPoissonQ( rng->getEngine() );
61  }
62  return m_RandPoisson ;
63 }
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, putAnalogSignal(), and PCaloHit::time().

203 {
204  if( 0 != m_index.size() ) blankOutUsedSamples() ;
205 
206  for( MixCollection<PCaloHit>::MixItr hitItr ( hits.begin() ) ;
207  hitItr != hits.end() ; ++hitItr )
208  {
209  const PCaloHit& hit ( *hitItr ) ;
210  const int bunch ( hitItr.bunch() ) ;
211  if( m_minBunch <= bunch &&
212  m_maxBunch >= bunch &&
213  !isnan( hit.time() ) &&
214  ( 0 == m_hitFilter ||
216  }
217 }
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 163 of file CaloHitRespoNew.cc.

References m_vSamp.

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

Definition at line 105 of file CaloHitRespoNew.cc.

References m_maxBunch, m_minBunch, maxBunch(), and minBunch().

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

Definition at line 113 of file CaloHitRespoNew.cc.

References geometry(), and m_geometry.

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

Definition at line 137 of file CaloHitRespoNew.cc.

References m_hitCorrection.

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

Definition at line 131 of file CaloHitRespoNew.cc.

References alcazmumu_cfi::filter, and m_hitFilter.

132 {
133  m_hitFilter = filter ;
134 }
const CaloVHitFilter * m_hitFilter
void CaloHitRespoNew::setPECorrection ( const CaloVPECorrection peCorrection)

Definition at line 143 of file CaloHitRespoNew.cc.

References m_PECorrection.

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

Definition at line 119 of file CaloHitRespoNew.cc.

References m_phaseShift, and phaseShift().

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

Definition at line 149 of file CaloHitRespoNew.cc.

References m_RandGauss, and m_RandPoisson.

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

Definition at line 169 of file CaloHitRespoNew.cc.

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

Referenced by CaloHitRespoNew().

170 {
171  const CaloSimParameters& parameters ( *params( detId ) ) ;
172 
173  const unsigned int rSize ( parameters.readoutFrameSize() ) ;
174  const unsigned int nPre ( parameters.binOfMaximum() - 1 ) ;
175 
176  m_vSamp = VecSam( CaloGenericDetId( detId ).sizeForDenseIndexing() ) ;
177 
178  const unsigned int size ( m_vSamp.size() ) ;
179 
180  for( unsigned int i ( 0 ) ; i != size ; ++i )
181  {
182  m_vSamp[ i ].setDetId( CaloGenericDetId( detId.det(), detId.subdetId(), i ) ) ;
183  m_vSamp[ i ].setSize( rSize ) ;
184  m_vSamp[ i ].setPresamples( nPre ) ;
185  }
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 ( void  ) const
protected

Definition at line 91 of file CaloHitRespoNew.cc.

References m_shape.

Referenced by putAnalogSignal().

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

Definition at line 281 of file CaloHitRespoNew.cc.

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

Referenced by putAnalogSignal().

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

Member Data Documentation

const CaloSubdetectorGeometry* CaloHitRespoNew::m_geometry
private

Definition at line 111 of file CaloHitRespoNew.h.

Referenced by geometry(), and setGeometry().

const CaloVHitCorrection* CaloHitRespoNew::m_hitCorrection
private

Definition at line 108 of file CaloHitRespoNew.h.

Referenced by putAnalogSignal(), and setHitCorrection().

const CaloVHitFilter* CaloHitRespoNew::m_hitFilter
private

Definition at line 110 of file CaloHitRespoNew.h.

Referenced by hitFilter(), run(), and setHitFilter().

VecInd CaloHitRespoNew::m_index
private

Definition at line 122 of file CaloHitRespoNew.h.

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

int CaloHitRespoNew::m_maxBunch
private

Definition at line 118 of file CaloHitRespoNew.h.

Referenced by maxBunch(), run(), and setBunchRange().

int CaloHitRespoNew::m_minBunch
private

Definition at line 117 of file CaloHitRespoNew.h.

Referenced by minBunch(), run(), and setBunchRange().

const CaloVSimParameterMap* CaloHitRespoNew::m_parameterMap
private

Definition at line 106 of file CaloHitRespoNew.h.

Referenced by params().

const CaloVPECorrection* CaloHitRespoNew::m_PECorrection
private

Definition at line 109 of file CaloHitRespoNew.h.

Referenced by analogSignalAmplitude(), and setPECorrection().

double CaloHitRespoNew::m_phaseShift
private

Definition at line 119 of file CaloHitRespoNew.h.

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

CLHEP::RandGaussQ* CaloHitRespoNew::m_RandGauss
mutableprivate

Definition at line 115 of file CaloHitRespoNew.h.

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

CLHEP::RandPoissonQ* CaloHitRespoNew::m_RandPoisson
mutableprivate

Definition at line 113 of file CaloHitRespoNew.h.

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

const CaloVShape* CaloHitRespoNew::m_shape
private

Definition at line 107 of file CaloHitRespoNew.h.

Referenced by shape().

VecSam CaloHitRespoNew::m_vSamp
private