70 G4AdjointSimManager::G4AdjointSimManager():
71 fUserRunAction(0), fUserEventAction(0),fUserPrimaryGeneratorAction(0),
72 fUserTrackingAction(0), fUserSteppingAction(0), fUserStackingAction(0),
73 theAdjointRunAction(0), theAdjointEventAction(0)
76 G4cout<<
"G4AdjointSimManager::G4AdjointSimManager() Here"<<std::endl;
88 user_action_already_defined=
false;
89 use_user_StackingAction =
false;
91 adjoint_sim_mode =
false;
97 welcome_message =
true;
117 G4AdjointSimManager::~G4AdjointSimManager()
119 if (theAdjointRunAction)
delete theAdjointRunAction;
120 if (theAdjointPrimaryGeneratorAction)
delete theAdjointPrimaryGeneratorAction;
121 if (theAdjointSteppingAction)
delete theAdjointSteppingAction;
122 if (theAdjointEventAction)
delete theAdjointEventAction;
123 if (theAdjointTrackingAction)
delete theAdjointTrackingAction;
124 if (theAdjointStackingAction)
delete theAdjointStackingAction;
125 if (theMessenger)
delete theMessenger;
138 if (welcome_message) {
139 G4cout<<
"****************************************************************"<<std::endl;
140 G4cout<<
"*** Geant4 Reverse/Adjoint Monte Carlo mode ***"<<std::endl;
141 G4cout<<
"*** Author: L.Desorgher ***"<<std::endl;
142 G4cout<<
"*** Company: SpaceIT GmbH, Bern, Switzerland ***"<<std::endl;
143 G4cout<<
"*** Sponsored by: ESA/ESTEC contract contract 21435/08/NL/AT ***"<<std::endl;
144 G4cout<<
"****************************************************************"<<std::endl;
145 welcome_message=
false;
155 nb_evt_of_last_run =nb_evt;
187 void G4AdjointSimManager::SetRestOfAdjointActions()
191 if (!user_action_already_defined) DefineUserActions();
211 adjoint_sim_mode=
true;
212 ID_of_last_particle_that_reach_the_ext_source=0;
220 adjoint_sim_mode=
false;
225 void G4AdjointSimManager::SetAdjointActions()
229 if (!user_action_already_defined) DefineUserActions();
234 theRunManager->
SetUserAction(theAdjointPrimaryGeneratorAction);
238 if (theAdjointEventAction) theRunManager->
SetUserAction(theAdjointEventAction);
244 void G4AdjointSimManager::SetAdjointPrimaryRunAndStackingActions()
248 if (!user_action_already_defined) DefineUserActions();
254 theRunManager->
SetUserAction(theAdjointPrimaryGeneratorAction);
261 void G4AdjointSimManager::ResetUserActions()
276 void G4AdjointSimManager::ResetRestOfUserActions()
290 void G4AdjointSimManager::ResetUserPrimaryRunAndStackingActions()
301 void G4AdjointSimManager::DefineUserActions()
311 user_action_already_defined=
true;
317 adjoint_tracking_mode = aBool;
319 if (adjoint_tracking_mode) {
320 SetRestOfAdjointActions();
327 ResetRestOfUserActions();
403 last_direction /=last_direction.
mag();
404 last_cos_th = last_direction.
z();
409 last_fwd_part_name.
remove(0,4);
414 last_fwd_part_index=-1;
416 while(i<aList.size() && last_fwd_part_index<0) {
417 if (aList[i]->GetParticleName() == last_fwd_part_name) last_fwd_part_index=i;
421 last_ekin = theAdjointSteppingAction->
GetLastEkin();
422 last_ekin_nuc = last_ekin;
425 last_ekin_nuc /=nb_nuc;
455 ID_of_last_particle_that_reach_the_ext_source++;
492 area_of_the_adjoint_source=area;
503 area_of_the_adjoint_source=area;
512 area_of_the_adjoint_source=area;
522 theAdjointPrimaryGeneratorAction->
SetEmin(Emin);
528 theAdjointPrimaryGeneratorAction->
SetEmax(Emax);
553 theAdjointPrimaryGeneratorAction->
SetPrimaryIon(adjointIon, fwdIon);
565 theAdjointPrimaryWeight = aWeight;
573 theAdjointEventAction = anAction;
592 theAdjointRunAction=anAction;
600 G4cout<<
"G4AdjointSimManager::BeginOfRunAction"<<std::endl;
602 if (!adjoint_sim_mode){
612 {
if (!adjoint_sim_mode){
615 else if (theAdjointRunAction) theAdjointRunAction->
EndOfRunAction(aRun);
static G4AdjointSimManager * GetInstance()
void UpdateListOfPrimaryParticles()
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
size_t GetNbOfPrimaryFwdParticles()
G4ThreeVector GetLastPosition()
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4bool AddaSphericalSurface(const G4String &SurfaceName, G4double radius, G4ThreeVector pos, G4double &area)
G4bool GetDidAdjParticleReachTheExtSource()
void SetAdjointSourceEmax(G4double Emax)
G4String & remove(str_size)
void SetAdjointStackingAction(G4UserStackingAction *anAction)
void SwitchToAdjointSimulationMode()
void SetEmax(G4double val)
virtual void EndOfRunAction(const G4Run *aRun)
G4int GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack()
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
G4bool DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String &volume_name)
G4int GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack()
G4int GetPDGEncoding() const
const G4String & GetFwdParticleNameAtEndOfLastAdjointTrack()
void SetUserAdjointStackingAction(G4UserStackingAction *anAction)
G4bool DefineSphericalAdjointSource(G4double radius, G4ThreeVector pos)
G4double GetWeightAtEndOfLastAdjointTrack()
G4bool GetDidAdjParticleReachTheExtSource()
const G4UserSteppingAction * GetUserSteppingAction() const
const G4String & GetParticleName() const
virtual void EndOfRunAction(const G4Run *aRun)
void SetAdjointSourceEmin(G4double Emin)
G4bool AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(const G4String &SurfaceName, G4double radius, const G4String &volume_name, G4ThreeVector ¢er, G4double &area)
void SetPrimaryIon(G4ParticleDefinition *adjointIon, G4ParticleDefinition *fwdIon)
G4double GetEkinAtEndOfLastAdjointTrack()
G4double GetEkinAtEndOfLastAdjointTrack()
void ConsiderParticleAsPrimary(const G4String &particle_name)
G4GLOB_DLL std::ostream G4cout
void SetAdjointTrackingMode(G4bool aBool)
const G4UserStackingAction * GetUserStackingAction() const
G4AdjointPrimaryGeneratorAction()
virtual void BeginOfRunAction(const G4Run *aRun)
G4bool DefineAdjointSourceOnTheExtSurfaceOfAVolume(const G4String &volume_name)
const G4UserEventAction * GetUserEventAction() const
size_t GetNbOfAdjointPrimaryTypes()
void RunAdjointSimulation(G4int nb_evt)
G4double GetCosthAtEndOfLastAdjointTrack()
const G4UserTrackingAction * GetUserTrackingAction() const
const G4String & GetParticleType() const
G4double GetEkinNucAtEndOfLastAdjointTrack()
const G4String & GetPrimaryIonName()
void SetUserForwardSteppingAction(G4UserSteppingAction *anAction)
G4bool DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String &volume_name)
const G4String & GetFwdParticleNameAtEndOfLastAdjointTrack()
void SetPrimaryIon(G4ParticleDefinition *adjointIon, G4ParticleDefinition *fwdIon)
const G4String & GetPrimaryIonName()
G4ThreeVector GetDirectionAtEndOfLastAdjointTrack()
G4bool DefineSphericalExtSource(G4double radius, G4ThreeVector pos)
void BackToFwdSimulationMode()
static G4AdjointCrossSurfChecker * GetInstance()
void SetPrimWeight(G4double weight)
G4ParticleDefinition * GetLastPartDef()
static G4RunManager * GetRunManager()
void SetExtSourceEMax(G4double Emax)
void SetAdjointRunAction(G4UserRunAction *anAction)
G4bool AddanExtSurfaceOfAvolume(const G4String &SurfaceName, const G4String &volume_name, G4double &area)
void SetAdjointEventAction(G4UserEventAction *anAction)
static G4ParticleTable * GetParticleTable()
G4double GetEkinNucAtEndOfLastAdjointTrack()
std::vector< G4ParticleDefinition * > GetListOfPrimaryFwdParticles()
G4double GetCosthAtEndOfLastAdjointTrack()
void NeglectParticleAsPrimary(const G4String &particle_name)
void ConsiderParticleAsPrimary(const G4String &particle_name)
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String &volume_name)
G4double GetWeightAtEndOfLastAdjointTrack()
virtual void BeginOfRunAction(const G4Run *aRun)
void RegisterAdjointPrimaryWeight(G4double aWeight)
G4bool DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String &volume_name)
void SetUserAdjointSteppingAction(G4UserSteppingAction *anAction)
const G4UserRunAction * GetUserRunAction() const
void SetKillTracks(G4bool aBool)
void SetUserFwdStackingAction(G4UserStackingAction *anAction)
G4ThreeVector GetPositionAtEndOfLastAdjointTrack()
void SetExtSourceEmax(G4double Emax)
void RegisterAtEndOfAdjointTrack()
void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos)
void SetAdjointMode(G4bool aBool)
G4ThreeVector GetPositionAtEndOfLastAdjointTrack()
void SetAdjointSteppingAction(G4UserSteppingAction *anAction)
G4ThreeVector GetLastMomentum()
G4ThreeVector GetDirectionAtEndOfLastAdjointTrack()
void SetEmin(G4double val)
void NeglectParticleAsPrimary(const G4String &particle_name)
std::vector< G4ParticleDefinition * > GetListOfPrimaryFwdParticles()
G4int GetBaryonNumber() const
virtual void SetUserAction(G4UserRunAction *userAction)