GGS(GenericGEANT4Simulation)Software  2.99.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Macros
GGSAcceptanceCheckAction.cpp
Go to the documentation of this file.
1 /*
2  * GGSAcceptanceCheckAction.cpp
3  *
4  * Created on: 08 Oct 2013
5  * Author: Nicola Mori
6  */
14 
15 #include "G4GenericMessenger.hh"
16 #include "G4Track.hh"
17 
18 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
19 
21 
22 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
23 
25  _messenger = new G4GenericMessenger(this, "/GGS/userActions/acceptanceCheckAction/");
26  _messenger->DeclareProperty("reSimulateKilled", _reSimulateKilled, "Simulate again events outside acceptance")
27  .SetDefaultValue("true");
28 }
29 
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
36 G4ClassificationOfNewTrack GGSAcceptanceCheckAction::ClassifyNewTrack(const G4Track *track) {
37  static const std::string routineName("GGSAcceptanceCheckAction::ClassifyNewTrack");
38  if (track->GetParentID() == 0) {
39  GGSDetectorConstruction *detConst =
40  (GGSDetectorConstruction *)(GGSRunManager::GetRunManager()->GetUserDetectorConstruction());
41  if (detConst->GetGeometry()->IsInsideAcceptance(track->GetPosition(), track->GetMomentum().unit())) {
42  return fUrgent;
43  } else {
44  GGSPrimaryParticleInfo *userInfo =
45  (GGSPrimaryParticleInfo *)(track->GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation());
46  if (!userInfo)
47  userInfo = new GGSPrimaryParticleInfo;
48  userInfo->isTrackKilled = true;
49  GGSCOUT(DEBUG) << "Killed primary track " << track->GetTrackID() << GGSENDL;
50  track->GetDynamicParticle()->GetPrimaryParticle()->SetUserInformation(userInfo);
51  if (G4EventManager::GetEventManager()->GetStackManager()->GetNTotalTrack() == 0) {
52  GGSRunManagerExtensions &rmExt = dynamic_cast<GGSRunManagerExtensions &>(*(G4RunManager::GetRunManager()));
53  rmExt.KillEvent();
54  if (_reSimulateKilled) {
56  GGSCOUT(DEBUG) << "Will be simulated again" << GGSENDL;
57  }
58  }
59  return fKill;
60  }
61  }
62  return G4UserStackingAction::ClassifyNewTrack(track);
63 }
G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *track)
Override of the ClassifyNewTrack method.
Data class to store informations about the primary particle.
#define GGSENDL
Definition: GGSSmartLog.h:131
Class for GGS detector construction.
Class with additional functionalities for run managers.
bool isTrackKilled
True if the particle&#39;s track has been killed.
void SimulateAgainKilledEvent()
Simulates again a killed event.
const GGSVGeometryConstruction * GetGeometry() const
Returns a pointer to the geometry.
An action to kill primary tracks outside acceptance.
#define RegisterUA(uaClassName)
Macro for registration of user actions classes.
void KillEvent()
Kills the current event.
virtual bool IsInsideAcceptance(const G4ThreeVector &, const G4ThreeVector &) const
Checks if a particle is inside the instrument&#39;s acceptance.