CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/SimCalorimetry/HcalSimAlgos/src/HcalShape.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/HcalSimAlgos/interface/HcalShape.h"
00002 #include <cmath>
00003   
00004 HcalShape::HcalShape()
00005 : nbin_(256),
00006   nt_(nbin_, 0.)
00007 {
00008    computeShape();
00009 }
00010 
00011 HcalShape::HcalShape(const HcalShape&d):
00012   CaloVShape(d),
00013   nbin_(d.nbin_),
00014   nt_(d.nt_)
00015 {
00016 }
00017 
00018 double
00019 HcalShape::timeToRise() const 
00020 {
00021    return 0. ;
00022 }
00023 
00024 void HcalShape::computeShape()
00025 {
00026 
00027   // pulse shape time constant_s in ns
00028   const float ts1  = 8.;          // scintillation time constant_s : 1,2,3
00029   const float ts2  = 10.;           
00030   const float ts3  = 29.3;         
00031   const float thpd = 4.;          // HPD current_ collection drift time
00032   const float tpre = 9.;          // preamp time constant_ (refit on TB04 data)
00033   
00034   const float wd1 = 2.;           // relative weights of decay exponent_s 
00035   const float wd2 = 0.7;
00036   const float wd3 = 1.;
00037   
00038   // pulse shape componnt_s over a range of time 0 ns to 255 ns in 1 ns steps
00039   std::vector<float> nth(nbin_,0.0);   // zeroing HPD drift shape
00040   std::vector<float> ntp(nbin_,0.0);   // zeroing Binkley preamp shape
00041   std::vector<float> ntd(nbin_,0.0);   // zeroing Scintillator decay shape
00042 
00043   int i,j,k;
00044   float norm;
00045 
00046   // HPD starts at I and rises to 2I in thpd of time
00047   norm=0.0;
00048   for(j=0;j<thpd && j<nbin_;j++){
00049     nth[j] = 1.0 + j/thpd;
00050     norm += nth[j];
00051   }
00052   // normalize integrated current_ to 1.0
00053   for(j=0;j<thpd && j<nbin_;j++){
00054     nth[j] /= norm;
00055   }
00056   
00057   // Binkley shape over 6 time constant_s
00058   norm=0.0;
00059   for(j=0;j<6*tpre && j<nbin_;j++){
00060     ntp[j] = j*exp(-(j*j)/(tpre*tpre));
00061     norm += ntp[j];
00062   }
00063   // normalize pulse area to 1.0
00064   for(j=0;j<6*tpre && j<nbin_;j++){
00065     ntp[j] /= norm;
00066   }
00067 
00068 // ignore stochastic variation of photoelectron emission
00069 // <...>
00070 
00071 // effective tile plus wave-length shifter decay time over 4 time constant_s
00072   int tmax = 6 * static_cast<int>(ts3);
00073  
00074   norm=0.0;
00075   for(j=0;j<tmax && j<nbin_;j++){
00076     ntd[j] = wd1 * exp(-j/ts1) + 
00077       wd2 * exp(-j/ts2) + 
00078       wd3 * exp(-j/ts3) ; 
00079     norm += ntd[j];
00080   }
00081   // normalize pulse area to 1.0
00082   for(j=0;j<tmax && j<nbin_;j++){
00083     ntd[j] /= norm;
00084   }
00085   
00086   int t1,t2,t3,t4;
00087   for(i=0;i<tmax && i<nbin_;i++){
00088     t1 = i;
00089     //    t2 = t1 + top*rand;
00090     // ignoring jitter from optical path length
00091     t2 = t1;
00092     for(j=0;j<thpd && j<nbin_;j++){
00093       t3 = t2 + j;
00094       for(k=0;k<4*tpre && k<nbin_;k++){       // here "4" is set deliberately,
00095  t4 = t3 + k;                         // as in test fortran toy MC ...
00096  if(t4<nbin_){                         
00097    int ntb=t4;                        
00098    nt_[ntb] += ntd[i]*nth[j]*ntp[k];
00099         }
00100       }
00101     }
00102   }
00103   
00104   // normalize for 1 GeV pulse height
00105   norm = 0.;
00106   for(i=0;i<nbin_;i++){
00107     norm += nt_[i];
00108   }
00109 
00110   //cout << " Convoluted SHAPE ==============  " << endl;
00111   for(i=0; i<nbin_; i++){
00112     nt_[i] /= norm;
00113     //  cout << " shape " << i << " = " << nt_[i] << endl;   
00114   }
00115 
00116 }
00117 
00118 double HcalShape::operator () (double time_) const
00119 {
00120 
00121   // return pulse amplitude for request time in ns
00122   int jtime = static_cast<int>(time_+0.5);
00123   if(jtime>=0 && jtime<nbin_){
00124     return nt_[jtime];
00125   } else {
00126     return 0.0;
00127   }
00128 
00129 }
00130 
00131