| 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: NTSTEventAction.cc,v 1.6 2006/06/29 18:26:10 gunter Exp $
|
|---|
| 27 | // GEANT4 tag $Name: HEAD $
|
|---|
| 28 | //
|
|---|
| 29 | //
|
|---|
| 30 |
|
|---|
| 31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 33 |
|
|---|
| 34 | #include "G4Timer.hh"
|
|---|
| 35 | #include "G4Event.hh"
|
|---|
| 36 | #include "G4EventManager.hh"
|
|---|
| 37 | #include "G4HCofThisEvent.hh"
|
|---|
| 38 | #include "G4VHitsCollection.hh"
|
|---|
| 39 | #include "G4TrajectoryContainer.hh"
|
|---|
| 40 | #include "G4VTrajectory.hh"
|
|---|
| 41 | #include "G4VVisManager.hh"
|
|---|
| 42 | #include "G4SDManager.hh"
|
|---|
| 43 | #include "G4UImanager.hh"
|
|---|
| 44 | #include "G4ios.hh"
|
|---|
| 45 | #include "G4UnitsTable.hh"
|
|---|
| 46 | #include "NTSTEventAction.hh"
|
|---|
| 47 | #include "NTSTEventActionMessenger.hh"
|
|---|
| 48 |
|
|---|
| 49 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 50 |
|
|---|
| 51 | NTSTEventAction::NTSTEventAction()
|
|---|
| 52 | : EventTime(new G4Timer()),
|
|---|
| 53 | MeanUserEventTime(0), RmsUserEventTime(0),
|
|---|
| 54 | MeanRealEventTime(0), RmsRealEventTime(0),
|
|---|
| 55 | NumberOfEvents(0),
|
|---|
| 56 | MeanVertices(0), RmsVertices(0),
|
|---|
| 57 | MeanTracks(0), RmsTracks(0),
|
|---|
| 58 | drawFlag("all"), eventMessenger(NULL)
|
|---|
| 59 | {
|
|---|
| 60 | eventMessenger = new NTSTEventActionMessenger(this);
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | #include <iomanip>
|
|---|
| 64 |
|
|---|
| 65 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 66 |
|
|---|
| 67 | NTSTEventAction::~NTSTEventAction()
|
|---|
| 68 | {
|
|---|
| 69 | if (NumberOfEvents>0) {
|
|---|
| 70 | G4cout << "### Processed number of events for all runs: "
|
|---|
| 71 | << NumberOfEvents << G4endl;
|
|---|
| 72 | MeanUserEventTime = MeanUserEventTime / NumberOfEvents;
|
|---|
| 73 | MeanRealEventTime = MeanRealEventTime / NumberOfEvents;
|
|---|
| 74 | RmsUserEventTime = RmsUserEventTime / NumberOfEvents;
|
|---|
| 75 | RmsRealEventTime = RmsRealEventTime / NumberOfEvents;
|
|---|
| 76 | G4double ErrUserEventTime =
|
|---|
| 77 | std::sqrt((RmsUserEventTime - MeanUserEventTime*MeanUserEventTime)
|
|---|
| 78 | /NumberOfEvents);
|
|---|
| 79 | G4double ErrRealEventTime =
|
|---|
| 80 | std::sqrt((RmsRealEventTime - MeanRealEventTime*MeanRealEventTime)
|
|---|
| 81 | /NumberOfEvents);
|
|---|
| 82 | G4cout << std::setprecision(3)
|
|---|
| 83 | << "### Event user time = " << std::setw(6) << MeanUserEventTime
|
|---|
| 84 | << std::setprecision(3)
|
|---|
| 85 | << " +- " << std::setw(6)
|
|---|
| 86 | << ErrUserEventTime << " (sec) " << G4endl;
|
|---|
| 87 | G4cout << std::setprecision(3)
|
|---|
| 88 | << "### Event real time = " << std::setw(6) << MeanRealEventTime
|
|---|
| 89 | << std::setprecision(3)
|
|---|
| 90 | << " +- " << std::setw(6)
|
|---|
| 91 | << ErrRealEventTime << " (sec) " << G4endl;
|
|---|
| 92 |
|
|---|
| 93 | MeanVertices = MeanVertices / NumberOfEvents;
|
|---|
| 94 | RmsVertices = RmsVertices / NumberOfEvents;
|
|---|
| 95 | MeanTracks = MeanTracks / NumberOfEvents;
|
|---|
| 96 | RmsTracks = RmsTracks / NumberOfEvents;
|
|---|
| 97 | G4double ErrVertices =
|
|---|
| 98 | std::sqrt((RmsVertices - MeanVertices*MeanVertices)/NumberOfEvents);
|
|---|
| 99 | G4double ErrTracks =
|
|---|
| 100 | std::sqrt((RmsTracks - MeanTracks*MeanTracks)/NumberOfEvents);
|
|---|
| 101 |
|
|---|
| 102 | G4cout << std::setprecision(3)
|
|---|
| 103 | << "### Number of Vertices = " << std::setw(6) << MeanVertices << " +- "
|
|---|
| 104 | << std::setw(6) << ErrVertices
|
|---|
| 105 | << " Number of Tracks = " << std::setw(6) << MeanTracks << " +- "
|
|---|
| 106 | << std::setw(6) << ErrTracks << G4endl;
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 | }
|
|---|
| 110 | delete eventMessenger;
|
|---|
| 111 | delete EventTime;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 115 |
|
|---|
| 116 | void NTSTEventAction::BeginOfEventAction(const G4Event* ) // evt)
|
|---|
| 117 | {
|
|---|
| 118 | EventTime->Start();
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|
| 122 |
|
|---|
| 123 | void NTSTEventAction::EndOfEventAction(const G4Event* evt)
|
|---|
| 124 | {
|
|---|
| 125 | EventTime->Stop();
|
|---|
| 126 | G4cout << "### Event " << std::setprecision(3)
|
|---|
| 127 | << evt->GetEventID()+1 << " " << *EventTime << G4endl;
|
|---|
| 128 |
|
|---|
| 129 | // event statistics
|
|---|
| 130 | G4double ElapsedUserTime = EventTime->GetUserElapsed();
|
|---|
| 131 | G4double ElapsedRealTime = EventTime->GetRealElapsed();
|
|---|
| 132 | MeanUserEventTime += ElapsedUserTime;
|
|---|
| 133 | MeanRealEventTime += ElapsedRealTime;
|
|---|
| 134 | RmsUserEventTime += ElapsedUserTime*ElapsedUserTime;
|
|---|
| 135 | RmsRealEventTime += ElapsedRealTime*ElapsedRealTime;
|
|---|
| 136 | NumberOfEvents++;
|
|---|
| 137 |
|
|---|
| 138 | // vertex, track statistics
|
|---|
| 139 | G4int Vertices = evt->GetNumberOfPrimaryVertex();
|
|---|
| 140 | MeanVertices+=Vertices;
|
|---|
| 141 | RmsVertices+=Vertices*Vertices;
|
|---|
| 142 | G4int Tracks=0;
|
|---|
| 143 | for (G4int iv=0; iv<Vertices; iv++){
|
|---|
| 144 | Tracks+=evt->GetPrimaryVertex(iv)->GetNumberOfParticle();
|
|---|
| 145 | }
|
|---|
| 146 | MeanTracks+=Tracks;
|
|---|
| 147 | RmsTracks+=Tracks*Tracks;
|
|---|
| 148 |
|
|---|
| 149 | G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
|
|---|
| 150 | G4int n_trajectories = 0;
|
|---|
| 151 | if(trajectoryContainer)
|
|---|
| 152 | { n_trajectories = trajectoryContainer->entries(); }
|
|---|
| 153 | G4cout << " " << n_trajectories
|
|---|
| 154 | << " trajectories stored in this event." << G4endl;
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 | G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
|---|
| 158 |
|
|---|
| 159 | if(pVVisManager) {
|
|---|
| 160 | for(G4int i=0; i<n_trajectories; i++) {
|
|---|
| 161 | G4VTrajectory* trj = (*(evt->GetTrajectoryContainer()))[i];
|
|---|
| 162 | // if (drawFlag == "all") trj->DrawTrajectory(50);
|
|---|
| 163 | // else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
|
|---|
| 164 | trj->DrawTrajectory(50);
|
|---|
| 165 | }
|
|---|
| 166 | }
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
|---|