Go to the documentation of this file.00001 #include "SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h"
00002 #include "SimCalorimetry/EcalSimAlgos/interface/APDSimParameters.h"
00003 #include "SimCalorimetry/CaloSimAlgos/interface/CaloVSimParameterMap.h"
00004 #include "SimCalorimetry/CaloSimAlgos/interface/CaloSimParameters.h"
00005 #include "SimCalorimetry/CaloSimAlgos/interface/CaloVShape.h"
00006 #include "CLHEP/Random/RandPoissonQ.h"
00007 #include "CLHEP/Random/RandGaussQ.h"
00008 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00009
00010
00011 EBHitResponse::EBHitResponse( const CaloVSimParameterMap* parameterMap ,
00012 const CaloVShape* shape ,
00013 bool apdOnly ,
00014 const APDSimParameters* apdPars = 0 ,
00015 const CaloVShape* apdShape = 0 ) :
00016
00017 CaloHitResponse( parameterMap,
00018 shape ),
00019
00020 m_apdOnly ( apdOnly ) ,
00021 m_apdPars ( apdPars ) ,
00022 m_apdShape ( apdShape ) ,
00023 m_timeOffVec ( kNOffsets, apdParameters()->timeOffset() )
00024 {
00025 for( unsigned int i ( 0 ) ; i != kNOffsets ; ++i )
00026 {
00027 m_timeOffVec[ i ] +=
00028 ranGauss()->fire( 0 , apdParameters()->timeOffWidth() ) ;
00029 }
00030 }
00031
00032 EBHitResponse::~EBHitResponse()
00033 {
00034 }
00035
00036
00037 const APDSimParameters*
00038 EBHitResponse::apdParameters() const
00039 {
00040 assert ( 0 != m_apdPars ) ;
00041 return m_apdPars ;
00042 }
00043
00044 const CaloVShape*
00045 EBHitResponse::apdShape() const
00046 {
00047 assert( 0 != m_apdShape ) ;
00048 return m_apdShape ;
00049 }
00050
00051 void
00052 EBHitResponse::putAnalogSignal( const PCaloHit& hit )
00053 {
00054 const unsigned int depth ( hit.depth() ) ;
00055 if( !m_apdOnly &&
00056 0 == depth )
00057 {
00058 CaloHitResponse::putAnalogSignal( hit ) ;
00059 }
00060 else
00061 {
00062 if( 0 != depth &&
00063 ( apdParameters()->addToBarrel() ||
00064 m_apdOnly ) )
00065 {
00066 const DetId detId ( hit.id() ) ;
00067 CaloSamples& result ( *findSignal( detId ) );
00068
00069
00070
00071
00072
00073
00074
00075 const double signal ( apdSignalAmplitude( hit ) ) ;
00076
00077 const CaloSimParameters& parameters ( *params( detId ) ) ;
00078
00079 const double jitter ( hit.time() - timeOfFlight( detId ) ) ;
00080
00081 const double tzero ( apdShape()->timeToRise()
00082 - jitter
00083 - offsets()[ EBDetId( detId ).denseIndex()%kNOffsets ]
00084 - BUNCHSPACE*( parameters.binOfMaximum()
00085 - phaseShift() ) ) ;
00086 double binTime ( tzero ) ;
00087
00088 for( int bin ( 0 ) ; bin != result.size(); ++bin )
00089 {
00090 result[bin] += (*apdShape())(binTime)*signal;
00091 binTime += BUNCHSPACE;
00092 }
00093 }
00094 }
00095 }
00096
00097 double
00098 EBHitResponse::apdSignalAmplitude( const PCaloHit& hit ) const
00099 {
00100 assert( 1 == hit.depth() ||
00101 2 == hit.depth() ) ;
00102
00103 double npe ( hit.energy()*( 2 == hit.depth() ?
00104 apdParameters()->simToPELow() :
00105 apdParameters()->simToPEHigh() ) ) ;
00106
00107
00108 if( apdParameters()->doPEStats() &&
00109 !m_apdOnly ) npe = ranPois()->fire( npe ) ;
00110
00111 assert( 0 != m_intercal ) ;
00112 double fac ( 1 ) ;
00113 findIntercalibConstant( hit.id(), fac ) ;
00114
00115 npe *= fac ;
00116
00117
00118
00119
00120
00121
00122 return npe ;
00123 }
00124
00125 void
00126 EBHitResponse::setIntercal( const EcalIntercalibConstantsMC* ical )
00127 {
00128 m_intercal = ical ;
00129 }
00130
00131 void
00132 EBHitResponse::findIntercalibConstant( const DetId& detId,
00133 double& icalconst ) const
00134 {
00135 EcalIntercalibConstantMC thisconst ( 1. ) ;
00136
00137 if( 0 == m_intercal )
00138 {
00139 edm::LogError( "EBHitResponse" ) <<
00140 "No intercal constant defined for EBHitResponse" ;
00141 }
00142 else
00143 {
00144 const EcalIntercalibConstantMCMap& icalMap ( m_intercal->getMap() ) ;
00145 EcalIntercalibConstantMCMap::const_iterator icalit ( icalMap.find( detId ) ) ;
00146 if( icalit != icalMap.end() )
00147 {
00148 thisconst = *icalit ;
00149 if ( thisconst == 0. ) thisconst = 1. ;
00150 }
00151 else
00152 {
00153 edm::LogError("EBHitResponse") << "No intercalib const found for xtal "
00154 << detId.rawId()
00155 << "! something wrong with EcalIntercalibConstants in your DB? ";
00156 }
00157 }
00158 icalconst = thisconst ;
00159 }