CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GflashTrajectory Class Reference

#include <GflashTrajectory.h>

Public Member Functions

void _cacheSinesAndCosines (double s) const
 
void _refreshCache () const
 
double getCosPhi0 () const
 
double getCosTheta () const
 
double getCotTheta () const
 
double getCurvature () const
 
double getD0 () const
 
HepGeom::Vector3D< double > getDirection (double s=0.0) const
 
void getGflashTrajectoryPoint (GflashTrajectoryPoint &point, double s) const
 
double getL2DAtR (double r) const
 
double getPathLengthAtRhoEquals (double rho) const
 
double getPathLengthAtZ (double z) const
 
double getPhi0 () const
 
HepGeom::Point3D< double > getPosition (double s=0.0) const
 
double getSinPhi0 () const
 
double getSinTheta () const
 
double getZ0 () const
 
double getZAtR (double r) const
 
 GflashTrajectory ()
 
void initializeTrajectory (const HepGeom::Vector3D< double > &, const HepGeom::Point3D< double > &, double q, double Field)
 
void setCotTheta (double cotTheta)
 
void setCurvature (double curvature)
 
void setD0 (double d0)
 
void setPhi0 (double phi0)
 
void setZ0 (double z0)
 
 ~GflashTrajectory ()
 

Private Attributes

double _aa
 
double _cc
 
double _cosPhi0
 
double _cosTheta
 
double _cotTheta
 
double _curvature
 
double _d0
 
bool _isStale
 
double _phi0
 
double _s
 
double _sinPhi0
 
double _sinTheta
 
double _ss
 
double _z0
 

Detailed Description

Definition at line 6 of file GflashTrajectory.h.

Constructor & Destructor Documentation

◆ GflashTrajectory()

GflashTrajectory::GflashTrajectory ( )

Definition at line 5 of file GflashTrajectory.cc.

6  : _cotTheta(0.0),
7  _curvature(0.0),
8  _z0(0.0),
9  _d0(0.0),
10  _phi0(0.0),
11  _isStale(true),
12  _sinPhi0(2),
13  _cosPhi0(2),
14  _sinTheta(2),
15  _cosTheta(2),
16  _s(-999.999),
17  _aa(2),
18  _ss(2),
19  _cc(2) {
20  // detault constructor
21 }

◆ ~GflashTrajectory()

GflashTrajectory::~GflashTrajectory ( )

Definition at line 87 of file GflashTrajectory.cc.

87 {}

Member Function Documentation

◆ _cacheSinesAndCosines()

void GflashTrajectory::_cacheSinesAndCosines ( double  s) const

Definition at line 247 of file GflashTrajectory.cc.

References _aa, _cc, _curvature, _refreshCache(), _s, _sinTheta, _ss, funct::cos(), alignCSCRings::s, and funct::sin().

Referenced by getDirection(), getGflashTrajectoryPoint(), and getPosition().

247  {
248  _refreshCache();
249  if (_s != s) {
250  _s = s;
251  _aa = 2.0 * _s * _curvature * _sinTheta;
252  if (_aa == 0.0) {
253  _ss = 0.0;
254  _cc = 1.0;
255  } else {
256  _ss = sin(_aa);
257  _cc = cos(_aa);
258  }
259  }
260 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void _refreshCache() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22

◆ _refreshCache()

void GflashTrajectory::_refreshCache ( ) const

Definition at line 217 of file GflashTrajectory.cc.

References _cosPhi0, _cosTheta, _cotTheta, _isStale, _phi0, _sinPhi0, _sinTheta, funct::cos(), M_PI, funct::sin(), mathSSE::sqrt(), and theta().

Referenced by _cacheSinesAndCosines(), getCosPhi0(), getCosTheta(), getSinPhi0(), and getSinTheta().

217  {
218  if (_isStale) {
219  _isStale = false;
220  double theta;
221  if (_cotTheta == 0.0) {
222  theta = M_PI / 2.0;
223  } else {
224  theta = atan(1.0 / _cotTheta);
225  if (theta < 0.0)
226  theta += M_PI;
227  }
228  if (theta == 0.0) {
229  _sinTheta = 0.0;
230  _cosTheta = 1.0;
231  } else {
232  _cosTheta = cos(theta);
234  }
235  if (_phi0 == 0.0) {
236  _sinPhi0 = 0.0;
237  _cosPhi0 = 1.0;
238  } else {
239  _cosPhi0 = cos(_phi0);
240  _sinPhi0 = sin(_phi0);
241  // _sinPhi0 = sqrt(1.0-_cosPhi0*_cosPhi0);
242  // if (_phi0>M_PI) _sinPhi0 = -_sinPhi0;
243  }
244  }
245 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:23
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
Geom::Theta< T > theta() const

◆ getCosPhi0()

double GflashTrajectory::getCosPhi0 ( ) const

Definition at line 118 of file GflashTrajectory.cc.

References _cosPhi0, and _refreshCache().

118  {
119  _refreshCache();
120  return _cosPhi0;
121 }
void _refreshCache() const

◆ getCosTheta()

double GflashTrajectory::getCosTheta ( ) const

Definition at line 126 of file GflashTrajectory.cc.

References _cosTheta, and _refreshCache().

Referenced by getPathLengthAtZ().

126  {
127  _refreshCache();
128  return _cosTheta;
129 }
void _refreshCache() const

◆ getCotTheta()

double GflashTrajectory::getCotTheta ( ) const
inline

Definition at line 19 of file GflashTrajectory.h.

References _cotTheta.

Referenced by getZAtR().

19 { return _cotTheta; }

◆ getCurvature()

double GflashTrajectory::getCurvature ( ) const
inline

Definition at line 20 of file GflashTrajectory.h.

References _curvature.

Referenced by getL2DAtR().

20 { return _curvature; }

◆ getD0()

double GflashTrajectory::getD0 ( ) const
inline

Definition at line 22 of file GflashTrajectory.h.

References _d0.

Referenced by getL2DAtR().

22 { return _d0; };

◆ getDirection()

HepGeom::Vector3D< double > GflashTrajectory::getDirection ( double  s = 0.0) const

Definition at line 144 of file GflashTrajectory.cc.

References _cacheSinesAndCosines(), _cc, _cosPhi0, _cosTheta, _sinPhi0, _sinTheta, _ss, and alignCSCRings::s.

144  {
146  if (s == 0.0) {
147  return HepGeom::Vector3D<double>(_cosPhi0 * _sinTheta, _sinPhi0 * _sinTheta, _cosTheta);
148  }
149  double xtan = _sinTheta * (_cosPhi0 * _cc - _sinPhi0 * _ss);
150  double ytan = _sinTheta * (_cosPhi0 * _ss + _sinPhi0 * _cc);
151  double ztan = _cosTheta;
152  return HepGeom::Vector3D<double>(xtan, ytan, ztan);
153 }
void _cacheSinesAndCosines(double s) const

◆ getGflashTrajectoryPoint()

void GflashTrajectory::getGflashTrajectoryPoint ( GflashTrajectoryPoint point,
double  s 
) const

Definition at line 155 of file GflashTrajectory.cc.

References _cacheSinesAndCosines(), _cc, _cosPhi0, _cosTheta, _curvature, _d0, _sinPhi0, _sinTheta, _ss, _z0, point, and alignCSCRings::s.

Referenced by GflashHadronShowerProfile::hadronicParameterization(), CalorimetryManager::HDShowerSimulation(), GflashHadronShowerProfile::hoProfile(), GflashEMShowerProfile::parameterization(), GflashShowino::simulateFirstInteractionPoint(), and GflashShowino::updateShowino().

155  {
157 
158  double cP0sT = _cosPhi0 * _sinTheta, sP0sT = _sinPhi0 * _sinTheta;
159  if (s && _curvature) {
160  point.getPosition().set((_cosPhi0 * _ss - _sinPhi0 * (2.0 * _curvature * _d0 + 1.0 - _cc)) / (2.0 * _curvature),
161  (_sinPhi0 * _ss + _cosPhi0 * (2.0 * _curvature * _d0 + 1.0 - _cc)) / (2.0 * _curvature),
162  s * _cosTheta + _z0);
163 
164  point.getMomentum().set(cP0sT * _cc - sP0sT * _ss, cP0sT * _ss + sP0sT * _cc, _cosTheta);
165  point.setPathLength(s);
166  } else {
167  point.getPosition().set(-_d0 * _sinPhi0 + s * cP0sT, _d0 * _cosPhi0 + s * sP0sT, _z0 + s * _cosTheta);
168 
169  point.getMomentum().set(cP0sT, sP0sT, _cosTheta);
170 
171  point.setPathLength(s);
172  }
173 }
void _cacheSinesAndCosines(double s) const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ getL2DAtR()

double GflashTrajectory::getL2DAtR ( double  r) const

Definition at line 185 of file GflashTrajectory.cc.

References DummyCfis::c, ztail::d, getCurvature(), getD0(), M_PI, rho, and mathSSE::sqrt().

Referenced by getPathLengthAtRhoEquals(), and getZAtR().

185  {
186  double L2D;
187 
188  double c = getCurvature();
189  double d = getD0();
190 
191  if (c != 0.0) {
192  double rad = (rho * rho - d * d) / (1.0 + 2.0 * c * d);
193  double rprime;
194  if (rad < 0.0) {
195  rprime = 0.0;
196  } else {
197  rprime = sqrt(rad);
198  }
199  if (c * rprime > 1.0 || c * rprime < -1.0) {
200  L2D = c * rprime > 0. ? M_PI / c : -M_PI / c;
201  } else
202  L2D = asin(c * rprime) / c;
203  } else {
204  double rad = rho * rho - d * d;
205  double rprime;
206  if (rad < 0.0)
207  rprime = 0.0;
208  else
209  rprime = sqrt(rad);
210 
211  L2D = rprime;
212  }
213  return L2D;
214 }
T sqrt(T t)
Definition: SSEVec.h:23
double getCurvature() const
d
Definition: ztail.py:151
#define M_PI
double getD0() const

◆ getPathLengthAtRhoEquals()

double GflashTrajectory::getPathLengthAtRhoEquals ( double  rho) const

◆ getPathLengthAtZ()

double GflashTrajectory::getPathLengthAtZ ( double  z) const

Definition at line 179 of file GflashTrajectory.cc.

References getCosTheta(), getZ0(), and z.

Referenced by GflashShowino::evaluateLengths(), GflashEMShowerProfile::getDistanceToOut(), and GflashShowino::simulateFirstInteractionPoint().

179  {
180  return (getCosTheta() ? (z - getZ0()) / getCosTheta() : 0.0);
181 }
double getZ0() const
double getCosTheta() const

◆ getPhi0()

double GflashTrajectory::getPhi0 ( ) const
inline

Definition at line 23 of file GflashTrajectory.h.

References _phi0.

23 { return _phi0; };

◆ getPosition()

HepGeom::Point3D< double > GflashTrajectory::getPosition ( double  s = 0.0) const

Definition at line 131 of file GflashTrajectory.cc.

References _cacheSinesAndCosines(), _cc, _cosPhi0, _cosTheta, _curvature, _d0, _s, _sinPhi0, _sinTheta, _ss, _z0, and alignCSCRings::s.

131  {
133  if (s == 0.0 || _curvature == 0.0) {
134  return HepGeom::Point3D<double>(
136  } else {
137  return HepGeom::Point3D<double>(
138  (_cosPhi0 * _ss - _sinPhi0 * (2.0 * _curvature * _d0 + 1.0 - _cc)) / (2.0 * _curvature),
139  (_sinPhi0 * _ss + _cosPhi0 * (2.0 * _curvature * _d0 + 1.0 - _cc)) / (2.0 * _curvature),
140  _s * _cosTheta + _z0);
141  }
142 }
void _cacheSinesAndCosines(double s) const

◆ getSinPhi0()

double GflashTrajectory::getSinPhi0 ( ) const

Definition at line 114 of file GflashTrajectory.cc.

References _refreshCache(), and _sinPhi0.

114  {
115  _refreshCache();
116  return _sinPhi0;
117 }
void _refreshCache() const

◆ getSinTheta()

double GflashTrajectory::getSinTheta ( ) const

Definition at line 122 of file GflashTrajectory.cc.

References _refreshCache(), and _sinTheta.

Referenced by getPathLengthAtRhoEquals().

122  {
123  _refreshCache();
124  return _sinTheta;
125 }
void _refreshCache() const

◆ getZ0()

double GflashTrajectory::getZ0 ( ) const
inline

Definition at line 21 of file GflashTrajectory.h.

References _z0.

Referenced by getPathLengthAtZ().

21 { return _z0; };

◆ getZAtR()

double GflashTrajectory::getZAtR ( double  r) const

Definition at line 183 of file GflashTrajectory.cc.

References _z0, getCotTheta(), getL2DAtR(), and rho.

183 { return _z0 + getCotTheta() * getL2DAtR(rho); }
double getCotTheta() const
double getL2DAtR(double r) const

◆ initializeTrajectory()

void GflashTrajectory::initializeTrajectory ( const HepGeom::Vector3D< double > &  MomentumGev,
const HepGeom::Point3D< double > &  PositionCm,
double  q,
double  Field 
)

Definition at line 27 of file GflashTrajectory.cc.

References _aa, _cc, _cosPhi0, _cosTheta, _cotTheta, _curvature, _d0, _isStale, _phi0, _s, _sinPhi0, _sinTheta, _ss, _z0, funct::cos(), CustomPhysics_cfi::gamma, M_PI, submitPVResolutionJobs::q, alignCSCRings::s, funct::sin(), x, y, z, and Z0.

Referenced by GflashShowino::initialize().

30  {
31  double CotTheta = 0.0;
32  double W = 0;
33  double Z0 = 0;
34  double D0 = 0;
35  double Phi0 = 0;
36 
37  if (BFieldTesla != 0.0 && q != 0.0) {
38  double CurvatureConstant = 0.0029979;
39  double Helicity = -1.0 * fabs(BFieldTesla) * fabs(q) / (BFieldTesla * q);
40  double Radius = fabs(MomentumGev.perp() / (CurvatureConstant * BFieldTesla * q));
41 
42  if (Radius == 0.0)
43  W = HUGE_VAL;
44  else
45  W = Helicity / Radius;
46  double phi1 = MomentumGev.phi();
47  double x = PositionCm.x(), y = PositionCm.y(), z = PositionCm.z();
48  double sinPhi1 = sin(phi1), cosPhi1 = cos(phi1);
49  double gamma = atan((x * cosPhi1 + y * sinPhi1) / (x * sinPhi1 - y * cosPhi1 - 1 / W));
50  Phi0 = phi1 + gamma;
51  if (Phi0 > M_PI)
52  Phi0 = Phi0 - 2.0 * M_PI;
53  if (Phi0 < -M_PI)
54  Phi0 = Phi0 + 2.0 * M_PI;
55  D0 = ((1 / W + y * cosPhi1 - x * sinPhi1) / cos(gamma) - 1 / W);
56  CotTheta = MomentumGev.z() / MomentumGev.perp();
57  Z0 = z + gamma * CotTheta / W;
58  } else {
59  CLHEP::Hep3Vector direction = MomentumGev.unit();
60  CLHEP::Hep3Vector projectedDirection = CLHEP::Hep3Vector(direction.x(), direction.y(), 0.0).unit();
61  double s = projectedDirection.dot(PositionCm);
62  double sprime = s / sin(direction.theta());
63  Z0 = (PositionCm - sprime * direction).z();
64  Phi0 = MomentumGev.phi();
65  CotTheta = MomentumGev.z() / MomentumGev.perp();
66  W = 0.0;
67  D0 = (PositionCm.y() * cos(Phi0) - PositionCm.x() * sin(Phi0));
68  }
69 
70  _cotTheta = CotTheta;
71  _curvature = W / 2;
72  _z0 = Z0;
73  _d0 = D0;
74  _phi0 = Phi0;
75 
76  _isStale = true;
77  _s = -999.999;
78  _aa = -999.999;
79  _ss = -999.999;
80  _cc = -999.999;
81  _sinPhi0 = 1.0;
82  _cosPhi0 = 1.0;
83  _sinTheta = 1.0;
84  _cosTheta = 1.0;
85 }
Divides< arg, void > D0
Definition: Factorize.h:135
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
static const double Z0

◆ setCotTheta()

void GflashTrajectory::setCotTheta ( double  cotTheta)

Definition at line 89 of file GflashTrajectory.cc.

References _cotTheta, and _isStale.

89  {
90  _cotTheta = cotTheta;
91  _isStale = true;
92 }

◆ setCurvature()

void GflashTrajectory::setCurvature ( double  curvature)

Definition at line 94 of file GflashTrajectory.cc.

References _curvature, _isStale, and PixelRecoUtilities::curvature().

94  {
96  _isStale = true;
97 }
T curvature(T InversePt, const MagneticField &field)

◆ setD0()

void GflashTrajectory::setD0 ( double  d0)

Definition at line 104 of file GflashTrajectory.cc.

References _d0, _isStale, and d0.

104  {
105  _d0 = d0;
106  _isStale = true;
107 }
static constexpr float d0

◆ setPhi0()

void GflashTrajectory::setPhi0 ( double  phi0)

Definition at line 109 of file GflashTrajectory.cc.

References _isStale, and _phi0.

109  {
110  _phi0 = phi0;
111  _isStale = true;
112 }

◆ setZ0()

void GflashTrajectory::setZ0 ( double  z0)

Definition at line 99 of file GflashTrajectory.cc.

References _isStale, _z0, and HLTMuonOfflineAnalyzer_cfi::z0.

Member Data Documentation

◆ _aa

double GflashTrajectory::_aa
mutableprivate

Definition at line 66 of file GflashTrajectory.h.

Referenced by _cacheSinesAndCosines(), and initializeTrajectory().

◆ _cc

double GflashTrajectory::_cc
mutableprivate

◆ _cosPhi0

double GflashTrajectory::_cosPhi0
mutableprivate

◆ _cosTheta

double GflashTrajectory::_cosTheta
mutableprivate

◆ _cotTheta

double GflashTrajectory::_cotTheta
private

Definition at line 52 of file GflashTrajectory.h.

Referenced by _refreshCache(), getCotTheta(), initializeTrajectory(), and setCotTheta().

◆ _curvature

double GflashTrajectory::_curvature
private

◆ _d0

double GflashTrajectory::_d0
private

◆ _isStale

bool GflashTrajectory::_isStale
mutableprivate

◆ _phi0

double GflashTrajectory::_phi0
private

Definition at line 56 of file GflashTrajectory.h.

Referenced by _refreshCache(), getPhi0(), initializeTrajectory(), and setPhi0().

◆ _s

double GflashTrajectory::_s
mutableprivate

Definition at line 64 of file GflashTrajectory.h.

Referenced by _cacheSinesAndCosines(), getPosition(), and initializeTrajectory().

◆ _sinPhi0

double GflashTrajectory::_sinPhi0
mutableprivate

◆ _sinTheta

double GflashTrajectory::_sinTheta
mutableprivate

◆ _ss

double GflashTrajectory::_ss
mutableprivate

◆ _z0

double GflashTrajectory::_z0
private