00001 #include "SimGeneral/GFlash/interface/GflashPiKShowerProfile.h"
00002 #include <CLHEP/Random/RandGaussQ.h>
00003
00004 void GflashPiKShowerProfile::loadParameters()
00005 {
00006 double einc = theShowino->getEnergy();
00007 Gflash3Vector position = theShowino->getPositionAtShower();
00008 int showerType = theShowino->getShowerType();
00009
00010
00011 double energyMeanHcal = 0.0;
00012 double energySigmaHcal = 0.0;
00013
00014 if(showerType == 0 || showerType == 1 || showerType == 4 || showerType == 5) {
00015
00016 double r1 = 0.0;
00017 double r2 = 0.0;
00018
00019
00020 double energyRho = fTanh(einc,Gflash::correl_hadem);
00021
00022 r1 = CLHEP::RandGaussQ::shoot();
00023
00024 if(showerType == 0 || showerType == 1) {
00025 energyScale[Gflash::kESPM] = einc*(fTanh(einc,Gflash::emscale[0]) + fTanh(einc,Gflash::emcorr_pid[0])
00026 +(fTanh(einc,Gflash::emscale[2]) + fTanh(einc,Gflash::emscale[3])*depthScale(position.getRho(),151.,22.) )*r1);
00027
00028 energyMeanHcal = (fTanh(einc,Gflash::hadscale[0]) +
00029 fTanh(einc,Gflash::hadscale[1])*depthScale(position.getRho(),Gflash::RFrontCrystalEB,Gflash::LengthCrystalEB));
00030 energySigmaHcal = (fTanh(einc,Gflash::hadscale[2]) +
00031 fTanh(einc,Gflash::hadscale[3])*depthScale(position.getRho(),Gflash::RFrontCrystalEB,Gflash::LengthCrystalEB));
00032
00033 r2 = CLHEP::RandGaussQ::shoot();
00034 energyScale[Gflash::kHB] = std::max(0.0,
00035 einc*fTanh(einc,Gflash::hadcorr_pid[0]) +
00036 exp(energyMeanHcal+energySigmaHcal*(energyRho*r1 + sqrt(1.0- energyRho*energyRho)*r2 ))-0.05*einc);
00037 }
00038 else {
00039 energyScale[Gflash::kENCA] = einc*(fTanh(einc,Gflash::emscale[0]) + fTanh(einc,Gflash::emcorr_pid[1])
00040 +(fTanh(einc,Gflash::emscale[2]) + fTanh(einc,Gflash::emscale[3])*depthScale(std::fabs(position.getZ()),338.0,21.) )*r1);
00041
00042
00043 energyMeanHcal = (fTanh(einc,Gflash::hadscale[0]) +
00044 fTanh(einc,Gflash::hadscale[1])*depthScale(std::fabs(position.getZ()),Gflash::ZFrontCrystalEE,Gflash::LengthCrystalEE));
00045 energySigmaHcal = (fTanh(einc,Gflash::hadscale[2]) +
00046 fTanh(einc,Gflash::hadscale[3])*depthScale(std::fabs(position.getZ()),Gflash::ZFrontCrystalEE,Gflash::LengthCrystalEE));
00047 r2 = CLHEP::RandGaussQ::shoot();
00048 energyScale[Gflash::kHE] = std::max(0.0,
00049 einc*fTanh(einc,Gflash::hadcorr_pid[1]) +
00050 exp(energyMeanHcal+energySigmaHcal*(energyRho*r1 + sqrt(1.0- energyRho*energyRho)*r2 ))-0.05*einc);
00051 }
00052 }
00053 else if(showerType == 2 || showerType == 6 || showerType == 3 || showerType == 7) {
00054
00055
00056 energyMeanHcal = fTanh(einc,Gflash::hadscale[4]);
00057 energySigmaHcal = fTanh(einc,Gflash::hadscale[5]);
00058 double gap_corr = einc * fTanh(einc,Gflash::hadscale[6]);
00059
00060 if(showerType == 2 || showerType == 3) {
00061 energyScale[Gflash::kHB] = std::max(0.0, einc*fTanh(einc,Gflash::mipcorr_pid[0]) +
00062 exp(energyMeanHcal+energySigmaHcal*CLHEP::RandGaussQ::shoot())-2.0);
00063 if(showerType == 2) {
00064 energyScale[Gflash::kHB] = std::max(0.0,energyScale[Gflash::kHB]
00065 - gap_corr*depthScale(position.getRho(),Gflash::Rmin[Gflash::kHB],28.));
00066 }
00067 }
00068 else if(showerType == 6 || showerType == 7 ) {
00069 energyScale[Gflash::kHE] = std::max(0.0, einc*fTanh(einc,Gflash::mipcorr_pid[1]) +
00070 exp(energyMeanHcal+energySigmaHcal*CLHEP::RandGaussQ::shoot())-2.0);
00071 if(showerType == 6) {
00072 energyScale[Gflash::kHE] = std::max(0.0,energyScale[Gflash::kHE]
00073 - gap_corr*depthScale(std::fabs(position.getZ()),Gflash::Zmin[Gflash::kHE],66.));
00074 }
00075 }
00076 }
00077
00078
00079
00080 double *rhoHcal = new double [2*Gflash::NPar];
00081 double *correlationVectorHcal = new double [Gflash::NPar*(Gflash::NPar+1)/2];
00082
00083
00084 bool isEndcap = false;
00085 if(showerType>3) {
00086 showerType -= 4;
00087 isEndcap = true;
00088 }
00089
00090 if(showerType==0) showerType = 1;
00091
00092
00093 for(int i = 0 ; i < 2*Gflash::NPar ; i++ ) {
00094 rhoHcal[i] = fTanh(einc,Gflash::rho[i + showerType*2*Gflash::NPar]);
00095 }
00096
00097 getFluctuationVector(rhoHcal,correlationVectorHcal);
00098
00099 double normalZ[Gflash::NPar];
00100 for (int i = 0; i < Gflash::NPar ; i++) normalZ[i] = CLHEP::RandGaussQ::shoot();
00101
00102 for(int i = 0 ; i < Gflash::NPar ; i++) {
00103 double correlationSum = 0.0;
00104 for(int j = 0 ; j < i+1 ; j++) {
00105 correlationSum += correlationVectorHcal[i*(i+1)/2+j]*normalZ[j];
00106 }
00107 longHcal[i] = fTanh(einc,Gflash::par[i+showerType*Gflash::NPar]) +
00108 fTanh(einc,Gflash::par[i+(4+showerType)*Gflash::NPar])*correlationSum;
00109 }
00110
00111 delete [] rhoHcal;
00112 delete [] correlationVectorHcal;
00113
00114
00115
00116 for (int i = 0 ; i < Gflash::Nrpar ; i++) {
00117 lateralPar[Gflash::kHB][i] = fLnE1(einc,Gflash::rpar[i+showerType*Gflash::Nrpar]);
00118
00119
00120 if(showerType==3 && i == 0) lateralPar[Gflash::kHB][i] *= 1.1;
00121 lateralPar[Gflash::kHE][i] = lateralPar[Gflash::kHB][i];
00122 }
00123
00124
00125
00126 if(showerType == 1) {
00127
00128
00129
00130 if(!isEndcap) lateralPar[Gflash::kHB][0] -= 2.3562e-01*(position.getRho()-131.0);
00131 else lateralPar[Gflash::kHE][0] -= 2.3562e-01*(std::abs(position.getZ())-332.0);
00132
00133 double *rhoEcal = new double [2*Gflash::NPar];
00134 double *correlationVectorEcal = new double [Gflash::NPar*(Gflash::NPar+1)/2];
00135 for(int i = 0 ; i < 2*Gflash::NPar ; i++ ) rhoEcal[i] = fTanh(einc,Gflash::rho[i]);
00136
00137 getFluctuationVector(rhoEcal,correlationVectorEcal);
00138
00139 for (int i = 0; i < Gflash::NPar ; i++) normalZ[i] = CLHEP::RandGaussQ::shoot();
00140 for(int i = 0 ; i < Gflash::NPar ; i++) {
00141 double correlationSum = 0.0;
00142 for(int j = 0 ; j < i+1 ; j++) {
00143 correlationSum += correlationVectorEcal[i*(i+1)/2+j]*normalZ[j];
00144 }
00145 longEcal[i] = fTanh(einc,Gflash::par[i]) +
00146 fTanh(einc,Gflash::par[i+4*Gflash::NPar])*correlationSum;
00147 }
00148
00149 delete [] rhoEcal;
00150 delete [] correlationVectorEcal;
00151
00152
00153
00154 for (int i = 0 ; i < Gflash::Nrpar ; i++) {
00155 lateralPar[Gflash::kESPM][i] = fLnE1(einc,Gflash::rpar[i]);
00156 lateralPar[Gflash::kENCA][i] = lateralPar[Gflash::kESPM][i];
00157 }
00158 }
00159
00160 }