ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Extensions
Quirks
src
HyperbolaStep.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
HyperbolaStep.h
"
6
7
#include "
HyperbolaStepper.h
"
8
#include "
InfracolorForce.h
"
9
10
#include "G4ElectroMagneticField.hh"
11
#include "G4Track.hh"
12
#include "G4DynamicParticle.hh"
13
14
HyperbolaStep::HyperbolaStep
(
const
HyperbolaStepper
* stepper,
InfracolorForce
&
string
,
const
G4Track& track) :
15
m_stepper
(stepper),
16
m_stringPtr
(
string
.GetStringVectors().begin()),
17
m_stringEnd
(
string
.GetStringVectors().end()),
18
m_fracLeft
(1.0),
19
m_position
(track.GetPosition()),
20
m_time
(track.GetGlobalTime()),
21
m_momentum
(track.GetDynamicParticle()->Get4Momentum()),
22
m_stringIn
(0,0,0,0),
23
m_maxFracTaken
(1.0),
24
m_stringOut
(0,0,0,0),
25
m_maxLength
(0.0),
26
m_length
(0.0)
27
{}
28
29
HyperbolaStep::~HyperbolaStep
() {}
30
31
void
HyperbolaStep::PrepareNextStep
() {
32
if
(
m_stringPtr
==
m_stringEnd
) {
33
// End of string vectors
34
m_stringIn
.set(0,0,0,0);
35
m_stringOut
.set(0,0,0,0);
36
m_maxLength
=
m_length
;
37
}
else
{
38
G4double force =
m_stepper
->GetForce();
39
G4double mass =
m_stepper
->GetMass();
40
41
// Get incoming string vector
42
m_stringIn
= (*m_stringPtr) *
m_fracLeft
;
43
m_maxFracTaken
= 1.0;
44
45
// Find maximum remaining boost allowed for this step
46
G4double gamma0 = std::max(
m_momentum
*
m_stepper
->GetStartMomentum() /
sqr
(mass), 1.0);
47
G4double expRapidity0 = gamma0 + std::sqrt(
sqr
(gamma0) - 1);
48
G4double maxExpRapidity = std::max(
m_stepper
->GetMaxExpRapidity() / expRapidity0, 1.0);
49
50
// Reduce string vector if boost too large
51
G4double tmp = 2 * force *
m_stringIn
.lv() *
m_momentum
/
sqr
(mass);
52
if
(tmp > maxExpRapidity - 1) {
53
m_maxFracTaken
= (maxExpRapidity - 1) / tmp;
54
m_stringIn
*=
m_maxFracTaken
;
55
}
56
57
// Reflect string vector and compute maximum step length
58
m_stringOut
=
m_stringIn
.reflect(
m_momentum
+ force *
m_stringIn
.lv());
59
m_maxLength
=
m_length
+ (
m_stringIn
.lv() +
m_stringOut
.lv()).rho();
60
}
61
}
62
63
void
HyperbolaStep::Step
(G4double
length
) {
64
//G4cout << "steplength/maxlength: " << length << " / " << m_maxLength << G4endl;
65
G4double force =
m_stepper
->GetForce();
66
G4double mass =
m_stepper
->GetMass();
67
68
// Cut step to proper length
69
G4double fracTaken =
m_maxFracTaken
;
70
if
(
length
<
m_maxLength
) {
71
if
(
length
>
m_length
) {
72
// Calculate fraction of string vector to next-to-leading order in step length
73
G4double currMaxLength =
m_maxLength
-
m_length
;
74
for
(G4int i = 0; i < 2 && currMaxLength > 0; i++) {
75
G4double
r
= (
length
-
m_length
) / currMaxLength;
76
m_stringIn
*=
r
;
77
m_stringOut
=
m_stringIn
.reflect(
m_momentum
+ force *
m_stringIn
.lv());
78
fracTaken *=
r
;
79
currMaxLength = (
m_stringIn
.lv() +
m_stringOut
.lv()).rho();
80
}
81
}
else
{
82
m_stringIn
.set(0,0,0,0);
83
m_stringOut
.set(0,0,0,0);
84
fracTaken = 0.0;
85
}
86
}
87
m_length
=
length
;
88
89
// Advance string pointer
90
m_fracLeft
*= (1 - fracTaken);
91
if
(
m_fracLeft
<= 0.0) {
92
if
(
m_stringPtr
!=
m_stringEnd
) ++
m_stringPtr
;
93
m_fracLeft
= 1.0;
94
}
95
96
// Update position, momentum
97
G4LorentzVector dPosition =
m_stringIn
.lv() +
m_stringOut
.lv();
98
m_position
+= dPosition.vect();
99
G4double dTime = dPosition.t() / CLHEP::c_light;
100
m_time
+= dTime;
101
m_momentum
+= force * (
m_stringIn
.lv() -
m_stringOut
.lv());
102
103
// Field
104
if
(
m_stepper
->GetField() != 0) {
105
G4ThreeVector p =
m_position
- dPosition.vect()/2;
106
G4double point[4] = {p.x(), p.y(), p.z(),
m_time
- dTime/2};
107
G4double field[6] = {0};
108
m_stepper
->GetField()->GetFieldValue(point, field);
109
G4ThreeVector B(field[0], field[1], field[2]);
110
G4ThreeVector E(field[3], field[4], field[5]);
111
G4double
charge
=
m_stepper
->GetCharge();
112
G4ThreeVector dMomField = E * dTime + dPosition.vect().cross(B);
113
m_momentum
+=
charge
* G4LorentzVector(CLHEP::c_light * dMomField, E * dPosition.vect());
114
}
115
116
// Renormalize 4-momentum (TODO: address possible instability)
117
m_momentum
*= mass /
m_momentum
.m();
118
}
119
120
// Set track variables
121
void
HyperbolaStep::Dump
(G4double
y
[]) {
122
y
[0] =
m_position
.x();
123
y
[1] =
m_position
.y();
124
y
[2] =
m_position
.z();
125
y
[3] =
m_momentum
.x();
126
y
[4] =
m_momentum
.y();
127
y
[5] =
m_momentum
.z();
128
y
[6] =
m_momentum
.t() -
m_stepper
->GetMass();
129
y
[7] =
m_time
;
130
y
[8] =
m_length
;
131
}
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
length
double length(const pvec &v)
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
HyperbolaStep.h
HyperbolaStepper.h
InfracolorForce.h
sqr
#define sqr(t)
Definition
PolygonTriangulator.cxx:113
y
#define y
HyperbolaStep::HyperbolaStep
HyperbolaStep(const HyperbolaStepper *stepper, InfracolorForce &string, const G4Track &track)
Definition
HyperbolaStep.cxx:14
HyperbolaStep::m_momentum
G4LorentzVector m_momentum
Definition
HyperbolaStep.h:43
HyperbolaStep::PrepareNextStep
void PrepareNextStep()
Definition
HyperbolaStep.cxx:31
HyperbolaStep::m_stringOut
StringVector m_stringOut
Definition
HyperbolaStep.h:47
HyperbolaStep::m_stringEnd
std::deque< StringVector >::const_iterator m_stringEnd
Definition
HyperbolaStep.h:39
HyperbolaStep::m_maxLength
G4double m_maxLength
Definition
HyperbolaStep.h:48
HyperbolaStep::m_position
G4ThreeVector m_position
Definition
HyperbolaStep.h:41
HyperbolaStep::m_stringPtr
std::deque< StringVector >::const_iterator m_stringPtr
Definition
HyperbolaStep.h:38
HyperbolaStep::m_maxFracTaken
G4double m_maxFracTaken
Definition
HyperbolaStep.h:46
HyperbolaStep::~HyperbolaStep
~HyperbolaStep()
Definition
HyperbolaStep.cxx:29
HyperbolaStep::m_time
G4double m_time
Definition
HyperbolaStep.h:42
HyperbolaStep::m_length
G4double m_length
Definition
HyperbolaStep.h:49
HyperbolaStep::m_stringIn
StringVector m_stringIn
Definition
HyperbolaStep.h:45
HyperbolaStep::Dump
void Dump(G4double y[])
Definition
HyperbolaStep.cxx:121
HyperbolaStep::m_stepper
const HyperbolaStepper * m_stepper
Definition
HyperbolaStep.h:36
HyperbolaStep::Step
void Step(G4double length)
Definition
HyperbolaStep.cxx:63
HyperbolaStep::m_fracLeft
G4double m_fracLeft
Definition
HyperbolaStep.h:40
HyperbolaStepper
Definition
HyperbolaStepper.h:19
InfracolorForce
Definition
InfracolorForce.h:14
string
STL class.
r
int r
Definition
globals.cxx:22
Generated on
for ATLAS Offline Software by
1.17.0