ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ErrorTrajState.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ErrorTrajState.cc
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"
34 #include "G4ParticleDefinition.hh"
35 #include "G4ErrorPropagatorData.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), fCharge(0.),
45  fError(errmat), theTSType(G4eTS_FREE), theG4Track(0)
46 {
48 }
49 
50 
51 //--------------------------------------------------------------------------
53 {
54  std::ostringstream message;
55  message << "Wrong trajectory state type !" << G4endl
56  << "Called for trajectory state type: " << G4int(GetTSType());
57  G4Exception("G4ErrorTrajState::PropagateError()", "GEANT4e-Error",
58  FatalException, message);
59  return -1;
60 }
61 
62 
63 //--------------------------------------------------------------------------
65  const G4Vector3D& mom )
66 {
67  fPosition = pos;
68  fMomentum = mom;
69 }
70 
71 
72 //--------------------------------------------------------------------------
73 void G4ErrorTrajState::SetData( const G4String& partType,
74  const G4Point3D& pos, const G4Vector3D& mom )
75 {
76  fParticleType = partType;
77  BuildCharge();
78  fPosition = pos;
79  fMomentum = mom;
80 }
81 
82 
83 //--------------------------------------------------------------------------
85 {
88  if( particle == 0)
89  {
90  std::ostringstream message;
91  message << "Particle type not defined: " << fParticleType;
92  G4Exception( "G4ErrorTrajState::BuildCharge()", "GEANT4e-error",
93  FatalException, message);
94  }
95  else
96  {
97  fCharge = particle->GetPDGCharge();
98  }
99 }
100 
101 
102 //------------------------------------------------------------------------
103 void G4ErrorTrajState::DumpPosMomError( std::ostream& out ) const
104 {
105  out << *this;
106 }
107 
108 
109 //--------------------------------------------------------------------------
110 std::ostream& operator<<(std::ostream& out, const G4ErrorTrajState& ts)
111 {
112  // long mode = out.setf(std::ios::fixed,std::ios::floatfield);
113  out
114  << " G4ErrorTrajState of type " << ts.theTSType << " : partycle: "
115  << ts.fParticleType << " position: " << std::setw(6) << ts.fPosition
116  << " momentum: " << ts.fMomentum
117  << " error matrix ";
118  G4cout << ts.fError << G4endl;
119 
120  return out;
121 }
122