LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
VisualizationAction.cxx
Go to the documentation of this file.
1 //
15 
18 
19 #include "Geant4/G4Run.hh"
20 #include "Geant4/G4RunManager.hh"
21 #include "Geant4/G4Event.hh"
22 #include "Geant4/G4UImanager.hh"
23 #include "Geant4/G4VVisManager.hh"
24 #include "Geant4/G4TrajectoryContainer.hh"
25 #include "Geant4/G4Trajectory.hh"
26 #include "Geant4/G4ios.hh"
27 
28 #include <cmath>
29 #include <cstring>
30 
31 namespace larg4 {
32 
34  {
36  m_energyCutoff = lgp->VisualizationEnergyCut()*CLHEP::GeV;
38 
39  }
40 
42  {
43  }
44 
46  {
47  // If graphics is ON
48  if(G4VVisManager::GetConcreteInstance()){
49  G4cout << "Geant4 visualisation is ON" << G4endl;
50  G4UImanager* UI = G4UImanager::GetUIpointer();
51  UI->ApplyCommand("/tracking/storeTrajectory 1");
52  UI->ApplyCommand("/vis/scene/notifyhandlers");
53  }
54  }
55 
57  {
58  // If graphics is ON
59  if (G4VVisManager::GetConcreteInstance())
60  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
61  }
62 
64  {}
65 
66  void VisualizationAction::EndOfEventAction(const G4Event* a_event)
67  {
68  G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
69 
70  if (pVVisManager)
71  {
72  G4TrajectoryContainer* trajectoryContainer = a_event->GetTrajectoryContainer();
73  G4int n_trajectories = 0;
74  if (trajectoryContainer)
75  n_trajectories = trajectoryContainer->entries();
76 
77  for (G4int i=0; i < n_trajectories; i++)
78  {
79  G4VTrajectory* trajectory = (*trajectoryContainer)[i];
80 
81  // Only draw "interesting" trajectories, according to cuts
82  // and limits set by the user.
83 
84  G4bool drawThisTrack = false;
85  if ( trajectory->GetInitialMomentum().mag() > m_energyCutoff )
86  drawThisTrack = true;
87 
88  if ( ! m_drawNeutrals )
89  {
90  G4double charge = trajectory->GetCharge();
91  // electron-, muon-, and tau-neutrino codes:
92  if ( charge == 0 )
93  drawThisTrack = false;
94  }
95 
96  if ( drawThisTrack )
97  trajectory->DrawTrajectory();
98  //trajectory->DrawTrajectory(50);
99  }
100  }
101  }
102 
103 
104 
105 
106 } // namespace LArG4
Store parameters for running LArG4.
double VisualizationEnergyCut() const
G4bool m_drawNeutrals
Whether or not to draw neutral tracks (default is no).
virtual void BeginOfEventAction(const G4Event *)
G4UserEventAction interfaces.
Geant4 interface.
virtual void BeginOfRunAction(const G4Run *)
G4UserRunAction interfaces.
virtual void EndOfEventAction(const G4Event *)
virtual void EndOfRunAction(const G4Run *)
G4double m_energyCutoff
Don&#39;t draw particles with energies less than this cut.
bool DrawNeutrals() const