CMS 3D CMS Logo

GflashShowino.cc
Go to the documentation of this file.
2 #include <CLHEP/Random/Randomize.h>
3 
5  : theShowerType(-1),
6  theEnergy(0),
7  thePositionAtShower(0, 0, 0),
8  thePathLengthAtShower(0),
9  thePathLengthOnEcal(0),
10  theStepLengthToHcal(0),
11  theStepLengthToOut(0),
12  thePathLength(0),
13  theGlobalTime(0),
14  thePosition(0, 0, 0),
15  theEnergyDeposited(0) {
17 }
18 
20 
21 void GflashShowino::initialize(int showerType,
22  double energy,
23  double globalTime,
24  double charge,
26  Gflash3Vector &momentum,
27  double magneticField) {
28  theEnergy = energy;
29  theGlobalTime = globalTime;
30  theEnergyDeposited = 0.0;
31 
32  // inside the magnetic field (tesla unit);
33  theHelix->initializeTrajectory(momentum, position, charge, magneticField);
34 
35  if (showerType < 100) {
38  theShowerType = showerType;
39 
40  } else {
41  // this input is from FastSimulation
42  // 1. simulate the shower starting position
43  thePositionAtShower = simulateFirstInteractionPoint(showerType, position);
45 
46  // 2. find shower type depending on where is the shower starting point
48  }
49 
51 }
52 
53 void GflashShowino::updateShowino(double deltaStep) {
54  thePathLength += deltaStep;
55  // trajectory point of showino along the shower depth at the pathLength
56  GflashTrajectoryPoint trajectoryShowino;
57  theHelix->getGflashTrajectoryPoint(trajectoryShowino, thePathLength);
58 
59  thePosition = trajectoryShowino.getPosition();
60 
61  theGlobalTime += (theEnergy / 100.0) * deltaStep / 30.0; //@@@calculate exact time change in nsec
62 }
63 
65  // thePathLengthAtShower: path Length from the origin to the shower starting
66  // point in cm theStepLengthToOut: the total path length from the starting
67  // point of
68  // shower to the maximum distance inside paramerized
69  // envelopes
70  double eta = thePosition.getEta();
71 
72  if (std::fabs(eta) < Gflash::EtaMax[Gflash::kESPM]) {
75  double pathLengthAtHcalBack = theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]);
76  if (pathLengthAtHcalBack > 0) {
77  theStepLengthToOut = std::min(300., pathLengthAtHcalBack - thePathLengthAtShower);
78  } else {
79  theStepLengthToOut = 200.;
80  }
82 
83  } else if (std::fabs(eta) < Gflash::EtaMax[Gflash::kENCA]) {
84  double zsign = (eta > 0) ? 1.0 : -1.0;
90  } else {
91  //@@@extend for HF later
92  theStepLengthToOut = 200.0;
93  }
94 
96 }
97 
99  // determine the shower starting point (ssp):
100  // the position at the entrance + the mean free path till the inelastic
101  // interaction inside calo
102 
103  double depthAtShower = 0.0;
104 
105  // set thePathLengthOnEcal, the pathLength at the reference (r=123.8 for
106  // barrel and z=304.5 for endcap)
107 
108  // effective interaction length fitter to ssp from Geant4
109  double effectiveLambda = 0.0;
110  if (theEnergy > 0.0 && theEnergy < 15) {
111  effectiveLambda = 24.6 + 2.6 * std::tanh(3.0 * (std::log(theEnergy) - 1.43));
112  } else {
113  effectiveLambda = 28.4 + 1.20 * std::tanh(1.5 * (std::log(theEnergy) - 4.3));
114  }
115  // fraction before the crystal, but inside Ecal
116  // double frac_ssp1
117  // = 1.5196e-01+1.3300e-01*tanh(-4.6971e-01*(std::log(theEnergy)+2.4162e+00));
118  // fraction after the crystal, but before Hcal
119  double frac_ssp2 = 2.8310e+00 + 2.6766e+00 * tanh(-4.8068e-01 * (std::log(theEnergy) + 3.4857e+00));
120 
121  if (fastSimShowerType == 100) { // fastTrack.onEcal() == 1
122 
123  // double rhoTemp = Gflash::ROffCrystalEB +
124  // Gflash::LengthCrystalEB*std::sin(position.getTheta());
125  double rhoTemp = Gflash::LengthCrystalEB * std::sin(position.getTheta());
127  double pathLengthAt2 = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB + rhoTemp);
128  double pathLengthAt3 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmin[Gflash::kHB]);
129 
131  /*
132  if(CLHEP::HepUniformRand() < frac_ssp1 ) {
133  depthAtShower =
134  (pathLengthAt1-thePathLengthOnEcal)*CLHEP::HepUniformRand();
135  }
136  else {
137  */
138  // inside the crystal
139  // depthAtShower = (pathLengthAt1-thePathLengthOnEcal) -
140  // effectiveLambda*log(CLHEP::HepUniformRand());
141  depthAtShower = -effectiveLambda * log(CLHEP::HepUniformRand());
142  // after the crystal
143  if (depthAtShower > (pathLengthAt2 - thePathLengthOnEcal)) {
144  // before Hcal
145  if (CLHEP::HepUniformRand() < frac_ssp2) {
146  depthAtShower =
147  (pathLengthAt2 - thePathLengthOnEcal) + (pathLengthAt3 - pathLengthAt2) * CLHEP::HepUniformRand();
148  }
149  // inside Hcal
150  else {
151  depthAtShower = (pathLengthAt3 - thePathLengthOnEcal) - effectiveLambda * log(CLHEP::HepUniformRand());
152  // check whether the shower starts beyond HB
153  double pathLengthAt4 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]);
154  if (depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
155  depthAtShower = (pathLengthAt4 - pathLengthAt3) * CLHEP::HepUniformRand();
156  }
157  }
158  }
159  // }
160  } else if (fastSimShowerType == 101) { // fastTrack.onEcal() == 2
161 
162  double zTemp = Gflash::LengthCrystalEE;
163  double zsign = (position.getEta() > 0) ? 1.0 : -1.0;
164 
166  double pathLengthAt2 = theHelix->getPathLengthAtZ(zsign * (Gflash::ZFrontCrystalEE + zTemp));
167  double pathLengthAt3 = theHelix->getPathLengthAtZ(zsign * Gflash::Zmin[Gflash::kHE]);
168 
169  /*
170  if(CLHEP::HepUniformRand() < frac_ssp1 ) {
171  depthAtShower =
172  (pathLengthAt1-thePathLengthOnEcal)*CLHEP::HepUniformRand();
173  }
174  else {
175  */
176  // depthAtShower =
177  // (pathLengthAt1-thePathLengthOnEcal)-effectiveLambda*std::log(CLHEP::HepUniformRand());
178  depthAtShower = -effectiveLambda * std::log(CLHEP::HepUniformRand());
179 
180  if (depthAtShower > (pathLengthAt2 - thePathLengthOnEcal)) {
181  if (CLHEP::HepUniformRand() < frac_ssp2) {
182  depthAtShower =
183  (pathLengthAt2 - thePathLengthOnEcal) + (pathLengthAt3 - pathLengthAt2) * CLHEP::HepUniformRand();
184  } else {
185  depthAtShower = (pathLengthAt3 - thePathLengthOnEcal) - effectiveLambda * std::log(CLHEP::HepUniformRand());
186  // shower starts beyond HE
187  double pathLengthAt4 = theHelix->getPathLengthAtZ(zsign * Gflash::Zmax[Gflash::kHE]);
188  if (depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
189  depthAtShower = (pathLengthAt4 - pathLengthAt3) * CLHEP::HepUniformRand();
190  }
191  }
192  }
193  // }
194  } else {
195  depthAtShower = 0.0;
196  }
197 
198  double pathLength = thePathLengthOnEcal + depthAtShower;
199 
201 
202  // return the initial showino position at the shower starting position
204 }
const double ZFrontCrystalEE
double getPathLengthAtZ(double z) const
const double Zmax[kNumberCalorimeter]
double thePathLengthAtShower
Definition: GflashShowino.h:56
GflashTrajectory * theHelix
Definition: GflashShowino.h:67
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Gflash3Vector & simulateFirstInteractionPoint(int showType, Gflash3Vector &pos)
void evaluateLengths()
const double EtaMax[kNumberCalorimeter]
double theStepLengthToHcal
Definition: GflashShowino.h:58
double thePathLength
Definition: GflashShowino.h:62
const double LengthCrystalEE
Gflash3Vector thePosition
Definition: GflashShowino.h:64
const double LengthCrystalEB
T min(T a, T b)
Definition: MathUtil.h:58
double theEnergy
Definition: GflashShowino.h:54
void getGflashTrajectoryPoint(GflashTrajectoryPoint &point, double s) const
int findShowerType(const Gflash3Vector &position)
const double RFrontCrystalEB
const double Zmin[kNumberCalorimeter]
Gflash3Vector thePositionAtShower
Definition: GflashShowino.h:55
CLHEP::Hep3Vector Gflash3Vector
Definition: Gflash3Vector.h:6
double thePathLengthOnEcal
Definition: GflashShowino.h:57
double theEnergyDeposited
Definition: GflashShowino.h:65
Gflash3Vector & getPosition()
static int position[264][3]
Definition: ReadPGInfo.cc:509
double theStepLengthToOut
Definition: GflashShowino.h:59
const double Rmax[kNumberCalorimeter]
GflashTrajectoryPoint theTrajectoryPoint
Definition: GflashShowino.h:68
const double Rmin[kNumberCalorimeter]
double theGlobalTime
Definition: GflashShowino.h:63
double getPathLengthAtRhoEquals(double rho) const
void initialize(int showerType, double energy, double globalTime, double charge, Gflash3Vector &position, Gflash3Vector &momentum, double magneticField)
void initializeTrajectory(const HepGeom::Vector3D< double > &, const HepGeom::Point3D< double > &, double q, double Field)
void updateShowino(double deltaStep)