Go to the documentation of this file.00001 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShapes.h"
00002 #include <cmath>
00003
00004 HcalPulseShapes::HcalPulseShapes() {
00005 computeHPDShape(hpdShape_);
00006 computeHFShape(hfShape_);
00007 }
00008
00009
00010 void HcalPulseShapes::computeHPDShape(HcalPulseShapes::Shape& sh)
00011 {
00012
00013
00014 const float ts1 = 8.;
00015 const float ts2 = 10.;
00016 const float ts3 = 29.3;
00017 const float thpd = 4.;
00018 const float tpre = 9.;
00019
00020 const float wd1 = 2.;
00021 const float wd2 = 0.7;
00022 const float wd3 = 1.;
00023
00024
00025 int nbin = 256;
00026 sh.setNBin(nbin);
00027 std::vector<float> ntmp(nbin,0.0);
00028 std::vector<float> nth(nbin,0.0);
00029 std::vector<float> ntp(nbin,0.0);
00030 std::vector<float> ntd(nbin,0.0);
00031
00032 int i,j,k;
00033 float norm;
00034
00035
00036 norm=0.0;
00037 for(j=0;j<thpd && j<nbin;j++){
00038 nth[j] = 1.0 + ((float)j)/thpd;
00039 norm += nth[j];
00040 }
00041
00042 for(j=0;j<thpd && j<nbin;j++){
00043 nth[j] /= norm;
00044 }
00045
00046
00047 norm=0.0;
00048 for(j=0;j<6*tpre && j<nbin;j++){
00049 ntp[j] = ((float)j)*exp(-((float)(j*j))/(tpre*tpre));
00050 norm += ntp[j];
00051 }
00052
00053 for(j=0;j<6*tpre && j<nbin;j++){
00054 ntp[j] /= norm;
00055 }
00056
00057
00058
00059
00060
00061 int tmax = 6 * (int)ts3;
00062
00063 norm=0.0;
00064 for(j=0;j<tmax && j<nbin;j++){
00065 ntd[j] = wd1 * exp(-((float)j)/ts1) +
00066 wd2 * exp(-((float)j)/ts2) +
00067 wd3 * exp(-((float)j)/ts3) ;
00068 norm += ntd[j];
00069 }
00070
00071 for(j=0;j<tmax && j<nbin;j++){
00072 ntd[j] /= norm;
00073 }
00074
00075 int t1,t2,t3,t4;
00076 for(i=0;i<tmax && i<nbin;i++){
00077 t1 = i;
00078
00079
00080 t2 = t1;
00081 for(j=0;j<thpd && j<nbin;j++){
00082 t3 = t2 + j;
00083 for(k=0;k<4*tpre && k<nbin;k++){
00084 t4 = t3 + k;
00085 if(t4<nbin){
00086 int ntb=t4;
00087 ntmp[ntb] += ntd[i]*nth[j]*ntp[k];
00088 }
00089 }
00090 }
00091 }
00092
00093
00094 norm = 0.;
00095 for(i=0;i<nbin;i++){
00096 norm += ntmp[i];
00097 }
00098
00099
00100 for(i=0; i<nbin; i++){
00101 ntmp[i] /= norm;
00102
00103 }
00104
00105 for(i=0; i<nbin; i++){
00106 sh.setShapeBin(i,ntmp[i]);
00107 }
00108 }
00109
00110 void HcalPulseShapes::computeHFShape(HcalPulseShapes::Shape& sh) {
00111
00112 int nbin = 256;
00113 sh.setNBin(nbin);
00114 std::vector<float> ntmp(nbin,0.0);
00115
00116 const float k0=0.7956;
00117 const float p2=1.355;
00118 const float p4=2.327;
00119 const float p1=4.3;
00120
00121 float norm = 0.0;
00122
00123 for(int j = 0; j < 25 && j < nbin; ++j){
00124
00125 float r0 = j-p1;
00126 float sigma0 = (r0<0) ? p2 : p2*p4;
00127 r0 /= sigma0;
00128 if(r0 < k0) ntmp[j] = exp(-0.5*r0*r0);
00129 else ntmp[j] = exp(0.5*k0*k0-k0*r0);
00130 norm += ntmp[j];
00131 }
00132
00133 for(int j = 0; j < 25 && j < nbin; ++j){
00134 ntmp[j] /= norm;
00135 sh.setShapeBin(j,ntmp[j]);
00136 }
00137 }
00138
00139 HcalPulseShapes::Shape::Shape() {
00140 nbin_=0;
00141 tpeak_=0;
00142 }
00143
00144 void HcalPulseShapes::Shape::setNBin(int n) {
00145 nbin_=n;
00146 shape_=std::vector<float>(n,0.0f);
00147 }
00148
00149 void HcalPulseShapes::Shape::setShapeBin(int i, float f) {
00150 if (i>=0 && i<nbin_) shape_[i]=f;
00151 }
00152
00153 float HcalPulseShapes::Shape::operator()(double t) const {
00154
00155 return at(t);
00156 }
00157
00158 float HcalPulseShapes::Shape::at(double t) const {
00159
00160 int i=(int)(t+0.5);
00161 float rv=0;
00162 if (i>=0 && i<nbin_) rv=shape_[i];
00163 return rv;
00164 }
00165
00166 float HcalPulseShapes::Shape::integrate(double t1, double t2) const {
00167 static const float int_delta_ns = 0.05f;
00168 double intval = 0.0;
00169
00170 for (double t = t1; t < t2; t+= int_delta_ns) {
00171 float loedge = at(t);
00172 float hiedge = at(t+int_delta_ns);
00173 intval += (loedge+hiedge)*int_delta_ns/2.0;
00174 }
00175 return (float)intval;
00176 }