ATLAS Offline Software
InfracolorForce.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 "InfracolorForce.h"
6 
7 #include "G4Track.hh"
8 #include "G4DynamicParticle.hh"
9 
11  m_stringForce(0.0),
12  m_reactionForce(0),
13  m_initU(),
14  m_initialized(false),
15  m_killed(false),
16  m_firstStep(false),
17  m_stringVectors(),
18  m_firstString(),
19  m_borrowedString(),
20  m_firstStringLength(1*CLHEP::nm),
21  m_maxExpRapidity(1e-3),
22  m_maxMergeT(0.0),
23  m_maxMergeMag(0.0)
24 {}
25 
27 
28 void InfracolorForce::StartTracking(const G4Track* dest) {
29  if (m_reactionForce == 0) {
30  G4Exception("InfracolorForce::StartTracking", "NoAntiQuirk", FatalErrorInArgument, "InfracolorForce: No antiquirk defined");
31  }
32  if (dest->GetCurrentStepNumber() != 0) return;
33 
34  // Clear old stuff
36  Clear();
38  }
39 
40  // Set momentum
41  m_initialized = true;
42  m_initU = dest->GetDynamicParticle()->Get4Momentum();
43  m_initU /= m_initU.m();
44 
45  // Compute first string vector
47  m_firstStep = true;
48  G4double dot = m_initU * m_reactionForce->m_initU;
49  G4LorentzVector firstString = m_reactionForce->m_initU - m_initU * (dot - std::sqrt(dot*dot - 1));
50  firstString *= m_firstStringLength / firstString.t();
51  m_firstString.set(firstString.vect(), 0);
52  m_stringVectors.push_back(m_firstString);
53  // TODO: Check oscillation period
54  }
55 }
56 
58  m_initU.set(0,0,0,0);
59  m_initialized = false;
60  m_killed = false;
61  m_firstStep = false;
62  m_stringVectors.clear();
63  m_firstString.set(0,0,0,0);
64  m_borrowedString.set(0,0,0,0);
65 }
66 
68  //G4cout << "killed, and other killed is " << m_reactionForce->m_killed << G4endl;
69  m_killed = true;
70 }
71 
72 void InfracolorForce::PopTo(std::deque<StringVector>::const_iterator stringPtr, G4double fracLeft) {
73  if (fracLeft > 1.0 || fracLeft < 0.0) {
74  Clear();
76  G4Exception("InfracolorForce::PopTo", "QuirkStringBadFraction", EventMustBeAborted, "invalid fraction of string vector");
77  }
78  if (m_firstStep) {
79  if (stringPtr == m_stringVectors.begin()) {
80  m_borrowedString = (1 - fracLeft) * m_firstString;
81  } else {
83  }
84  m_firstStep = false;
85  m_stringVectors.clear();
86  } else {
87  std::deque<StringVector>::iterator stringPtr2 = m_stringVectors.begin() + (stringPtr - m_stringVectors.begin());
88  m_stringVectors.erase(m_stringVectors.begin(), stringPtr2);
89  if (fracLeft != 1.0 && !m_stringVectors.empty()) {
90  m_stringVectors[0] *= fracLeft;
91  }
92  }
93 }
94 
96  if (v.t() == 0) return;
97  if (m_borrowedString.t() == 0) {
99  } else if (m_borrowedString.t() <= v.t()) {
100  G4double r = m_borrowedString.t() / v.t();
101  CombineStringVector((1-r) * v);
102  m_borrowedString.set(0,0,0,0);
103  } else {
104  G4double r = v.t() / m_borrowedString.t();
105  m_borrowedString *= 1-r;
106  G4Exception("InfracolorForce::PushStringVector()",
107  "BorrowedStringSplit", JustWarning,
108  "Initial step too long.");
109  }
110 }
111 
113  if (m_stringVectors.empty()) {
114  m_stringVectors.push_back(v);
115  } else {
116  G4LorentzVector sum = m_stringVectors.back().lv() + v.lv();
117  if (sum.t() < m_maxMergeT && sum.m2() < sqr(m_maxMergeMag)) {
118  m_stringVectors.back().set(sum.vect(), sum.m());
119  } else {
120  m_stringVectors.push_back(v);
121  }
122  }
123 }
124 
125 G4LorentzVector InfracolorForce::GetSumStrings() const {
126  G4LorentzVector x(0,0,0,0);
127  std::deque<StringVector>::const_iterator it = m_stringVectors.begin();
128  for (; it != m_stringVectors.end(); ++it) {
129  x += it->lv();
130  }
131  return x - m_borrowedString.lv();
132 }
133 
134 G4ThreeVector InfracolorForce::GetAngMomentum() const {
135  std::deque<StringVector>::const_iterator it = m_stringVectors.begin();
136  G4LorentzVector x(0,0,0,0);
137  G4ThreeVector L(0,0,0);
138  for (; it != m_stringVectors.end(); ++it) {
139  G4LorentzVector dx = it->lv();
140  L += m_stringForce * x.vect().cross(dx.vect());
141  x += dx;
142  }
143  return L;
144 }
145 
146 G4ThreeVector InfracolorForce::GetMomentOfE() const {
147  std::deque<StringVector>::const_iterator it = m_stringVectors.begin();
148  G4LorentzVector x(0,0,0,0);
149  G4ThreeVector Excm(0,0,0);
150  for (; it != m_stringVectors.end(); ++it) {
151  G4LorentzVector dx = it->lv();
152  Excm += m_stringForce * (dx.t() * x.vect() - dx.vect() * x.t());
153  x += dx;
154  }
155  return Excm;
156 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
beamspotman.r
def r
Definition: beamspotman.py:676
InfracolorForce::InfracolorForce
InfracolorForce()
Definition: InfracolorForce.cxx:10
InfracolorForce::m_initU
G4LorentzVector m_initU
Definition: InfracolorForce.h:47
StringVector::t
G4double t() const
Definition: StringVector.h:62
InfracolorForce::m_firstStringLength
G4double m_firstStringLength
Definition: InfracolorForce.h:54
StringVector::set
void set(const G4ThreeVector &p, G4double m)
Definition: StringVector.h:74
skel.it
it
Definition: skel.GENtoEVGEN.py:423
InfracolorForce::m_initialized
G4bool m_initialized
Definition: InfracolorForce.h:48
perfmonmt-printer.dest
dest
Definition: perfmonmt-printer.py:189
InfracolorForce::StartTracking
void StartTracking(const G4Track *dest)
Definition: InfracolorForce.cxx:28
InfracolorForce::~InfracolorForce
~InfracolorForce()
Definition: InfracolorForce.cxx:26
x
#define x
InfracolorForce::PopTo
void PopTo(std::deque< StringVector >::const_iterator stringPtr, G4double fracLeft)
Definition: InfracolorForce.cxx:72
InfracolorForce::PushStringVector
void PushStringVector(const StringVector &v)
Definition: InfracolorForce.cxx:95
InfracolorForce::m_stringVectors
std::deque< StringVector > m_stringVectors
Definition: InfracolorForce.h:51
InfracolorForce::m_stringForce
G4double m_stringForce
Definition: InfracolorForce.h:45
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
InfracolorForce::CombineStringVector
void CombineStringVector(const StringVector &v)
Definition: InfracolorForce.cxx:112
sqr
#define sqr(t)
Definition: PolygonTriangulator.cxx:110
InfracolorForce::Clear
void Clear()
Definition: InfracolorForce.cxx:57
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
InfracolorForce::GetAngMomentum
G4ThreeVector GetAngMomentum() const
Definition: InfracolorForce.cxx:134
InfracolorForce::m_reactionForce
InfracolorForce * m_reactionForce
Definition: InfracolorForce.h:46
StringVector
Definition: StringVector.h:11
InfracolorForce::m_maxMergeT
G4double m_maxMergeT
Definition: InfracolorForce.h:56
InfracolorForce.h
InfracolorForce::m_killed
G4bool m_killed
Definition: InfracolorForce.h:49
InfracolorForce::m_firstString
StringVector m_firstString
Definition: InfracolorForce.h:52
InfracolorForce::GetSumStrings
G4LorentzVector GetSumStrings() const
Definition: InfracolorForce.cxx:125
python.PyAthena.v
v
Definition: PyAthena.py:157
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
InfracolorForce::TrackKilled
void TrackKilled()
Definition: InfracolorForce.cxx:67
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
InfracolorForce::m_maxMergeMag
G4double m_maxMergeMag
Definition: InfracolorForce.h:57
InfracolorForce::GetMomentOfE
G4ThreeVector GetMomentOfE() const
Definition: InfracolorForce.cxx:146
StringVector::lv
G4LorentzVector lv() const
Definition: StringVector.h:66
dot
Definition: dot.py:1
InfracolorForce::m_borrowedString
StringVector m_borrowedString
Definition: InfracolorForce.h:53
InfracolorForce::m_firstStep
G4bool m_firstStep
Definition: InfracolorForce.h:50