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