Geant4  10.02.p02
RE01EventAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 // $Id: RE01EventAction.cc 90679 2015-06-08 07:58:19Z gcosmo $
30 //
31 
32 #include "RE01EventAction.hh"
33 #include "RE01TrackerHit.hh"
34 #include "RE01CalorimeterHit.hh"
35 
36 #include "G4Event.hh"
37 #include "G4EventManager.hh"
38 #include "G4HCofThisEvent.hh"
39 #include "G4VHitsCollection.hh"
40 #include "G4TrajectoryContainer.hh"
41 #include "G4VVisManager.hh"
42 #include "G4SDManager.hh"
43 #include "G4UImanager.hh"
44 #include "G4ios.hh"
45 #include "RE01Trajectory.hh"
46 #include "G4PrimaryVertex.hh"
47 #include "G4PrimaryParticle.hh"
48 #include "G4SystemOfUnits.hh"
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53  fTrackerCollID(-1),fCalorimeterCollID(-1)
54 {;}
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 {;}
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 {
65  {
66  G4String colNam;
67  fTrackerCollID = SDman->GetCollectionID(colNam="trackerCollection");
68  fCalorimeterCollID = SDman->GetCollectionID(colNam="calCollection");
69  }
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 {
75  G4cout << ">>> Summary of Event " << evt->GetEventID() << G4endl;
76 
77  if(fTrackerCollID<0||fCalorimeterCollID<0) return;
78 
79  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
82  if(HCE)
83  {
86  }
87 
88  if(THC)
89  {
90  int n_hit = THC->entries();
91  G4cout << G4endl;
92  G4cout << "Tracker hits " <<
93  "--------------------------------------------------------------"
94  << G4endl;
95  G4cout << n_hit << " hits are stored in RE01TrackerHitsCollection."
96  << G4endl;
98  {
99  G4cout << "List of hits in tracker" << G4endl;
100  for(int i=0;i<n_hit;i++)
101  { (*THC)[i]->Print(); }
102  }
103  }
104  if(CHC)
105  {
106  int n_hit = CHC->entries();
107  G4cout << G4endl;
108  G4cout << "Calorimeter hits "<<
109  "--------------------------------------------------------------"
110  << G4endl;
111  G4cout << n_hit << " hits are stored in RE01CalorimeterHitsCollection."
112  << G4endl;
113  G4double totE = 0;
114  for(int i=0;i<n_hit;i++)
115  { totE += (*CHC)[i]->GetEdep(); }
116  G4cout << " Total energy deposition in calorimeter : "
117  << totE / GeV << " (GeV)" << G4endl;
118  }
119 
120  // get number of stored trajectories
121  G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
122  G4int n_trajectories = 0;
123  if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
124  // extract the trajectories and print them out
125  G4cout << G4endl;
126  G4cout << "Trajectories in tracker "<<
127  "--------------------------------------------------------------"
128  << G4endl;
130  {
131  for(G4int i=0; i<n_trajectories; i++)
132  {
133  RE01Trajectory* trj =
134  (RE01Trajectory*)((*(evt->GetTrajectoryContainer()))[i]);
135  trj->ShowTrajectory();
136  }
137  }
138 
139  G4cout << G4endl;
140  G4cout << "Primary particles "<<
141  "--------------------------------------------------------------"
142  << G4endl;
143  G4int n_vertex = evt->GetNumberOfPrimaryVertex();
144  for(G4int iv=0;iv<n_vertex;iv++)
145  {
146  G4PrimaryVertex* pv = evt->GetPrimaryVertex(iv);
147  G4cout << G4endl;
148  G4cout << "Primary vertex "
149  << G4ThreeVector(pv->GetX0(),pv->GetY0(),pv->GetZ0())
150  << " at t = " << (pv->GetT0())/ns << " [ns]" << G4endl;
152  {
154  while(pp)
155  {
156  PrintPrimary(pp,0);
157  pp = pp->GetNext();
158  }
159  }
160  }
161 }
162 
163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165 {
166  for(G4int ii=0;ii<=ind;ii++)
167  { G4cout << " "; }
168  G4cout << "==PDGcode " << pp->GetPDGcode() << " ";
169  if(pp->GetG4code()!=0)
170  { G4cout << "(" << pp->GetG4code()->GetParticleName() << ")"; }
171  else
172  { G4cout << "is not defined in G4"; }
173  G4cout << " " << pp->GetMomentum()/GeV << " [GeV] ";
174  if(pp->GetTrackID()<0)
175  { G4cout << G4endl; }
176  else
177  { G4cout << ">>> G4Track ID " << pp->GetTrackID() << G4endl; }
178 
179  G4PrimaryParticle* daughter = pp->GetDaughter();
180  while(daughter)
181  {
182  PrintPrimary(daughter,ind+1);
183  daughter = daughter->GetNext();
184  }
185 }
186 
187 
G4double GetX0() const
void PrintPrimary(G4PrimaryParticle *pp, G4int ind)
G4ThreeVector GetMomentum() const
Definition of the RE01CalorimeterHit class.
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
virtual void EndOfEventAction(const G4Event *)
G4int GetTrackID() const
CLHEP::Hep3Vector G4ThreeVector
G4int GetNumberOfPrimaryVertex() const
Definition: G4Event.hh:164
virtual ~RE01EventAction()
virtual void ShowTrajectory(std::ostream &os=G4cout) const
G4int entries() const
G4double GetT0() const
G4EventManager * fpEventManager
int G4int
Definition: G4Types.hh:78
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:189
const G4String & GetParticleName() const
G4ParticleDefinition * GetG4code() const
G4int GetEventID() const
Definition: G4Event.hh:151
G4PrimaryParticle * GetPrimary(G4int i=0) const
G4GLOB_DLL std::ostream G4cout
virtual void BeginOfEventAction(const G4Event *)
G4PrimaryParticle * GetDaughter() const
G4double GetZ0() const
static const double GeV
Definition: G4SIunits.hh:214
G4PrimaryVertex * GetPrimaryVertex(G4int i=0) const
Definition: G4Event.hh:167
G4int GetPDGcode() const
Definition of the RE01EventAction class.
G4PrimaryParticle * GetNext() const
Definition of the RE01TrackerHit class.
G4int GetVerboseLevel()
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
G4double GetY0() const
#define G4endl
Definition: G4ios.hh:61
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
double G4double
Definition: G4Types.hh:76
#define ns
Definition: xmlparse.cc:614
Definition of the RE01Trajectory class.