ACTARSim
ACTAR TPC Simulation Reference Guide
ActarSimEventAction.cc
Go to the documentation of this file.
1 // - AUTHOR: Hector Alvarez-Pol 11/2004
2 /******************************************************************
3  * Copyright (C) 2005-2016, Hector Alvarez-Pol *
4  * All rights reserved. *
5  * *
6  * License according to GNU LESSER GPL (see lgpl-3.0.txt). *
7  * For the list of contributors see CREDITS. *
8  ******************************************************************/
9 //////////////////////////////////////////////////////////////////
10 /// \class ActarSimEventAction
11 /// Actions to be performed before or after each event
12 /////////////////////////////////////////////////////////////////
13 
14 #include "ActarSimEventAction.hh"
16 
17 #include "ActarSimROOTAnalysis.hh"
18 
19 #include "G4Event.hh"
20 #include "G4TrajectoryContainer.hh"
21 #include "G4VTrajectory.hh"
22 #include "G4Trajectory.hh"
23 #include "G4VVisManager.hh"
24 #include "G4UnitsTable.hh"
25 #include "G4ThreeVector.hh"
26 
27 #include "G4RunManager.hh"
28 
29 #include "Randomize.hh"
30 #include <iomanip>
31 
32 //////////////////////////////////////////////////////////////////
33 /// Constructor
35  :drawFlag("all"), printModulo(1) {
37 }
38 
39 //////////////////////////////////////////////////////////////////
40 /// Destructor
42  delete eventMessenger;
43 }
44 
45 //////////////////////////////////////////////////////////////////
46 /// Actions performed at the beginning of each event
47 void ActarSimEventAction::BeginOfEventAction(const G4Event* evt){
48  G4int evtNb = evt->GetEventID();
49 
50  const G4int verboseLevel = G4RunManager::GetRunManager()->GetVerboseLevel();
51  if(verboseLevel>0){
52  if (evtNb%printModulo == 0) {
53  G4cout << "##################################################################"
54  << G4endl
55  << "######## ActarSimEventAction::BeginOfEventAction() ##########"
56  << G4endl
57  << "######## Begin of event: " << evtNb << " ########"<< G4endl;
58  CLHEP::HepRandom::showEngineStatus();
59  G4cout << "##################################################################"
60  << G4endl;
61  }
62  }
63 
64  // Histogramming and other ROOT related actions
66 }
67 
68 //////////////////////////////////////////////////////////////////
69 /// Actions performed at the end of each event (some information
70 /// of the trajectories display is included)
71 void ActarSimEventAction::EndOfEventAction(const G4Event* evt) {
72  G4int evtNb = evt->GetEventID();
73 
74  if (evtNb%printModulo == 0){
75  G4cout << "##################################################################"
76  << G4endl
77  << "######### ActarSimEventAction::EndOfEventAction() #########"
78  << G4endl
79  << "#### End of event: " << evtNb << G4endl;
80  G4cout << "##################################################################"
81  << G4endl;
82  }
83 
84  // Histogramming
87 
88  // extract the trajectories and draw them
89 
90  // You can get a default drawing without this code by using, e.g.,
91  // /vis/scene/add/trajectories 1000
92  // The code here adds sophistication under control of drawFlag.
93 
94  // See comments in G4VTrajectory::DrawTrajectory for the
95  // interpretation of the argument, 1000.
96 
97  G4VVisManager* pVisManager = G4VVisManager::GetConcreteInstance();
98  if (pVisManager) {
99  G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
100  G4int n_trajectories = 0;
101  if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
102 
103  for (G4int i=0; i<n_trajectories; i++) {
104  G4VTrajectory* trj = (G4Trajectory*)((*(evt->GetTrajectoryContainer()))[i]);
105  if (drawFlag == "all") trj->DrawTrajectory();
106  else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
107  trj->DrawTrajectory();
108  else if ((drawFlag == "neutral")&&(trj->GetCharge() == 0.))
109  trj->DrawTrajectory();
110  }
111  }
112 }
void BeginOfEventAction(const G4Event *)
Actions performed at the beginning of each event.
~ActarSimEventAction()
Destructor.
void EndOfEventAction(const G4Event *)
Actions to perform in the analysis at the end of the event.
ActarSimEventActionMessenger * eventMessenger
Pointer to the messenger.
void BeginOfEventAction(const G4Event *)
Actions to perform in the analysis at the beginning of the event.
void EndOfEventAction(const G4Event *)
ActarSimROOTAnalysis * gActarSimROOTAnalysis
Global pointer to this soliton.
ActarSimEventAction()
Constructor.