ATLAS Offline Software
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 
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
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;
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) {
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;
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 }
beamspotman.r
def r
Definition: beamspotman.py:676
HyperbolaStep::~HyperbolaStep
~HyperbolaStep()
Definition: HyperbolaStep.cxx:29
HyperbolaStep::HyperbolaStep
HyperbolaStep(const HyperbolaStepper *stepper, InfracolorForce &string, const G4Track &track)
Definition: HyperbolaStep.cxx:14
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
HyperbolaStepper::GetStartMomentum
const G4LorentzVector & GetStartMomentum() const
Definition: HyperbolaStepper.h:74
calibdata.force
bool force
Definition: calibdata.py:19
StringVector::set
void set(const G4ThreeVector &p, G4double m)
Definition: StringVector.h:74
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
HyperbolaStep::m_stringEnd
std::deque< StringVector >::const_iterator m_stringEnd
Definition: HyperbolaStep.h:39
HyperbolaStepper::GetMass
G4double GetMass() const
Definition: HyperbolaStepper.h:72
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
HyperbolaStep::m_momentum
G4LorentzVector m_momentum
Definition: HyperbolaStep.h:43
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
HyperbolaStepper.h
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
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::m_length
G4double m_length
Definition: HyperbolaStep.h:49
HyperbolaStepper
Definition: HyperbolaStepper.h:19
HyperbolaStep::m_maxLength
G4double m_maxLength
Definition: HyperbolaStep.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:92
InfracolorForce
Definition: InfracolorForce.h:14
sqr
#define sqr(t)
Definition: PolygonTriangulator.cxx:110
StringVector::reflect
StringVector reflect(const G4LorentzVector &axis) const
Definition: StringVector.h:70
HyperbolaStep::m_stringOut
StringVector m_stringOut
Definition: HyperbolaStep.h:47
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
HyperbolaStepper::GetMaxExpRapidity
G4double GetMaxExpRapidity() const
Definition: HyperbolaStepper.h:75
HyperbolaStepper::GetField
const G4ElectroMagneticField * GetField() const
Definition: HyperbolaStepper.h:71
HyperbolaStepper::GetForce
G4double GetForce() const
Definition: HyperbolaStepper.h:70
InfracolorForce.h
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
HyperbolaStepper::GetCharge
G4double GetCharge() const
Definition: HyperbolaStepper.h:73
charge
double charge(const T &p)
Definition: AtlasPID.h:494
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
python.PhysicalConstants.c_light
float c_light
Definition: PhysicalConstants.py:63
HyperbolaStep::m_stepper
const HyperbolaStepper * m_stepper
Definition: HyperbolaStep.h:36
HyperbolaStep::Dump
void Dump(G4double y[])
Definition: HyperbolaStep.cxx:121
y
#define y
HyperbolaStep::m_stringIn
StringVector m_stringIn
Definition: HyperbolaStep.h:45
StringVector::lv
G4LorentzVector lv() const
Definition: StringVector.h:66
HyperbolaStep::Step
void Step(G4double length)
Definition: HyperbolaStep.cxx:63
HyperbolaStep::m_position
G4ThreeVector m_position
Definition: HyperbolaStep.h:41
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
HyperbolaStep::m_time
G4double m_time
Definition: HyperbolaStep.h:42
HyperbolaStep.h
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
HyperbolaStep::PrepareNextStep
void PrepareNextStep()
Definition: HyperbolaStep.cxx:31
fitman.rho
rho
Definition: fitman.py:532
HyperbolaStep::m_fracLeft
G4double m_fracLeft
Definition: HyperbolaStep.h:40