source: trunk/source/geometry/divisions/test/ExDivisions/src/ExDivDetectorConstruction.cc @ 1316

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

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 6.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: ExDivDetectorConstruction.cc,v 1.3 2006/06/29 18:19:53 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
29//
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33#include "ExDivDetectorConstruction.hh"
34
35#include "G4Material.hh"
36#include "G4Box.hh"
37#include "G4VisAttributes.hh"
38#include "G4Colour.hh"
39
40#include "G4ios.hh"
41
42#include "ExDivTesterBox.hh"
43#include "ExDivTesterTubs.hh"
44#include "ExDivTesterCons.hh"
45#include "ExDivTesterTrd.hh"
46#include "ExDivTesterPara.hh"
47#include "ExDivTesterPolycone.hh"
48#include "ExDivTesterPolyhedra.hh"
49
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
52ExDivDetectorConstruction::
53ExDivDetectorConstruction( const G4String& solidTypeStr,
54                           const G4String& PVTypeStr,
55                           const G4String& PosTypeStr,
56                           const std::vector<G4String>& extraPars )
57  : theSolidTypeStr( solidTypeStr ),
58    thePVTypeStr( PVTypeStr ),
59    thePosTypeStr( PosTypeStr ),
60    theExtraPars( extraPars )
61{
62}
63
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
66ExDivDetectorConstruction::~ExDivDetectorConstruction()
67{
68}
69
70//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
72G4VPhysicalVolume* ExDivDetectorConstruction::Construct()
73{
74
75  theDivTester = CreateSolidTester(theSolidTypeStr, thePVTypeStr,
76                                   thePosTypeStr, theExtraPars);
77
78  //-  SolidType soltype = getSolidType( theSolidTypeStr );
79  //  PVType pvtype = pvDivision;
80
81  G4VPhysicalVolume* myTopNode = theDivTester->BuildGeometry( );
82 
83  theDivTester->GenerateScanPoints();
84
85  /*  // Repeat tests but with full voxels
86  G4GeometryManager::GetInstance()->OpenGeometry();
87  G4GeometryManager::GetInstance()->CloseGeometry(true);
88  testG4Navigator1(myTopNode);
89  testG4Navigator2(myTopNode);
90  */
91 
92  // theDivTester->PrintParentSolid( G4cout );
93  // theDivTester->PrintChildrenSolids( G4cout );
94 
95  // G4GeometryManager::GetInstance()->OpenGeometry();
96
97  return myTopNode;
98}
99
100//--------------------------------------------------------------------------
101ExVDivTester*
102ExDivDetectorConstruction::CreateSolidTester( const G4String& stype,
103                                              const G4String& thePVTypeStr,
104                                              const G4String& thePosTypeStr,
105                                              std::vector<G4String>& extraPars )
106{
107  PVType pvtype = getPVType( thePVTypeStr );
108  PlaceType postype = getPosType( thePosTypeStr );
109
110  ExVDivTester* theSolidTester = 0;
111  if( stype == "box" ) {
112   theSolidTester = new ExDivTesterBox( pvtype, postype, extraPars );
113  } else if( stype == "tubs" ) {
114    theSolidTester = new ExDivTesterTubs( pvtype, postype, extraPars );
115    ExVDivTester::bDivCylindrical = 1;
116  } else if( stype == "cons" ) {
117    theSolidTester = new ExDivTesterCons( pvtype, postype, extraPars );
118    ExVDivTester::bDivCylindrical = 1;
119  } else if( stype == "trd" ) {
120    theSolidTester = new ExDivTesterTrd( pvtype, postype, extraPars );
121  } else if( stype == "para" ) {
122    theSolidTester = new ExDivTesterPara( pvtype, postype, extraPars );
123  } else if( stype == "pcone" ) {
124    theSolidTester = new ExDivTesterPolycone( pvtype, postype, extraPars );
125    ExVDivTester::bDivCylindrical = 1;
126  } else if( stype == "phedra" ) {
127    theSolidTester = new ExDivTesterPolyhedra( pvtype, postype, extraPars );
128  } else {
129    G4cout << "ERROR - ExDivDetectorConstruction::CreateSolidTester()"
130           << G4endl
131           << "        Only the following solid types are allowed:"
132           << G4endl
133           << "        'tubs', 'cons', 'trd', 'para', 'pcone', 'phedra'."
134           << G4endl
135           << "        Wrong identifier: " << stype << G4endl;
136    G4Exception("ExDivDetectorConstruction::CreateSolidTester()",
137                "InvalidSetup", FatalException, "Unknown solid type.");
138  }
139  return theSolidTester;
140}
141
142
143//--------------------------------------------------------------------------
144PVType ExDivDetectorConstruction::getPVType( const G4String& pvt )
145{
146  G4cout << pvt << G4endl;
147  PVType vtype = pvPlacement;
148
149  if( pvt == "division")
150  {
151    vtype = pvDivision; 
152  }
153  else if( pvt == "replica")
154  {
155    vtype = pvReplica; 
156  }
157  else
158  {
159    G4Exception("ExDivDetectorConstruction::getPVType()",
160                "InvalidArgument", FatalException,
161                "PV type can only be 'division' or 'replica' ");
162  }
163  return vtype;
164}
165
166
167//--------------------------------------------------------------------------
168PlaceType ExDivDetectorConstruction::getPosType( const G4String& pos )
169{
170  G4cout << pos << G4endl;
171  PlaceType ptype = pvNormal;
172
173  if( pos == "normal")
174  {
175    ptype = pvNormal; 
176  }
177  else if( pos == "reflected")
178  {
179    ptype = pvReflected; 
180  }
181  else
182  {
183    G4Exception("ExDivDetectorConstruction::getPosType()",
184                "InvalidArgument", FatalException,
185                "The positioning type can only be 'normal' or 'reflected' ");
186  }
187  return ptype;
188}
Note: See TracBrowser for help on using the repository browser.