Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 
30 #include "exGPSEventAction.hh"
31 
32 #ifdef G4ANALYSIS_USE
33 #include "exGPSAnalysisManager.hh"
34 #endif
35 
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....
47 :fDrawFlag("all"), fPrintModulo(1000), fEventMessenger(NULL)
48 {
49  fEventMessenger = new exGPSEventActionMessenger(this);
50 }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
53 
55 {
56  delete fEventMessenger;
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60 
62 {
63 
64  G4int evtNb = evt->GetEventID();
65  if (evtNb%fPrintModulo == 0)
66  {
67  G4cout << "\n---> Begin of event: " << evtNb << G4endl;
68  // HepRandom::showEngineStatus();
69  }
70 
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
74 #ifdef G4ANALYSIS_USE
76 #else
78 #endif
79 {
80  // G4int evtNb = evt->GetEventID();
81 
82 #ifdef G4ANALYSIS_USE
83  G4int nVertex = evt->GetNumberOfPrimaryVertex();
84  for ( G4int j = 0; j < nVertex; j++) {
85  G4int nPart = evt->GetPrimaryVertex(j)->GetNumberOfParticle();
86  for ( G4int i = 0; i < nPart; i++) {
88  G4ThreeVector direction=evt->GetPrimaryVertex(j)->GetPrimary(i)
89  ->GetMomentum();
90  G4double P=direction.mag();
93  ->GetPDGMass();
94  E=std::sqrt(P*P+E0*E0);
95  E -= E0;
97  ->GetPDGcode());
98  //
99  direction=direction*(1./direction.mag());
100  direction = -direction; // reverse the direction
101  G4double x,y,z,w;
102  G4double Phi=direction.phi();
103  if (Phi <0) Phi=Phi+twopi;
104  G4double Theta=direction.theta();
105  x=position.x();
106  y=position.y();
107  z=position.z();
108  w = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetWeight();
109 // exGPSAnalysisManager::getInstance()->Fill(pname,E,x,y,z,Theta,Phi,w);
110  exGPSAnalysisManager::GetInstance()->Fill(pid,E,x,y,z,Theta,Phi,w);
111  }
112  }
113 #endif
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
117 
118 
119 
120 
121 
122