source: trunk/examples/extended/field/field01/src/F01EventAction.cc@ 1330

Last change on this file since 1330 was 1230, checked in by garnier, 16 years ago

update to geant4.9.3

File size: 4.9 KB
RevLine 
[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// $Id: F01EventAction.cc,v 1.6 2006/06/29 17:16:29 gunter Exp $
[1230]28// GEANT4 tag $Name: geant4-09-03-cand-01 $
[807]29//
30//
31
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34
35#include "F01EventAction.hh"
36
37#include "F01RunAction.hh"
38
39#include "F01CalorHit.hh"
40#include "F01EventActionMessenger.hh"
41
42#include "G4Event.hh"
43#include "G4EventManager.hh"
44#include "G4HCofThisEvent.hh"
45#include "G4VHitsCollection.hh"
46#include "G4SDManager.hh"
47#include "G4TrajectoryContainer.hh"
48#include "G4Trajectory.hh"
49#include "G4VVisManager.hh"
50#include "G4ios.hh"
51#include "G4UnitsTable.hh"
52#include "Randomize.hh"
53
54//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55
56F01EventAction::F01EventAction(F01RunAction* F01RA)
57 : calorimeterCollID(-1), eventMessenger(0),
58 runaction(F01RA), verboselevel(0),
59 drawFlag("all"), printModulo(10000)
60{
61 eventMessenger = new F01EventActionMessenger(this);
62}
63
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
65
66F01EventAction::~F01EventAction()
67{
68 delete eventMessenger;
69}
70
71//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
72
73void F01EventAction::BeginOfEventAction(const G4Event* evt)
74{
75 G4int evtNb = evt->GetEventID();
76 if (evtNb%printModulo == 0)
77 G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
78
79 if(verboselevel>1)
80 G4cout << "<<< Event " << evtNb << " started." << G4endl;
81
82 if (calorimeterCollID==-1)
83 {
84 G4SDManager * SDman = G4SDManager::GetSDMpointer();
85 calorimeterCollID = SDman->GetCollectionID("CalCollection");
86 }
87}
88
89//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
90
91void F01EventAction::EndOfEventAction(const G4Event* evt)
92{
93
94 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
95
96 if(pVVisManager)
97 {
98 G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
99 G4int n_trajectories = 0;
100 if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
101 for(G4int i=0; i<n_trajectories; i++)
102 { G4Trajectory* trj = (G4Trajectory *)((*(evt->GetTrajectoryContainer()))[i]);
103 if (drawFlag == "all") trj->DrawTrajectory(50);
104 else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
105 trj->DrawTrajectory(50);
106 }
107 }
108
109 if(verboselevel>0)
110 G4cout << "<<< Event " << evt->GetEventID() << " ended." << G4endl;
111
112
113 //save rndm status
114 if (runaction->GetRndmFreq() == 2)
115 {
116 CLHEP::HepRandom::saveEngineStatus("endOfEvent.rndm");
117 G4int evtNb = evt->GetEventID();
118 if (evtNb%printModulo == 0)
119 {
120 G4cout << "\n---> End of Event: " << evtNb << G4endl;
121 CLHEP::HepRandom::showEngineStatus();
122 }
123 }
124}
125
126//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
127
128G4int F01EventAction::GetEventno()
129{
130 G4int evno = fpEventManager->GetConstCurrentEvent()->GetEventID() ;
131 return evno ;
132}
133
134//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
135
136void F01EventAction::setEventVerbose(G4int level)
137{
138 verboselevel = level ;
139}
140
141//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Note: See TracBrowser for help on using the repository browser.