Loading...
Searching...
No Matches
Functions | Variables
errProp.cc File Reference

Main program of the errorpropagation example. More...

#include "ExErrorDetectorConstruction.hh"
#include "G4SteppingVerbose.hh"
#include "G4ErrorPropagator.hh"
#include "G4ErrorPropagatorData.hh"
#include "G4ErrorPropagatorManager.hh"
#include "G4ErrorPlaneSurfaceTarget.hh"
#include "G4ErrorCylSurfaceTarget.hh"
#include "G4ErrorGeomVolumeTarget.hh"
#include "G4ErrorTrackLengthTarget.hh"
#include "G4ErrorFreeTrajState.hh"
#include "G4UImanager.hh"
#include "G4SystemOfUnits.hh"

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

◆ Initialize()

void Initialize ( )

Definition at line 100 of file errProp.cc.

101{
102 G4VSteppingVerbose::SetInstance(new G4SteppingVerbose);
103
104 // Initialize the GEANT4e manager
106 = G4ErrorPropagatorManager::GetErrorPropagatorManager();
107 G4ErrorPropagatorData* g4edata
108 = G4ErrorPropagatorData::GetErrorPropagatorData();
109
110 g4emgr->SetUserInitialization(new ExErrorDetectorConstruction);
111
112 G4UImanager::GetUIpointer()->ApplyCommand("/exerror/setField -10. kilogauss");
113
114 g4emgr->InitGeant4e();
115
116 G4UImanager::GetUIpointer()->ApplyCommand("/control/verbose 1");
117 G4UImanager::GetUIpointer()->ApplyCommand("/tracking/verbose 1");
118 G4UImanager::GetUIpointer()->ApplyCommand("/geant4e/limits/stepLength 100 mm");
119
120 //----- Choose target type:
121 // 1: PlaneSurfaceTarget
122 // 2: CylSurfaceTarget
123 // 3: GeomVolumeTarget
124 // 4: TrackLengthTarget
125 G4int iTarget = 1;
126 char* target = std::getenv("G4ERROR_TARGET");
127 if( target ) {
128 if( G4String(target) == G4String("PLANE_SURFACE") ) {
129 iTarget = 1;
130 }else if( G4String(target) == G4String("CYL_SURFACE") ) {
131 iTarget = 2;
132 }else if( G4String(target) == G4String("VOLUME") ) {
133 iTarget = 3;
134 }else if( G4String(target) == G4String("TRKLEN") ) {
135 iTarget = 4;
136 }else {
137 G4Exception("exG4eReco","Fatal error in Argument",
138 FatalErrorInArgument,
139 G4String("Variable G4ERROR_TARGET = " + G4String(target) +
140 " It must be: PLANE_SURFACE, CYL_SURFACE, VOLUME, TRKLEN").c_str());
141 }
142 } else {
143 G4Exception("exG4eReco","Fatal error in Argument",
144 JustWarning,"Variable G4ERROR_TARGET not defined, taking it = PLANE_SURFACE");
145 }
146
147 theTarget = BuildTarget( iTarget );
148 g4edata->SetTarget( theTarget );
149
150 theG4ErrorMode = G4ErrorMode_PropBackwards;
151 char* mode = std::getenv("G4ERROR_MODE");
152 if( mode ) {
153 if( G4String(mode) == G4String("FORWARDS") ) {
154 theG4ErrorMode = G4ErrorMode_PropForwards;
155 } else if( G4String(mode) == G4String("BACKWARDS") ) {
156 theG4ErrorMode = G4ErrorMode_PropBackwards;
157 } else {
158 G4Exception("exG4eReco","Fatal error in Argument",
159 FatalErrorInArgument,
160 G4String("Variable G4ERROR_MODE = " + G4String(mode) +
161 " It must be: FORWARDS or BACKWARDS").c_str());
162 }
163 } else {
164 G4Exception("exG4eReco","Fatal error in Argument",
165 JustWarning,"Variable G4ERROR_MODE not defined, taking it = BACKWARDS");
166 }
167
168}
G4ErrorTarget * BuildTarget(G4int iTarget)
Definition errProp.cc:232
G4ErrorMode theG4ErrorMode
Definition errProp.cc:59
G4ErrorTarget * theTarget
Definition errProp.cc:58

◆ BuildTarget()

G4ErrorTarget * BuildTarget ( G4int  iTarget)

Definition at line 232 of file errProp.cc.

233{
234
235 G4ErrorTarget* target = 0;
236 if( iTarget == 1 ) {
237 G4Point3D surfPos(221.*cm,0.,0.);
238 G4Normal3D surfNorm(1.,0.,0.);
239 target = new G4ErrorPlaneSurfaceTarget(surfNorm, surfPos );
240 }else if( iTarget == 2 ) {
241 G4double radius = 222*cm;
242 target = new G4ErrorCylSurfaceTarget(radius);
243 }else if( iTarget == 3 ) {
244 target = new G4ErrorGeomVolumeTarget("MUON");
245 }else if( iTarget == 4 ) {
246 target = new G4ErrorTrackLengthTarget(223.*cm);
247 }else {
248 G4Exception("exG4eReco","Fatal error in Argument",
249 FatalErrorInArgument,"Target type has to be between 1 and 4");
250 }
251 return target;
252}

◆ ProcessEvent()

void ProcessEvent ( G4int  iProp,
size_t  nEv 
)

Definition at line 171 of file errProp.cc.

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

◆ Finalize()

void Finalize ( )

Definition at line 256 of file errProp.cc.

257{
258 G4ErrorPropagatorManager::GetErrorPropagatorManager()->CloseGeometry();
259
260}

◆ main()

int main ( )

Definition at line 62 of file errProp.cc.

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

Variable Documentation

◆ theTarget

G4ErrorTarget* theTarget

Definition at line 58 of file errProp.cc.

◆ theG4ErrorMode

G4ErrorMode theG4ErrorMode

Definition at line 59 of file errProp.cc.


Applications | User Support | Publications | Collaboration