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);
34 
35  if (showerType < 100) {
38  theShowerType = showerType;
39 
40  } else {
41  // this input is from FastSimulation
42  // 1. simulate the shower starting 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 }
GflashShowino::thePositionAtShower
Gflash3Vector thePositionAtShower
Definition: GflashShowino.h:55
GflashTrajectory::getPathLengthAtRhoEquals
double getPathLengthAtRhoEquals(double rho) const
Definition: GflashTrajectory.cc:175
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
Gflash::LengthCrystalEE
const double LengthCrystalEE
Definition: GflashNameSpace.h:41
Gflash::ZFrontCrystalEE
const double ZFrontCrystalEE
Definition: GflashNameSpace.h:37
min
T min(T a, T b)
Definition: MathUtil.h:58
Gflash::Rmax
const double Rmax[kNumberCalorimeter]
Definition: GflashNameSpace.h:31
GflashShowino::initialize
void initialize(int showerType, double energy, double globalTime, double charge, Gflash3Vector &position, Gflash3Vector &momentum, double magneticField)
Definition: GflashShowino.cc:21
GflashShowino::updateShowino
void updateShowino(double deltaStep)
Definition: GflashShowino.cc:53
Gflash::EtaMax
const double EtaMax[kNumberCalorimeter]
Definition: GflashNameSpace.h:34
GflashTrajectory::initializeTrajectory
void initializeTrajectory(const HepGeom::Vector3D< double > &, const HepGeom::Point3D< double > &, double q, double Field)
Definition: GflashTrajectory.cc:27
Gflash::findShowerType
int findShowerType(const Gflash3Vector &position)
Definition: GflashNameSpace.cc:41
GflashShowino::thePosition
Gflash3Vector thePosition
Definition: GflashShowino.h:64
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
GflashTrajectory
Definition: GflashTrajectory.h:6
GflashShowino::thePathLength
double thePathLength
Definition: GflashShowino.h:62
Gflash::kHB
Definition: GflashNameSpace.h:13
Gflash::kHE
Definition: GflashNameSpace.h:15
Gflash::kENCA
Definition: GflashNameSpace.h:14
Gflash::Zmax
const double Zmax[kNumberCalorimeter]
Definition: GflashNameSpace.h:29
PVValHelper::eta
Definition: PVValidationHelpers.h:69
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
GflashShowino::~GflashShowino
~GflashShowino()
Definition: GflashShowino.cc:19
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
GflashTrajectoryPoint::getPosition
Gflash3Vector & getPosition()
Definition: GflashTrajectoryPoint.h:20
Gflash::LengthCrystalEB
const double LengthCrystalEB
Definition: GflashNameSpace.h:40
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
GflashShowino::simulateFirstInteractionPoint
Gflash3Vector & simulateFirstInteractionPoint(int showType, Gflash3Vector &pos)
Definition: GflashShowino.cc:98
GflashShowino::evaluateLengths
void evaluateLengths()
Definition: GflashShowino.cc:64
Gflash::Zmin
const double Zmin[kNumberCalorimeter]
Definition: GflashNameSpace.h:28
Gflash3Vector
CLHEP::Hep3Vector Gflash3Vector
Definition: Gflash3Vector.h:6
GflashShowino::GflashShowino
GflashShowino()
Definition: GflashShowino.cc:4
Gflash::RFrontCrystalEB
const double RFrontCrystalEB
Definition: GflashNameSpace.h:36
GflashShowino::thePathLengthOnEcal
double thePathLengthOnEcal
Definition: GflashShowino.h:57
GflashShowino::theEnergyDeposited
double theEnergyDeposited
Definition: GflashShowino.h:65
GflashShowino::thePathLengthAtShower
double thePathLengthAtShower
Definition: GflashShowino.h:56
GflashShowino::theStepLengthToHcal
double theStepLengthToHcal
Definition: GflashShowino.h:58
GflashShowino::theHelix
GflashTrajectory * theHelix
Definition: GflashShowino.h:67
GflashTrajectory::getPathLengthAtZ
double getPathLengthAtZ(double z) const
Definition: GflashTrajectory.cc:179
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
GflashShowino.h
Gflash::Rmin
const double Rmin[kNumberCalorimeter]
Definition: GflashNameSpace.h:30
GflashShowino::theShowerType
int theShowerType
Definition: GflashShowino.h:53
GflashShowino::theEnergy
double theEnergy
Definition: GflashShowino.h:54
GflashShowino::theGlobalTime
double theGlobalTime
Definition: GflashShowino.h:63
GflashShowino::theStepLengthToOut
double theStepLengthToOut
Definition: GflashShowino.h:59
GflashTrajectoryPoint
Definition: GflashTrajectoryPoint.h:8
GflashShowino::theTrajectoryPoint
GflashTrajectoryPoint theTrajectoryPoint
Definition: GflashShowino.h:68
Gflash::kESPM
Definition: GflashNameSpace.h:12
GflashTrajectory::getGflashTrajectoryPoint
void getGflashTrajectoryPoint(GflashTrajectoryPoint &point, double s) const
Definition: GflashTrajectory.cc:155
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37