CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimGeneral/GFlash/src/GflashAntiProtonShowerProfile.cc

Go to the documentation of this file.
00001 #include "SimGeneral/GFlash/interface/GflashAntiProtonShowerProfile.h"
00002 #include <CLHEP/Random/RandGaussQ.h>
00003 
00004 void GflashAntiProtonShowerProfile::loadParameters()
00005 {
00006   double einc = theShowino->getEnergy();
00007   Gflash3Vector position = theShowino->getPositionAtShower();
00008   int showerType = theShowino->getShowerType();
00009 
00010   // energy scale
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     //energy dependent energyRho based on tuning with testbeam data
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::pbar_emscale[0]) + fTanh(einc,Gflash::emcorr_pid[6]) +
00026                                          fTanh(einc,Gflash::pbar_emscale[1])*r1);
00027       
00028       r2 = CLHEP::RandGaussQ::shoot();
00029       energyMeanHcal  = (fTanh(einc,Gflash::pbar_hadscale[0]) +
00030                          fTanh(einc,Gflash::pbar_hadscale[1])*depthScale(position.getRho(),Gflash::RFrontCrystalEB,Gflash::LengthCrystalEB));
00031       energySigmaHcal = (fTanh(einc,Gflash::pbar_hadscale[2]) +
00032                          fTanh(einc,Gflash::pbar_hadscale[3])*depthScale(position.getRho(),Gflash::RFrontCrystalEB,Gflash::LengthCrystalEB));
00033       energyScale[Gflash::kHB] = std::max(0.0,
00034         einc*fTanh(einc,Gflash::hadcorr_pid[6]) +
00035         exp(energyMeanHcal+energySigmaHcal*(energyRho*r1 + sqrt(1.0- energyRho*energyRho)*r2 )));
00036     }
00037     else {
00038       energyScale[Gflash::kENCA] = einc*(fTanh(einc,Gflash::pbar_emscale[0]) + fTanh(einc,Gflash::emcorr_pid[7]) +
00039                                          fTanh(einc,Gflash::pbar_emscale[1])*r1);
00040       
00041       r2 = CLHEP::RandGaussQ::shoot();
00042       energyMeanHcal  = (fTanh(einc,Gflash::pbar_hadscale[0]) +
00043                          fTanh(einc,Gflash::pbar_hadscale[1])*depthScale(std::fabs(position.getZ()),Gflash::ZFrontCrystalEE,Gflash::LengthCrystalEE));
00044       energySigmaHcal = (fTanh(einc,Gflash::pbar_hadscale[2]) +
00045                          fTanh(einc,Gflash::pbar_hadscale[3])*depthScale(std::fabs(position.getZ()),Gflash::ZFrontCrystalEE,Gflash::LengthCrystalEE));
00046       
00047       energyScale[Gflash::kHE] =  std::max(0.0,
00048         einc*fTanh(einc,Gflash::hadcorr_pid[7]) +
00049         exp(energyMeanHcal+energySigmaHcal*(energyRho*r1 + sqrt(1.0- energyRho*energyRho)*r2 )));
00050     }
00051   }
00052   else if(showerType == 2 || showerType == 6 || showerType == 3 || showerType == 7) { 
00053     //Hcal response for mip-like pions (mip)
00054     
00055     energyMeanHcal  = fTanh(einc,Gflash::pbar_hadscale[4]);
00056     energySigmaHcal = fTanh(einc,Gflash::pbar_hadscale[5]);
00057     double gap_corr = fTanh(einc,Gflash::pbar_hadscale[6]);
00058 
00059     if(showerType == 2 || showerType == 3) {
00060       energyScale[Gflash::kHB] =  std::max(0.0, einc*fTanh(einc,Gflash::mipcorr_pid[6]) +
00061                                            exp(energyMeanHcal+energySigmaHcal*CLHEP::RandGaussQ::shoot()));
00062       
00063       if(showerType == 2) {
00064         energyScale[Gflash::kHB] = std::max(0.0,
00065              energyScale[Gflash::kHB]*(1.0- 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[7])) +
00070                                            exp(energyMeanHcal+energySigmaHcal*CLHEP::RandGaussQ::shoot()));
00071       if(showerType == 6) {
00072         energyScale[Gflash::kHE] = std::max(0.0,
00073           energyScale[Gflash::kHE]*(1.0- gap_corr*depthScale(std::fabs(position.getZ()),Gflash::Zmin[Gflash::kHE],60.)));
00074       }
00075     }
00076   }
00077 
00078   // parameters for the longitudinal profiles
00079 
00080   double *rhoHcal = new double [2*Gflash::NPar];
00081   double *correlationVectorHcal = new double [Gflash::NPar*(Gflash::NPar+1)/2];
00082 
00083   //@@@until we have a separate parameterization for Endcap 
00084   bool isEndcap = false;
00085   if(showerType>3) {
00086     showerType -= 4;
00087     isEndcap = true;
00088   }
00089   //no separate parameterization before crystal
00090   if(showerType==0) showerType = 1; 
00091 
00092   //Hcal parameters are always needed regardless of showerType
00093 
00094   for(int i = 0 ; i < 2*Gflash::NPar ; i++ ) {
00095     rhoHcal[i] = fTanh(einc,Gflash::pbar_rho[i + showerType*2*Gflash::NPar]);
00096   }
00097 
00098   getFluctuationVector(rhoHcal,correlationVectorHcal);
00099 
00100   double normalZ[Gflash::NPar];
00101   for (int i = 0; i < Gflash::NPar ; i++) normalZ[i] = CLHEP::RandGaussQ::shoot();
00102   
00103   for(int i = 0 ; i < Gflash::NPar ; i++) {
00104     double correlationSum = 0.0;
00105     for(int j = 0 ; j < i+1 ; j++) {
00106       correlationSum += correlationVectorHcal[i*(i+1)/2+j]*normalZ[j];
00107     }
00108     longHcal[i] = fTanh(einc,Gflash::pbar_par[i+showerType*Gflash::NPar]) +
00109                   fTanh(einc,Gflash::pbar_par[i+(4+showerType)*Gflash::NPar])*correlationSum;
00110   }
00111 
00112   delete [] rhoHcal;
00113   delete [] correlationVectorHcal;
00114 
00115   // lateral parameters for Hcal
00116 
00117   for (int i = 0 ; i < Gflash::Nrpar ; i++) {
00118     lateralPar[Gflash::kHB][i] = fLnE1(einc,Gflash::pbar_rpar[i+showerType*Gflash::Nrpar]);
00119     lateralPar[Gflash::kHE][i] = lateralPar[Gflash::kHB][i];
00120   }
00121 
00122   //Ecal parameters are needed if and only if the shower starts inside the crystal
00123 
00124   if(showerType == 1) {
00125     //A depth dependent correction for the core term of R in Hcal is the linear in 
00126     //the shower start point while for the spread term is nearly constant
00127 
00128     if(!isEndcap) lateralPar[Gflash::kHB][0] -= 2.3562e-01*(position.getRho()-131.0); 
00129     else  lateralPar[Gflash::kHE][0] -= 2.3562e-01*(std::abs(position.getZ())-332.0);
00130 
00131     double *rhoEcal = new double [2*Gflash::NPar];
00132     double *correlationVectorEcal = new double [Gflash::NPar*(Gflash::NPar+1)/2];
00133     for(int i = 0 ; i < 2*Gflash::NPar ; i++ ) rhoEcal[i] = fTanh(einc,Gflash::pbar_rho[i]);
00134 
00135     getFluctuationVector(rhoEcal,correlationVectorEcal);
00136 
00137     for(int i = 0 ; i < Gflash::NPar ; i++) normalZ[i] = CLHEP::RandGaussQ::shoot();
00138     for(int i = 0 ; i < Gflash::NPar ; i++) {
00139       double correlationSum = 0.0;
00140       for(int j = 0 ; j < i+1 ; j++) {
00141         correlationSum += correlationVectorEcal[i*(i+1)/2+j]*normalZ[j];
00142       }
00143       longEcal[i] = fTanh(einc,Gflash::pbar_par[i]) +
00144         fTanh(einc,Gflash::pbar_par[i+4*Gflash::NPar])*correlationSum;
00145     }
00146 
00147     delete [] rhoEcal;
00148     delete [] correlationVectorEcal;
00149 
00150   }
00151 }