CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GflashKaonMinusShowerProfile.cc
Go to the documentation of this file.
2 #include <CLHEP/Random/RandGaussQ.h>
3 
5 {
6  double einc = theShowino->getEnergy();
8  int showerType = theShowino->getShowerType();
9 
10  // energy scale
11  double energyMeanHcal = 0.0;
12  double energySigmaHcal = 0.0;
13 
14  double r1 = 0.0;
15  double r2 = 0.0;
16 
17  if(showerType == 0 || showerType == 1 || showerType == 4 || showerType == 5) {
18 
19  //@@@ energy dependent energyRho based on tuning with testbeam data
20  double energyRho = fTanh(einc,Gflash::kminus_correl_hadem);
21 
22  if(showerType == 0 || showerType == 1) {
23  do {
24  r1 = CLHEP::RandGaussQ::shoot();
25 
27 
28  //LogNormal mean and sigma of Hcal energy
29  energyMeanHcal = (fTanh(einc,Gflash::kminus_hadscale[0]) +
31  energySigmaHcal = (fTanh(einc,Gflash::kminus_hadscale[2]) +
33 
34  r2 = CLHEP::RandGaussQ::shoot();
35  energyScale[Gflash::kHB] = exp(energyMeanHcal+energySigmaHcal*(energyRho*r1 + sqrt(1.0- energyRho*energyRho)*r2 ));
36  } while ( energyScale[Gflash::kESPM] < 0 || energyScale[Gflash::kHB] > einc*1.5 );
37  }
38  else {
39  do {
40  r1 = CLHEP::RandGaussQ::shoot();
42 
43  //@@@extend depthScale for HE
44  energyMeanHcal = (fTanh(einc,Gflash::kminus_hadscale[0]) +
46  energySigmaHcal = (fTanh(einc,Gflash::kminus_hadscale[2]) +
48  r2 = CLHEP::RandGaussQ::shoot();
49  energyScale[Gflash::kHE] = exp(energyMeanHcal+energySigmaHcal*(energyRho*r1 + sqrt(1.0- energyRho*energyRho)*r2 ));
50  } while ( energyScale[Gflash::kENCA] < 0 || energyScale[Gflash::kHE] > einc*1.5 );
51  }
52  }
53  else if(showerType == 2 || showerType == 3 || showerType == 6 || showerType == 7) {
54  //Hcal response for mip-like pions (mip)
55 
56  energyMeanHcal = fTanh(einc,Gflash::kminus_hadscale[4]);
57  energySigmaHcal = fTanh(einc,Gflash::kminus_hadscale[5]);
58 
59  double gap_corr = einc*fTanh(einc,Gflash::kminus_hadscale[6]);
60 
61  if(showerType == 2 || showerType == 3) {
63 
64  do {
65  r1 = CLHEP::RandGaussQ::shoot();
66  energyScale[Gflash::kHB] = exp(energyMeanHcal+energySigmaHcal*r1);
67  } while ( energyScale[Gflash::kHB] > einc*1.5 );
68 
69  if(showerType == 2) {
71  - gap_corr*depthScale(position.getRho(),Gflash::Rmin[Gflash::kHB],28.));
72  }
73  }
74  else if(showerType == 6 || showerType == 7 ) {
76 
77  do {
78  r1 = CLHEP::RandGaussQ::shoot();
79  energyMeanHcal += std::log(1.0-fTanh(einc,Gflash::kminus_hadscale[7]));
80  energyScale[Gflash::kHE] = exp(energyMeanHcal+energySigmaHcal*r1);
81  } while ( energyScale[Gflash::kHE] > einc*1.5 );
82 
83 
84  if(showerType == 6) {
86  - gap_corr*depthScale(std::fabs(position.getZ()),Gflash::Zmin[Gflash::kHE],66.));
87  }
88  }
89  }
90 
91  // parameters for the longitudinal profiles
92  //@@@check longitudinal profiles of endcaps for possible variations
93 
94  double *rhoHcal = new double [2*Gflash::NPar];
95  double *correlationVectorHcal = new double [Gflash::NPar*(Gflash::NPar+1)/2];
96 
97  //@@@until we have a separate parameterization for Endcap
98 
99  if(showerType>3) {
100  showerType -= 4;
101  }
102  //no separate parameterization before crystal
103  if(showerType==0) showerType = 1;
104 
105  //Hcal parameters are always needed regardless of showerType
106  for(int i = 0 ; i < 2*Gflash::NPar ; i++ ) {
107  rhoHcal[i] = fTanh(einc,Gflash::kminus_rho[i + showerType*2*Gflash::NPar]);
108  }
109 
110  getFluctuationVector(rhoHcal,correlationVectorHcal);
111 
112  double normalZ[Gflash::NPar];
113  for (int i = 0; i < Gflash::NPar ; i++) normalZ[i] = CLHEP::RandGaussQ::shoot();
114 
115  for(int i = 0 ; i < Gflash::NPar ; i++) {
116  double correlationSum = 0.0;
117 
118  for(int j = 0 ; j < i+1 ; j++) {
119  correlationSum += correlationVectorHcal[i*(i+1)/2+j]*normalZ[j];
120  }
121  longHcal[i] = fTanh(einc,Gflash::kminus_par[i+showerType*Gflash::NPar]) +
122  fTanh(einc,Gflash::kminus_par[i+(4+showerType)*Gflash::NPar])*correlationSum;
123  }
124  delete [] rhoHcal;
125  delete [] correlationVectorHcal;
126 
127  // lateral parameters for Hcal
128 
129  for (int i = 0 ; i < Gflash::Nrpar ; i++) {
130  lateralPar[Gflash::kHB][i] = fTanh(einc,Gflash::kminus_rpar[i+showerType*Gflash::Nrpar]);
132  }
133 
134  //Ecal parameters are needed if and only if the shower starts inside the crystal
135 
136  if(showerType == 1) {
137 
138  double *rhoEcal = new double [2*Gflash::NPar];
139  double *correlationVectorEcal = new double [Gflash::NPar*(Gflash::NPar+1)/2];
140  for(int i = 0 ; i < 2*Gflash::NPar ; i++ ) rhoEcal[i] = fTanh(einc,Gflash::kminus_rho[i]);
141 
142  getFluctuationVector(rhoEcal,correlationVectorEcal);
143 
144  for(int i = 0 ; i < Gflash::NPar ; i++) normalZ[i] = CLHEP::RandGaussQ::shoot();
145  for(int i = 0 ; i < Gflash::NPar ; i++) {
146  double correlationSum = 0.0;
147 
148  for(int j = 0 ; j < i+1 ; j++) {
149  correlationSum += correlationVectorEcal[i*(i+1)/2+j]*normalZ[j];
150  }
151  longEcal[i] = fTanh(einc,Gflash::kminus_par[i]) +
152  0.5*fTanh(einc,Gflash::kminus_par[i+4*Gflash::NPar])*correlationSum;
153  }
154 
155  delete [] rhoEcal;
156  delete [] correlationVectorEcal;
157 
158  // lateral parameters for Ecal
159 
160  for (int i = 0 ; i < Gflash::Nrpar ; i++) {
163  }
164  }
165 
166 }
const double ZFrontCrystalEE
double fTanh(double einc, const double *par)
int i
Definition: DBlmapReader.cc:9
const double kminus_rho[8 *NPar][5]
double lateralPar[Gflash::kNumberCalorimeter][Gflash::Nrpar]
const double kminus_rpar[4 *Nrpar][5]
double getEnergy()
Definition: GflashShowino.h:24
int getShowerType()
Definition: GflashShowino.h:23
const int Nrpar
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
const T & max(const T &a, const T &b)
const double kminus_hadscale[8][5]
T sqrt(T t)
Definition: SSEVec.h:48
const double kminus_par[8 *NPar][5]
const double LengthCrystalEE
int j
Definition: DBlmapReader.cc:9
const double kminus_emscale[2][5]
const double LengthCrystalEB
Gflash3Vector & getPositionAtShower()
Definition: GflashShowino.h:27
const double kminus_correl_hadem[5]
const int NPar
const double RFrontCrystalEB
const double Zmin[kNumberCalorimeter]
CLHEP::Hep3Vector Gflash3Vector
Definition: Gflash3Vector.h:6
void getFluctuationVector(double *lowTriangle, double *correlationVector)
double depthScale(double ssp, double ssp0, double length)
const double Rmin[kNumberCalorimeter]
double energyScale[Gflash::kNumberCalorimeter]