CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBHitResponse.cc
Go to the documentation of this file.
6 #include "CLHEP/Random/RandPoissonQ.h"
7 #include "CLHEP/Random/RandGaussQ.h"
9 
10 
12  const CaloVShape* shape ,
13  bool apdOnly ,
14  const APDSimParameters* apdPars = 0 ,
15  const CaloVShape* apdShape = 0 ) :
16 
17  CaloHitResponse( parameterMap,
18  shape ),
19 
20  m_apdOnly ( apdOnly ) ,
21  m_apdPars ( apdPars ) ,
22  m_apdShape ( apdShape ) ,
23  m_timeOffVec ( kNOffsets, apdParameters()->timeOffset() )
24 {
25  for( unsigned int i ( 0 ) ; i != kNOffsets ; ++i )
26  {
27  m_timeOffVec[ i ] +=
28  ranGauss()->fire( 0 , apdParameters()->timeOffWidth() ) ;
29  }
30 }
31 
33 {
34 }
35 
36 
37 const APDSimParameters*
39 {
40  assert ( 0 != m_apdPars ) ;
41  return m_apdPars ;
42 }
43 
44 const CaloVShape*
46 {
47  assert( 0 != m_apdShape ) ;
48  return m_apdShape ;
49 }
50 
51 void
53 {
54  const unsigned int depth ( hit.depth() ) ;
55  if( !m_apdOnly &&
56  0 == depth )
57  {
59  }
60  else
61  {
62  if( 0 != depth &&
63  ( apdParameters()->addToBarrel() ||
64  m_apdOnly ) ) // can digitize apd
65  {
66  const DetId detId ( hit.id() ) ;
67  CaloSamples& result ( *findSignal( detId ) );
68 
69 // edm::LogError( "EBHitResponse" )<<"---APD SimHit found for "
70 /* std::cout<<"---APD SimHit found for "
71  << EBDetId( detId )
72  <<", depth="<< depth
73  <<std::endl ;*/
74 
75  const double signal ( apdSignalAmplitude( hit ) ) ;
76 
77  const CaloSimParameters& parameters ( *params( detId ) ) ;
78 
79  const double jitter ( hit.time() - timeOfFlight( detId ) ) ;
80 
81  const double tzero ( apdShape()->timeToRise()
82  - jitter
83  - offsets()[ EBDetId( detId ).denseIndex()%kNOffsets ]
84  - BUNCHSPACE*( parameters.binOfMaximum()
85  - phaseShift() ) ) ;
86  double binTime ( tzero ) ;
87 
88  for( int bin ( 0 ) ; bin != result.size(); ++bin )
89  {
90  result[bin] += (*apdShape())(binTime)*signal;
91  binTime += BUNCHSPACE;
92  }
93  }
94  }
95 }
96 
97 double
99 {
100  assert( 1 == hit.depth() ||
101  2 == hit.depth() ) ;
102 
103  double npe ( hit.energy()*( 2 == hit.depth() ?
105  apdParameters()->simToPEHigh() ) ) ;
106 
107  // do we need to doPoisson statistics for the photoelectrons?
108  if( apdParameters()->doPEStats() &&
109  !m_apdOnly ) npe = ranPois()->fire( npe ) ;
110 
111  assert( 0 != m_intercal ) ;
112  double fac ( 1 ) ;
113  findIntercalibConstant( hit.id(), fac ) ;
114 
115  npe *= fac ;
116 // edm::LogError( "EBHitResponse" ) << "--- # photoelectrons for "
117 /* std::cout << "--- # photoelectrons for "
118  << EBDetId( hit.id() )
119  <<" is " << npe //;
120  <<std::endl ;*/
121 
122  return npe ;
123 }
124 
125 void
127 {
128  m_intercal = ical ;
129 }
130 
131 void
133  double& icalconst ) const
134 {
135  EcalIntercalibConstantMC thisconst ( 1. ) ;
136 
137  if( 0 == m_intercal )
138  {
139  edm::LogError( "EBHitResponse" ) <<
140  "No intercal constant defined for EBHitResponse" ;
141  }
142  else
143  {
144  const EcalIntercalibConstantMCMap& icalMap ( m_intercal->getMap() ) ;
145  EcalIntercalibConstantMCMap::const_iterator icalit ( icalMap.find( detId ) ) ;
146  if( icalit != icalMap.end() )
147  {
148  thisconst = *icalit ;
149  if ( thisconst == 0. ) thisconst = 1. ;
150  }
151  else
152  {
153  edm::LogError("EBHitResponse") << "No intercalib const found for xtal "
154  << detId.rawId()
155  << "! something wrong with EcalIntercalibConstants in your DB? ";
156  }
157  }
158  icalconst = thisconst ;
159 }
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
double time() const
Definition: PCaloHit.h:34
double simToPEHigh() const
double timeOfFlight(const DetId &detId) const
const self & getMap() const
Creates electronics signals from hits.
double energy() const
Definition: PCaloHit.h:29
const CaloVShape * m_apdShape
Definition: EBHitResponse.h:57
Electronic response of the preamp.
Definition: CaloVShape.h:11
uint16_t depth() const
Definition: PCaloHit.h:45
const APDSimParameters * apdParameters() const
const APDSimParameters * m_apdPars
Definition: EBHitResponse.h:56
Main class for Parameters in different subdetectors.
CaloSamples * findSignal(const DetId &detId)
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
double phaseShift() const
CLHEP::RandGaussQ * ranGauss() const
void findIntercalibConstant(const DetId &detId, double &icalconst) const
virtual void putAnalogSignal(const PCaloHit &inputHit)
void setIntercal(const EcalIntercalibConstantsMC *ical)
const VecD & offsets() const
Definition: EBHitResponse.h:39
tuple result
Definition: query.py:137
unsigned int id() const
Definition: PCaloHit.h:40
const EcalIntercalibConstantsMC * m_intercal
Definition: EBHitResponse.h:58
std::vector< double > m_timeOffVec
Definition: EBHitResponse.h:60
EBHitResponse(const CaloVSimParameterMap *parameterMap, const CaloVShape *shape, bool apdOnly, const APDSimParameters *apdPars, const CaloVShape *apdShape)
Definition: DetId.h:20
virtual ~EBHitResponse()
std::vector< Item >::const_iterator const_iterator
virtual void putAnalogSignal(const PCaloHit &inputHit)
const CaloSimParameters * params(const DetId &detId) const
static const double tzero[3]
float EcalIntercalibConstantMC
CLHEP::RandPoissonQ * ranPois() const
double apdSignalAmplitude(const PCaloHit &hit) const
const bool m_apdOnly
Definition: EBHitResponse.h:55
int binOfMaximum() const
double simToPELow() const
const CaloVShape * apdShape() const