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

virtual void add (const PCaloHit &hit)
 
 CaloHitRespoNew (const CaloVSimParameterMap *parameterMap, const CaloVShape *shape, const DetId detId)
 
virtual void finalizeHits ()
 
virtual void initializeHits ()
 
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
 
bool withinBunchRange (int bunchCrossing) const
 
virtual ~CaloHitRespoNew ()
 

Protected Member Functions

double analogSignalAmplitude (const DetId &id, float energy) 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 24 of file CaloHitRespoNew.cc.

References setupSamples().

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

References m_RandGauss, and m_RandPoisson.

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

Member Function Documentation

void CaloHitRespoNew::add ( const PCaloHit hit)
virtual

Definition at line 218 of file CaloHitRespoNew.cc.

References CaloVHitFilter::accepts(), edm::isNotFinite(), m_hitFilter, putAnalogSignal(), and PCaloHit::time().

Referenced by run().

219 {
220  if( !edm::isNotFinite( hit.time() ) &&
221  ( 0 == m_hitFilter ||
222  m_hitFilter->accepts( hit ) ) ) putAnalogSignal( hit ) ;
223 }
double time() const
Definition: PCaloHit.h:36
virtual void putAnalogSignal(const PCaloHit &inputHit)
bool isNotFinite(T x)
Definition: isFinite.h:10
virtual bool accepts(const PCaloHit &hit) const =0
const CaloVHitFilter * m_hitFilter
double CaloHitRespoNew::analogSignalAmplitude ( const DetId id,
float  energy 
) const
protected

Definition at line 269 of file CaloHitRespoNew.cc.

References CaloVPECorrection::correctPE(), CaloSimParameters::doPhotostatistics(), m_PECorrection, Parameters::parameters, params(), ranPois(), and CaloSimParameters::simHitToPhotoelectrons().

Referenced by putAnalogSignal().

270 {
271  const CaloSimParameters& parameters ( *params( detId ) ) ;
272 
273  // OK, the "energy" in the hit could be a real energy, deposited energy,
274  // or pe count. This factor converts to photoelectrons
275 
276  double npe ( energy*parameters.simHitToPhotoelectrons( detId ) ) ;
277 
278  // do we need to doPoisson statistics for the photoelectrons?
279  if( parameters.doPhotostatistics() ) npe = ranPois()->fire( npe ) ;
280 
281  if( 0 != m_PECorrection ) npe = m_PECorrection->correctPE( detId, npe ) ;
282 
283  return npe ;
284 }
dictionary parameters
Definition: Parameters.py:2
const CaloVPECorrection * m_PECorrection
Main class for Parameters in different subdetectors.
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 190 of file CaloHitRespoNew.cc.

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

Referenced by run().

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

Definition at line 74 of file CaloHitRespoNew.h.

74 {}
CaloSamples * CaloHitRespoNew::findSignal ( const DetId detId)
protected

Definition at line 261 of file CaloHitRespoNew.cc.

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

Referenced by putAnalogSignal().

262 {
263  CaloSamples& result ( m_vSamp[ CaloGenericDetId( detId ).denseIndex() ] ) ;
264  if( result.isBlank() ) m_index.push_back( &result - &m_vSamp.front() ) ;
265  return &result ;
266 }
tuple result
Definition: query.py:137
const CaloSubdetectorGeometry * CaloHitRespoNew::geometry ( ) const
protected

Definition at line 99 of file CaloHitRespoNew.cc.

References m_geometry.

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

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

Definition at line 113 of file CaloHitRespoNew.h.

References m_hitFilter.

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

Definition at line 111 of file CaloHitRespoNew.h.

References m_index.

Referenced by BeautifulSoup.PageElement::_invert().

111 { return m_index ; }
virtual void CaloHitRespoNew::initializeHits ( )
inlinevirtual

Definition at line 72 of file CaloHitRespoNew.h.

72 {}
int CaloHitRespoNew::maxBunch ( ) const
inlineprotected

Definition at line 109 of file CaloHitRespoNew.h.

References m_maxBunch.

Referenced by setBunchRange().

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

Definition at line 107 of file CaloHitRespoNew.h.

References m_minBunch.

Referenced by setBunchRange().

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

Definition at line 157 of file CaloHitRespoNew.cc.

References i, and m_vSamp.

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

Definition at line 85 of file CaloHitRespoNew.cc.

References m_parameterMap, and CaloVSimParameterMap::simParameters().

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

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

Definition at line 126 of file CaloHitRespoNew.cc.

References m_phaseShift.

Referenced by setPhaseShift().

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

Definition at line 226 of file CaloHitRespoNew.cc.

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

Referenced by add().

227 {
228  const DetId detId ( hit.id() ) ;
229 
230  const CaloSimParameters* parameters ( params( detId ) ) ;
231 
232  const double signal ( analogSignalAmplitude( detId, hit.energy() ) ) ;
233 
234  double time = hit.time();
235 
236  if( m_hitCorrection ) {
237  time += m_hitCorrection->delay( hit ) ;
238  }
239 
240  const double jitter ( time - timeOfFlight( detId ) ) ;
241 
242  const double tzero = ( shape()->timeToRise()
243  + parameters->timePhase()
244  - jitter
245  - BUNCHSPACE*( parameters->binOfMaximum()
246  - m_phaseShift ) ) ;
247  double binTime ( tzero ) ;
248 
249  CaloSamples& result ( *findSignal( detId ) ) ;
250 
251  const unsigned int rsize ( result.size() ) ;
252 
253  for( unsigned int bin ( 0 ) ; bin != rsize ; ++bin )
254  {
255  result[ bin ] += (*shape())( binTime )*signal ;
256  binTime += BUNCHSPACE;
257  }
258 }
dictionary parameters
Definition: Parameters.py:2
double timeOfFlight(const DetId &detId) const
const CaloVShape * shape() const
Main class for Parameters in different subdetectors.
virtual double delay(const PCaloHit &hit) const =0
CaloSamples * findSignal(const DetId &detId)
double analogSignalAmplitude(const DetId &id, float energy) const
tuple result
Definition: query.py:137
virtual double timeToRise() const =0
unsigned int id
Definition: DetId.h:18
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 67 of file CaloHitRespoNew.cc.

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

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

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

Referenced by analogSignalAmplitude().

50 {
51  if( 0 == m_RandPoisson )
52  {
54  if ( !rng.isAvailable() )
55  {
56  throw cms::Exception("Configuration")
57  << "CaloHitRespoNew requires the RandomNumberGeneratorService\n"
58  "which is not present in the configuration file. You must add the service\n"
59  "in the configuration file or remove the modules that require it.";
60  }
61  m_RandPoisson = new CLHEP::RandPoissonQ( rng->getEngine() );
62  }
63  return m_RandPoisson ;
64 }
CLHEP::RandPoissonQ * m_RandPoisson
bool isAvailable() const
Definition: Service.h:46
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 203 of file CaloHitRespoNew.cc.

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

204 {
205  if( 0 != m_index.size() ) blankOutUsedSamples() ;
206 
207  for( MixCollection<PCaloHit>::MixItr hitItr ( hits.begin() ) ;
208  hitItr != hits.end() ; ++hitItr )
209  {
210  if(withinBunchRange(hitItr.bunch())) {
211  add(*hitItr);
212  }
213 
214  }
215 }
bool withinBunchRange(int bunchCrossing) const
virtual void add(const PCaloHit &hit)
iterator end()
iterator begin()
unsigned int CaloHitRespoNew::samplesSize ( ) const

Definition at line 164 of file CaloHitRespoNew.cc.

References m_vSamp.

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

Definition at line 106 of file CaloHitRespoNew.cc.

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

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

Definition at line 114 of file CaloHitRespoNew.cc.

References geometry(), and m_geometry.

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

Definition at line 138 of file CaloHitRespoNew.cc.

References m_hitCorrection.

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

Definition at line 132 of file CaloHitRespoNew.cc.

References alcazmumu_cfi::filter, and m_hitFilter.

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

Definition at line 144 of file CaloHitRespoNew.cc.

References m_PECorrection.

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

Definition at line 120 of file CaloHitRespoNew.cc.

References m_phaseShift, and phaseShift().

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

Definition at line 150 of file CaloHitRespoNew.cc.

References m_RandGauss, and m_RandPoisson.

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

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

171 {
172  const CaloSimParameters& parameters ( *params( detId ) ) ;
173 
174  const unsigned int rSize ( parameters.readoutFrameSize() ) ;
175  const unsigned int nPre ( parameters.binOfMaximum() - 1 ) ;
176 
177  m_vSamp = VecSam( CaloGenericDetId( detId ).sizeForDenseIndexing() ) ;
178 
179  const unsigned int size ( m_vSamp.size() ) ;
180 
181  for( unsigned int i ( 0 ) ; i != size ; ++i )
182  {
183  m_vSamp[ i ].setDetId( CaloGenericDetId( detId.det(), detId.subdetId(), i ) ) ;
184  m_vSamp[ i ].setSize( rSize ) ;
185  m_vSamp[ i ].setPresamples( nPre ) ;
186  }
187 }
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:37
const CaloSimParameters * params(const DetId &detId) const
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
tuple size
Write out results.
const CaloVShape * CaloHitRespoNew::shape ( void  ) const
protected

Definition at line 92 of file CaloHitRespoNew.cc.

References m_shape.

Referenced by putAnalogSignal().

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

Definition at line 287 of file CaloHitRespoNew.cc.

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

Referenced by putAnalogSignal().

288 {
289  const CaloCellGeometry* cellGeometry ( geometry()->getGeometry( detId ) ) ;
290  assert( 0 != cellGeometry ) ;
291  return cellGeometry->getPosition().mag()*cm/c_light ; // Units of c_light: mm/ns
292 }
const CaloSubdetectorGeometry * geometry() const
bool CaloHitRespoNew::withinBunchRange ( int  bunchCrossing) const
inline

Definition at line 76 of file CaloHitRespoNew.h.

References m_maxBunch, and m_minBunch.

Referenced by run().

76  {
77  return(bunchCrossing >= m_minBunch && bunchCrossing <= m_maxBunch);
78  }

Member Data Documentation

const CaloSubdetectorGeometry* CaloHitRespoNew::m_geometry
private

Definition at line 122 of file CaloHitRespoNew.h.

Referenced by geometry(), and setGeometry().

const CaloVHitCorrection* CaloHitRespoNew::m_hitCorrection
private

Definition at line 119 of file CaloHitRespoNew.h.

Referenced by putAnalogSignal(), and setHitCorrection().

const CaloVHitFilter* CaloHitRespoNew::m_hitFilter
private

Definition at line 121 of file CaloHitRespoNew.h.

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

VecInd CaloHitRespoNew::m_index
private

Definition at line 133 of file CaloHitRespoNew.h.

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

int CaloHitRespoNew::m_maxBunch
private

Definition at line 129 of file CaloHitRespoNew.h.

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

int CaloHitRespoNew::m_minBunch
private

Definition at line 128 of file CaloHitRespoNew.h.

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

const CaloVSimParameterMap* CaloHitRespoNew::m_parameterMap
private

Definition at line 117 of file CaloHitRespoNew.h.

Referenced by params().

const CaloVPECorrection* CaloHitRespoNew::m_PECorrection
private

Definition at line 120 of file CaloHitRespoNew.h.

Referenced by analogSignalAmplitude(), and setPECorrection().

double CaloHitRespoNew::m_phaseShift
private

Definition at line 130 of file CaloHitRespoNew.h.

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

CLHEP::RandGaussQ* CaloHitRespoNew::m_RandGauss
mutableprivate

Definition at line 126 of file CaloHitRespoNew.h.

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

CLHEP::RandPoissonQ* CaloHitRespoNew::m_RandPoisson
mutableprivate

Definition at line 124 of file CaloHitRespoNew.h.

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

const CaloVShape* CaloHitRespoNew::m_shape
private

Definition at line 118 of file CaloHitRespoNew.h.

Referenced by shape().

VecSam CaloHitRespoNew::m_vSamp
private