source: trunk/examples/extended/eventgenerator/exgps/src/exGPSEventAction.cc@ 1342

Last change on this file since 1342 was 1342, checked in by garnier, 15 years ago

update ti head

File size: 4.3 KB
Line 
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
27#include "exGPSEventAction.hh"
28
29#ifdef G4ANALYSIS_USE
30#include "exGPSAnalysisManager.hh"
31#endif
32
33#include "exGPSEventActionMessenger.hh"
34
35#include "G4Event.hh"
36#include "G4EventManager.hh"
37#include "G4ios.hh"
38#include "G4UnitsTable.hh"
39#include "G4ThreeVector.hh"
40
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42exGPSEventAction::exGPSEventAction()
43:drawFlag("all"), printModulo(1000), eventMessenger(NULL)
44{
45 eventMessenger = new exGPSEventActionMessenger(this);
46}
47
48//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
49
50exGPSEventAction::~exGPSEventAction()
51{
52 delete eventMessenger;
53}
54
55//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
56
57void exGPSEventAction::BeginOfEventAction(const G4Event* evt)
58{
59
60 G4int evtNb = evt->GetEventID();
61 if (evtNb%printModulo == 0)
62 {
63 G4cout << "\n---> Begin of event: " << evtNb << G4endl;
64 // HepRandom::showEngineStatus();
65 }
66
67}
68
69//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
70#ifdef G4ANALYSIS_USE
71void exGPSEventAction::EndOfEventAction(const G4Event* evt)
72#else
73void exGPSEventAction::EndOfEventAction(const G4Event*)
74#endif
75{
76 // G4int evtNb = evt->GetEventID();
77
78#ifdef G4ANALYSIS_USE
79 G4int nVertex = evt->GetNumberOfPrimaryVertex();
80 for ( G4int j = 0; j < nVertex; j++) {
81 G4int nPart = evt->GetPrimaryVertex(j)->GetNumberOfParticle();
82 for ( G4int i = 0; i < nPart; i++) {
83 G4ThreeVector position=evt->GetPrimaryVertex(j)->GetPosition();
84 G4ThreeVector direction=evt->GetPrimaryVertex(j)->GetPrimary(i)->GetMomentum();
85 G4double P=direction.mag();
86 G4double E=evt->GetPrimaryVertex(j)->GetPrimary(i)->GetMass();
87 G4double E0=evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetPDGMass();
88 E=std::sqrt(P*P+E0*E0);
89 E -= E0;
90// G4String pname = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetParticleName();
91 G4double pid = G4double(evt->GetPrimaryVertex(j)->GetPrimary(i)->GetPDGcode());
92 //
93 direction=direction*(1./direction.mag());
94 direction = -direction; // reverse the direction
95 G4double x,y,z,w;
96 G4double Phi=direction.phi();
97 if (Phi <0) Phi=Phi+twopi;
98 G4double Theta=direction.theta();
99 x=position.x();
100 y=position.y();
101 z=position.z();
102 w = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetWeight();
103// exGPSAnalysisManager::getInstance()->Fill(pname,E,x,y,z,Theta,Phi,w);
104 exGPSAnalysisManager::getInstance()->Fill(pid,E,x,y,z,Theta,Phi,w);
105 }
106 }
107#endif
108
109}
110
111//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
112
113
114
115
116
117
Note: See TracBrowser for help on using the repository browser.