Geant4  10.00.p02
exGPSEventAction.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 //
26 // $Id: exGPSEventAction.cc 76468 2013-11-11 10:27:19Z gcosmo $
27 //
30 //
31 
32 #include "exGPSEventAction.hh"
34 
35 #include "exGPSHistoManager.hh"
36 
37 
38 #include "G4Event.hh"
39 #include "G4EventManager.hh"
40 #include "G4ios.hh"
41 #include "G4UnitsTable.hh"
42 #include "G4ThreeVector.hh"
43 #include "G4PhysicalConstants.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
48  fDrawFlag("all"), fPrintModulo(1000), fEventMessenger(NULL),
49  fexGPSHistoManager(histoManager)
50 {
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
57 {
58  delete fEventMessenger;
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62 
64 {
65 
66  G4int evtNb = evt->GetEventID();
67  if (evtNb%fPrintModulo == 0)
68  {
69  G4cout << "\n---> Begin of event: " << evtNb << G4endl;
70  // HepRandom::showEngineStatus();
71  }
72 
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
76 
78 {
79  // G4int evtNb = evt->GetEventID();
80 
81  G4int nVertex = evt->GetNumberOfPrimaryVertex();
82  for ( G4int j = 0; j < nVertex; j++) {
83  G4int nPart = evt->GetPrimaryVertex(j)->GetNumberOfParticle();
84  for ( G4int i = 0; i < nPart; i++) {
86  G4ThreeVector direction=evt->GetPrimaryVertex(j)->GetPrimary(i)
87  ->GetMomentum();
88  G4double P=direction.mag();
91  ->GetPDGMass();
92  E=std::sqrt(P*P+E0*E0);
93  E -= E0;
94  G4int pid = evt->GetPrimaryVertex(j)->GetPrimary(i)
95  ->GetPDGcode();
96  //
97  direction=direction*(1./direction.mag());
98  direction = -direction; // reverse the direction
99  G4double x,y,z,w;
100  G4double Phi=direction.phi();
101  if (Phi <0) Phi=Phi+twopi;
102  G4double Theta=direction.theta();
103  x=position.x();
104  y=position.y();
105  z=position.z();
106  w = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetWeight();
107  fexGPSHistoManager->Fill(pid,E,x,y,z,Theta,Phi,w);
108  }
109  }
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
113 
114 
115 
116 
117 
118 
G4int GetNumberOfParticle() const
G4ThreeVector GetMomentum() const
virtual void BeginOfEventAction(const G4Event *)
exGPSHistoManager * fexGPSHistoManager
G4ThreeVector GetPosition() const
CLHEP::Hep3Vector G4ThreeVector
G4int GetNumberOfPrimaryVertex() const
Definition: G4Event.hh:153
G4double z
Definition: TRTMaterials.hh:39
virtual void EndOfEventAction(const G4Event *)
exGPSEventActionMessenger * fEventMessenger
int G4int
Definition: G4Types.hh:78
G4ParticleDefinition * GetG4code() const
Definition of the exGPSEventActionMessenger class.
G4int GetEventID() const
Definition: G4Event.hh:140
G4PrimaryParticle * GetPrimary(G4int i=0) const
void Fill(G4int PDGid, G4double e, G4double x, G4double y, G4double z, G4double t, G4double p, G4double w)
G4GLOB_DLL std::ostream G4cout
G4double GetMass() const
Definition of the exGPSHistoManager class.
G4PrimaryVertex * GetPrimaryVertex(G4int i=0) const
Definition: G4Event.hh:156
G4int GetPDGcode() const
G4double GetWeight() const
G4double GetPDGMass() const
int position
Definition: filter.cc:7
Definition of the exGPSEventAction class.
virtual ~exGPSEventAction()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
exGPSEventAction(exGPSHistoManager *histoManager)