source: trunk/examples/novice/N07/src/ExN07SteppingVerbose.cc@ 1191

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

update

File size: 4.8 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: ExN07SteppingVerbose.cc,v 1.1 2006/11/04 19:23:07 asaim Exp $
28// GEANT4 tag $Name: $
29//
30
31#include "ExN07SteppingVerbose.hh"
32
33#include "G4SteppingManager.hh"
34#include "G4UnitsTable.hh"
35#include "G4RegionStore.hh"
36#include "G4Region.hh"
37#include "G4Electron.hh"
38#include "G4Positron.hh"
39#include "G4RunManagerKernel.hh"
40#include "G4TrackingManager.hh"
41
42ExN07SteppingVerbose::ExN07SteppingVerbose()
43: nTimers(0),regIdx(-1),ep(false)
44{}
45
46ExN07SteppingVerbose::~ExN07SteppingVerbose()
47{
48 for(G4int j=0;j<nTimers;j++)
49 { delete fTimers[j]; }
50 fTimers.clear();
51}
52
53void ExN07SteppingVerbose::InitializeTimers()
54{
55 G4RegionStore* regionStore = G4RegionStore::GetInstance();
56 nRegions = regionStore->size();
57 nTimers = 2 * nRegions;
58 G4int nEnt = fTimers.size();
59 if(nEnt<nTimers)
60 {
61 for(G4int i=nEnt;i<nTimers;i++)
62 { fTimers.push_back(new G4SliceTimer); }
63 }
64 for(G4int j=0;j<nTimers;j++)
65 { fTimers[j]->Clear(); }
66 regIdx = -1;
67 ep = false;
68
69 // Set verbosity for timing
70 G4RunManagerKernel::GetRunManagerKernel()->GetTrackingManager()->SetVerboseLevel(0);
71 fManager->SetVerboseLevel(1);
72}
73
74void ExN07SteppingVerbose::Report()
75{
76 for(G4int i=0;i<nRegions;i++)
77 {
78 G4cout << G4endl;
79 G4cout << "Region <" << (*G4RegionStore::GetInstance())[i]->GetName() << ">" << G4endl;
80 G4cout << " All particles : User=" << fTimers[i]->GetUserElapsed()
81 << " Real=" << fTimers[i]->GetRealElapsed()
82 << " Sys=" << fTimers[i]->GetSystemElapsed() << G4endl;
83 G4cout << " e+ / e- : User=" << fTimers[nRegions+i]->GetUserElapsed()
84 << " Real=" << fTimers[nRegions+i]->GetRealElapsed()
85 << " Sys=" << fTimers[nRegions+i]->GetSystemElapsed() << G4endl;
86 }
87 G4cout << G4endl;
88}
89
90void ExN07SteppingVerbose::NewStep()
91{
92 CopyState();
93 G4Region* reg = fTrack->GetStep()->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion();
94 regIdx = FindRegion(reg);
95 fTimers[regIdx]->Start();
96 G4ParticleDefinition* pd = fTrack->GetDefinition();
97 if(pd==G4Electron::ElectronDefinition() || pd==G4Positron::PositronDefinition()) ep = true;
98 if(ep) fTimers[nRegions+regIdx]->Start();
99}
100
101void ExN07SteppingVerbose::StepInfo()
102{
103 fTimers[regIdx]->Stop();
104 if(ep)
105 {
106 fTimers[nRegions+regIdx]->Stop();
107 ep = false;
108 }
109 regIdx = -1;
110}
111
112G4int ExN07SteppingVerbose::FindRegion(G4Region* rgn)
113{
114 G4RegionStore* regionStore = G4RegionStore::GetInstance();
115 G4int sz = regionStore->size();
116 for(G4int i=0;i<sz;i++)
117 { if(rgn==(*regionStore)[i]) return i; }
118 return -1;
119}
120
121
122// Empty methods not to be used.
123void ExN07SteppingVerbose::TrackBanner()
124{;}
125void ExN07SteppingVerbose::AtRestDoItInvoked()
126{;}
127void ExN07SteppingVerbose::AlongStepDoItAllDone()
128{;}
129void ExN07SteppingVerbose::PostStepDoItAllDone()
130{;}
131void ExN07SteppingVerbose::AlongStepDoItOneByOne()
132{;}
133void ExN07SteppingVerbose::PostStepDoItOneByOne()
134{;}
135void ExN07SteppingVerbose::TrackingStarted()
136{;}
137void ExN07SteppingVerbose::DPSLStarted()
138{;}
139void ExN07SteppingVerbose::DPSLUserLimit()
140{;}
141void ExN07SteppingVerbose::DPSLPostStep()
142{;}
143void ExN07SteppingVerbose::DPSLAlongStep()
144{;}
145void ExN07SteppingVerbose::VerboseTrack()
146{;}
147void ExN07SteppingVerbose::VerboseParticleChange()
148{;}
149
150
Note: See TracBrowser for help on using the repository browser.