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