source: trunk/examples/extended/field/field02/src/F02EventAction.cc @ 1230

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

update to geant4.9.3

File size: 4.9 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// $Id: F02EventAction.cc,v 1.6 2006/06/29 17:18:02 gunter Exp $
28// GEANT4 tag $Name: geant4-09-03-cand-01 $
29//
30//
31
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34
35#include "F02EventAction.hh"
36
37#include "F02RunAction.hh"
38
39#include "F02CalorHit.hh"
40#include "F02EventActionMessenger.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
56F02EventAction::F02EventAction(F02RunAction* F02RA)
57 : calorimeterCollID(-1), eventMessenger(0),
58   runaction(F02RA), verboselevel(0),
59   drawFlag("all"), printModulo(10000)
60{
61  eventMessenger = new F02EventActionMessenger(this);
62}
63
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
65
66F02EventAction::~F02EventAction()
67{
68  delete eventMessenger;
69}
70
71//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
72
73void F02EventAction::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 F02EventAction::EndOfEventAction(const G4Event* evt)
92{ 
93  G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
94
95  if(pVVisManager)
96  {
97   G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
98   G4int n_trajectories = 0;
99   if (trajectoryContainer) n_trajectories = trajectoryContainer->entries(); 
100   for(G4int i=0; i<n_trajectories; i++) 
101      { G4Trajectory* trj = (G4Trajectory *)((*(evt->GetTrajectoryContainer()))[i]);
102        if (drawFlag == "all") trj->DrawTrajectory(50);
103        else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
104                               trj->DrawTrajectory(50); 
105      }
106  } 
107
108  if(verboselevel>0)
109    G4cout << "<<< Event  " << evt->GetEventID() << " ended." << G4endl;
110
111  // save rndm status
112  if (runaction->GetRndmFreq() == 2)
113    { 
114     CLHEP::HepRandom::saveEngineStatus("endOfEvent.rndm");   
115     G4int evtNb = evt->GetEventID();
116     if (evtNb%printModulo == 0)
117       { 
118        G4cout << "\n---> End of Event: " << evtNb << G4endl;
119        CLHEP::HepRandom::showEngineStatus();
120       }
121    }     
122}
123
124//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
125
126G4int F02EventAction::GetEventno()
127{
128  G4int evno = fpEventManager->GetConstCurrentEvent()->GetEventID() ;
129  return evno ;
130}
131
132//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
133
134void F02EventAction::setEventVerbose(G4int level)
135{
136  verboselevel = level ;
137}
138
139//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Note: See TracBrowser for help on using the repository browser.