source: trunk/source/processes/electromagnetic/lowenergy/test/hTest/src/hTestEventAction.cc @ 1350

Last change on this file since 1350 was 1350, checked in by garnier, 13 years ago

update to last version 4.9.4

File size: 4.6 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//
28//
29// -------------------------------------------------------------
30//      GEANT4 hTest
31//
32//      History: based on object model of
33//      2nd December 1995, G.Cosmo
34//      ---------- hTestEventAction -------------
35//             
36//  Modified: 05.04.01 Vladimir Ivanchenko new design of hTest
37//
38// -------------------------------------------------------------
39
40//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42
43#include "hTestEventAction.hh"
44#include "hTestHisto.hh"
45
46#include "G4UImanager.hh"
47#include "G4TrajectoryContainer.hh"
48#include "G4Trajectory.hh"
49#include "G4VVisManager.hh"
50#include "G4ios.hh"
51
52//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
53
54hTestEventAction::hTestEventAction(const hTestDetectorConstruction* det):
55  theDet(det),
56  nEvt(0),
57  verbose(0),
58  drawFlag("all")
59{}
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62
63hTestEventAction::~hTestEventAction()
64{}
65
66//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
67
68void hTestEventAction::BeginOfEventAction(const G4Event* evt)
69{ 
70  // New event
71  nEvt++;
72
73  // Switch on verbose mode
74  if(theDet->GetFirstEventToDebug() == nEvt) {
75    verbose = 2;
76    (hTestHisto::GetPointer())->SetVerbose(2);   
77    (G4UImanager::GetUIpointer())->ApplyCommand("/tracking/verbose 2");
78    /*
79    const G4ProcessManager* pm = G4Gamma::Gamma()->GetProcessManager();
80    const G4ProcessVector* pv = pm->GetProcessList();
81    G4int np = pm->GetProcessListLength();
82    for(G4int i=0; i<np; i++) {
83     ((*pv)[i])->SetVerboseLevel(2);
84    }
85    */
86  }
87   
88  // Switch off verbose mode
89  if(theDet->GetLastEventToDebug() == nEvt-1) {
90    verbose = 0;
91    (hTestHisto::GetPointer())->SetVerbose(0);   
92    (G4UImanager::GetUIpointer())->ApplyCommand("/tracking/verbose 0");
93  }
94
95  // Initialize user actions
96  if(verbose > 0) {
97    G4cout << "hTestEventAction: Event # " 
98           << nEvt << " started" << G4endl;
99  }
100
101}
102
103//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
104
105void hTestEventAction::EndOfEventAction(const G4Event* evt)
106{
107
108  G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
109
110  if(pVVisManager) {
111    G4TrajectoryContainer* trjc = evt->GetTrajectoryContainer();
112    G4int n_trajectories = 0;
113    if (trjc) n_trajectories = trjc->entries(); 
114
115    for(G4int i=0; i<n_trajectories; i++) {
116      G4Trajectory* t = (G4Trajectory*)((*(evt->GetTrajectoryContainer()))[i]);
117      if (drawFlag == "all") t->DrawTrajectory(50);
118      else if ((drawFlag == "charged")&&(t->GetCharge() != 0.))
119                             t->DrawTrajectory(50); 
120    }
121  } 
122
123  if(verbose > 0) {
124    G4cout << "hTestEventAction: Event # " 
125           << nEvt << " ended" << G4endl;
126  }
127}
128
129//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
130 
131
132
133
134
135
136
137
138
139
140
141
142
143
Note: See TracBrowser for help on using the repository browser.