source: trunk/examples/extended/electromagnetic/TestEm9/src/EventAction.cc@ 1228

Last change on this file since 1228 was 807, checked in by garnier, 17 years ago

update

File size: 4.1 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// $Id: EventAction.cc,v 1.4 2006/06/29 17:03:06 gunter Exp $
27// GEANT4 tag $Name: $
28
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
31
32#include "EventAction.hh"
33#include "HistoManager.hh"
34#include "EventActionMessenger.hh"
35
36#include "G4UImanager.hh"
37#include "G4TrajectoryContainer.hh"
38#include "G4Trajectory.hh"
39#include "G4VVisManager.hh"
40#include "G4Gamma.hh"
41#include "G4ios.hh"
42
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
44
45EventAction::EventAction():
46 nEvt(0),
47 printModulo(100),
48 verbose(0),
49 drawFlag("all")
50{
51 eventMessenger = new EventActionMessenger(this);
52}
53
54//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55
56EventAction::~EventAction()
57{}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
60
61void EventAction::BeginOfEventAction(const G4Event*)
62{
63 // New event
64 nEvt++;
65 HistoManager* hi = HistoManager::GetPointer();
66 hi->BeginOfEvent();
67
68 // Switch on verbose mode
69
70 if(hi->FirstEventToDebug() == nEvt) {
71 verbose = 2;
72 hi->SetVerbose(2);
73 (G4UImanager::GetUIpointer())->ApplyCommand("/tracking/verbose 2");
74 }
75
76 // Switch off verbose mode
77 if(hi->LastEventToDebug() == nEvt-1) {
78 verbose = 0;
79 hi->SetVerbose(0);
80 (G4UImanager::GetUIpointer())->ApplyCommand("/tracking/verbose 0");
81 }
82
83
84 // Initialize user actions
85 if(verbose > 0) {
86 G4cout << "EventAction: Event # "
87 << nEvt << " started" << G4endl;
88 }
89
90}
91
92//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
93
94void EventAction::EndOfEventAction(const G4Event* evt)
95{
96 (HistoManager::GetPointer())->EndOfEvent();
97 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
98
99 if(pVVisManager) {
100 G4TrajectoryContainer* trjc = evt->GetTrajectoryContainer();
101 G4int n_trajectories = 0;
102 if (trjc) n_trajectories = trjc->entries();
103
104 for(G4int i=0; i<n_trajectories; i++) {
105 G4Trajectory* t = (G4Trajectory*)((*(evt->GetTrajectoryContainer()))[i]);
106 if (drawFlag == "all") t->DrawTrajectory(1000);
107 else if ((drawFlag == "charged")&&(t->GetCharge() != 0.))
108 t->DrawTrajectory(1000);
109 }
110 }
111
112 if(verbose > 0) {
113 G4cout << "EventAction: Event # "
114 << nEvt << " ended" << G4endl;
115 }
116}
117
118//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Note: See TracBrowser for help on using the repository browser.