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]) {
72  }
73  else if (std::fabs(eta) < Gflash::EtaMax[Gflash::kENCA] ) {
74  double zsign = (eta > 0) ? 1.0 : -1.0 ;
79  }
80  else {
81  //@@@extend for HF later
82  theStepLengthToOut = 200.0;
83  }
84 
86 
87 }
88 
89 
91 
92  //determine the shower starting point (ssp):
93  //the position at the entrance + the mean free path till the inelastic interaction inside calo
94 
95  double depthAtShower = 0.0;
96 
97  //set thePathLengthOnEcal, the pathLength at the reference (r=123.8 for barrel and z=304.5 for endcap)
98 
99  //effective interaction length fitter to ssp from Geant4
100  double effectiveLambda = 0.0;
101  if(theEnergy > 0.0 && theEnergy < 15) {
102  effectiveLambda = 24.6+2.6*std::tanh(3.0*(std::log(theEnergy)-1.43));
103  }
104  else {
105  effectiveLambda = 28.4+1.20*std::tanh(1.5*(std::log(theEnergy)-4.3));
106  }
107  //fraction before the crystal, but inside Ecal
108  // double frac_ssp1 = 1.5196e-01+1.3300e-01*tanh(-4.6971e-01*(std::log(theEnergy)+2.4162e+00));
109  //fraction after the crystal, but before Hcal
110  double frac_ssp2 = 2.8310e+00+2.6766e+00*tanh(-4.8068e-01*(std::log(theEnergy)+3.4857e+00));
111 
112  if(fastSimShowerType == 100 ) { //fastTrack.onEcal() == 1
113 
114  // double rhoTemp = Gflash::ROffCrystalEB + Gflash::LengthCrystalEB*std::sin(position.getTheta());
115  double rhoTemp = Gflash::LengthCrystalEB*std::sin(position.getTheta());
117  double pathLengthAt2 = theHelix->getPathLengthAtRhoEquals(Gflash::RFrontCrystalEB + rhoTemp );
118  double pathLengthAt3 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmin[Gflash::kHB]);
119 
121  /*
122  if(CLHEP::HepUniformRand() < frac_ssp1 ) {
123  depthAtShower = (pathLengthAt1-thePathLengthOnEcal)*CLHEP::HepUniformRand();
124  }
125  else {
126  */
127  //inside the crystal
128  // depthAtShower = (pathLengthAt1-thePathLengthOnEcal) - effectiveLambda*log(CLHEP::HepUniformRand());
129  depthAtShower = - effectiveLambda*log(CLHEP::HepUniformRand());
130  //after the crystal
131  if(depthAtShower > (pathLengthAt2 - thePathLengthOnEcal) ) {
132  //before Hcal
133  if(CLHEP::HepUniformRand() < frac_ssp2 ) {
134  depthAtShower = (pathLengthAt2 - thePathLengthOnEcal) + (pathLengthAt3-pathLengthAt2)*CLHEP::HepUniformRand();
135  }
136  //inside Hcal
137  else {
138  depthAtShower = (pathLengthAt3 - thePathLengthOnEcal) - effectiveLambda*log(CLHEP::HepUniformRand());
139  //check whether the shower starts beyond HB
140  double pathLengthAt4 = theHelix->getPathLengthAtRhoEquals(Gflash::Rmax[Gflash::kHB]);
141  if(depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
142  depthAtShower = (pathLengthAt4 - pathLengthAt3)*CLHEP::HepUniformRand();
143  }
144  }
145  }
146  // }
147  }
148  else if(fastSimShowerType == 101 ) { //fastTrack.onEcal() == 2
149 
150  double zTemp = Gflash::LengthCrystalEE;
151  double zsign = (position.getEta() > 0) ? 1.0 : -1.0 ;
152 
154  double pathLengthAt2 = theHelix->getPathLengthAtZ(zsign*(Gflash::ZFrontCrystalEE + zTemp));
155  double pathLengthAt3 = theHelix->getPathLengthAtZ(zsign*Gflash::Zmin[Gflash::kHE]);
156 
157  /*
158  if(CLHEP::HepUniformRand() < frac_ssp1 ) {
159  depthAtShower = (pathLengthAt1-thePathLengthOnEcal)*CLHEP::HepUniformRand();
160  }
161  else {
162  */
163  // depthAtShower = (pathLengthAt1-thePathLengthOnEcal)-effectiveLambda*std::log(CLHEP::HepUniformRand());
164  depthAtShower = -effectiveLambda*std::log(CLHEP::HepUniformRand());
165 
166  if(depthAtShower > (pathLengthAt2 - thePathLengthOnEcal) ) {
167  if(CLHEP::HepUniformRand() < frac_ssp2 ) {
168  depthAtShower = (pathLengthAt2 - thePathLengthOnEcal) +(pathLengthAt3 - pathLengthAt2)*CLHEP::HepUniformRand();
169  }
170  else {
171  depthAtShower = (pathLengthAt3 - thePathLengthOnEcal)-effectiveLambda*std::log(CLHEP::HepUniformRand());
172  //shower starts beyond HE
173  double pathLengthAt4 = theHelix->getPathLengthAtZ(zsign*Gflash::Zmax[Gflash::kHE]);
174  if(depthAtShower > (pathLengthAt4 - thePathLengthOnEcal)) {
175  depthAtShower = (pathLengthAt4 - pathLengthAt3)*CLHEP::HepUniformRand();
176  }
177  }
178  }
179  // }
180  }
181  else {
182  depthAtShower = 0.0;
183  }
184 
185  double pathLength = thePathLengthOnEcal + depthAtShower;
186  GflashTrajectoryPoint trajectoryPoint;
187  theHelix->getGflashTrajectoryPoint(trajectoryPoint,pathLength);
188 
189  //return the initial showino position at the shower starting position
190  return trajectoryPoint.getPosition();
191 
192 }
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()
#define min(a, b)
Definition: mlp_lapack.h:161
const double EtaMax[kNumberCalorimeter]
T eta() const
double charge(const std::vector< uint8_t > &Ampls)
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
double theStepLengthToHcal
Definition: GflashShowino.h:56
int findShowerType(const Gflash3Vector position)
double thePathLength
Definition: GflashShowino.h:60
const double LengthCrystalEE
Gflash3Vector thePosition
Definition: GflashShowino.h:62
const double LengthCrystalEB
double theEnergy
Definition: GflashShowino.h:52
void getGflashTrajectoryPoint(GflashTrajectoryPoint &point, double s) const
const double RFrontCrystalEB
const double Zmin[kNumberCalorimeter]
Log< T >::type log(const T &t)
Definition: Log.h:22
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()
double theStepLengthToOut
Definition: GflashShowino.h:57
const double Rmax[kNumberCalorimeter]
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)