Geant4  10.01
G4tgrSolid.cc
Go to the documentation of this file.
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: G4tgrSolid.cc 66363 2012-12-18 09:12:54Z gcosmo $
28 //
29 //
30 // class G4tgrSolid
31 
32 // History:
33 // - Created. P.Arce, CIEMAT (November 2007)
34 // -------------------------------------------------------------------------
35 
36 #include <map>
37 #include <set>
38 
39 #include "G4tgrSolid.hh"
40 
41 #include "G4SystemOfUnits.hh"
42 #include "G4tgrUtils.hh"
43 #include "G4tgrMessenger.hh"
44 #include "G4tgrVolumeMgr.hh"
45 
46 // -------------------------------------------------------------------------
48 {
49 }
50 
51 
52 // -------------------------------------------------------------------------
54 {
55 }
56 
57 
58 // -------------------------------------------------------------------------
59 G4tgrSolid::G4tgrSolid( const std::vector<G4String>& wl)
60 {
61  //---------- set name
62  theName = G4tgrUtils::GetString( wl[1] );
63 
64  //---------- set solid type
65  theType = G4tgrUtils::GetString( wl[2] );
66 
67  //---------- create only vector<double> of theSolidParams
68  FillSolidParams( wl );
69 
71 
72 
73 #ifdef G4VERBOSE
75  {
76  G4cout << " Created " << *this << G4endl;
77  }
78 #endif
79 
80 }
81 
82 
83 // -------------------------------------------------------------------------
84 const std::vector< std::vector<G4double>* > G4tgrSolid::GetSolidParams() const
85 {
86  return theSolidParams;
87 }
88 
89 
90 // -------------------------------------------------------------------------
92 {
93  return theName; // Dummy ...
94 }
95 
96 
97 // -------------------------------------------------------------------------
99 {
100  return G4ThreeVector(0,0,0); // Dummy...
101 }
102 
103 
104 // -------------------------------------------------------------------------
105 void G4tgrSolid::FillSolidParams( const std::vector<G4String>& wl )
106 {
107  //---- Setting which are angle parameters (for dimensions...)
108  std::map< G4String, std::set<G4int> > angleParams;
109  std::set<G4int> apar;
110  apar.clear(); apar.insert(3); apar.insert(4);
111  angleParams["TUBS"] = apar;
112  apar.clear(); apar.insert(5); apar.insert(6);
113  angleParams["CONS"] = apar;
114  apar.clear(); apar.insert(3); apar.insert(4); apar.insert(5);
115  angleParams["PARA"] = apar;
116  apar.clear(); apar.insert(1); apar.insert(2); apar.insert(6); apar.insert(10);
117  angleParams["TRAP"] = apar;
118  apar.clear(); apar.insert(2); apar.insert(3); apar.insert(4); apar.insert(5);
119  angleParams["SPHERE"] = apar;
120  apar.clear(); apar.insert(3); apar.insert(4);
121  angleParams["TORUS"] = apar;
122  apar.clear(); apar.insert(0); apar.insert(1);
123  angleParams["POLYCONE"] = apar;
124  apar.clear(); apar.insert(0); apar.insert(1);
125  angleParams["POLYHEDRA"] = apar;
126  apar.clear(); apar.insert(2); apar.insert(3);
127  angleParams["HYPE"] = apar;
128  apar.clear(); apar.insert(0);
129  angleParams["TWISTED_BOX"] = apar;
130  apar.clear(); apar.insert(0); apar.insert(2); apar.insert(3); apar.insert(10);
131  angleParams["TWISTED_TRAP"] = apar;
132  apar.clear(); apar.insert(5);
133  angleParams["TWISTED_TRD"] = apar;
134  apar.clear(); apar.insert(0); apar.insert(4);
135  angleParams["TWISTED_TUBS"] = apar;
136 
137  std::vector<G4double>* vd = new std::vector<G4double>;
138  theSolidParams.push_back( vd );
139  size_t noParRead = wl.size()-3;
140 
141  G4String solidType = wl[2];
142  //--- Default unit (mm) if length, deg if angle
143  for(size_t ii = 0; ii < noParRead; ii++)
144  {
145  G4bool isAngle = 0;
146  std::map< G4String, std::set<G4int> >::iterator ite
147  = angleParams.find(solidType);
148  if( ite != angleParams.end() )
149  {
150  std::set<G4int> apar2 = (*ite).second;
151  if( apar2.find(ii) != apar2.end() )
152  {
153  isAngle = 1;
154  vd->push_back( G4tgrUtils::GetDouble( wl[3+ii], deg ));
155 #ifdef G4VERBOSE
157  {
158  G4cout << " G4tgrSolid::FillSolidParams() - Angle param found "
159  << solidType << " " << ii << G4endl;
160  }
161 #endif
162  }
163  }
164  if(!isAngle)
165  {
166  vd->push_back( G4tgrUtils::GetDouble( wl[3+ii] ) );
167  }
168  }
169 }
170 
171 
172 // -------------------------------------------------------------------------
173 std::ostream& operator<<(std::ostream& os, const G4tgrSolid& sol)
174 {
175  os << "G4tgrSolid= " << sol.theName
176  << " of type " << sol.theType << " PARAMS: ";
177  if( sol.theSolidParams.size() != 0 )
178  {
179  std::vector<G4double> solpar = *(sol.theSolidParams[0]);
180  for( size_t ii = 0; ii < solpar.size(); ii++)
181  {
182  os << solpar[ii] << " " ;
183  }
184  }
185  os << G4endl;
186 
187  return os;
188 }
std::vector< std::vector< G4double > * > theSolidParams
Definition: G4tgrSolid.hh:77
CLHEP::Hep3Vector G4ThreeVector
G4String theType
Definition: G4tgrSolid.hh:75
virtual const G4String & GetRelativeRotMatName() const
Definition: G4tgrSolid.cc:91
G4GLOB_DLL std::ostream G4cout
static G4int GetVerboseLevel()
static const double deg
Definition: G4SIunits.hh:133
bool G4bool
Definition: G4Types.hh:79
static G4tgrVolumeMgr * GetInstance()
std::ostream & operator<<(std::ostream &os, const G4tgrSolid &sol)
Definition: G4tgrSolid.cc:173
void RegisterMe(G4tgrSolid *vol)
const std::vector< std::vector< G4double > * > GetSolidParams() const
Definition: G4tgrSolid.cc:84
virtual G4ThreeVector GetRelativePlace() const
Definition: G4tgrSolid.cc:98
static G4double GetDouble(const G4String &str, G4double unitval=1.)
Definition: G4tgrUtils.cc:205
static G4String GetString(const G4String &str)
Definition: G4tgrUtils.cc:180
G4String theName
Definition: G4tgrSolid.hh:73
void FillSolidParams(const std::vector< G4String > &wl)
Definition: G4tgrSolid.cc:105
#define G4endl
Definition: G4ios.hh:61
virtual ~G4tgrSolid()
Definition: G4tgrSolid.cc:53