Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // << 26 // 7 // >> 8 // $Id: G3VolTableEntry.cc,v 1.2 1999/12/05 17:50:10 gcosmo Exp $ >> 9 // GEANT4 tag $Name: geant4-01-00 $ 27 // 10 // 28 // modified by I.Hrivnacova, 13.10.99 11 // modified by I.Hrivnacova, 13.10.99 29 12 30 #include "globals.hh" << 31 #include "G3VolTableEntry.hh" 13 #include "G3VolTableEntry.hh" 32 #include "G3VolTable.hh" 14 #include "G3VolTable.hh" 33 #include "G3RotTable.hh" << 34 #include "G4LogicalVolume.hh" 15 #include "G4LogicalVolume.hh" 35 #include "G4SubtractionSolid.hh" << 36 #include "G3Pos.hh" 16 #include "G3Pos.hh" 37 #include "G3toG4.hh" 17 #include "G3toG4.hh" >> 18 #include "globals.hh" 38 19 39 G3VolTableEntry::G3VolTableEntry(G4String& vna 20 G3VolTableEntry::G3VolTableEntry(G4String& vname, G4String& shape, 40 G4double* rpar, G4int npar, G4i << 21 G4double* rpar, G4int npar, G4int nmed, 41 G4VSolid* solid, G4bool hasNegP << 22 G4VSolid* solid, G4bool hasNegPars) 42 : fVname(vname), fShape(shape), fRpar(0), fN 23 : fVname(vname), fShape(shape), fRpar(0), fNpar(npar), fNmed(nmed), 43 fSolid(solid), fLV(0), fHasNegPars(hasNegP << 24 fSolid(solid), fLV(0), fHasNegPars(hasNegPars), fDivision(0) 44 fDivision(0) << 45 { 25 { 46 if (npar>0 && rpar!=0) { 26 if (npar>0 && rpar!=0) { 47 fRpar = new G4double[npar]; 27 fRpar = new G4double[npar]; 48 for (G4int i=0; i<npar; i++) fRpar[i] = rp 28 for (G4int i=0; i<npar; i++) fRpar[i] = rpar[i]; 49 } 29 } 50 fClones.push_back(this); << 30 fClones.insert(this); 51 } 31 } 52 32 53 G3VolTableEntry::~G3VolTableEntry(){ 33 G3VolTableEntry::~G3VolTableEntry(){ 54 if (fRpar!=0) delete [] fRpar; 34 if (fRpar!=0) delete [] fRpar; 55 delete fDivision; 35 delete fDivision; 56 } 36 } 57 37 58 G4bool << 38 inline G4bool 59 G3VolTableEntry::operator == ( const G3VolTabl 39 G3VolTableEntry::operator == ( const G3VolTableEntry& lv) const { 60 return (this==&lv) ? true : false; 40 return (this==&lv) ? true : false; 61 } << 41 }; 62 42 63 void 43 void 64 G3VolTableEntry::AddG3Pos(G3Pos* aG3Pos){ 44 G3VolTableEntry::AddG3Pos(G3Pos* aG3Pos){ 65 << 66 // insert this position to the vector << 67 G3Vol.CountG3Pos(); 45 G3Vol.CountG3Pos(); 68 fG3Pos.push_back(aG3Pos); << 46 fG3Pos.insert(aG3Pos); 69 << 70 // pass MANY info << 71 G4String vonly = aG3Pos->GetOnly(); << 72 if (vonly == "MANY") SetHasMANY(true); << 73 } 47 } 74 48 75 void 49 void 76 G3VolTableEntry::AddDaughter(G3VolTableEntry* 50 G3VolTableEntry::AddDaughter(G3VolTableEntry* aDaughter){ 77 if (FindDaughter(aDaughter->GetName()) == 0) 51 if (FindDaughter(aDaughter->GetName()) == 0) { 78 fDaughters.push_back(aDaughter); << 52 fDaughters.insert(aDaughter); 79 } 53 } 80 } 54 } 81 55 82 void 56 void 83 G3VolTableEntry::AddMother(G3VolTableEntry* it 57 G3VolTableEntry::AddMother(G3VolTableEntry* itsMother){ 84 if (FindMother(itsMother->GetName()) == 0) { 58 if (FindMother(itsMother->GetName()) == 0) { 85 fMothers.push_back(itsMother); << 59 fMothers.insert(itsMother); 86 } 60 } 87 } 61 } 88 62 89 void 63 void 90 G3VolTableEntry::AddClone(G3VolTableEntry* its 64 G3VolTableEntry::AddClone(G3VolTableEntry* itsClone){ 91 if (FindClone(itsClone->GetName()) == 0) { 65 if (FindClone(itsClone->GetName()) == 0) { 92 fClones.push_back(itsClone); << 66 fClones.insert(itsClone); 93 } 67 } 94 } 68 } 95 69 96 void 70 void 97 G3VolTableEntry::AddOverlap(G3VolTableEntry* o << 98 fOverlaps.push_back(overlap); << 99 } << 100 << 101 void << 102 G3VolTableEntry::ReplaceDaughter(G3VolTableEnt 71 G3VolTableEntry::ReplaceDaughter(G3VolTableEntry* vteOld, 103 G3VolTableEnt 72 G3VolTableEntry* vteNew) 104 { 73 { 105 G4int index = -1; 74 G4int index = -1; 106 for (G4int i=0; i<GetNoDaughters(); i++){ 75 for (G4int i=0; i<GetNoDaughters(); i++){ 107 if (fDaughters[i]->GetName() == vteOld->Ge 76 if (fDaughters[i]->GetName() == vteOld->GetName()) index = i; 108 } 77 } 109 if (index<0) { 78 if (index<0) { 110 G4String err_message = "Old daughter " + v << 79 G4Exception( 111 + " does not exist."; << 80 "G3VolTableEntry::ReplaceDaughter: old daughter " + 112 G4Exception("G3VolTableEntry::ReplaceDaugh << 81 vteOld->GetName() + " does not exist."); 113 FatalException, err_message); << 114 return; << 115 } 82 } 116 fDaughters[index] = vteNew; 83 fDaughters[index] = vteNew; 117 } 84 } 118 85 119 void 86 void 120 G3VolTableEntry::ReplaceMother(G3VolTableEntry 87 G3VolTableEntry::ReplaceMother(G3VolTableEntry* vteOld, 121 G3VolTableEntry 88 G3VolTableEntry* vteNew) 122 { 89 { 123 G4int index = -1; 90 G4int index = -1; 124 for (G4int i=0; i<GetNoMothers(); i++){ 91 for (G4int i=0; i<GetNoMothers(); i++){ 125 if (fMothers[i]->GetName() == vteOld->GetN 92 if (fMothers[i]->GetName() == vteOld->GetName()) index = i; 126 } 93 } 127 if (index<0) { 94 if (index<0) { 128 G4String err_message = "Old mother " + vte << 95 G4Exception( 129 + " does not exist."; << 96 "G3VolTableEntry::ReplaceMother: old mother " + 130 G4Exception("G3VolTableEntry::ReplaceMothe << 97 vteOld->GetName() + " does not exist."); 131 FatalException, err_message); << 132 return; << 133 } 98 } 134 fMothers[index] = vteNew; 99 fMothers[index] = vteNew; 135 } 100 } 136 101 137 G3VolTableEntry* 102 G3VolTableEntry* 138 G3VolTableEntry::FindDaughter(const G4String& 103 G3VolTableEntry::FindDaughter(const G4String& Dname){ 139 for (G4int idau=0; idau<GetNoDaughters(); id << 104 for (int idau=0; idau<GetNoDaughters(); idau++){ 140 if (GetDaughter(idau)->GetName() == Dname) 105 if (GetDaughter(idau)->GetName() == Dname) return GetDaughter(idau); 141 } 106 } 142 return 0; 107 return 0; 143 } << 108 }; 144 109 145 G3VolTableEntry* 110 G3VolTableEntry* 146 G3VolTableEntry::FindMother(const G4String& Mn 111 G3VolTableEntry::FindMother(const G4String& Mname){ 147 for (G4int i=0; i<GetNoMothers(); i++){ 112 for (G4int i=0; i<GetNoMothers(); i++){ 148 G3VolTableEntry* mvte = GetMother(i); 113 G3VolTableEntry* mvte = GetMother(i); 149 if (mvte->GetName() == Mname) return mvte; 114 if (mvte->GetName() == Mname) return mvte; 150 } 115 } 151 return 0; 116 return 0; 152 } << 117 }; 153 118 154 G3VolTableEntry* 119 G3VolTableEntry* 155 G3VolTableEntry::FindClone(const G4String& Cna 120 G3VolTableEntry::FindClone(const G4String& Cname){ 156 for (G4int i=0; i<GetNoClones(); i++){ 121 for (G4int i=0; i<GetNoClones(); i++){ 157 G3VolTableEntry* cvte = GetClone(i); 122 G3VolTableEntry* cvte = GetClone(i); 158 if (cvte->GetName() == Cname) return cvte; 123 if (cvte->GetName() == Cname) return cvte; 159 } 124 } 160 return 0; 125 return 0; 161 } << 126 }; 162 127 163 void G3VolTableEntry::PrintSolidInfo() { 128 void G3VolTableEntry::PrintSolidInfo() { 164 // only parameters related to solid definition 129 // only parameters related to solid definition 165 // are printed 130 // are printed 166 G4cout << "VTE: " << fVname << " " << this < << 131 G4cout << "VTE: " << fVname << " " << this << endl; 167 G4cout << "Solid: " << fSolid << G4endl; << 132 G4cout << "Solid: " << fSolid << endl; 168 G4cout << "Parameters (npar = " << fNpar << 133 G4cout << "Parameters (npar = " << fNpar << ") fRpar: "; 169 for (G4int i=0; i<fNpar; i++) G4cout << fRpa 134 for (G4int i=0; i<fNpar; i++) G4cout << fRpar[i] << " "; 170 G4cout << G4endl; << 135 G4cout << endl; 171 G4cout << "HasNegPars: " << fHasNegPars << G << 136 G4cout << "HasNegPars: " << fHasNegPars << endl; 172 G4cout << "HasMANY: " << fHasMANY << G4endl; << 137 G4cout << "================================= " << endl; 173 G4cout << "================================= << 174 } 138 } 175 139 176 void 140 void 177 G3VolTableEntry::SetName(G4String name){ 141 G3VolTableEntry::SetName(G4String name){ 178 fVname = name; 142 fVname = name; 179 } << 143 }; 180 144 181 void 145 void 182 G3VolTableEntry::SetLV(G4LogicalVolume* lv){ 146 G3VolTableEntry::SetLV(G4LogicalVolume* lv){ 183 fLV = lv; 147 fLV = lv; 184 } << 148 }; 185 149 186 void 150 void 187 G3VolTableEntry::SetSolid(G4VSolid* solid){ 151 G3VolTableEntry::SetSolid(G4VSolid* solid){ 188 fSolid = solid; 152 fSolid = solid; 189 } 153 } 190 154 191 void G3VolTableEntry::SetNmed(G4int nmed) { 155 void G3VolTableEntry::SetNmed(G4int nmed) { 192 fNmed = nmed; 156 fNmed = nmed; 193 } 157 } 194 158 195 void G3VolTableEntry::SetNRpar(G4int npar, G4d << 159 void G3VolTableEntry::SetNRpar(G4int npar, G4double* Rpar) { 196 if (npar != fNpar) { 160 if (npar != fNpar) { 197 fNpar = npar; 161 fNpar = npar; 198 delete [] fRpar; 162 delete [] fRpar; 199 fRpar = new G4double[fNpar]; 163 fRpar = new G4double[fNpar]; 200 } 164 } 201 for (G4int i=0; i<fNpar; i++) fRpar[i] = rpa << 165 for (G4int i=0; i<fNpar; i++) fRpar[i] = Rpar[i]; 202 } 166 } 203 167 204 void G3VolTableEntry::SetHasNegPars(G4bool has 168 void G3VolTableEntry::SetHasNegPars(G4bool hasNegPars) { 205 fHasNegPars = hasNegPars; 169 fHasNegPars = hasNegPars; 206 } 170 } 207 171 208 void G3VolTableEntry::SetHasMANY(G4bool hasMAN << 209 fHasMANY = hasMANY; << 210 } << 211 << 212 void G3VolTableEntry::ClearG3PosCopy(G4int cop << 213 if (fG3Pos.size()>0 && copy>=0 && copy<G4int << 214 std::vector<G3Pos*>::iterator it=fG3Pos.b << 215 for(G4int j=0;j<copy;j++) it++; << 216 if(it!=fG3Pos.end()) { << 217 fG3Pos.erase(it); << 218 } << 219 } << 220 } << 221 << 222 void G3VolTableEntry::ClearDivision() { << 223 delete fDivision; << 224 fDivision = 0; << 225 } << 226 << 227 G4String 172 G4String 228 G3VolTableEntry::GetName() { 173 G3VolTableEntry::GetName() { 229 return fVname; 174 return fVname; 230 } << 175 }; 231 176 232 G4String 177 G4String 233 G3VolTableEntry::GetShape() { 178 G3VolTableEntry::GetShape() { 234 return fShape; 179 return fShape; 235 } << 180 }; 236 181 237 G4int 182 G4int 238 G3VolTableEntry::GetNmed() { 183 G3VolTableEntry::GetNmed() { 239 return fNmed; 184 return fNmed; 240 } << 185 }; 241 186 242 G4int 187 G4int 243 G3VolTableEntry::GetNpar() { 188 G3VolTableEntry::GetNpar() { 244 return fNpar; 189 return fNpar; 245 } << 190 }; 246 191 247 G4double* 192 G4double* 248 G3VolTableEntry::GetRpar() { 193 G3VolTableEntry::GetRpar() { 249 return fRpar; 194 return fRpar; 250 } << 195 }; 251 196 252 G4int 197 G4int 253 G3VolTableEntry::NPCopies() { 198 G3VolTableEntry::NPCopies() { 254 return (G4int)fG3Pos.size(); << 199 return fG3Pos.entries(); 255 } << 200 }; 256 201 257 G3Pos* 202 G3Pos* 258 G3VolTableEntry::GetG3PosCopy(G4int copy) { 203 G3VolTableEntry::GetG3PosCopy(G4int copy) { 259 if (fG3Pos.size()>0 && copy>=0) << 204 if (fG3Pos.entries()>0 && copy>=0) 260 return fG3Pos[copy]; 205 return fG3Pos[copy]; 261 else 206 else 262 return 0; 207 return 0; 263 } 208 } 264 209 265 G4bool 210 G4bool 266 G3VolTableEntry::HasNegPars(){ 211 G3VolTableEntry::HasNegPars(){ 267 return fHasNegPars; 212 return fHasNegPars; 268 } << 213 }; 269 << 270 G4bool << 271 G3VolTableEntry::HasMANY(){ << 272 return fHasMANY; << 273 } << 274 214 275 G4VSolid* 215 G4VSolid* 276 G3VolTableEntry::GetSolid() { 216 G3VolTableEntry::GetSolid() { 277 return fSolid; 217 return fSolid; 278 } << 218 }; 279 219 280 G4LogicalVolume* 220 G4LogicalVolume* 281 G3VolTableEntry::GetLV() { 221 G3VolTableEntry::GetLV() { 282 return fLV; 222 return fLV; 283 } << 223 }; 284 224 285 G4int 225 G4int 286 G3VolTableEntry::GetNoDaughters() { 226 G3VolTableEntry::GetNoDaughters() { 287 return (G4int)fDaughters.size(); << 227 return fDaughters.entries(); 288 } << 228 }; 289 229 290 G4int 230 G4int 291 G3VolTableEntry::GetNoMothers() { 231 G3VolTableEntry::GetNoMothers() { 292 return (G4int)fMothers.size(); << 232 return fMothers.entries(); 293 } 233 } 294 234 295 G4int 235 G4int 296 G3VolTableEntry::GetNoClones() { 236 G3VolTableEntry::GetNoClones() { 297 return (G4int)fClones.size(); << 237 return fClones.entries(); 298 } << 299 << 300 G4int << 301 G3VolTableEntry::GetNoOverlaps() { << 302 return (G4int)fOverlaps.size(); << 303 } 238 } 304 239 305 G3VolTableEntry* 240 G3VolTableEntry* 306 G3VolTableEntry::GetDaughter(G4int i) { 241 G3VolTableEntry::GetDaughter(G4int i) { 307 if (i<G4int(fDaughters.size()) && i>=0) << 242 if (i<fDaughters.entries() && i>=0) 308 return fDaughters[i]; 243 return fDaughters[i]; 309 else 244 else 310 return 0; 245 return 0; 311 } << 246 }; 312 247 313 G3VolTableEntry* 248 G3VolTableEntry* 314 G3VolTableEntry::GetMother(G4int i){ 249 G3VolTableEntry::GetMother(G4int i){ 315 if (i<G4int(fMothers.size()) && i>=0) << 250 if (i<fMothers.entries() && i>=0) 316 return fMothers[i]; 251 return fMothers[i]; 317 else 252 else 318 return 0; 253 return 0; 319 } << 254 }; 320 255 321 // to be removed 256 // to be removed 322 G3VolTableEntry* 257 G3VolTableEntry* 323 G3VolTableEntry::GetMother(){ 258 G3VolTableEntry::GetMother(){ 324 if (fMothers.size()>0) << 259 if (fMothers.entries()>0) 325 return fMothers[0]; 260 return fMothers[0]; 326 else 261 else 327 return 0; 262 return 0; 328 } << 263 }; 329 264 330 G3VolTableEntry* 265 G3VolTableEntry* 331 G3VolTableEntry::GetClone(G4int i){ 266 G3VolTableEntry::GetClone(G4int i){ 332 if (i<G4int(fClones.size()) && i>=0) << 267 if (i<fClones.entries() && i>=0) 333 return fClones[i]; 268 return fClones[i]; 334 else 269 else 335 return 0; 270 return 0; 336 } << 271 }; 337 272 338 G3VolTableEntry* 273 G3VolTableEntry* 339 G3VolTableEntry::GetMasterClone(){ 274 G3VolTableEntry::GetMasterClone(){ 340 G3VolTableEntry* master; 275 G3VolTableEntry* master; 341 G4String name = fVname; 276 G4String name = fVname; 342 if (G4StrUtil::contains(name, gSeparator)) { << 277 if (name.contains(gSeparator)) { 343 name = name.substr(0, name.find(gSeparator << 278 name = name(0, name.first(gSeparator)); 344 master = G3Vol.GetVTE(name); 279 master = G3Vol.GetVTE(name); 345 } 280 } 346 else 281 else 347 master = this; 282 master = this; 348 283 349 return master; 284 return master; 350 } << 285 }; 351 << 352 std::vector<G3VolTableEntry*>* << 353 G3VolTableEntry::GetOverlaps(){ << 354 return &fOverlaps; << 355 } << 356 286