4 // Author: V. Berejnoi, I. Hrivnacova
6 // Class TG4GeometryManager
7 // ------------------------
8 // See the class description in the header file.
9 // C++ interface to Geant3 basic routines for building Geant4 geometry
10 // by V. Berejnoi, 25.2.1999;
11 // materials, tracking media support
12 // added by I.Hrivnacova, 27.5.1999.
14 #include "TG4GeometryManager.h"
15 #include "TG4GeometryOutputManager.h"
16 #include "TG4GeometryServices.h"
17 #include "TG4Limits.h"
18 #include "TG4G3Units.h"
19 #include "TG4G3CutVector.h"
20 #include "TG4G3ControlVector.h"
21 #include "TG4Globals.h"
24 #include <G3toG4BuildTree.hh>
25 #include <G3VolTable.hh>
26 #include <G3RotTable.hh>
27 #include <G3EleTable.hh>
28 #include <G3MatTable.hh>
29 #include <G3MedTable.hh>
30 #include <G3SensVolVector.hh>
32 #include <G4LogicalVolumeStore.hh>
33 #include <G4PVPlacement.hh>
34 #include <G4Material.hh>
35 #include <G4MaterialPropertiesTable.hh>
36 #include <G4Element.hh>
38 // extern global method from g3tog4
39 void G3CLRead(G4String &, char *);
41 TG4GeometryManager* TG4GeometryManager::fgInstance = 0;
43 //_____________________________________________________________________________
44 TG4GeometryManager::TG4GeometryManager()
48 fUseG3TMLimits(false),
53 TG4Globals::Exception(
54 "TG4GeometryManager: attempt to create two instances of singleton.");
58 = new TG4GeometryOutputManager();
61 = new TG4GeometryServices(&fMediumMap, &fNameMap);
65 // instantiate the default element table
66 //TG4ElementTable::Instance();
69 //_____________________________________________________________________________
70 TG4GeometryManager::TG4GeometryManager(const TG4GeometryManager& right) {
72 TG4Globals::Exception(
73 "Attempt to copy TG4GeometryManager singleton.");
77 //_____________________________________________________________________________
78 TG4GeometryManager::~TG4GeometryManager() {
80 delete fOutputManager;
81 delete fGeometryServices;
84 //=============================================================================
88 //=============================================================================
91 //_____________________________________________________________________________
93 TG4GeometryManager::operator=(const TG4GeometryManager& right)
95 // check assignement to self
96 if (this == &right) return *this;
98 TG4Globals::Exception(
99 "Attempt to assign TG4GeometryManager singleton.");
105 //=============================================================================
109 //=============================================================================
111 //_____________________________________________________________________________
112 void TG4GeometryManager::FillMediumMap()
114 // Maps G3 tracking medium IDs to volumes names.
118 static G4int done = 0;
120 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
122 for (G4int i=done; i<lvStore->size(); i++) {
123 G4String name = ((*lvStore)[i])->GetName();
124 G4int mediumID = G3Vol.GetVTE(name)->GetNmed();
125 fMediumMap.Add(name, mediumID);
128 done = lvStore->size();
132 //=============================================================================
134 // public methods - AliMC implementation
136 //=============================================================================
139 //_____________________________________________________________________________
140 void TG4GeometryManager::Material(Int_t& kmat, const char* name, Float_t a,
141 Float_t z, Float_t dens, Float_t radl, Float_t absl, Float_t* buf,
144 // Creates G4Material.
145 // !! Parameters radl, absl, buf, nwbuf are ignored in G4gsmate
147 // absl - this parameter is ignored by GEANT3, too
150 kmat = ++fMaterialCounter;
151 G4double* bufin = fGeometryServices->CreateG4doubleArray(buf, nwbuf);
152 G4String namein = fGeometryServices->CutMaterialName(name);
154 // write token to the output file
156 fOutputManager->WriteGsmate(kmat, namein, a, z, dens, radl, nwbuf, bufin);
158 // create new material only if it does not yet exist
159 G4Material* material = fGeometryServices->FindMaterial(a, z, dens);
162 G4cout << "!!! Material " << namein << " already exists as "
163 << material->GetName() << G4endl;
164 G3Mat.put(kmat, material);
167 G4gsmate(kmat, namein, a, z, dens, radl, nwbuf, bufin);
169 // save the original material name
170 fMaterialNameVector.push_back(namein);
176 = "TG4GeometryManager: user defined parameters for material ";
177 text = text + namein;
178 text = text + " are ignored by Geant4.";
179 TG4Globals::Warning(text);
184 //_____________________________________________________________________________
185 void TG4GeometryManager::Mixture(Int_t& kmat, const char *name, Float_t *a,
186 Float_t *z, Float_t dens, Int_t nlmat, Float_t *wmat)
188 // Creates G4Material composed of more elements.
189 // !! Parameters radl, absl, buf, nwbuf are ignored in G4gsmate
191 // absl - this parameter is ignored by GEANT3, too
194 Int_t npar = abs(nlmat);
195 G4double *ain = fGeometryServices->CreateG4doubleArray(a, npar);
196 G4double *zin = fGeometryServices->CreateG4doubleArray(z, npar);
197 G4double *wmatin = fGeometryServices->CreateG4doubleArray(wmat, npar);
198 G4String namein = fGeometryServices->CutMaterialName(name);
200 kmat = ++fMaterialCounter;
202 // write token to the output file
204 fOutputManager->WriteGsmixt(kmat, namein, ain, zin, dens, nlmat, wmatin);
206 // create new material only if it does not yet exist
208 = fGeometryServices->FindMaterial(ain, zin, dens, nlmat, wmatin);
211 G4cout << "!!! Material " << namein << " already exists as "
212 << material->GetName() << G4endl;
213 G3Mat.put(kmat, material);
216 G4gsmixt(kmat, namein, ain, zin, dens, nlmat, wmatin);
218 // save the original material name
219 fMaterialNameVector.push_back(namein);
222 // After a call with ratios by number (negative number of elements),
223 // the ratio array is changed to the ratio by weight, so all successive
224 // calls with the same array must specify the number of elements as
227 // wmatin may be modified
228 for (G4int i=0; i<npar; i++) wmat[i] = wmatin[i];
235 //_____________________________________________________________________________
236 void TG4GeometryManager::Medium(Int_t& kmed, const char *name, Int_t nmat,
237 Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd,
238 Float_t stemax, Float_t deemax, Float_t epsil,
239 Float_t stmin, Float_t* ubuf, Int_t nbuf)
241 // Creates a temporary "medium" that is used for
242 // assigning corresponding parameters to G4 objects:
243 // NTMED is stored as a second material index;
244 // ISVOL is used for builing G3SensVolVector;
245 // STEMAX is passed in TG4Limits (if fUseG3TMLimits is set true);
246 // !! The other parameters (IFIELD, FIELDM, TMAXFD, DEEMAX, EPSIL, STMIN)
247 // are ignored by Geant4.
250 // Geant3 desription:
251 // ==================
252 // NTMED Tracking medium number
253 // NAME Tracking medium name
254 // NMAT Material number
255 // ISVOL Sensitive volume flag
256 // IFIELD Magnetic field
257 // FIELDM Max. field value (Kilogauss)
258 // TMAXFD Max. angle due to field (deg/step)
259 // STEMAX Max. step allowed
260 // DEEMAX Max. fraction of energy lost in a step
261 // EPSIL Tracking precision (cm)
262 // STMIN Min. step due to continuos processes (cm)
264 // IFIELD = 0 if no magnetic field; IFIELD = -1 if user decision in GUSWIM;
265 // IFIELD = 1 if tracking performed with GRKUTA; IFIELD = 2 if tracking
266 // performed with GHELIX; IFIELD = 3 if tracking performed with GHELX3.
269 G4String namein = fGeometryServices->CutMaterialName(name);
271 kmed = ++fMediumCounter;
273 // write token to the output file
275 fOutputManager->WriteGstmed(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd,
276 stemax, deemax, epsil, stmin, 0, 0);
278 G4gstmed(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
279 epsil, stmin, 0, fUseG3TMLimits);
280 // !! instead of the nbuf argument the bool fIsG3Default is passed
282 // generate new unique name
285 ->GenerateLimitsName(kmed, namein, fMaterialNameVector[nmat-1]);
286 fMediumNameVector.push_back(newName);
289 G4String medName = name;
291 = "TG4GeometryManager: user defined parameters for medium ";
292 text = text + medName;
293 text = text + " are ignored by Geant4.";
294 TG4Globals::Warning(text);
299 //_____________________________________________________________________________
300 void TG4GeometryManager::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
301 Double_t thetaY, Double_t phiY, Double_t thetaZ, Double_t phiZ)
303 // Creates G4RotationMatrix.
306 krot = ++fMatrixCounter;
308 // write token to the output file
310 fOutputManager->WriteGsrotm(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
312 G4gsrotm(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
316 //_____________________________________________________________________________
317 void TG4GeometryManager::Matrix(Int_t& krot, Float_t thetaX, Float_t phiX,
318 Float_t thetaY, Float_t phiY, Float_t thetaZ, Float_t phiZ)
320 // Single precision interface.
323 //TG4Globals::Warning("TG4GeometryManager::Matrix in single precision.");
325 Double_t dthetaX = thetaX;
326 Double_t dphiX = phiX;
327 Double_t dthetaY = thetaY;
328 Double_t dphiY = phiY;
329 Double_t dthetaZ = thetaZ;
330 Double_t dphiZ = phiZ;
332 Matrix(krot, dthetaX, dphiX, dthetaY, dphiY, dthetaZ, dphiZ);
336 //_____________________________________________________________________________
337 void TG4GeometryManager::Ggclos()
339 // Sets the top VTE in temporary G3 volume table.
340 // Close geometry output file (if fWriteGeometry is set true).
342 // Geant3 desription:
343 // ==================
344 // close out the geometry
347 if (fWriteGeometry) fOutputManager->WriteGgclos();
353 //_____________________________________________________________________________
354 void TG4GeometryManager::Gfmate(Int_t imat, char *name, Float_t &a,
355 Float_t &z, Float_t &dens, Float_t &radl, Float_t &absl,
356 Float_t* ubuf, Int_t& nbuf)
358 // Geant3 desription:
359 // ==================
360 // Return parameters for material IMAT
363 G4Material* material = G3Mat.get(imat);
366 // to do: change this correctly
367 // !! unsafe conversion
368 const char* chName = material->GetName();
369 name = (char*)chName;
370 a = fGeometryServices->GetEffA(material);
371 z = fGeometryServices->GetEffZ(material);
373 dens = material->GetDensity();
374 dens /= TG4G3Units::MassDensity();
376 radl = material->GetRadlen();
377 radl /= TG4G3Units::Length();
379 // the following parameters are not defined in Geant4
385 TG4Globals::Exception(
386 "TG4GeometryManager::Gfmate: material has not been found.");
391 //_____________________________________________________________________________
392 void TG4GeometryManager::Gstpar(Int_t itmed, const char *param,
395 // Write token to the output file only,
396 // the method is performed by TG4PhysicsManager.
400 fOutputManager->WriteGstpar(itmed, param, parval);
404 //_____________________________________________________________________________
405 void TG4GeometryManager::SetCerenkov(Int_t itmed, Int_t npckov,
406 Float_t* ppckov, Float_t* absco, Float_t* effic,
410 // Geant3 desription:
411 // ==================
413 // Stores the tables for UV photon tracking in medium ITMED
414 // Please note that it is the user's responsability to
415 // provide all the coefficients:
418 // ITMED Tracking medium number
419 // NPCKOV Number of bins of each table
420 // PPCKOV Value of photon momentum (in GeV)
421 // ABSCO Absorbtion coefficients
422 // dielectric: absorbtion length in cm
423 // metals : absorbtion fraction (0<=x<=1)
424 // EFFIC Detection efficiency for UV photons
425 // RINDEX Refraction index (if=0 metal)
428 G4double* ppckovDbl = fGeometryServices->CreateG4doubleArray(ppckov, npckov);
429 G4double* abscoDbl = fGeometryServices->CreateG4doubleArray(absco, npckov);
430 G4double* efficDbl = fGeometryServices->CreateG4doubleArray(effic, npckov);
431 G4double* rindexDbl = fGeometryServices->CreateG4doubleArray(rindex, npckov);
435 for (i=0; i<npckov; i++) {
436 ppckovDbl[i] = ppckovDbl[i]*TG4G3Units::Energy();
437 abscoDbl[i] = abscoDbl[i]*TG4G3Units::Length();
440 // create material properties table
441 G4MaterialPropertiesTable* table = new G4MaterialPropertiesTable();
442 table->AddProperty("ABSLENGTH", ppckovDbl, abscoDbl, npckov);
443 // used in G4OpAbsorption process
444 table->AddProperty("EFFICIENCY", ppckovDbl, efficDbl, npckov);
445 // used in G4OpBoundary process
446 table->AddProperty("RINDEX", ppckovDbl, rindexDbl, npckov);
447 // used in G4Cerenkov, G4OpRayleigh, G4OpBoundary
449 // get material of medium from table
450 G3MedTableEntry* medium = G3Med.get(itmed);
452 G4String text = "TG4GeometryManager::SetCerenkov: \n";
453 text = text + " Medium not found.";
456 G4Material* material = medium->GetMaterial();
458 // set material properties table
459 material->SetMaterialPropertiesTable(table);
461 G4cout << "The tables for UV photon tracking set for "
462 << material->GetName() << G4endl;
463 for (i=0; i<npckov; i++)
464 G4cout << ppckovDbl[i] << " " << rindexDbl[i] << G4endl;
473 //_____________________________________________________________________________
474 void TG4GeometryManager::Gsdvn(const char *name, const char *mother,
475 Int_t ndiv, Int_t iaxis)
477 // Geant3 desription:
478 // ==================
480 // MOTHER Mother volume name
481 // NDIV Number of divisions
484 // X,Y,Z of CAXIS will be translated to 1,2,3 for IAXIS.
485 // It divides a previously defined volume.
488 // write token to the output file
490 fOutputManager->WriteGsdvn(name, mother, ndiv, iaxis);
492 G4gsdvn(fGeometryServices->CutName(name),
493 fGeometryServices->CutName(mother), ndiv, iaxis);
495 // register name in name map
496 fNameMap.AddName(fGeometryServices->CutName(name));
500 //_____________________________________________________________________________
501 void TG4GeometryManager::Gsdvn2(const char *name, const char *mother,
502 Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed)
504 // Geant3 desription:
505 // ==================
506 // DIVIDES MOTHER INTO NDIV DIVISIONS CALLED NAME
507 // ALONG AXIS IAXIS STARTING AT COORDINATE VALUE C0.
508 // THE NEW VOLUME CREATED WILL BE MEDIUM NUMBER NUMED.
511 // write token to the output file
513 fOutputManager->WriteGsdvn2(name, mother, ndiv, iaxis, c0i, numed);
515 G4gsdvn2(fGeometryServices->CutName(name),
516 fGeometryServices->CutName(mother), ndiv, iaxis, c0i, numed);
518 // register name in name map
519 fNameMap.AddName(fGeometryServices->CutName(name));
523 //_____________________________________________________________________________
524 void TG4GeometryManager::Gsdvn2(const char *name, const char *mother,
525 Int_t ndiv, Int_t iaxis, Float_t c0i, Int_t numed)
527 // Single precision interface.
530 //TG4Globals::Warning("TG4GeometryManager::Gsdvn2 in single precision.");
534 Gsdvn2(name, mother, ndiv, iaxis, dc0i, numed);
538 //_____________________________________________________________________________
539 void TG4GeometryManager::Gsdvt(const char *name, const char *mother,
540 Double_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
542 // Geant3 desription:
543 // ==================
544 // Divides MOTHER into divisions called NAME along
545 // axis IAXIS in steps of STEP. If not exactly divisible
546 // will make as many as possible and will centre them
547 // with respect to the mother. Divisions will have medium
548 // number NUMED. If NUMED is 0, NUMED of MOTHER is taken.
549 // NDVMX is the expected maximum number of divisions
550 // (If 0, no protection tests are performed)
553 // write token to the output file
555 fOutputManager->WriteGsdvt(name, mother, step, iaxis, numed, ndvmx);
557 G4gsdvt(fGeometryServices->CutName(name),
558 fGeometryServices->CutName(mother), step, iaxis, numed, ndvmx);
560 // register name in name map
561 fNameMap.AddName(fGeometryServices->CutName(name));
565 //_____________________________________________________________________________
566 void TG4GeometryManager::Gsdvt(const char *name, const char *mother,
567 Float_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
569 // Single precision interface.
572 //TG4Globals::Warning("TG4GeometryManager::Gsdvt in single precision.");
574 G4double dstep = step;
576 Gsdvt(name, mother, dstep, iaxis, numed, ndvmx);
580 //_____________________________________________________________________________
581 void TG4GeometryManager::Gsdvt2(const char *name, const char *mother,
582 Double_t step, Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx)
584 // Geant3 desription:
585 // ==================
586 // Create a new volume by dividing an existing one
588 // Divides MOTHER into divisions called NAME along
589 // axis IAXIS starting at coordinate value C0 with step
591 // The new volume created will have medium number NUMED.
592 // If NUMED is 0, NUMED of mother is taken.
593 // NDVMX is the expected maximum number of divisions
594 // (If 0, no protection tests are performed)
597 // write token to the output file
599 fOutputManager->WriteGsdvt2(name, mother, step, iaxis, c0, numed, ndvmx);
601 G4gsdvt2(fGeometryServices->CutName(name),
602 fGeometryServices->CutName(mother), step, iaxis, c0, numed, ndvmx);
604 // register name in name map
605 fNameMap.AddName(fGeometryServices->CutName(name));
609 //_____________________________________________________________________________
610 void TG4GeometryManager::Gsdvt2(const char *name, const char *mother,
611 Float_t step, Int_t iaxis, Float_t c0, Int_t numed, Int_t ndvmx)
613 // Single precision interface.
616 //TG4Globals::Warning("TG4GeometryManager::Gsdvt2 in single precision.");
618 G4double dstep = step;
621 Gsdvt2(name, mother, dstep, iaxis, dc0, numed, ndvmx);
625 //_____________________________________________________________________________
626 void TG4GeometryManager::Gsord(const char *name, Int_t iax)
628 // No corresponding action in G4.
630 // Geant3 desription:
631 // ==================
632 // Flags volume CHNAME whose contents will have to be ordered
633 // along axis IAX, by setting the search flag to -IAX
637 // IAX = 4 Rxy (static ordering only -> GTMEDI)
638 // IAX = 14 Rxy (also dynamic ordering -> GTNEXT)
639 // IAX = 5 Rxyz (static ordering only -> GTMEDI)
640 // IAX = 15 Rxyz (also dynamic ordering -> GTNEXT)
641 // IAX = 6 PHI (PHI=0 => X axis)
642 // IAX = 7 THETA (THETA=0 => Z axis)
645 TG4Globals::Warning("TG4GeometryManager::Gsord: dummy method.");
649 //_____________________________________________________________________________
650 void TG4GeometryManager::Gspos(const char *vname, Int_t num,
651 const char *vmoth, Double_t x, Double_t y, Double_t z, Int_t irot,
654 // Geant3 desription:
655 // ==================
656 // Position a volume into an existing one
659 // NUMBER Copy number of the volume
660 // MOTHER Mother volume name
661 // X X coord. of the volume in mother ref. sys.
662 // Y Y coord. of the volume in mother ref. sys.
663 // Z Z coord. of the volume in mother ref. sys.
664 // IROT Rotation matrix number w.r.t. mother ref. sys.
665 // ONLY ONLY/MANY flag
667 // It positions a previously defined volume in the mother.
670 // write token to the output file
672 fOutputManager->WriteGspos(vname, num, vmoth, x, y, z, irot, vonly);
674 G4gspos(fGeometryServices->CutName(vname), num,
675 fGeometryServices->CutName(vmoth), x, y, z, irot, vonly);
677 // register name in name map
678 fNameMap.AddName(fGeometryServices->CutName(vname));
682 //_____________________________________________________________________________
683 void TG4GeometryManager::Gspos(const char *vname, Int_t num,
684 const char *vmoth, Float_t x, Float_t y, Float_t z, Int_t irot,
687 // Single precision interface.
690 //TG4Globals::Warning("TG4GeometryManager::Gspos in single precision.");
696 Gspos(vname, num, vmoth, dx, dy, dz, irot, vonly);
700 //_____________________________________________________________________________
701 void TG4GeometryManager::Gsposp(const char *name, Int_t nr,
702 const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
703 const char *konly, Double_t *upar, Int_t np )
705 // Geant3 desription:
706 // ==================
707 // Place a copy of generic volume NAME with user number
708 // NR inside MOTHER, with its parameters UPAR(1..NP)
711 // write token to the output file
713 fOutputManager->WriteGsposp(name, nr, mother, x, y, z, irot, konly, upar, np);
715 G4gsposp(fGeometryServices->CutName(name), nr,
716 fGeometryServices->CutName(mother), x, y, z, irot, konly,
719 // register name in name map
720 fNameMap.AddName(fGeometryServices->CutName(name));
724 //_____________________________________________________________________________
725 void TG4GeometryManager::Gsposp(const char *name, Int_t nr,
726 const char *mother, Float_t x, Float_t y, Float_t z, Int_t irot,
727 const char *konly, Float_t *upar, Int_t np )
729 // Single precision interface.
732 //TG4Globals::Warning("TG4GeometryManager::Gsposp in single precision.");
737 G4double* parin = fGeometryServices->CreateG4doubleArray(upar, np);
739 Gsposp(name, nr, mother, dx, dy, dz, irot, konly, parin, np);
745 //_____________________________________________________________________________
746 Int_t TG4GeometryManager::Gsvolu(const char *name, const char *shape,
747 Int_t nmed, Double_t *upar, Int_t npar)
749 // Geant3 desription:
750 // ==================
753 // NUMED Tracking medium number
754 // NPAR Number of shape parameters
755 // UPAR Vector containing shape parameters
757 // It creates a new volume in the JVOLUM data structure.
760 // write token to the output file
762 fOutputManager->WriteGsvolu(name, shape, nmed, upar, npar);
764 G4gsvolu(fGeometryServices->CutName(name),
765 fGeometryServices->CutName(shape), nmed, upar, npar);
767 // register name in name map
768 fNameMap.AddName(fGeometryServices->CutName(name));
774 //_____________________________________________________________________________
775 Int_t TG4GeometryManager::Gsvolu(const char *name, const char *shape,
776 Int_t nmed, Float_t *upar, Int_t npar)
778 // Single precision interface.
781 //TG4Globals::Warning("TG4GeometryManager::Gsvolu in single precision.");
783 G4double* parin = fGeometryServices->CreateG4doubleArray(upar, npar);
786 = Gsvolu(name, shape, nmed, parin, npar);
794 //_____________________________________________________________________________
795 void TG4GeometryManager::WriteEuclid(const char* fileName,
796 const char* topVolName, Int_t number, Int_t nlevel)
798 // Geant3 desription:
799 // ==================
801 // ******************************************************************
803 // * Write out the geometry of the detector in EUCLID file format *
805 // * filnam : will be with the extension .euc *
806 // * topvol : volume name of the starting node *
807 // * number : copy number of topvol (relevant for gsposp) *
808 // * nlevel : number of levels in the tree structure *
809 // * to be written out, starting from topvol *
811 // * Author : M. Maire *
813 // ******************************************************************
815 // File filnam.tme is written out with the definitions of tracking
816 // medias and materials.
817 // As to restore original numbers for materials and medias, program
818 // searches in the file euc_medi.dat and comparing main parameters of
819 // the mat. defined inside geant and the one in file recognizes them
820 // and is able to take number from file. If for any material or medium,
821 // this procedure fails, ordering starts from 1.
822 // Arrays IOTMED and IOMATE are used for this procedure
826 "TG4GeometryManager::WriteEuclid(..) is not yet implemented.");
830 //=============================================================================
832 // public methods - Geant4 only
834 //=============================================================================
837 //_____________________________________________________________________________
838 G4VPhysicalVolume* TG4GeometryManager::CreateG4Geometry()
840 // Creates G4 geometry objects according to the G3VolTable
841 // and returns the top physical volume in case it was created
842 // (return zero otherwise).
845 // set the first entry in the G3Vol table
847 G3VolTableEntry* first = G3Vol.GetFirstVTE();
849 // create G4 geometry
850 G3toG4BuildTree(first,0);
855 // print G3 volume table statistics
858 // print G4 geometry statistics
859 G4cout << "G4 Stat: instantiated "
860 << fGeometryServices->NofG4LogicalVolumes()
861 << " logical volumes \n"
863 << fGeometryServices->NofG4PhysicalVolumes()
864 << " physical volumes" << G4endl;
866 // position the first entry
867 // (in Geant3 the top volume cannot be positioned)
869 G4VPhysicalVolume* top = 0;
870 if (first->GetLV()->GetNoDaughters() == 0) {
871 top = new G4PVPlacement(0, G4ThreeVector(), first->GetName(),
872 first->GetLV(), 0, false, 0);
878 //_____________________________________________________________________________
879 void TG4GeometryManager::SetUserLimits(const TG4G3CutVector& cuts,
880 const TG4G3ControlVector& controls) const
882 // Sets user limits defined in G3MedTable for all logical volumes.
885 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
887 for (G4int i=0; i<lvStore->size(); i++) {
888 G4LogicalVolume* lv = (*lvStore)[i];
890 // get limits from G3Med
891 G4int mediumIndex = fGeometryServices->GetMediumId(lv);
892 G4UserLimits* limits = G3Med.get(mediumIndex)->GetLimits();
893 TG4Limits* tg4Limits = fGeometryServices->GetLimits(limits);
895 // get tracking medium name
896 G4String name = fMediumNameVector[mediumIndex-1];
899 tg4Limits->SetName(name);
901 tg4Limits = fGeometryServices->FindLimits(name, true);
903 tg4Limits = new TG4Limits(name, cuts, controls);
906 // update controls in limits according to the setup
907 // in the passed vector
908 tg4Limits->Update(controls);
910 // set limits to logical volume
911 lv->SetUserLimits(tg4Limits);
915 //_____________________________________________________________________________
916 void TG4GeometryManager::ReadG3Geometry(G4String filePath)
918 // Processes g3calls.dat file and fills G3 tables.
922 G4cout << "Reading the call list file " << filePath << "..." << G4endl;
923 G3CLRead(filePath, NULL);
924 G4cout << "Call list file read completed. Build geometry" << G4endl;
928 //_____________________________________________________________________________
929 void TG4GeometryManager::UseG3TrackingMediaLimits()
931 // Sets fUseG3TMLimits option.
932 // !! This method has to be called only before starting
933 // creating geometry.
936 if (fMediumCounter == 0) {
937 fUseG3TMLimits = true;
940 G4String text = "TG4GeometryManager::UseG3TMLimits: \n";
941 text = text + " It is too late to set G3 defaults. \n";
942 text = text + " Some media has been already processed.";
943 TG4Globals::Exception(text);
948 //_____________________________________________________________________________
949 void TG4GeometryManager::ClearG3Tables()
951 // Clears G3 volumes, materials, rotations(?) tables
952 // and sensitive volumes vector.
953 // The top volume is kept in the vol table.
956 // clear volume table
957 // but keep the top volume in the table
958 G3VolTableEntry* top = G3Vol.GetFirstVTE();
959 G4String name = top->GetName();
960 G4String shape = top->GetShape();
961 G3VolTableEntry* keep
962 = new G3VolTableEntry(name, shape, top->GetRpar(), top->GetNpar(),
963 top->GetNmed(), top->GetSolid(), false);
964 keep->SetLV(top->GetLV());
968 // clear other tables
974 //_____________________________________________________________________________
975 void TG4GeometryManager::ClearG3TablesFinal()
977 // Clears G3 medias and volumes tables
978 // (the top volume is removed from the vol table)
987 //_____________________________________________________________________________
988 void TG4GeometryManager::OpenOutFile(G4String filePath)
990 // Opens output file.
993 fOutputManager->OpenFile(filePath);
997 //_____________________________________________________________________________
998 void TG4GeometryManager::CloseOutFile()
1000 // Closes output file.
1003 fOutputManager->CloseFile();
1007 //_____________________________________________________________________________
1008 void TG4GeometryManager::SetWriteGeometry(G4bool writeGeometry)
1010 // Controls geometry output.
1013 fWriteGeometry = writeGeometry;
1017 //_____________________________________________________________________________
1018 void TG4GeometryManager::SetMapSecond(const G4String& name)
1020 // Sets the second name for the map of volumes names.
1023 fNameMap.SetSecond(name);