Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4BlineTracer Class Reference

#include <G4BlineTracer.hh>

Inheritance diagram for G4BlineTracer:
Collaboration diagram for G4BlineTracer:

Public Member Functions

 G4BlineTracer ()
 
virtual ~G4BlineTracer ()
 
virtual void BeginOfRunAction (const G4Run *aRun)
 
virtual void EndOfRunAction (const G4Run *aRun)
 
void ComputeBlines (G4int nlines)
 
void SetMaxTrackingStep (G4double max_step)
 
G4BlineEventActionGetEventAction ()
 
- Public Member Functions inherited from G4UserRunAction
 G4UserRunAction ()
 
virtual ~G4UserRunAction ()
 
virtual G4RunGenerateRun ()
 
virtual void SetMaster (G4bool val=true)
 
G4bool IsMaster () const
 

Additional Inherited Members

- Protected Attributes inherited from G4UserRunAction
G4bool isMaster
 

Detailed Description

Definition at line 67 of file G4BlineTracer.hh.

Constructor & Destructor Documentation

G4BlineTracer::G4BlineTracer ( )

Definition at line 60 of file G4BlineTracer.cc.

61 {
62  fMessenger = new G4BlineTracerMessenger(this);
63  fSteppingAction = new G4BlineSteppingAction(this) ;
64  fEventAction = new G4BlineEventAction(this);
65  fPrimaryGeneratorAction = new G4BlinePrimaryGeneratorAction();
66  fMaxTrackingStep =1000.*m;
67  fWas_ResetChordFinders_already_called=false;
68 }
static constexpr double m
Definition: G4SIunits.hh:129
G4BlineTracer::~G4BlineTracer ( )
virtual

Definition at line 72 of file G4BlineTracer.cc.

73 {
74  delete fMessenger;
75  delete fSteppingAction;
76  delete fEventAction;
77  delete fPrimaryGeneratorAction;
78  for (size_t i=0; i< fVecEquationOfMotion.size();i++)
79  {
80  if (fVecEquationOfMotion[i]) delete fVecEquationOfMotion[i];
81  if (fVecChordFinders[i]) delete fVecChordFinders[i];
82  }
83 }

Member Function Documentation

void G4BlineTracer::BeginOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 87 of file G4BlineTracer.cc.

88 {
89 }
void G4BlineTracer::ComputeBlines ( G4int  nlines)

Definition at line 99 of file G4BlineTracer.cc.

100 {
101  //the first time ResetChordFinders should be called
102  //
103  if (!fWas_ResetChordFinders_already_called)
104  {
105  ResetChordFinders();
106  fWas_ResetChordFinders_already_called=true;
107  }
108 
109  // Replace the user action by the ad-hoc actions for Blines
110 
111  G4RunManager* theRunManager = G4RunManager::GetRunManager();
112  G4UserRunAction* user_run_action =
113  (G4UserRunAction*)theRunManager->GetUserRunAction();
114  theRunManager->SetUserAction(this);
115 
116  G4UserSteppingAction* user_stepping_action =
117  (G4UserSteppingAction*)theRunManager->GetUserSteppingAction();
118  theRunManager->SetUserAction(fSteppingAction);
119 
120  G4VUserPrimaryGeneratorAction* userPrimaryAction =
122  if (userPrimaryAction)
123  fPrimaryGeneratorAction->SetUserPrimaryAction(userPrimaryAction);
124  theRunManager->SetUserAction(fPrimaryGeneratorAction);
125 
126  G4UserEventAction* user_event_action =
127  (G4UserEventAction*)theRunManager->GetUserEventAction();
128  theRunManager->SetUserAction(fEventAction);
129 
130  G4UserTrackingAction* user_tracking_action =
131  (G4UserTrackingAction*)theRunManager->GetUserTrackingAction();
132  G4UserTrackingAction* aNullTrackingAction = 0;
133  theRunManager->SetUserAction(aNullTrackingAction);
134 
135  G4UserStackingAction* user_stacking_action =
136  (G4UserStackingAction*)theRunManager->GetUserStackingAction();
137  G4UserStackingAction* aNullStackingAction = 0;
138  theRunManager->SetUserAction(aNullStackingAction);
139 
140  // replace the user defined chordfinder by the element of fVecChordFinders
141 
142  std::vector<G4ChordFinder*> user_chord_finders;
143  std::vector<G4double> user_largest_acceptable_step;
144  for (size_t i=0;i<fVecChordFinders.size();i++)
145  {
146  user_largest_acceptable_step.push_back(-1.);
147  if (fVecChordFinders[i])
148  {
149  user_chord_finders.push_back(fVecFieldManagers[i]->GetChordFinder());
150  fVecChordFinders[i]->SetDeltaChord(user_chord_finders[i]->GetDeltaChord());
151  fVecFieldManagers[i]->SetChordFinder(fVecChordFinders[i]);
152  }
153  else user_chord_finders.push_back(0);
154  }
155 
156  // I have tried to use the smooth line filter ability but I could not obtain
157  // a smooth trajectory in the G4TrajectoryContainer after an event
158  // Another solution for obtaining a smooth trajectory is to limit
159  // the LargestAcceptableStep in the G4PropagatorInField object.
160  // This is the solution I used.
161 
162  // Old solution:
163  // G4TransportationManager::GetTransportationManager()
164  // ->GetPropagatorInField()->SetTrajectoryFilter(fTrajectoryFilter);
165 
166  // New solution:
167  // set the largest_acceptable_step to max_step:length
168 
169  G4TransportationManager* tmanager =
171  G4double previous_largest_acceptable_step =
173 
174  tmanager->GetPropagatorInField()
175  ->SetLargestAcceptableStep(fMaxTrackingStep);
176 
177  // Start the integration of n_of_lines different magnetic field lines
178 
179  for (G4int il=0; il<n_of_lines;il++)
180  {
181  // for each magnetic field line we integrate once backward and once
182  // forward from the same starting point
183 
184  // backward integration
185 
186  for (size_t i=0; i< fVecEquationOfMotion.size();i++)
187  {
188  if (fVecEquationOfMotion[i])
189  fVecEquationOfMotion[i]->SetBackwardDirectionOfIntegration(true);
190  }
191  theRunManager->BeamOn(1);
192 
193  // forward integration
194 
195  for (size_t i=0; i < fVecEquationOfMotion.size();i++)
196  {
197  if (fVecEquationOfMotion[i])
198  fVecEquationOfMotion[i]->SetBackwardDirectionOfIntegration(false);
199  }
200  theRunManager->BeamOn(1);
201  }
202 
203  // Remove trajectory filter to PropagatorInField
204  // It was for old solution when using smooth trajectory filter
205 
206  // tmanager->GetPropagatorInField()->SetTrajectoryFilter(0);
207 
208  // back to User defined actions and other parameters
209  // -------------------------------------------------
210 
211  tmanager->GetPropagatorInField()
212  ->SetLargestAcceptableStep(previous_largest_acceptable_step);
213 
214  // return to User actions
215 
216  theRunManager->SetUserAction(user_run_action);
217  theRunManager->SetUserAction(user_event_action);
218  theRunManager->SetUserAction(userPrimaryAction);
219  theRunManager->SetUserAction(user_stepping_action);
220  theRunManager->SetUserAction(user_tracking_action);
221  theRunManager->SetUserAction(user_stacking_action);
222 
223  // set user defined chord finders and largest acceptable step
224 
225  for (size_t i=0;i<fVecFieldManagers.size();i++)
226  {
227  if (user_chord_finders[i])
228  fVecFieldManagers[i]->SetChordFinder(user_chord_finders[i]);
229  }
230 }
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
int G4int
Definition: G4Types.hh:78
const G4UserSteppingAction * GetUserSteppingAction() const
const G4UserStackingAction * GetUserStackingAction() const
const G4UserEventAction * GetUserEventAction() const
const G4UserTrackingAction * GetUserTrackingAction() const
static G4TransportationManager * GetTransportationManager()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetUserPrimaryAction(G4VUserPrimaryGeneratorAction *anAction)
const G4UserRunAction * GetUserRunAction() const
void SetLargestAcceptableStep(G4double newBigDist)
double G4double
Definition: G4Types.hh:76
G4PropagatorInField * GetPropagatorInField() const
G4double GetLargestAcceptableStep()
virtual void SetUserAction(G4UserRunAction *userAction)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4BlineTracer::EndOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 93 of file G4BlineTracer.cc.

94 {
95 }
G4BlineEventAction* G4BlineTracer::GetEventAction ( )
inline

Definition at line 81 of file G4BlineTracer.hh.

82  { return fEventAction; }

Here is the caller graph for this function:

void G4BlineTracer::SetMaxTrackingStep ( G4double  max_step)
inline

Definition at line 79 of file G4BlineTracer.hh.

80  { fMaxTrackingStep=max_step; }

Here is the caller graph for this function:


The documentation for this class was generated from the following files: