Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
G4BlineTracer Class Reference

#include <Doxymodules_field.h>

Inheritance diagram for G4BlineTracer:
G4UserRunAction

Public Member Functions

 G4BlineTracer ()
 
 ~G4BlineTracer () override
 
void BeginOfRunAction (const G4Run *aRun) override
 
void EndOfRunAction (const G4Run *aRun) override
 
void ComputeBlines (G4int nlines)
 
void SetMaxTrackingStep (G4double max_step)
 
G4BlineEventActionGetEventAction ()
 

Private Member Functions

void ResetChordFinders ()
 

Private Attributes

G4BlineTracerMessengerfMessenger = nullptr
 
G4BlineSteppingActionfSteppingAction = nullptr
 
G4BlineEventActionfEventAction = nullptr
 
G4BlinePrimaryGeneratorActionfPrimaryGeneratorAction = nullptr
 
G4double fMaxTrackingStep = 1000. * CLHEP::m
 
G4bool fWas_ResetChordFinders_already_called = false
 
std::vector< G4ChordFinder * > fVecChordFinders
 
std::vector< G4FieldManager * > fVecFieldManagers
 
std::vector< G4MagneticField * > fVecMagneticFields
 
std::vector< G4BlineEquation * > fVecEquationOfMotion
 

Detailed Description

Definition at line 22 of file Doxymodules_field.h.

Constructor & Destructor Documentation

◆ G4BlineTracer()

G4BlineTracer::G4BlineTracer ( )

Definition at line 60 of file G4BlineTracer.cc.

◆ ~G4BlineTracer()

G4BlineTracer::~G4BlineTracer ( )
override

Definition at line 70 of file G4BlineTracer.cc.

71{
72 delete fMessenger;
73 delete fSteppingAction;
74 delete fEventAction;
76 for (size_t i=0; i< fVecEquationOfMotion.size();i++)
77 {
79 if (fVecChordFinders[i]) delete fVecChordFinders[i];
80 }
81}
std::vector< G4BlineEquation * > fVecEquationOfMotion
std::vector< G4ChordFinder * > fVecChordFinders

Member Function Documentation

◆ BeginOfRunAction()

void G4BlineTracer::BeginOfRunAction ( const G4Run aRun)
override

Definition at line 85 of file G4BlineTracer.cc.

86{
87}

◆ EndOfRunAction()

void G4BlineTracer::EndOfRunAction ( const G4Run aRun)
override

Definition at line 91 of file G4BlineTracer.cc.

92{
93}

◆ ComputeBlines()

void G4BlineTracer::ComputeBlines ( G4int  nlines)

Definition at line 97 of file G4BlineTracer.cc.

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

◆ SetMaxTrackingStep()

void G4BlineTracer::SetMaxTrackingStep ( G4double  max_step)
inline

Definition at line 80 of file G4BlineTracer.hh.

81 { fMaxTrackingStep=max_step; }

◆ GetEventAction()

G4BlineEventAction * G4BlineTracer::GetEventAction ( )
inline

Definition at line 82 of file G4BlineTracer.hh.

83 { return fEventAction; }

◆ ResetChordFinders()

void G4BlineTracer::ResetChordFinders ( )
private

Definition at line 270 of file G4BlineTracer.cc.

271{
272 for (size_t i=0; i<fVecEquationOfMotion.size();i++)
273 {
274 delete fVecEquationOfMotion[i];
275 delete fVecChordFinders[i];
276 }
277
278 fVecChordFinders.clear();
279 fVecFieldManagers.clear();
280 fVecMagneticFields.clear();
281 fVecEquationOfMotion.clear();
282
283 // global field
284
285 fVecChordFinders.push_back(nullptr);
286 fVecMagneticFields.push_back(nullptr);
287 fVecEquationOfMotion.push_back(nullptr);
288 fVecFieldManagers.push_back(G4TransportationManager::GetTransportationManager()
289 ->GetFieldManager());
290 if (fVecFieldManagers[0])
291 {
293 (G4MagneticField*) fVecFieldManagers[0]->GetDetectorField();
294 if (fVecMagneticFields[0])
295 {
297 auto pStepper = new G4CashKarpRKF45(fVecEquationOfMotion[0]);
298 auto pIntgrDriver =
299 new G4MagInt_Driver(0.01*mm,pStepper,pStepper->GetNumberOfVariables());
300 fVecChordFinders[0] = new G4ChordFinder(pIntgrDriver);
301 }
302 }
303
304 // local fields
305
306 G4LogicalVolumeStore* theVolumeStore = G4LogicalVolumeStore::GetInstance();
307
308 size_t j=0;
309 for (size_t i=0; i<theVolumeStore->size();i++)
310 {
311 if ((*theVolumeStore)[i]->GetFieldManager())
312 {
313 j++;
314 fVecFieldManagers.push_back(((*theVolumeStore)[i])->GetFieldManager());
316 fVecFieldManagers[j]->GetDetectorField());
317 fVecEquationOfMotion.push_back(nullptr);
318 fVecChordFinders.push_back(nullptr);
319 if (fVecMagneticFields[j])
320 {
322 auto pStepper = new G4CashKarpRKF45(fVecEquationOfMotion[j]);
323 auto pIntgrDriver =
324 new G4MagInt_Driver(.01*mm,pStepper,pStepper->GetNumberOfVariables());
325 fVecChordFinders[j] = new G4ChordFinder(pIntgrDriver);
326 }
327 }
328 }
329}
std::vector< G4MagneticField * > fVecMagneticFields

Member Data Documentation

◆ fMessenger

G4BlineTracerMessenger* G4BlineTracer::fMessenger = nullptr
private

Definition at line 91 of file G4BlineTracer.hh.

◆ fSteppingAction

G4BlineSteppingAction* G4BlineTracer::fSteppingAction = nullptr
private

Definition at line 92 of file G4BlineTracer.hh.

◆ fEventAction

G4BlineEventAction* G4BlineTracer::fEventAction = nullptr
private

Definition at line 93 of file G4BlineTracer.hh.

◆ fPrimaryGeneratorAction

G4BlinePrimaryGeneratorAction* G4BlineTracer::fPrimaryGeneratorAction = nullptr
private

Definition at line 94 of file G4BlineTracer.hh.

◆ fMaxTrackingStep

G4double G4BlineTracer::fMaxTrackingStep = 1000. * CLHEP::m
private

Definition at line 95 of file G4BlineTracer.hh.

◆ fWas_ResetChordFinders_already_called

G4bool G4BlineTracer::fWas_ResetChordFinders_already_called = false
private

Definition at line 96 of file G4BlineTracer.hh.

◆ fVecChordFinders

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

Definition at line 101 of file G4BlineTracer.hh.

◆ fVecFieldManagers

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

Definition at line 102 of file G4BlineTracer.hh.

◆ fVecMagneticFields

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

Definition at line 103 of file G4BlineTracer.hh.

◆ fVecEquationOfMotion

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

Definition at line 104 of file G4BlineTracer.hh.


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

Applications | User Support | Publications | Collaboration