[807] | 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.... |
---|
| 42 | exGPSEventAction::exGPSEventAction() |
---|
| 43 | :drawFlag("all"), printModulo(1000), eventMessenger(NULL) |
---|
| 44 | { |
---|
| 45 | eventMessenger = new exGPSEventActionMessenger(this); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 49 | |
---|
| 50 | exGPSEventAction::~exGPSEventAction() |
---|
| 51 | { |
---|
| 52 | delete eventMessenger; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 56 | |
---|
| 57 | void 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 | |
---|
| 71 | void exGPSEventAction::EndOfEventAction(const G4Event* evt) |
---|
| 72 | { |
---|
| 73 | // G4int evtNb = evt->GetEventID(); |
---|
| 74 | |
---|
| 75 | #ifdef G4ANALYSIS_USE |
---|
| 76 | G4int nVertex = evt->GetNumberOfPrimaryVertex(); |
---|
| 77 | for ( G4int j = 0; j < nVertex; j++) { |
---|
| 78 | G4int nPart = evt->GetPrimaryVertex(j)->GetNumberOfParticle(); |
---|
| 79 | for ( G4int i = 0; i < nPart; i++) { |
---|
| 80 | G4ThreeVector position=evt->GetPrimaryVertex(j)->GetPosition(); |
---|
| 81 | G4ThreeVector direction=evt->GetPrimaryVertex(j)->GetPrimary(i)->GetMomentum(); |
---|
| 82 | G4double P=direction.mag(); |
---|
| 83 | G4double E=evt->GetPrimaryVertex(j)->GetPrimary(i)->GetMass(); |
---|
| 84 | G4double E0=evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetPDGMass(); |
---|
| 85 | E=std::sqrt(P*P+E0*E0); |
---|
| 86 | E -= E0; |
---|
[1230] | 87 | // G4String pname = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetG4code()->GetParticleName(); |
---|
| 88 | G4double pid = G4double(evt->GetPrimaryVertex(j)->GetPrimary(i)->GetPDGcode()); |
---|
[807] | 89 | // |
---|
| 90 | direction=direction*(1./direction.mag()); |
---|
| 91 | direction = -direction; // reverse the direction |
---|
| 92 | G4double x,y,z,w; |
---|
| 93 | G4double Phi=direction.phi(); |
---|
| 94 | if (Phi <0) Phi=Phi+twopi; |
---|
| 95 | G4double Theta=direction.theta(); |
---|
| 96 | x=position.x(); |
---|
| 97 | y=position.y(); |
---|
| 98 | z=position.z(); |
---|
| 99 | w = evt->GetPrimaryVertex(j)->GetPrimary(i)->GetWeight(); |
---|
[1230] | 100 | // exGPSAnalysisManager::getInstance()->Fill(pname,E,x,y,z,Theta,Phi,w); |
---|
| 101 | exGPSAnalysisManager::getInstance()->Fill(pid,E,x,y,z,Theta,Phi,w); |
---|
[807] | 102 | } |
---|
| 103 | } |
---|
| 104 | #endif |
---|
[1230] | 105 | |
---|
[807] | 106 | } |
---|
| 107 | |
---|
| 108 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | |
---|