Geant4  10.02.p03
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 ()
 
void SetMaster (G4bool val=true)
 
G4bool IsMaster () const
 

Private Member Functions

void ResetChordFinders ()
 

Private Attributes

G4BlineTracerMessengerfMessenger
 
G4BlineSteppingActionfSteppingAction
 
G4BlineEventActionfEventAction
 
G4BlinePrimaryGeneratorActionfPrimaryGeneratorAction
 
G4double fMaxTrackingStep
 
G4bool fWas_ResetChordFinders_already_called
 
std::vector< G4ChordFinder *> fVecChordFinders
 
std::vector< G4FieldManager *> fVecFieldManagers
 
std::vector< G4MagneticField *> fVecMagneticFields
 
std::vector< G4BlineEquation *> fVecEquationOfMotion
 

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::G4BlineTracer ( )

Definition at line 60 of file G4BlineTracer.cc.

61 {
64  fEventAction = new G4BlineEventAction(this);
66  fMaxTrackingStep =1000.*m;
68 }
G4BlineEventAction * fEventAction
G4BlineTracerMessenger * fMessenger
G4BlineSteppingAction * fSteppingAction
G4double fMaxTrackingStep
static const double m
Definition: G4SIunits.hh:128
G4BlinePrimaryGeneratorAction * fPrimaryGeneratorAction
G4bool fWas_ResetChordFinders_already_called

◆ ~G4BlineTracer()

G4BlineTracer::~G4BlineTracer ( )
virtual

Definition at line 72 of file G4BlineTracer.cc.

73 {
74  delete fMessenger;
75  delete fSteppingAction;
76  delete fEventAction;
78  for (size_t i=0; i< fVecEquationOfMotion.size();i++)
79  {
81  if (fVecChordFinders[i]) delete fVecChordFinders[i];
82  }
83 }
G4BlineEventAction * fEventAction
G4BlineTracerMessenger * fMessenger
G4BlineSteppingAction * fSteppingAction
std::vector< G4BlineEquation *> fVecEquationOfMotion
std::vector< G4ChordFinder *> fVecChordFinders
G4BlinePrimaryGeneratorAction * fPrimaryGeneratorAction

Member Function Documentation

◆ BeginOfRunAction()

void G4BlineTracer::BeginOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 87 of file G4BlineTracer.cc.

88 {
89 }

◆ ComputeBlines()

void G4BlineTracer::ComputeBlines ( G4int  nlines)

Definition at line 99 of file G4BlineTracer.cc.

100 {
101  //the first time ResetChordFinders should be called
102  //
104  {
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()
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 G4UserEventAction * GetUserEventAction() const
G4BlineEventAction * fEventAction
void ResetChordFinders()
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
G4BlineSteppingAction * fSteppingAction
const G4UserRunAction * GetUserRunAction() const
int G4int
Definition: G4Types.hh:78
G4double fMaxTrackingStep
static G4TransportationManager * GetTransportationManager()
std::vector< G4FieldManager *> fVecFieldManagers
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetUserPrimaryAction(G4VUserPrimaryGeneratorAction *anAction)
const G4UserStackingAction * GetUserStackingAction() const
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
const G4UserSteppingAction * GetUserSteppingAction() const
const G4UserTrackingAction * GetUserTrackingAction() const
void SetLargestAcceptableStep(G4double newBigDist)
G4PropagatorInField * GetPropagatorInField() const
double G4double
Definition: G4Types.hh:76
std::vector< G4BlineEquation *> fVecEquationOfMotion
std::vector< G4ChordFinder *> fVecChordFinders
G4BlinePrimaryGeneratorAction * fPrimaryGeneratorAction
G4double GetLargestAcceptableStep()
G4bool fWas_ResetChordFinders_already_called
virtual void SetUserAction(G4UserRunAction *userAction)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EndOfRunAction()

void G4BlineTracer::EndOfRunAction ( const G4Run aRun)
virtual

Reimplemented from G4UserRunAction.

Definition at line 93 of file G4BlineTracer.cc.

94 {
95 }

◆ GetEventAction()

G4BlineEventAction* G4BlineTracer::GetEventAction ( )
inline

Definition at line 81 of file G4BlineTracer.hh.

82  { return fEventAction; }
G4BlineEventAction * fEventAction
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetChordFinders()

void G4BlineTracer::ResetChordFinders ( )
private

Definition at line 271 of file G4BlineTracer.cc.

272 {
273  for (size_t i=0; i<fVecEquationOfMotion.size();i++)
274  {
275  delete fVecEquationOfMotion[i];
276  delete fVecChordFinders[i];
277  }
278 
279  fVecChordFinders.clear();
280  fVecFieldManagers.clear();
281  fVecMagneticFields.clear();
282  fVecEquationOfMotion.clear();
283 
284  // global field
285 
286  fVecChordFinders.push_back(0);
287  fVecMagneticFields.push_back(0);
288  fVecEquationOfMotion.push_back(0);
290  ->GetFieldManager());
291  if (fVecFieldManagers[0])
292  {
293  fVecMagneticFields[0] =
294  (G4MagneticField*) fVecFieldManagers[0]->GetDetectorField();
295  if (fVecMagneticFields[0])
296  {
299  G4MagInt_Driver* pIntgrDriver =
300  new G4MagInt_Driver(0.01*mm,pStepper,pStepper->GetNumberOfVariables());
301  fVecChordFinders[0] = new G4ChordFinder(pIntgrDriver);
302  }
303  }
304 
305  // local fields
306 
308 
309  size_t j=0;
310  for (size_t i=0; i<theVolumeStore->size();i++)
311  {
312  if ((*theVolumeStore)[i]->GetFieldManager())
313  {
314  j++;
315  fVecFieldManagers.push_back(((*theVolumeStore)[i])->GetFieldManager());
317  fVecFieldManagers[j]->GetDetectorField());
318  fVecEquationOfMotion.push_back(0);
319  fVecChordFinders.push_back(0);
320  if (fVecMagneticFields[j])
321  {
324  G4MagInt_Driver* pIntgrDriver =
325  new G4MagInt_Driver(.01*mm,pStepper,pStepper->GetNumberOfVariables());
326  fVecChordFinders[j] = new G4ChordFinder(pIntgrDriver);
327  }
328  }
329  }
330 }
G4int GetNumberOfVariables() const
static G4LogicalVolumeStore * GetInstance()
std::vector< G4MagneticField *> fVecMagneticFields
static G4TransportationManager * GetTransportationManager()
std::vector< G4FieldManager *> fVecFieldManagers
std::vector< G4BlineEquation *> fVecEquationOfMotion
std::vector< G4ChordFinder *> fVecChordFinders
static const double mm
Definition: G4SIunits.hh:114
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetMaxTrackingStep()

void G4BlineTracer::SetMaxTrackingStep ( G4double  max_step)
inline

Definition at line 79 of file G4BlineTracer.hh.

80  { fMaxTrackingStep=max_step; }
G4double fMaxTrackingStep
Here is the caller graph for this function:

Member Data Documentation

◆ fEventAction

G4BlineEventAction* G4BlineTracer::fEventAction
private

Definition at line 92 of file G4BlineTracer.hh.

◆ fMaxTrackingStep

G4double G4BlineTracer::fMaxTrackingStep
private

Definition at line 94 of file G4BlineTracer.hh.

◆ fMessenger

G4BlineTracerMessenger* G4BlineTracer::fMessenger
private

Definition at line 90 of file G4BlineTracer.hh.

◆ fPrimaryGeneratorAction

G4BlinePrimaryGeneratorAction* G4BlineTracer::fPrimaryGeneratorAction
private

Definition at line 93 of file G4BlineTracer.hh.

◆ fSteppingAction

G4BlineSteppingAction* G4BlineTracer::fSteppingAction
private

Definition at line 91 of file G4BlineTracer.hh.

◆ fVecChordFinders

std::vector<G4ChordFinder* > G4BlineTracer::fVecChordFinders
private

Definition at line 100 of file G4BlineTracer.hh.

◆ fVecEquationOfMotion

std::vector<G4BlineEquation* > G4BlineTracer::fVecEquationOfMotion
private

Definition at line 103 of file G4BlineTracer.hh.

◆ fVecFieldManagers

std::vector<G4FieldManager* > G4BlineTracer::fVecFieldManagers
private

Definition at line 101 of file G4BlineTracer.hh.

◆ fVecMagneticFields

std::vector<G4MagneticField* > G4BlineTracer::fVecMagneticFields
private

Definition at line 102 of file G4BlineTracer.hh.

◆ fWas_ResetChordFinders_already_called

G4bool G4BlineTracer::fWas_ResetChordFinders_already_called
private

Definition at line 95 of file G4BlineTracer.hh.


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