64G4AdjointSimManager::G4AdjointSimManager()
69 theAdjointRunAction = 0;
72 theAdjointEventAction = 0;
73 theAdjointTrackingAction = 0;
80 user_action_already_defined=
false;
81 use_user_StackingAction =
false;
83 fUserTrackingAction= 0;
85 fUserSteppingAction= 0;
86 fUserPrimaryGeneratorAction= 0;
88 fUserStackingAction= 0;
90 adjoint_sim_mode =
false;
96 welcome_message =
true;
104G4AdjointSimManager::~G4AdjointSimManager()
106 if (theAdjointRunAction)
delete theAdjointRunAction;
107 if (theAdjointPrimaryGeneratorAction)
delete theAdjointPrimaryGeneratorAction;
108 if (theAdjointSteppingAction)
delete theAdjointSteppingAction;
109 if (theAdjointEventAction)
delete theAdjointEventAction;
110 if (theAdjointTrackingAction)
delete theAdjointTrackingAction;
111 if (theAdjointStackingAction)
delete theAdjointStackingAction;
112 if (theMessenger)
delete theMessenger;
125 if (welcome_message) {
126 G4cout<<
"****************************************************************"<<std::endl;
127 G4cout<<
"*** Geant4 Reverse/Adjoint Monte Carlo mode ***"<<std::endl;
128 G4cout<<
"*** Author: L.Desorgher ***"<<std::endl;
129 G4cout<<
"*** Company: SpaceIT GmbH, Bern, Switzerland ***"<<std::endl;
130 G4cout<<
"*** Sponsored by: ESA/ESTEC contract contract 21435/08/NL/AT ***"<<std::endl;
131 G4cout<<
"****************************************************************"<<std::endl;
132 welcome_message=
false;
137 SetAdjointPrimaryRunAndStackingActions();
138 SetRestOfAdjointActions();
144 adjoint_sim_mode=
true;
146 ID_of_last_particle_that_reach_the_ext_source=0;
151 nb_evt_of_last_run =nb_evt;
156 ResetRestOfUserActions();
157 ResetUserPrimaryRunAndStackingActions();
158 adjoint_sim_mode=
false;
184void G4AdjointSimManager::SetRestOfAdjointActions()
188 if (!user_action_already_defined) DefineUserActions();
199void G4AdjointSimManager::SetAdjointPrimaryRunAndStackingActions()
203 if (!user_action_already_defined) DefineUserActions();
209 theRunManager->
SetUserAction(theAdjointPrimaryGeneratorAction);
216void G4AdjointSimManager::ResetRestOfUserActions()
230void G4AdjointSimManager::ResetUserPrimaryRunAndStackingActions()
241void G4AdjointSimManager::DefineUserActions()
250 user_action_already_defined=
true;
256 adjoint_tracking_mode = aBool;
258 if (adjoint_tracking_mode) {
259 SetRestOfAdjointActions();
266 ResetRestOfUserActions();
293 last_direction /=last_direction.
mag();
294 last_cos_th = last_direction.
z();
299 last_fwd_part_name.
remove(0,4);
304 last_fwd_part_index=-1;
306 while(i<aList.size() && last_fwd_part_index<0) {
307 if (aList[i]->GetParticleName() == last_fwd_part_name) last_fwd_part_index=i;
311 last_ekin = theAdjointSteppingAction->
GetLastEkin();
312 last_ekin_nuc = last_ekin;
315 last_ekin_nuc /=nb_nuc;
345 ID_of_last_particle_that_reach_the_ext_source++;
382 area_of_the_adjoint_source=area;
393 area_of_the_adjoint_source=area;
402 area_of_the_adjoint_source=area;
412 theAdjointPrimaryGeneratorAction->
SetEmin(Emin);
418 theAdjointPrimaryGeneratorAction->
SetEmax(Emax);
443 theAdjointPrimaryGeneratorAction->
SetPrimaryIon(adjointIon, fwdIon);
455 theAdjointPrimaryWeight = aWeight;
463 theAdjointEventAction = anAction;
481 theAdjointTrackingAction=anAction;
487 theAdjointRunAction=anAction;
G4DLLIMPORT std::ostream G4cout
G4bool AddaSphericalSurface(const G4String &SurfaceName, G4double radius, G4ThreeVector pos, G4double &area)
G4bool AddanExtSurfaceOfAvolume(const G4String &SurfaceName, const G4String &volume_name, G4double &area)
static G4AdjointCrossSurfChecker * GetInstance()
G4bool AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(const G4String &SurfaceName, G4double radius, const G4String &volume_name, G4ThreeVector ¢er, G4double &area)
void UpdateListOfPrimaryParticles()
std::vector< G4ParticleDefinition * > GetListOfPrimaryFwdParticles()
void ConsiderParticleAsPrimary(const G4String &particle_name)
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String &volume_name)
const G4String & GetPrimaryIonName()
void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos)
size_t GetNbOfAdjointPrimaryTypes()
void SetEmin(G4double val)
void NeglectParticleAsPrimary(const G4String &particle_name)
void SetPrimaryIon(G4ParticleDefinition *adjointIon, G4ParticleDefinition *fwdIon)
void SetEmax(G4double val)
void SetAdjointStackingAction(G4UserStackingAction *anAction)
G4bool DefineAdjointSourceOnTheExtSurfaceOfAVolume(const G4String &volume_name)
const G4String & GetPrimaryIonName()
G4bool DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String &volume_name)
G4bool GetDidAdjParticleReachTheExtSource()
void RunAdjointSimulation(G4int nb_evt)
G4bool DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String &volume_name)
void SetAdjointTrackingMode(G4bool aBool)
std::vector< G4ParticleDefinition * > GetListOfPrimaryFwdParticles()
void ConsiderParticleAsPrimary(const G4String &particle_name)
void SetAdjointRunAction(G4UserRunAction *anAction)
void SetExtSourceEmax(G4double Emax)
void RegisterAtEndOfAdjointTrack()
void SetAdjointSourceEmax(G4double Emax)
void RegisterAdjointPrimaryWeight(G4double aWeight)
void SetAdjointSourceEmin(G4double Emin)
void SetAdjointEventAction(G4UserEventAction *anAction)
void NeglectParticleAsPrimary(const G4String &particle_name)
G4bool DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String &volume_name)
static G4AdjointSimManager * GetInstance()
void SetAdjointSteppingAction(G4UserSteppingAction *anAction)
void SetAdjointTrackingAction(G4UserTrackingAction *anAction)
G4bool DefineSphericalExtSource(G4double radius, G4ThreeVector pos)
G4bool DefineSphericalAdjointSource(G4double radius, G4ThreeVector pos)
void SetPrimaryIon(G4ParticleDefinition *adjointIon, G4ParticleDefinition *fwdIon)
void SetKillTracks(G4bool aBool)
void SetAdjointMode(G4bool aBool)
void SetUserFwdStackingAction(G4UserStackingAction *anAction)
void SetUserAdjointStackingAction(G4UserStackingAction *anAction)
G4ParticleDefinition * GetLastPartDef()
void SetExtSourceEMax(G4double Emax)
void SetUserAdjointSteppingAction(G4UserSteppingAction *anAction)
G4bool GetDidAdjParticleReachTheExtSource()
G4ThreeVector GetLastMomentum()
void SetPrimWeight(G4double weight)
G4ThreeVector GetLastPosition()
const G4String & GetParticleType() const
G4int GetPDGEncoding() const
G4int GetBaryonNumber() const
const G4String & GetParticleName() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
const G4UserTrackingAction * GetUserTrackingAction() const
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
const G4UserEventAction * GetUserEventAction() const
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
static G4RunManager * GetRunManager()
const G4UserStackingAction * GetUserStackingAction() const
const G4UserSteppingAction * GetUserSteppingAction() const
void SetUserAction(G4UserRunAction *userAction)
const G4UserRunAction * GetUserRunAction() const
G4String & remove(str_size)