Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ErrorTrajState.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// ------------------------------------------------------------
28// GEANT 4 class implementation file
29// ------------------------------------------------------------
30//
31
32#include "G4ErrorTrajState.hh"
33#include "G4ParticleTable.hh"
36
37#include <iomanip>
38
39//--------------------------------------------------------------------------
41 const G4Point3D& pos,
42 const G4Vector3D& mom,
43 const G4ErrorTrajErr& errmat)
44 : fParticleType(partType), fPosition(pos), fMomentum(mom),
45 fError(errmat), theTSType(G4eTS_FREE)
46{
48}
49
50
51//--------------------------------------------------------------------------
53{
54 *this = ts;
55}
56
57
58//--------------------------------------------------------------------------
60 : fParticleType(ts.fParticleType), fPosition(ts.fPosition),
61 fMomentum(ts.fMomentum), fCharge(ts.fCharge),
62 fError(ts.fError), theTSType(ts.theTSType),
63 theG4Track(ts.theG4Track), iverbose(ts.iverbose)
64{
65 // Release data from source object
66 ts.theG4Track = nullptr;
67}
68
69
70//--------------------------------------------------------------------------
72{
73 if(this != &ts)
74 {
78 fCharge = ts.fCharge;
79 fError = ts.fError;
81 iverbose = ts.iverbose;
82 delete theG4Track;
83 theG4Track = new G4Track(*ts.theG4Track);
84 }
85 return *this;
86}
87
88
89//--------------------------------------------------------------------------
91{
92 if(this != &ts)
93 {
94 fParticleType = ts.fParticleType;
95 fPosition = ts.fPosition;
96 fMomentum = ts.fMomentum;
97 fCharge = ts.fCharge;
98 fError = ts.fError;
99 theTSType = ts.theTSType;
100 iverbose = ts.iverbose;
101 delete theG4Track;
102 theG4Track = ts.theG4Track;
103
104 // Release data from source object
105 ts.theG4Track = nullptr;
106 }
107 return *this;
108}
109
110
111//--------------------------------------------------------------------------
113{
114 std::ostringstream message;
115 message << "Wrong trajectory state type !" << G4endl
116 << "Called for trajectory state type: " << G4int(GetTSType());
117 G4Exception("G4ErrorTrajState::PropagateError()", "GEANT4e-Error",
118 FatalException, message);
119 return -1;
120}
121
122
123//--------------------------------------------------------------------------
125 const G4Vector3D& mom )
126{
127 fPosition = pos;
128 fMomentum = mom;
129}
130
131
132//--------------------------------------------------------------------------
134 const G4Point3D& pos, const G4Vector3D& mom )
135{
136 fParticleType = partType;
137 BuildCharge();
138 fPosition = pos;
139 fMomentum = mom;
140}
141
142
143//--------------------------------------------------------------------------
145{
147 G4ParticleDefinition* particle = particleTable->FindParticle(fParticleType);
148 if( particle == nullptr )
149 {
150 std::ostringstream message;
151 message << "Particle type not defined: " << fParticleType;
152 G4Exception( "G4ErrorTrajState::BuildCharge()", "GEANT4e-error",
153 FatalException, message);
154 }
155 else
156 {
157 fCharge = particle->GetPDGCharge();
158 }
159}
160
161
162//------------------------------------------------------------------------
163void G4ErrorTrajState::DumpPosMomError( std::ostream& out ) const
164{
165 out << *this;
166}
167
168
169//--------------------------------------------------------------------------
170std::ostream& operator<<(std::ostream& out, const G4ErrorTrajState& ts)
171{
172 // long mode = out.setf(std::ios::fixed,std::ios::floatfield);
173 out
174 << " G4ErrorTrajState of type " << ts.theTSType << " : partycle: "
175 << ts.fParticleType << " position: " << std::setw(6) << ts.fPosition
176 << " momentum: " << ts.fMomentum
177 << " error matrix ";
178 G4cout << ts.fError << G4endl;
179
180 return out;
181}
182
std::ostream & operator<<(std::ostream &out, const G4ErrorTrajState &ts)
@ G4eTS_FREE
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void DumpPosMomError(std::ostream &out=G4cout) const
G4ErrorTrajErr fError
virtual G4int PropagateError(const G4Track *)
void UpdatePosMom(const G4Point3D &pos, const G4Vector3D &mom)
void SetData(const G4String &partType, const G4Point3D &pos, const G4Vector3D &mom)
G4ErrorTrajState & operator=(const G4ErrorTrajState &)
virtual G4eTSType GetTSType() const
G4double GetPDGCharge() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()