CMS 3D CMS Logo

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