ATLAS Offline Software
Loading...
Searching...
No Matches
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
14HyperbolaStep::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
30
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);
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;
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
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 }
88
89 // Advance string pointer
90 m_fracLeft *= (1 - fracTaken);
91 if (m_fracLeft <= 0.0) {
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
121void 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}
double charge(const T &p)
Definition AtlasPID.h:997
double length(const pvec &v)
#define sqr(t)
#define y
HyperbolaStep(const HyperbolaStepper *stepper, InfracolorForce &string, const G4Track &track)
G4LorentzVector m_momentum
StringVector m_stringOut
std::deque< StringVector >::const_iterator m_stringEnd
G4double m_maxLength
G4ThreeVector m_position
std::deque< StringVector >::const_iterator m_stringPtr
G4double m_maxFracTaken
G4double m_time
G4double m_length
StringVector m_stringIn
void Dump(G4double y[])
const HyperbolaStepper * m_stepper
void Step(G4double length)
G4double m_fracLeft
STL class.
int r
Definition globals.cxx:22