Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
errprop.cc File Reference

Main program of the errorpropagation example. More...

Include dependency graph for errprop.cc:

Go to the source code of this file.

Functions

void Initialize ()
 
G4ErrorTargetBuildTarget (G4int iTarget)
 
void ProcessEvent (G4int iProp, size_t nEv)
 
void Finalize ()
 
int main ()
 

Variables

G4ErrorTargettheTarget
 
G4ErrorMode theG4ErrorMode
 

Detailed Description

Main program of the errorpropagation example.

Definition in file errprop.cc.

Function Documentation

G4ErrorTarget * BuildTarget ( G4int  iTarget)

Definition at line 233 of file errprop.cc.

234 {
235 
236  G4ErrorTarget* target = 0;
237  if( iTarget == 1 ) {
238  G4Point3D surfPos(221.*cm,0.,0.);
239  G4Normal3D surfNorm(1.,0.,0.);
240  target = new G4ErrorPlaneSurfaceTarget(surfNorm, surfPos );
241  }else if( iTarget == 2 ) {
242  G4double radius = 222*cm;
243  target = new G4ErrorCylSurfaceTarget(radius);
244  }else if( iTarget == 3 ) {
245  target = new G4ErrorGeomVolumeTarget("MUON");
246  }else if( iTarget == 4 ) {
247  target = new G4ErrorTrackLengthTarget(223.*cm);
248  }else {
249  G4Exception("exG4eReco","Fatal error in Argument",
250  FatalErrorInArgument,"Target type has to be between 1 and 4");
251  }
252  return target;
253 }
const XML_Char * target
Definition: expat.h:268
static constexpr double cm
Definition: G4SIunits.hh:119
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void Finalize ( )

Definition at line 257 of file errprop.cc.

258 {
260 
261 }
static G4ErrorPropagatorManager * GetErrorPropagatorManager()

Here is the call graph for this function:

Here is the caller graph for this function:

void Initialize ( )

Definition at line 101 of file errprop.cc.

102 {
104 
105  // Initialize the GEANT4e manager
106  G4ErrorPropagatorManager* g4emgr
108  G4ErrorPropagatorData* g4edata
110 
112 
113  G4UImanager::GetUIpointer()->ApplyCommand("/exerror/setField -10. kilogauss");
114 
115  g4emgr->InitGeant4e();
116 
117  G4UImanager::GetUIpointer()->ApplyCommand("/control/verbose 1");
118  G4UImanager::GetUIpointer()->ApplyCommand("/tracking/verbose 1");
119  G4UImanager::GetUIpointer()->ApplyCommand("/geant4e/limits/stepLength 100 mm");
120 
121  //----- Choose target type:
122  // 1: PlaneSurfaceTarget
123  // 2: CylSurfaceTarget
124  // 3: GeomVolumeTarget
125  // 4: TrackLengthTarget
126  G4int iTarget = 1;
127  char* target = getenv("G4ERROR_TARGET");
128  if( target ) {
129  if( G4String(target) == G4String("PLANE_SURFACE") ) {
130  iTarget = 1;
131  }else if( G4String(target) == G4String("CYL_SURFACE") ) {
132  iTarget = 2;
133  }else if( G4String(target) == G4String("VOLUME") ) {
134  iTarget = 3;
135  }else if( G4String(target) == G4String("TRKLEN") ) {
136  iTarget = 4;
137  }else {
138  G4Exception("exG4eReco","Fatal error in Argument",
140  G4String("Variable G4ERROR_TARGET = " + G4String(target) +
141  " It must be: PLANE_SURFACE, CYL_SURFACE, VOLUME, TRKLEN").c_str());
142  }
143  } else {
144  G4Exception("exG4eReco","Fatal error in Argument",
145  JustWarning,"Variable G4ERROR_TARGET not defined, taking it = PLANE_SURFACE");
146  }
147 
148  theTarget = BuildTarget( iTarget );
149  g4edata->SetTarget( theTarget );
150 
152  char* mode = getenv("G4ERROR_MODE");
153  if( mode ) {
154  if( G4String(mode) == G4String("FORWARDS") ) {
156  } else if( G4String(mode) == G4String("BACKWARDS") ) {
158  } else {
159  G4Exception("exG4eReco","Fatal error in Argument",
161  G4String("Variable G4ERROR_MODE = " + G4String(mode) +
162  " It must be: FORWARDS or BACKWARDS").c_str());
163  }
164  } else {
165  G4Exception("exG4eReco","Fatal error in Argument",
166  JustWarning,"Variable G4ERROR_MODE not defined, taking it = BACKWARDS");
167  }
168 
169 }
const XML_Char * target
Definition: expat.h:268
static G4ErrorPropagatorManager * GetErrorPropagatorManager()
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:59
G4ErrorMode theG4ErrorMode
Definition: errprop.cc:60
void SetUserInitialization(G4VUserDetectorConstruction *userInit)
G4ErrorTarget * theTarget
Definition: errprop.cc:59
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetTarget(const G4ErrorTarget *target)
static void SetInstance(G4VSteppingVerbose *Instance)
G4ErrorTarget * BuildTarget(G4int iTarget)
Definition: errprop.cc:233
static G4ErrorPropagatorData * GetErrorPropagatorData()
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:447

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( )

Definition at line 63 of file errprop.cc.

64 {
65 
66  Initialize();
67 
68  //----- Choose propagation mode
69  // 0: propagate until target, all steps in one go
70  // 1: propagate until target, returning control to the user at each step
71  G4int iProp = 0;
72  char* prop = getenv("G4ERROR_PROP");
73  if( prop ) {
74  if( G4String(prop) == G4String("UNTIL_TARGET") ){
75  iProp = 0;
76  } else if ( G4String(prop) == G4String("STEP_BY_STEP") ) {
77  iProp = 1;
78  } else {
79  G4Exception("exG4eReco","Fatal error in Argument",
81  G4String("Variable G4ERROR_PROP = " + G4String(prop) +
82  " It must be: UNTIL_TARGET or STEP_BY_STEP").c_str());
83  }
84  } else {
85  G4Exception("exG4eReco","Fatal error in Argument",
87  "Variable G4ERROR_PROP not defined, taking it = UNTIL_TARGET");
88  }
89 
90  size_t nEvents = 3;
91  for( size_t ii = 0; ii < nEvents; ii++ ){
92  ProcessEvent( iProp, ii );
93  }
94 
95  Finalize();
96 
97 }
void Initialize()
Definition: errprop.cc:101
void ProcessEvent(G4int iProp, size_t nEv)
Definition: errprop.cc:172
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void Finalize()
Definition: errprop.cc:257

Here is the call graph for this function:

void ProcessEvent ( G4int  iProp,
size_t  nEv 
)

Definition at line 172 of file errprop.cc.

173 {
174 
175 // Set the starting trajectory.
176  G4ThreeVector xv3( 0, 0, 0 );
177  G4ThreeVector pv3( 20.0*GeV, 0.0, 0.0 );
178  G4ErrorTrajErr error( 5, 0 );
179  G4ErrorFreeTrajState* g4ErrorTrajState
180  = new G4ErrorFreeTrajState( "mu-", xv3, pv3, error );
181 
182  G4ErrorPropagatorManager* g4emgr
184 
185  //int ierr = 0;
186 
187  G4Point3D surfPos(224.*cm,0.,0.);
188  G4Normal3D surfNorm(1.,0.,0.);
189  //- G4ErrorTarget* theG4ErrorTarget
190  // = new G4ErrorPlaneSurfaceTarget(surfNorm, surfPos );
191 
192  if( iProp == 0){
193  // Propagate until G4ErrorTarget is found all in one go
194  //ierr =
195  g4emgr->Propagate( g4ErrorTrajState, theTarget, theG4ErrorMode );
196  } else if( iProp == 1){
197 
198  // Propagate until G4ErrorTarget is reached step by step
199 
200  g4emgr->InitTrackPropagation();
201 
202  // G4Track* aTrack
203  // = G4EventManager::GetEventManager()->GetTrackingManager()->GetTrack();
204  bool moreEvt = TRUE;
205  while( moreEvt ){
206 
207  //ierr =
208  g4emgr->PropagateOneStep( g4ErrorTrajState, theG4ErrorMode );
209 
210  //---- Check if target is reached
211  if( g4emgr->GetPropagator()->CheckIfLastStep( g4ErrorTrajState->GetG4Track() )) {
212  g4emgr->GetPropagator()
213  ->InvokePostUserTrackingAction( g4ErrorTrajState->GetG4Track() );
214  moreEvt = 0;
215  G4cout << "STEP_BY_STEP propagation: Last Step " << G4endl;
216  }
217  }
218  }
219 
220  G4cout << " $$$ PROPAGATION ENDED " << G4endl;
221  // extract current state info
222  G4Point3D posEnd = g4ErrorTrajState->GetPosition();
223  G4Normal3D momEnd = g4ErrorTrajState->GetMomentum();
224  G4ErrorTrajErr errorEnd = g4ErrorTrajState->GetError();
225 
226  G4cout << " Position: " << posEnd << G4endl
227  << " Momentum: " << momEnd << G4endl
228  << " Error: " << errorEnd << G4endl;
229 }
G4int PropagateOneStep(G4ErrorTrajState *currentTS, G4ErrorMode mode=G4ErrorMode_PropForwards)
void InvokePostUserTrackingAction(G4Track *fpTrack)
G4Point3D GetPosition() const
static G4ErrorPropagatorManager * GetErrorPropagatorManager()
G4ErrorMode theG4ErrorMode
Definition: errprop.cc:60
G4GLOB_DLL std::ostream G4cout
G4ErrorPropagator * GetPropagator() const
static constexpr double cm
Definition: G4SIunits.hh:119
G4Vector3D GetMomentum() const
G4ErrorTarget * theTarget
Definition: errprop.cc:59
#define TRUE
Definition: globals.hh:55
G4Track * GetG4Track() const
G4bool CheckIfLastStep(G4Track *aTrack)
G4int Propagate(G4ErrorTrajState *currentTS, const G4ErrorTarget *target, G4ErrorMode mode=G4ErrorMode_PropForwards)
static constexpr double GeV
Definition: G4SIunits.hh:217
#define G4endl
Definition: G4ios.hh:61
static PROLOG_HANDLER error
Definition: xmlrole.cc:112
G4ErrorTrajErr GetError() const

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

G4ErrorMode theG4ErrorMode

Definition at line 60 of file errprop.cc.

G4ErrorTarget* theTarget

Definition at line 59 of file errprop.cc.