CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GflashProtonShowerProfile.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::pro_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::pro_hadscale[0]) +
31  energySigmaHcal = (fTanh(einc,Gflash::pro_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::pro_hadscale[0]) +
46  energySigmaHcal = (fTanh(einc,Gflash::pro_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::pro_hadscale[4]);
57  energySigmaHcal = fTanh(einc,Gflash::pro_hadscale[5]);
58 
59  double gap_corr = einc*fTanh(einc,Gflash::pro_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::pro_hadscale[7]));
80  energyScale[Gflash::kHE] = exp(energyMeanHcal+energySigmaHcal*r1);
81  } while ( energyScale[Gflash::kHE] > einc*1.5 );
82 
83  if(showerType == 6) {
85  - gap_corr*depthScale(std::fabs(position.getZ()),Gflash::Zmin[Gflash::kHE],66.));
86  }
87  }
88  }
89 
90  // parameters for the longitudinal profiles
91  //@@@check longitudinal profiles of endcaps for possible variations
92 
93  double *rhoHcal = new double [2*Gflash::NPar];
94  double *correlationVectorHcal = new double [Gflash::NPar*(Gflash::NPar+1)/2];
95 
96  //@@@until we have a separate parameterization for Endcap
97 
98  if(showerType>3) {
99  showerType -= 4;
100  }
101  //no separate parameterization before crystal
102  if(showerType==0) showerType = 1;
103 
104  //Hcal parameters are always needed regardless of showerType
105  for(int i = 0 ; i < 2*Gflash::NPar ; i++ ) {
106  rhoHcal[i] = fTanh(einc,Gflash::pro_rho[i + showerType*2*Gflash::NPar]);
107  }
108 
109  getFluctuationVector(rhoHcal,correlationVectorHcal);
110 
111  double normalZ[Gflash::NPar];
112  for (int i = 0; i < Gflash::NPar ; i++) normalZ[i] = CLHEP::RandGaussQ::shoot();
113 
114  for(int i = 0 ; i < Gflash::NPar ; i++) {
115  double correlationSum = 0.0;
116 
117  for(int j = 0 ; j < i+1 ; j++) {
118  correlationSum += correlationVectorHcal[i*(i+1)/2+j]*normalZ[j];
119  }
120  longHcal[i] = fTanh(einc,Gflash::pro_par[i+showerType*Gflash::NPar]) +
121  fTanh(einc,Gflash::pro_par[i+(4+showerType)*Gflash::NPar])*correlationSum;
122  }
123  delete [] rhoHcal;
124  delete [] correlationVectorHcal;
125 
126  // lateral parameters for Hcal
127 
128  for (int i = 0 ; i < Gflash::Nrpar ; i++) {
129  lateralPar[Gflash::kHB][i] = fTanh(einc,Gflash::pro_rpar[i+showerType*Gflash::Nrpar]);
131  }
132 
133  //Ecal parameters are needed if and only if the shower starts inside the crystal
134 
135  if(showerType == 1) {
136 
137  double *rhoEcal = new double [2*Gflash::NPar];
138  double *correlationVectorEcal = new double [Gflash::NPar*(Gflash::NPar+1)/2];
139  for(int i = 0 ; i < 2*Gflash::NPar ; i++ ) rhoEcal[i] = fTanh(einc,Gflash::pro_rho[i]);
140 
141  getFluctuationVector(rhoEcal,correlationVectorEcal);
142 
143  for(int i = 0 ; i < Gflash::NPar ; i++) normalZ[i] = CLHEP::RandGaussQ::shoot();
144  for(int i = 0 ; i < Gflash::NPar ; i++) {
145  double correlationSum = 0.0;
146 
147  for(int j = 0 ; j < i+1 ; j++) {
148  correlationSum += correlationVectorEcal[i*(i+1)/2+j]*normalZ[j];
149  }
150  longEcal[i] = fTanh(einc,Gflash::pro_par[i]) +
151  0.5*fTanh(einc,Gflash::pro_par[i+4*Gflash::NPar])*correlationSum;
152  }
153 
154  delete [] rhoEcal;
155  delete [] correlationVectorEcal;
156 
157  // lateral parameters for Ecal
158 
159  for (int i = 0 ; i < Gflash::Nrpar ; i++) {
162  }
163  }
164 
165 }
const double pro_hadscale[8][5]
const double ZFrontCrystalEE
double fTanh(double einc, const double *par)
int i
Definition: DBlmapReader.cc:9
double lateralPar[Gflash::kNumberCalorimeter][Gflash::Nrpar]
const double pro_par[8 *NPar][5]
double getEnergy()
Definition: GflashShowino.h:24
int getShowerType()
Definition: GflashShowino.h:23
const int Nrpar
const double pro_rho[8 *NPar][5]
T sqrt(T t)
Definition: SSEVec.h:48
const double LengthCrystalEE
int j
Definition: DBlmapReader.cc:9
const double pro_correl_hadem[5]
const double LengthCrystalEB
Gflash3Vector & getPositionAtShower()
Definition: GflashShowino.h:27
const double pro_emscale[2][5]
const int NPar
const double RFrontCrystalEB
const double Zmin[kNumberCalorimeter]
CLHEP::Hep3Vector Gflash3Vector
Definition: Gflash3Vector.h:6
const double pro_rpar[4 *Nrpar][5]
static int position[264][3]
Definition: ReadPGInfo.cc:509
void getFluctuationVector(double *lowTriangle, double *correlationVector)
double depthScale(double ssp, double ssp0, double length)
const double Rmin[kNumberCalorimeter]
tuple log
Definition: cmsBatch.py:347
double energyScale[Gflash::kNumberCalorimeter]