source: trunk/source/geometry/management/test/TestAssemblyVolume/src/TstVAEventAction.cc@ 1350

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

geant4 tag 9.4

File size: 5.0 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: TstVAEventAction.cc,v 1.8 2006/06/29 18:34:37 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30// --------------------------------------------------------------
31
32#include "TstVAEventAction.hh"
33
34#include "TstVAEventActionMessenger.hh"
35
36#include "G4Event.hh"
37#include "G4EventManager.hh"
38#include "G4HCofThisEvent.hh"
39#include "G4VHitsCollection.hh"
40#include "G4TrajectoryContainer.hh"
41#include "G4Trajectory.hh"
42#include "G4VVisManager.hh"
43#include "G4SDManager.hh"
44#include "G4UImanager.hh"
45#include "G4ios.hh"
46#include "G4UnitsTable.hh"
47
48TstVAEventAction::TstVAEventAction()
49 : calorimeterCollID(-1), drawFlag("all"),
50 printModulo(1), eventMessenger(NULL)
51{
52 eventMessenger = new TstVAEventActionMessenger(this);
53}
54
55TstVAEventAction::~TstVAEventAction()
56{
57 delete eventMessenger;
58}
59
60void TstVAEventAction::BeginOfEventAction(const G4Event*)
61{
62}
63
64void TstVAEventAction::EndOfEventAction(const G4Event* evt)
65{
66
67 if (G4VVisManager::GetConcreteInstance())
68 {
69 G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
70
71 G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
72 G4int n_trajectories = 0;
73 if (trajectoryContainer)
74 {
75 n_trajectories = trajectoryContainer->entries();
76 }
77
78 for( int i = 0; i < n_trajectories; i++ )
79 {
80 (*trajectoryContainer)[i]->DrawTrajectory(50);
81 }
82 }
83
84
85/*
86 G4int evtNb = evt->GetEventID();
87
88 // extracted from hits, compute the total energy deposit (and total charged
89 // track length) in all absorbers and in all gaps
90
91 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
92
93 ExN03CalorHitsCollection* CHC = NULL;
94 G4int n_hit = 0;
95 G4double totEAbs=0, totLAbs=0, totEGap=0, totLGap=0;
96
97 if (HCE) CHC = (ExN03CalorHitsCollection*)(HCE->GetHC(calorimeterCollID));
98
99 if (CHC)
100 {
101 n_hit = CHC->entries();
102 for (G4int i=0;i<n_hit;i++)
103 {
104 totEAbs += (*CHC)[i]->GetEdepAbs();
105 totLAbs += (*CHC)[i]->GetTrakAbs();
106 totEGap += (*CHC)[i]->GetEdepGap();
107 totLGap += (*CHC)[i]->GetTrakGap();
108 }
109 }
110
111 // print this information event by event (modulo n)
112
113 if (evtNb%printModulo == 0) {
114 G4cout << "---> End of event: " << evtNb << G4endl;
115
116 G4cout
117 << " Absorber: total energy: " << std::setw(7) << G4BestUnit(totEAbs,"Energy")
118 << " total track length: " << std::setw(7) << G4BestUnit(totLAbs,"Length")
119 << G4endl
120 << " Gap: total energy: " << std::setw(7) << G4BestUnit(totEGap,"Energy")
121 << " total track length: " << std::setw(7) << G4BestUnit(totLGap,"Length")
122 << G4endl;
123
124 G4cout << "\n " << n_hit
125 << " hits are stored in ExN03CalorHitsCollection." << G4endl;
126 }
127 // extract the trajectories and draw them
128
129 if (G4VVisManager::GetConcreteInstance())
130 {
131 G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
132 G4int n_trajectories = 0;
133 if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
134
135 for (G4int i=0; i<n_trajectories; i++)
136 { G4Trajectory* trj = (G4Trajectory*)((*(evt->GetTrajectoryContainer()))[i]);
137 if (drawFlag == "all") trj->DrawTrajectory(50);
138 else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
139 trj->DrawTrajectory(50);
140 else if ((drawFlag == "neutral")&&(trj->GetCharge() == 0.))
141 trj->DrawTrajectory(50);
142 }
143 }
144*/
145}
Note: See TracBrowser for help on using the repository browser.