source: trunk/source/geometry/divisions/test/ExDivisions/src/ExDivRunAction.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.7 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: ExDivRunAction.cc,v 1.2 2006/06/29 18:20:01 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32#include "G4Timer.hh"
33#include "ExDivRunAction.hh"
34
35#include "G4Run.hh"
36#include "G4UImanager.hh"
37#include "G4VVisManager.hh"
38#include "G4Navigator.hh"
39#include "G4TransportationManager.hh"
40#include "G4ios.hh"
41#include "ExVDivTester.hh"
42
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45ExDivRunAction::ExDivRunAction()
46 : theNavigator(0)
47{}
48
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50
51ExDivRunAction::~ExDivRunAction()
52{}
53
54//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55
56void ExDivRunAction::BeginOfRunAction(const G4Run* aRun)
57{
58 G4int runID = aRun->GetRunID();
59 G4cout << "### Run " << runID << " start." << G4endl;
60
61 if (!runID)
62 {
63 theNavigator = G4TransportationManager::
64 GetTransportationManager()->GetNavigatorForTracking();
65 TestNavigator1();
66 TestNavigator2();
67 }
68
69 if (G4VVisManager::GetConcreteInstance())
70 {
71 G4UImanager* UI = G4UImanager::GetUIpointer();
72 UI->ApplyCommand("/vis/scene/notifyHandlers");
73 }
74}
75
76//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77
78void ExDivRunAction::EndOfRunAction(const G4Run*)
79{
80 if (G4VVisManager::GetConcreteInstance())
81 {
82 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
83 }
84}
85
86//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87
88// Test LocateGlobalPointAndSetup
89//
90void ExDivRunAction::TestNavigator1()
91{
92 G4Timer timer1;
93 timer1.Start();
94 G4cout << G4endl
95 << " @@@@@@@@@@@@@@@@@@@@@ START testNavigator1 @@@@@@@@@@@@ "
96 << G4endl;
97 G4VPhysicalVolume *located=0;
98
99 std::ofstream fout("output.points");
100 std::ifstream fin("points.lis");
101 G4double posX, posY, posZ;
102 G4int ii = 0;
103 for( ;;ii++ )
104 {
105 fin >> posX >> posY >> posZ;
106 if( fin.eof() ) break;
107 G4ThreeVector pos(posX,posY,posZ);
108 located=theNavigator->LocateGlobalPointAndSetup(pos,0,false);
109 // G4cout << ii+1 << ". LOCATED POINT " << pos << " "
110 // << located->GetName() << " " << located->GetCopyNo() << G4endl;
111 if( !ExVDivTester::bDivCylindrical ){
112 fout << ii+1 << ". " << pos;
113 } else {
114 G4double phi = pos.phi()/deg;
115 if( phi < 0. ) phi += 360.;
116 fout << ii+1 << ". (" << pos.perp() << "," << phi << "," << pos.z() << ")";
117 }
118 fout << " " << located->GetName() << " "
119 << located->GetCopyNo() << G4endl;
120 }
121 timer1.Stop();
122 G4cout << " TIME in TestNavigator1 " << timer1 << G4endl;
123}
124
125//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126
127// Test Stepping
128//
129void ExDivRunAction::TestNavigator2()
130{
131 G4Timer timer2;
132 timer2.Start();
133 G4cout << G4endl
134 << " @@@@@@@@@@@@@@@@@@@@@ START testNavigator2 @@@@@@@@@@@@ "
135 << G4endl;
136 G4VPhysicalVolume *located=0;
137 G4double Step,physStep,safety;
138 G4ThreeVector* Hat = new G4ThreeVector[3];
139 Hat[0] = G4ThreeVector(1,0,0);
140 Hat[1] = G4ThreeVector(0,1,0);
141 Hat[2] = G4ThreeVector(0,0,1);
142
143 std::ofstream fout("output.step");
144 std::ifstream fin("points.lis");
145 G4double posX, posY, posZ;
146 G4int ii = 0;
147 for( ;;ii++ )
148 {
149 if( fin.eof() ) break;
150 fin >> posX >> posY >> posZ;
151 G4ThreeVector pos(posX,posY,posZ);
152 located=theNavigator->LocateGlobalPointAndSetup(pos);
153 physStep=kInfinity;
154 if( !ExVDivTester::bDivCylindrical ){
155 fout << ii+1 << ". " << pos;
156 } else {
157 G4double phi = pos.phi()/deg;
158 if( phi < 0. ) phi += 360.;
159 fout << ii+1 << ". R(" << pos.perp() << "," << phi << "," << pos.z() << ")";
160 }
161 for( G4int jj = 0; jj < 3; jj++ )
162 {
163 Step=theNavigator->ComputeStep(G4ThreeVector(posX,posY,posZ),
164 Hat[jj],physStep,safety);
165 fout << " " << Step << " ";
166 }
167 fout << G4endl;
168 }
169 timer2.Stop();
170 G4cout << " TIME in TestNavigator2 " << timer2 << G4endl;
171}
172
Note: See TracBrowser for help on using the repository browser.