Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4tgrSolid implementation << 27 // 26 // 28 // Author: P.Arce, CIEMAT (November 2007) << 27 // $Id: G4tgrSolid.cc 66363 2012-12-18 09:12:54Z gcosmo $ 29 // ------------------------------------------- << 28 // >> 29 // >> 30 // class G4tgrSolid >> 31 >> 32 // History: >> 33 // - Created. P.Arce, CIEMAT (November 2007) >> 34 // ------------------------------------------------------------------------- 30 35 31 #include <map> 36 #include <map> 32 #include <set> 37 #include <set> 33 38 34 #include "G4tgrSolid.hh" 39 #include "G4tgrSolid.hh" 35 40 36 #include "G4SystemOfUnits.hh" 41 #include "G4SystemOfUnits.hh" 37 #include "G4tgrUtils.hh" 42 #include "G4tgrUtils.hh" 38 #include "G4tgrMessenger.hh" 43 #include "G4tgrMessenger.hh" 39 #include "G4tgrVolumeMgr.hh" 44 #include "G4tgrVolumeMgr.hh" 40 45 41 // ------------------------------------------- << 46 // ------------------------------------------------------------------------- 42 G4tgrSolid::G4tgrSolid() 47 G4tgrSolid::G4tgrSolid() 43 { 48 { 44 } 49 } 45 50 46 // ------------------------------------------- << 51 >> 52 // ------------------------------------------------------------------------- 47 G4tgrSolid::~G4tgrSolid() 53 G4tgrSolid::~G4tgrSolid() 48 { 54 { 49 } 55 } 50 56 51 // ------------------------------------------- << 57 52 G4tgrSolid::G4tgrSolid(const std::vector<G4Str << 58 // ------------------------------------------------------------------------- >> 59 G4tgrSolid::G4tgrSolid( const std::vector<G4String>& wl) 53 { 60 { 54 //---------- set name << 61 //---------- set name 55 theName = G4tgrUtils::GetString(wl[1]); << 62 theName = G4tgrUtils::GetString( wl[1] ); 56 63 57 //---------- set solid type 64 //---------- set solid type 58 theType = G4tgrUtils::GetString(wl[2]); << 65 theType = G4tgrUtils::GetString( wl[2] ); 59 66 60 //---------- create only vector<double> of t 67 //---------- create only vector<double> of theSolidParams 61 FillSolidParams(wl); << 68 FillSolidParams( wl ); >> 69 >> 70 G4tgrVolumeMgr::GetInstance()->RegisterMe( this ); 62 71 63 G4tgrVolumeMgr::GetInstance()->RegisterMe(th << 64 72 65 #ifdef G4VERBOSE 73 #ifdef G4VERBOSE 66 if(G4tgrMessenger::GetVerboseLevel() >= 1) << 74 if( G4tgrMessenger::GetVerboseLevel() >= 1 ) 67 { 75 { 68 G4cout << " Created " << *this << G4endl; << 76 G4cout << " Created " << *this << G4endl; 69 } 77 } 70 #endif 78 #endif >> 79 71 } 80 } 72 81 73 // ------------------------------------------- << 82 74 const std::vector<std::vector<G4double>*> G4tg << 83 // ------------------------------------------------------------------------- >> 84 const std::vector< std::vector<G4double>* > G4tgrSolid::GetSolidParams() const 75 { 85 { 76 return theSolidParams; 86 return theSolidParams; 77 } 87 } 78 88 79 // ------------------------------------------- << 89 >> 90 // ------------------------------------------------------------------------- 80 const G4String& G4tgrSolid::GetRelativeRotMatN 91 const G4String& G4tgrSolid::GetRelativeRotMatName() const 81 { 92 { 82 return theName; // Dummy ... 93 return theName; // Dummy ... 83 } 94 } 84 95 85 // ------------------------------------------- << 96 >> 97 // ------------------------------------------------------------------------- 86 G4ThreeVector G4tgrSolid::GetRelativePlace() c 98 G4ThreeVector G4tgrSolid::GetRelativePlace() const 87 { 99 { 88 return G4ThreeVector(0, 0, 0); // Dummy... << 100 return G4ThreeVector(0,0,0); // Dummy... 89 } 101 } 90 102 91 // ------------------------------------------- << 103 92 void G4tgrSolid::FillSolidParams(const std::ve << 104 // ------------------------------------------------------------------------- >> 105 void G4tgrSolid::FillSolidParams( const std::vector<G4String>& wl ) 93 { 106 { 94 //---- Setting which are angle parameters (f 107 //---- Setting which are angle parameters (for dimensions...) 95 std::map<G4String, std::set<G4int>> anglePar << 108 std::map< G4String, std::set<G4int> > angleParams; 96 std::set<G4int> apar; 109 std::set<G4int> apar; 97 apar.clear(); << 110 apar.clear(); apar.insert(3); apar.insert(4); 98 apar.insert(3); << 99 apar.insert(4); << 100 angleParams["TUBS"] = apar; 111 angleParams["TUBS"] = apar; 101 apar.clear(); << 112 apar.clear(); apar.insert(5); apar.insert(6); 102 apar.insert(5); << 103 apar.insert(6); << 104 angleParams["CONS"] = apar; 113 angleParams["CONS"] = apar; 105 apar.clear(); << 114 apar.clear(); apar.insert(3); apar.insert(4); apar.insert(5); 106 apar.insert(3); << 107 apar.insert(4); << 108 apar.insert(5); << 109 angleParams["PARA"] = apar; 115 angleParams["PARA"] = apar; 110 apar.clear(); << 116 apar.clear(); apar.insert(1); apar.insert(2); apar.insert(6); apar.insert(10); 111 apar.insert(1); << 112 apar.insert(2); << 113 apar.insert(6); << 114 apar.insert(10); << 115 angleParams["TRAP"] = apar; 117 angleParams["TRAP"] = apar; 116 apar.clear(); << 118 apar.clear(); apar.insert(2); apar.insert(3); apar.insert(4); apar.insert(5); 117 apar.insert(2); << 118 apar.insert(3); << 119 apar.insert(4); << 120 apar.insert(5); << 121 angleParams["SPHERE"] = apar; 119 angleParams["SPHERE"] = apar; 122 apar.clear(); << 120 apar.clear(); apar.insert(3); apar.insert(4); 123 apar.insert(3); << 124 apar.insert(4); << 125 angleParams["TORUS"] = apar; 121 angleParams["TORUS"] = apar; 126 apar.clear(); << 122 apar.clear(); apar.insert(0); apar.insert(1); 127 apar.insert(0); << 128 apar.insert(1); << 129 angleParams["POLYCONE"] = apar; 123 angleParams["POLYCONE"] = apar; 130 apar.clear(); << 124 apar.clear(); apar.insert(0); apar.insert(1); 131 apar.insert(0); << 132 apar.insert(1); << 133 angleParams["POLYHEDRA"] = apar; 125 angleParams["POLYHEDRA"] = apar; 134 apar.clear(); << 126 apar.clear(); apar.insert(2); apar.insert(3); 135 apar.insert(2); << 136 apar.insert(3); << 137 angleParams["HYPE"] = apar; 127 angleParams["HYPE"] = apar; 138 apar.clear(); << 128 apar.clear(); apar.insert(0); 139 apar.insert(0); << 140 angleParams["TWISTED_BOX"] = apar; 129 angleParams["TWISTED_BOX"] = apar; 141 apar.clear(); << 130 apar.clear(); apar.insert(0); apar.insert(2); apar.insert(3); apar.insert(10); 142 apar.insert(0); << 143 apar.insert(2); << 144 apar.insert(3); << 145 apar.insert(10); << 146 angleParams["TWISTED_TRAP"] = apar; 131 angleParams["TWISTED_TRAP"] = apar; 147 apar.clear(); << 132 apar.clear(); apar.insert(5); 148 apar.insert(5); << 149 angleParams["TWISTED_TRD"] = apar; 133 angleParams["TWISTED_TRD"] = apar; 150 apar.clear(); << 134 apar.clear(); apar.insert(0); apar.insert(4); 151 apar.insert(0); << 135 angleParams["TWISTED_TUBS"] = apar; 152 apar.insert(4); << 153 angleParams["TWISTED_TUBS"] = std::move(apar << 154 136 155 std::vector<G4double>* vd = new std::vector< 137 std::vector<G4double>* vd = new std::vector<G4double>; 156 theSolidParams.push_back(vd); << 138 theSolidParams.push_back( vd ); 157 std::size_t noParRead = wl.size() - 3; << 139 size_t noParRead = wl.size()-3; 158 140 159 G4String solidType = wl[2]; 141 G4String solidType = wl[2]; 160 //--- Default unit (mm) if length, deg if an 142 //--- Default unit (mm) if length, deg if angle 161 for(G4int ii = 0; ii < (G4int)noParRead; ++i << 143 for(size_t ii = 0; ii < noParRead; ii++) 162 { 144 { 163 G4bool isAngle = 0; 145 G4bool isAngle = 0; 164 std::map<G4String, std::set<G4int>>::const << 146 std::map< G4String, std::set<G4int> >::iterator ite 165 angleParams.find(solidType); << 147 = angleParams.find(solidType); 166 if(ite != angleParams.cend()) << 148 if( ite != angleParams.end() ) 167 { 149 { 168 std::set<G4int> apar2 = (*ite).second; 150 std::set<G4int> apar2 = (*ite).second; 169 if(apar2.find(ii) != apar2.cend()) << 151 if( apar2.find(ii) != apar2.end() ) 170 { 152 { 171 isAngle = 1; 153 isAngle = 1; 172 vd->push_back(G4tgrUtils::GetDouble(wl << 154 vd->push_back( G4tgrUtils::GetDouble( wl[3+ii], deg )); 173 #ifdef G4VERBOSE 155 #ifdef G4VERBOSE 174 if(G4tgrMessenger::GetVerboseLevel() > << 156 if( G4tgrMessenger::GetVerboseLevel() >= 3 ) 175 { 157 { 176 G4cout << " G4tgrSolid::FillSolidPar 158 G4cout << " G4tgrSolid::FillSolidParams() - Angle param found " 177 << solidType << " " << ii << 159 << solidType << " " << ii << G4endl; 178 } 160 } 179 #endif 161 #endif 180 } 162 } 181 } << 163 } 182 if(!isAngle) 164 if(!isAngle) 183 { 165 { 184 vd->push_back(G4tgrUtils::GetDouble(wl[3 << 166 vd->push_back( G4tgrUtils::GetDouble( wl[3+ii] ) ); 185 } 167 } 186 } 168 } 187 } 169 } 188 170 189 // ------------------------------------------- << 171 >> 172 // ------------------------------------------------------------------------- 190 std::ostream& operator<<(std::ostream& os, con 173 std::ostream& operator<<(std::ostream& os, const G4tgrSolid& sol) 191 { 174 { 192 os << "G4tgrSolid= " << sol.theName << " of << 175 os << "G4tgrSolid= " << sol.theName 193 << " PARAMS: "; << 176 << " of type " << sol.theType << " PARAMS: "; 194 if(sol.theSolidParams.size() != 0) << 177 if( sol.theSolidParams.size() != 0 ) 195 { 178 { 196 std::vector<G4double> solpar = *(sol.theSo << 179 std::vector<G4double> solpar = *(sol.theSolidParams[0]); 197 for(std::size_t ii = 0; ii < solpar.size() << 180 for( size_t ii = 0; ii < solpar.size(); ii++) 198 { 181 { 199 os << solpar[ii] << " "; << 182 os << solpar[ii] << " " ; 200 } 183 } 201 } 184 } 202 os << G4endl; 185 os << G4endl; 203 186 204 return os; 187 return os; 205 } 188 } 206 189