Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4MCGeometry.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
18
19#include "TG4MCGeometry.h"
20#include "TG4G3ControlVector.h"
21#include "TG4G3CutVector.h"
22#include "TG4G3Units.h"
23#include "TG4GeometryServices.h"
24#include "TG4Globals.h"
25#include "TG4Limits.h"
26#include "TG4Medium.h"
27
28#ifdef USE_G3TOG4
29#include <G3MatTable.hh>
30#include <G3toG4.hh>
31#endif
32
33#include <G4Box.hh>
34#include <G4Cons.hh>
35#include <G4EllipticalTube.hh>
36#include <G4Hype.hh>
37#include <G4LogicalBorderSurface.hh>
38#include <G4LogicalSkinSurface.hh>
39#include <G4LogicalVolume.hh>
40#include <G4Material.hh>
41#include <G4MaterialPropertiesTable.hh>
42#include <G4OpticalSurface.hh>
43#include <G4Para.hh>
44#include <G4Polycone.hh>
45#include <G4Polyhedra.hh>
46#include <G4ReflectedSolid.hh>
47#include <G4Sphere.hh>
48#include <G4SystemOfUnits.hh>
49#include <G4Torus.hh>
50#include <G4Transform3D.hh>
51#include <G4Trap.hh>
52#include <G4Trd.hh>
53#include <G4Tubs.hh>
54#include <G4TwistedTrap.hh>
55
56#include <Riostream.h>
57#include <TArrayD.h>
58#include <TString.h>
59
60#ifdef USE_G3TOG4
62void G3CLRead(G4String&, char*);
63#endif
64
65//_____________________________________________________________________________
67 : TG4Verbose("g4MCGeometry"), fGeometryServices(0), fMaterialNameVector()
68{
70
72 if (!fGeometryServices) {
73 TG4Globals::Exception("TG4MCGeometry", "TG4MCGeometry",
74 "TG4GeometryServices have to be defined first");
75 }
76}
77
78//_____________________________________________________________________________
83
84//
85// public methods
86//
87
88//_____________________________________________________________________________
89void TG4MCGeometry::Material(Int_t& kmat, const char* name, Double_t a,
90 Double_t z, Double_t dens, Double_t radl, Double_t absl, Float_t* buf,
91 Int_t nwbuf)
92{
95
96 G4double* bufin = fGeometryServices->CreateG4doubleArray(buf, nwbuf);
97 Material(kmat, name, a, z, dens, radl, absl, bufin, nwbuf);
98 delete[] bufin;
99}
100
101#ifdef USE_G3TOG4
102//_____________________________________________________________________________
103void TG4MCGeometry::Material(Int_t& kmat, const char* name, Double_t a,
104 Double_t z, Double_t dens, Double_t radl, Double_t /*absl*/, Double_t* buf,
105 Int_t nwbuf)
106{
110
111 G4String namein = fGeometryServices->CutMaterialName(name);
112
113 // create new material only if it does not yet exist
114 G4Material* material = fGeometryServices->FindMaterial(a, z, dens);
115 if (material) {
116 // verbose
117 if (VerboseLevel() > 1) {
118 G4cout << "!!! Material " << namein << " already exists as "
119 << material->GetName() << G4endl;
120 }
121 G3Mat.put(kmat, material);
122 }
123 else
124 G4gsmate(kmat, namein, a, z, dens, radl, nwbuf, buf);
125
126 // save the original material name
127 fMaterialNameVector.push_back(namein);
128
129 if (nwbuf > 0) {
130 TG4Globals::Warning("TG4MCGeometry", "Material",
131 "User defined parameters for material " + TString(namein) +
132 " are ignored by Geant4.");
133 }
134}
135#else
136//_____________________________________________________________________________
137void TG4MCGeometry::Material(Int_t&, const char*, Double_t, Double_t, Double_t,
138 Double_t, Double_t, Double_t*, Int_t)
139{
141
142 TG4Globals::Exception("TG4MCGeometry", "Material",
143 "This method requires Geant4 installation with G3toG4.");
144}
145#endif
146
147//_____________________________________________________________________________
148void TG4MCGeometry::Mixture(Int_t& kmat, const char* name, Float_t* a,
149 Float_t* z, Double_t dens, Int_t nlmat, Float_t* wmat)
150{
153
154 G4double* ain = fGeometryServices->CreateG4doubleArray(a, abs(nlmat));
155 G4double* zin = fGeometryServices->CreateG4doubleArray(z, abs(nlmat));
156 G4double* wmatin = fGeometryServices->CreateG4doubleArray(wmat, abs(nlmat));
157
158 Mixture(kmat, name, ain, zin, dens, nlmat, wmatin);
159
160 // !!! in Geant3:
161 // After a call with ratios by number (negative number of elements),
162 // the ratio array is changed to the ratio by weight, so all successive
163 // calls with the same array must specify the number of elements as
164 // positive
165
166 // wmatin may be modified
167 for (G4int i = 0; i < abs(nlmat); i++) wmat[i] = wmatin[i];
168
169 delete[] ain;
170 delete[] zin;
171 delete[] wmatin;
172}
173
174#ifdef USE_G3TOG4
175//_____________________________________________________________________________
176void TG4MCGeometry::Mixture(Int_t& kmat, const char* name, Double_t* a,
177 Double_t* z, Double_t dens, Int_t nlmat, Double_t* wmat)
178{
182
183 G4String namein = fGeometryServices->CutMaterialName(name);
184
185 // create new material only if it does not yet exist
186 G4Material* material =
187 fGeometryServices->FindMaterial(a, z, dens, nlmat, wmat);
188 if (material) {
189 // verbose
190 if (VerboseLevel() > 1) {
191 G4cout << "!!! Material " << namein << " already exists as "
192 << material->GetName() << G4endl;
193 }
194 G3Mat.put(kmat, material);
195 }
196 else
197 G4gsmixt(kmat, namein, a, z, dens, nlmat, wmat);
198
199 // save the original material name
200 fMaterialNameVector.push_back(namein);
201}
202#else
203//_____________________________________________________________________________
205 Int_t&, const char*, Double_t*, Double_t*, Double_t, Int_t, Double_t*)
206{
209
210 TG4Globals::Exception("TG4MCGeometry", "Mixture",
211 "This method requires Geant4 installation with G3toG4.");
212}
213#endif
214
215//_____________________________________________________________________________
216void TG4MCGeometry::Medium(Int_t& kmed, const char* name, Int_t nmat,
217 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, Double_t stemax,
218 Double_t deemax, Double_t epsil, Double_t stmin, Float_t* ubuf, Int_t nbuf)
219{
247
248 G4double* bufin = fGeometryServices->CreateG4doubleArray(ubuf, nbuf);
249 Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil,
250 stmin, bufin, nbuf);
251 delete[] bufin;
252}
253
254#ifdef USE_G3TOG4
255//_____________________________________________________________________________
256void TG4MCGeometry::Medium(Int_t& kmed, const char* name, Int_t nmat,
257 Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, Double_t stemax,
258 Double_t deemax, Double_t epsil, Double_t stmin, Double_t* /*ubuf*/,
259 Int_t nbuf)
260{
289
290 G4String namein = fGeometryServices->CutMaterialName(name);
291
292 G4gstmed(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax,
293 epsil, stmin, 0, stemax > 0.);
294 // instead of the nbuf argument the bool is passed
295 // in order to pass stemax into G4UserLimits
296
297 // Add medium to the map (to keep its name which is not stored in G3toG4)
299 medium->SetName(name);
300 medium->SetIfield(ifield);
301
302 if (nbuf > 0) {
303 TG4Globals::Warning("TG4MCGeometry", "Medium",
304 "User defined parameters for medium " + TString(namein) +
305 " are ignored by Geant4.");
306 }
307}
308#else
309//_____________________________________________________________________________
310void TG4MCGeometry::Medium(Int_t&, const char*, Int_t, Int_t, Int_t, Double_t,
311 Double_t, Double_t, Double_t, Double_t, Double_t, Double_t*, Int_t)
312{
315
316 TG4Globals::Exception("TG4MCGeometry", "Medium",
317 "This method requires Geant4 installation with G3toG4.");
318}
319#endif
320
321#ifdef USE_G3TOG4
322//_____________________________________________________________________________
323void TG4MCGeometry::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
324 Double_t thetaY, Double_t phiY, Double_t thetaZ, Double_t phiZ)
325{
328
329 G4gsrotm(krot, thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
330}
331#else
332//_____________________________________________________________________________
334 Int_t&, Double_t, Double_t, Double_t, Double_t, Double_t, Double_t)
335{
338
339 TG4Globals::Exception("TG4MCGeometry", "Matrix",
340 "This method requires Geant4 installation with G3toG4.");
341}
342#endif
343
344//_____________________________________________________________________________
346{
352
353#ifdef USE_G3TOG4
354 G4ggclos();
355#else
356 TG4Globals::Exception("TG4MCGeometry", "Ggclos()",
357 "This method requires Geant4 installation with G3toG4.");
358#endif
359}
360
361#ifdef USE_G3TOG4
362//_____________________________________________________________________________
364 const char* name, const char* shape, Int_t nmed, Double_t* upar, Int_t npar)
365{
376 // ---
377
378 G4gsvolu(fGeometryServices->CutName(name), fGeometryServices->CutName(shape),
379 nmed, upar, npar);
380 return 0;
381}
382#else
383//_____________________________________________________________________________
384Int_t TG4MCGeometry::Gsvolu(const char*, const char*, Int_t, Double_t*, Int_t)
385{
388
389 TG4Globals::Exception("TG4MCGeometry", "Gsvolu",
390 "This method requires Geant4 installation with G3toG4.");
391 return 0;
392}
393#endif
394
395//_____________________________________________________________________________
397 const char* name, const char* shape, Int_t nmed, Float_t* upar, Int_t npar)
398{
400
401 G4double* parin = fGeometryServices->CreateG4doubleArray(upar, npar);
402
403 G4int result = Gsvolu(name, shape, nmed, parin, npar);
404
405 delete[] parin;
406
407 return result;
408}
409
410#ifdef USE_G3TOG4
411//_____________________________________________________________________________
413 const char* name, const char* mother, Int_t ndiv, Int_t iaxis)
414{
425 // ---
426
427 G4gsdvn(fGeometryServices->CutName(name), fGeometryServices->CutName(mother),
428 ndiv, iaxis);
429}
430#else
431//_____________________________________________________________________________
432void TG4MCGeometry::Gsdvn(const char*, const char*, Int_t, Int_t)
433{
436 // ---
437
438 TG4Globals::Exception("TG4MCGeometry", "Gsdvn",
439 "This method requires Geant4 installation with G3toG4.");
440}
441#endif
442
443#ifdef USE_G3TOG4
444//_____________________________________________________________________________
445void TG4MCGeometry::Gsdvn2(const char* name, const char* mother, Int_t ndiv,
446 Int_t iaxis, Double_t c0i, Int_t numed)
447{
453
454 G4gsdvn2(fGeometryServices->CutName(name), fGeometryServices->CutName(mother),
455 ndiv, iaxis, c0i, numed);
456}
457#else
458//_____________________________________________________________________________
460 const char*, const char*, Int_t, Int_t, Double_t, Int_t)
461{
466
467 TG4Globals::Exception("TG4MCGeometry", "Gsdvn2",
468 "This method requires Geant4 installation with G3toG4.");
469}
470#endif
471
472#ifdef USE_G3TOG4
473//_____________________________________________________________________________
474void TG4MCGeometry::Gsdvt(const char* name, const char* mother, Double_t step,
475 Int_t iaxis, Int_t numed, Int_t ndvmx)
476{
486
487 G4gsdvt(fGeometryServices->CutName(name), fGeometryServices->CutName(mother),
488 step, iaxis, numed, ndvmx);
489}
490#else
491//_____________________________________________________________________________
493 const char*, const char*, Double_t, Int_t, Int_t, Int_t)
494{
498
499 TG4Globals::Exception("TG4MCGeometry", "Gsdvt",
500 "This method requires Geant4 installation with G3toG4.");
501}
502#endif
503
504#ifdef USE_G3TOG4
505//_____________________________________________________________________________
506void TG4MCGeometry::Gsdvt2(const char* name, const char* mother, Double_t step,
507 Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx)
508{
519
520 G4gsdvt2(fGeometryServices->CutName(name), fGeometryServices->CutName(mother),
521 step, iaxis, c0, numed, ndvmx);
522}
523#else
524//_____________________________________________________________________________
526 const char*, const char*, Double_t, Int_t, Double_t, Int_t, Int_t)
527{
531
532 TG4Globals::Exception("TG4MCGeometry", "Gsdvt",
533 "This method requires Geant4 installation with G3toG4.");
534}
535#endif
536
537//_____________________________________________________________________________
538void TG4MCGeometry::Gsord(const char* /*name*/, Int_t /*iax*/)
539{
555
556 TG4Globals::Warning("TG4MCGeometry", "Gsord", "Dummy method.");
557}
558
559#ifdef USE_G3TOG4
560//_____________________________________________________________________________
561void TG4MCGeometry::Gspos(const char* vname, Int_t num, const char* vmoth,
562 Double_t x, Double_t y, Double_t z, Int_t irot, const char* vonly)
563{
578 // ---
579
580 G4gspos(fGeometryServices->CutName(vname), ++num,
581 fGeometryServices->CutName(vmoth), x, y, z, irot, vonly);
582}
583#else
584//_____________________________________________________________________________
585void TG4MCGeometry::Gspos(const char*, Int_t, const char*, Double_t, Double_t,
586 Double_t, Int_t, const char*)
587{
590 // ---
591
592 TG4Globals::Exception("TG4MCGeometry", "Gspos",
593 "This method requires Geant4 installation with G3toG4.");
594}
595#endif
596
597#ifdef USE_G3TOG4
598//_____________________________________________________________________________
599void TG4MCGeometry::Gsposp(const char* name, Int_t nr, const char* mother,
600 Double_t x, Double_t y, Double_t z, Int_t irot, const char* konly,
601 Double_t* upar, Int_t np)
602{
607
608 G4gsposp(fGeometryServices->CutName(name), ++nr,
609 fGeometryServices->CutName(mother), x, y, z, irot, konly, upar, np);
610}
611#else
612//_____________________________________________________________________________
613void TG4MCGeometry::Gsposp(const char*, Int_t, const char*, Double_t, Double_t,
614 Double_t, Int_t, const char*, Double_t*, Int_t)
615{
619
620 TG4Globals::Exception("TG4MCGeometry", "Gsposp",
621 "This method requires Geant4 installation with G3toG4.");
622}
623#endif
624
625//_____________________________________________________________________________
626void TG4MCGeometry::Gsposp(const char* name, Int_t nr, const char* mother,
627 Double_t x, Double_t y, Double_t z, Int_t irot, const char* konly,
628 Float_t* upar, Int_t np)
629{
631
632 G4double* parin = fGeometryServices->CreateG4doubleArray(upar, np);
633 Gsposp(name, nr, mother, x, y, z, irot, konly, parin, np);
634 delete[] parin;
635}
636
637#ifdef USE_G3TOG4
638//_____________________________________________________________________________
639void TG4MCGeometry::Gsbool(const char* onlyVolName, const char* manyVolName)
640{
645 // ---
646
647 G4gsbool(onlyVolName, manyVolName);
648}
649#else
650//_____________________________________________________________________________
651void TG4MCGeometry::Gsbool(const char*, const char*)
652{
655 // ---
656
657 TG4Globals::Exception("TG4MCGeometry", "Gsbool",
658 "This method requires Geant4 installation with G3toG4.");
659}
660#endif
661
662//_____________________________________________________________________________
664 const TString& volumePath, TGeoHMatrix& matrix)
665{
668
669 G4String path = volumePath.Data();
670
671 G4String volName;
672 G4int copyNo;
673 path = fGeometryServices->CutVolumePath(path, volName, copyNo);
674
675 // Get the first volume
676 G4VPhysicalVolume* pvTop = 0;
677 if (fGeometryServices->GetWorld()->GetName() == volName) {
678 // Check world volume first
679 pvTop = fGeometryServices->GetWorld();
680 }
681 else
682 pvTop = fGeometryServices->FindPhysicalVolume(volName, copyNo, true);
683
684 if (!pvTop) {
685 TG4Globals::Warning("TG4MCGeometry",
686 "GetTransformation:", "Top volume in " + volumePath + " does not exist.");
687 return false;
688 }
689
690 // Calculate transformation
691 //
692 G4VPhysicalVolume* pvMother = pvTop;
693 G4Transform3D transform;
694
695 while (path.length() > 0) {
696 // Extract next volume name & copyNo
697 path = fGeometryServices->CutVolumePath(path, volName, copyNo);
698
699 // Find daughter
700 G4VPhysicalVolume* pvDaughter = fGeometryServices->FindDaughter(
701 volName, copyNo, pvMother->GetLogicalVolume(), true);
702
703 if (!pvDaughter) {
704 TG4Globals::Warning("TG4MCGeometry", "GetTransformation",
705 "Daughter volume " + TString(volName) + " in " + volumePath +
706 " does not exist.");
707 return false;
708 }
709
710 transform = transform * G4Transform3D(*pvDaughter->GetObjectRotation(),
711 pvDaughter->GetObjectTranslation());
712 pvMother = pvDaughter;
713 }
714
715 // put transform in TGeoHMatrix here
716 fGeometryServices->Convert(transform, matrix);
717 return true;
718}
719
720//_____________________________________________________________________________
722 const TString& volumePath, TString& shapeType, TArrayD& par)
723{
726
727 // Get volume & copyNo
728 G4String path = volumePath.Data();
729 G4int last1 = path.rfind('/');
730 G4int last2 = path.rfind('_');
731 G4String volName = path.substr(last1 + 1, last2 - last1 - 1);
732 G4String copyNoStr = path.substr(last2 + 1, path.length() - last2);
733 std::istringstream in(copyNoStr);
734 G4int copyNo;
735 in >> copyNo;
736
737 // Find physical volume
738 G4VPhysicalVolume* pv =
739 fGeometryServices->FindPhysicalVolume(volName, copyNo, true);
740
741 if (!pv) {
742 TG4Globals::Warning("TG4MCGeometry", "GetShape",
743 "Physical volume " + volumePath + " does not exist.");
744 return false;
745 }
746
747 // Get solid
748 G4VSolid* solid = pv->GetLogicalVolume()->GetSolid();
749
750 // Get constituent solid if reflected solid
751 Bool_t isReflected = false;
752 G4ReflectedSolid* reflSolid = dynamic_cast<G4ReflectedSolid*>(solid);
753 if (reflSolid) {
754 solid = reflSolid->GetConstituentMovedSolid();
755 isReflected = true;
756 }
757
758 Int_t npar;
759
760 if (solid->GetEntityType() == "G4Box") {
761 shapeType = "BOX";
762 npar = 3;
763 par.Set(npar);
764 G4Box* box = (G4Box*)solid;
765 par.AddAt(box->GetXHalfLength() / cm, 0);
766 par.AddAt(box->GetYHalfLength() / cm, 1);
767 par.AddAt(box->GetZHalfLength() / cm, 2);
768 return kTRUE;
769 }
770
771 if (solid->GetEntityType() == "G4Cons") {
772 shapeType = "CONS";
773 npar = 7;
774 par.Set(npar);
775 G4Cons* cons = (G4Cons*)solid;
776 par.AddAt(cons->GetZHalfLength() / cm, 0);
777 if (!isReflected) {
778 par.AddAt(cons->GetInnerRadiusMinusZ() / cm, 1);
779 par.AddAt(cons->GetOuterRadiusMinusZ() / cm, 2);
780 par.AddAt(cons->GetInnerRadiusPlusZ() / cm, 3);
781 par.AddAt(cons->GetOuterRadiusPlusZ() / cm, 4);
782 }
783 else {
784 par.AddAt(cons->GetInnerRadiusPlusZ() / cm, 1);
785 par.AddAt(cons->GetOuterRadiusPlusZ() / cm, 2);
786 par.AddAt(cons->GetInnerRadiusMinusZ() / cm, 3);
787 par.AddAt(cons->GetOuterRadiusMinusZ() / cm, 4);
788 }
789 par.AddAt(cons->GetStartPhiAngle() / deg, 5);
790 par.AddAt(cons->GetDeltaPhiAngle() / deg, 6);
791 return kTRUE;
792 }
793
794 if (solid->GetEntityType() == "G4EllipticalTube") {
795 shapeType = "ELTU";
796 npar = 3;
797 par.Set(npar);
798 G4EllipticalTube* eltu = (G4EllipticalTube*)solid;
799 par.AddAt(eltu->GetDx() / cm, 0);
800 par.AddAt(eltu->GetDy() / cm, 1);
801 par.AddAt(eltu->GetDz() / cm, 2);
802 return kTRUE;
803 }
804
805 // Add to G3toG4, VGM
806 if (solid->GetEntityType() == "G4Hype") {
807 shapeType = "HYPE";
808 npar = 5;
809 par.Set(npar);
810 G4Hype* hype = (G4Hype*)solid;
811 par.AddAt(hype->GetInnerRadius() / cm, 0);
812 par.AddAt(hype->GetOuterRadius() / cm, 1);
813 par.AddAt(hype->GetZHalfLength() / cm, 2);
814 par.AddAt(hype->GetInnerStereo(), 3); // ?? unit
815 par.AddAt(hype->GetOuterStereo(), 4); // ?? unit
816 return kTRUE;
817 }
818
819 // Add G4Orb
820
821 if (solid->GetEntityType() == "G4Para") {
822 shapeType = "PARA";
823 npar = 6;
824 par.Set(npar);
825 G4Para* para = (G4Para*)solid;
826 par.AddAt(para->GetXHalfLength() / cm, 0);
827 par.AddAt(para->GetYHalfLength() / cm, 1);
828 par.AddAt(para->GetZHalfLength() / cm, 2);
829 par.AddAt(atan(para->GetTanAlpha()) / deg, 3);
830 if (!isReflected)
831 par.AddAt(para->GetSymAxis().theta() / deg, 4);
832 else
833 par.AddAt((M_PI - para->GetSymAxis().theta()) / deg, 4);
834 par.AddAt(para->GetSymAxis().phi() / deg, 5);
835 return kTRUE;
836 }
837
838 if (solid->GetEntityType() == "G4Polycone") {
839 shapeType = "PCON";
840 G4Polycone* pcon = (G4Polycone*)solid;
841 Int_t nz = pcon->GetOriginalParameters()->Num_z_planes;
842 const Double_t* rmin = pcon->GetOriginalParameters()->Rmin;
843 const Double_t* rmax = pcon->GetOriginalParameters()->Rmax;
844 const Double_t* z = pcon->GetOriginalParameters()->Z_values;
845 npar = 3 + 3 * nz;
846 par.Set(npar);
847 par.AddAt(pcon->GetStartPhi() / deg, 0);
848 par.AddAt((pcon->GetEndPhi() - pcon->GetStartPhi()) / deg, 1);
849 par.AddAt(pcon->GetOriginalParameters()->Num_z_planes, 2);
850 for (Int_t i = 0; i < nz; i++) {
851 if (!isReflected)
852 par.AddAt(z[i] / cm, 3 + 3 * i);
853 else
854 par.AddAt(-z[i] / cm, 3 + 3 * i);
855 par.AddAt(rmin[i] / cm, 3 + 3 * i + 1);
856 par.AddAt(rmax[i] / cm, 3 + 3 * i + 2);
857 }
858 return kTRUE;
859 }
860
861 if (solid->GetEntityType() == "G4Polyhedra") {
862 shapeType = "PGON";
863 G4Polyhedra* pgon = (G4Polyhedra*)solid;
864 Int_t nz = pgon->GetOriginalParameters()->Num_z_planes;
865 const Double_t* rmin = pgon->GetOriginalParameters()->Rmin;
866 const Double_t* rmax = pgon->GetOriginalParameters()->Rmax;
867 const Double_t* z = pgon->GetOriginalParameters()->Z_values;
868 npar = 4 + 3 * nz;
869 par.Set(npar);
870 par.AddAt(pgon->GetStartPhi() / deg, 0);
871 par.AddAt((pgon->GetEndPhi() - pgon->GetStartPhi()) / deg, 1);
872 par.AddAt(pgon->GetOriginalParameters()->numSide, 2);
873 par.AddAt(pgon->GetOriginalParameters()->Num_z_planes, 3);
874 for (Int_t i = 0; i < nz; i++) {
875 if (!isReflected)
876 par.AddAt(z[i] / cm, 4 + 3 * i);
877 else
878 par.AddAt(-z[i] / cm, 4 + 3 * i);
879 par.AddAt(rmin[i] / cm, 4 + 3 * i + 1);
880 par.AddAt(rmax[i] / cm, 4 + 3 * i + 2);
881 }
882 return kTRUE;
883 }
884
885 if (solid->GetEntityType() == "G4Sphere") {
886 shapeType = "SPHE";
887 npar = 6;
888 par.Set(npar);
889 G4Sphere* sphe = (G4Sphere*)solid;
890 par.AddAt(sphe->GetInnerRadius() / cm, 0);
891 par.AddAt(sphe->GetOuterRadius() / cm, 1);
892 if (!isReflected)
893 par.AddAt(sphe->GetStartThetaAngle() / deg, 2);
894 else
895 par.AddAt((M_PI - sphe->GetStartThetaAngle()) / deg, 2);
896 par.AddAt(sphe->GetStartPhiAngle() / deg, 3);
897 par.AddAt(sphe->GetStartPhiAngle() / deg, 4);
898 par.AddAt(sphe->GetDeltaPhiAngle() / deg, 5);
899 return kTRUE;
900 }
901
902 // Add G4Torus
903
904 if (solid->GetEntityType() == "G4Trap") {
905 shapeType = "TRAP";
906 npar = 11;
907 par.Set(npar);
908 G4Trap* trap = (G4Trap*)solid;
909 par.AddAt(trap->GetZHalfLength() / cm, 0);
910 if (!isReflected) {
911 par.AddAt(trap->GetSymAxis().theta() / deg, 1);
912 par.AddAt(trap->GetSymAxis().phi() / deg, 2);
913 par.AddAt(trap->GetYHalfLength1() / cm, 3);
914 par.AddAt(trap->GetXHalfLength1() / cm, 4);
915 par.AddAt(trap->GetXHalfLength2() / cm, 5);
916 par.AddAt(atan(trap->GetTanAlpha1()) / deg, 6);
917 par.AddAt(trap->GetYHalfLength2() / cm, 7);
918 par.AddAt(trap->GetXHalfLength3() / cm, 8);
919 par.AddAt(trap->GetXHalfLength4() / cm, 9);
920 }
921 else {
922 par.AddAt(-(trap->GetSymAxis().theta()) / deg, 1);
923 par.AddAt(-(trap->GetSymAxis().phi()) / deg, 2);
924 par.AddAt(trap->GetYHalfLength2() / cm, 3);
925 par.AddAt(trap->GetXHalfLength3() / cm, 4);
926 par.AddAt(trap->GetXHalfLength4() / cm, 5);
927 par.AddAt(atan(trap->GetTanAlpha2()) / deg, 6);
928 par.AddAt(trap->GetYHalfLength1() / cm, 7);
929 par.AddAt(trap->GetXHalfLength1() / cm, 8);
930 par.AddAt(trap->GetXHalfLength2() / cm, 9);
931 par.AddAt(atan(trap->GetTanAlpha1()) / deg, 10);
932 }
933 return kTRUE;
934 }
935
936 if (solid->GetEntityType() == "G4Trd") {
937 shapeType = "TRD2";
938 npar = 5;
939 par.Set(npar);
940 G4Trd* trd2 = (G4Trd*)solid;
941 if (!isReflected) {
942 par.AddAt(trd2->GetXHalfLength1() / cm, 0);
943 par.AddAt(trd2->GetXHalfLength2() / cm, 1);
944 par.AddAt(trd2->GetYHalfLength1() / cm, 2);
945 par.AddAt(trd2->GetYHalfLength2() / cm, 3);
946 }
947 else {
948 par.AddAt(trd2->GetXHalfLength2() / cm, 0);
949 par.AddAt(trd2->GetXHalfLength1() / cm, 1);
950 par.AddAt(trd2->GetYHalfLength2() / cm, 2);
951 par.AddAt(trd2->GetYHalfLength1() / cm, 3);
952 }
953 par.AddAt(trd2->GetZHalfLength() / cm, 4);
954 return kTRUE;
955 }
956
957 if (solid->GetEntityType() == "G4Tubs") {
958 shapeType = "TUBS";
959 npar = 5;
960 par.Set(npar);
961 G4Tubs* tubs = (G4Tubs*)solid;
962 par.AddAt(tubs->GetInnerRadius() / cm, 0);
963 par.AddAt(tubs->GetOuterRadius() / cm, 1);
964 par.AddAt(tubs->GetZHalfLength() / cm, 2);
965 par.AddAt(tubs->GetStartPhiAngle() / deg, 3);
966 par.AddAt(tubs->GetDeltaPhiAngle() / deg, 4);
967 return kTRUE;
968 }
969
970 // To do: add to VGM
971 if (solid->GetEntityType() == "G4TwistedTrap") {
972 shapeType = "GTRA";
973 npar = 12;
974 par.Set(npar);
975 G4TwistedTrap* trap = (G4TwistedTrap*)solid;
976 par.AddAt(trap->GetZHalfLength() / cm, 0);
977 if (!isReflected) {
978 par.AddAt(trap->GetPolarAngleTheta() / deg, 1);
979 par.AddAt(trap->GetAzimuthalAnglePhi() / deg, 2);
980 par.AddAt(trap->GetY1HalfLength() / cm, 3);
981 par.AddAt(trap->GetX1HalfLength() / cm, 4);
982 par.AddAt(trap->GetX2HalfLength() / cm, 5);
983 par.AddAt(trap->GetTiltAngleAlpha() / deg, 6);
984 par.AddAt(trap->GetY2HalfLength() / cm, 7);
985 par.AddAt(trap->GetX3HalfLength() / cm, 8);
986 par.AddAt(trap->GetX4HalfLength() / cm, 9);
987 par.AddAt(trap->GetTiltAngleAlpha() / deg, 10);
988 }
989 else {
990 par.AddAt(-trap->GetPolarAngleTheta() / deg, 1);
991 par.AddAt(-trap->GetAzimuthalAnglePhi() / deg, 2);
992 par.AddAt(trap->GetY2HalfLength() / cm, 3);
993 par.AddAt(trap->GetX3HalfLength() / cm, 4);
994 par.AddAt(trap->GetX4HalfLength() / cm, 5);
995 par.AddAt(trap->GetTiltAngleAlpha() / deg, 6);
996 par.AddAt(trap->GetY1HalfLength() / cm, 7);
997 par.AddAt(trap->GetX1HalfLength() / cm, 8);
998 par.AddAt(trap->GetX2HalfLength() / cm, 9);
999 par.AddAt(trap->GetTiltAngleAlpha() / deg, 10);
1000 }
1001 par.AddAt(trap->GetPhiTwist() / deg, 11);
1002 return kTRUE;
1003 }
1004
1005 TG4Globals::Warning("TG4MCGeometry", "GetShape",
1006 "Shape " + TString(solid->GetEntityType()) + " not implemented.");
1007 return false;
1008}
1009
1010//_____________________________________________________________________________
1011Bool_t TG4MCGeometry::GetMaterial(const TString& volumeName, TString& name,
1012 Int_t& imat, Double_t& a, Double_t& z, Double_t& density, Double_t& radl,
1013 Double_t& inter, TArrayD& par)
1014{
1017
1018 // Get volume
1019 G4LogicalVolume* lv =
1020 fGeometryServices->FindLogicalVolume(volumeName.Data(), true);
1021 if (!lv) {
1022 TG4Globals::Warning("TG4MCGeometry", "GetMaterial",
1023 "Logical volume " + volumeName + " does not exist.");
1024 return false;
1025 }
1026
1027 G4Material* material = lv->GetMaterial();
1028 imat = material->GetIndex();
1029 name = material->GetName();
1030 a = fGeometryServices->GetEffA(material);
1031 z = fGeometryServices->GetEffZ(material);
1032
1033 density = material->GetDensity();
1034 density /= TG4G3Units::MassDensity();
1035
1036 radl = material->GetRadlen();
1037 radl /= TG4G3Units::Length();
1038
1039 // the following parameters are not defined in Geant4
1040 inter = 0.;
1041 par.Set(0);
1042 return true;
1043}
1044
1045//_____________________________________________________________________________
1046Bool_t TG4MCGeometry::GetMedium(const TString& volumeName, TString& name,
1047 Int_t& imed, Int_t& nmat, Int_t& isvol, Int_t& ifield, Double_t& fieldm,
1048 Double_t& tmaxfd, Double_t& stemax, Double_t& deemax, Double_t& epsil,
1049 Double_t& stmin, TArrayD& par)
1050{
1053
1054 // Get volume
1055 G4LogicalVolume* lv =
1056 fGeometryServices->FindLogicalVolume(volumeName.Data(), true);
1057 if (!lv) {
1058 TG4Globals::Warning("TG4MCGeometry", "GetMaterial",
1059 "Logical volume " + volumeName + " does not exist.");
1060 return false;
1061 }
1062
1063 imed = fGeometryServices->GetMediumId(lv);
1064 nmat = lv->GetMaterial()->GetIndex();
1065
1066 TG4Limits* limits = fGeometryServices->GetLimits(lv->GetUserLimits());
1067 if (limits) {
1068 name = limits->GetName();
1069 stemax = limits->GetMaxUserStep();
1070 }
1071 else
1072 stemax = 0.;
1073
1074 // the following parameters are not defined in Geant4
1075 isvol = 0;
1076 ifield = 0;
1077 fieldm = 0;
1078 tmaxfd = 0.;
1079 deemax = 0.;
1080 epsil = 0.;
1081 stmin = 0.;
1082 par.Set(0);
1083
1084 return true;
1085}
1086
1087//_____________________________________________________________________________
1088Int_t TG4MCGeometry::MediumId(const Text_t* mediumName) const
1089{
1091
1093 TG4Medium* medium = mediumMap->GetMedium(G4String(mediumName), false);
1094
1095 if (!medium) {
1096 TG4Globals::Warning("TG4MCGeometry", "MediumId",
1097 "Medium " + TString(mediumName) + " not found.");
1098 return 0;
1099 }
1100
1101 return medium->GetID();
1102}
1103
1104//
1105// Not implemented functions
1106//
1107
1108//_____________________________________________________________________________
1109Int_t TG4MCGeometry::VolId(const Text_t* /*volName*/) const
1110{
1112
1113 TG4Globals::Exception("TG4MCGeometry", "VolId", "Not implemented.");
1114 return 0;
1115}
1116
1117//_____________________________________________________________________________
1118const char* TG4MCGeometry::VolName(Int_t /*id*/) const
1119{
1121
1122 TG4Globals::Exception("TG4MCGeometry", "VolName", "Not implemented.");
1123 return "";
1124}
1125
1126//_____________________________________________________________________________
1128{
1130
1131 TG4Globals::Exception("TG4MCGeometry", "NofVolumes", "Not implemented.");
1132 return 0;
1133}
1134
1135//_____________________________________________________________________________
1136Int_t TG4MCGeometry::NofVolDaughters(const char* /*volName*/) const
1137{
1139
1140 TG4Globals::Exception("TG4MCGeometry", "NofVolDaughters", "Not implemented.");
1141 return 0;
1142}
1143
1144//_____________________________________________________________________________
1146 const char* /*volName*/, Int_t /*i*/) const
1147{
1149
1150 TG4Globals::Exception("TG4MCGeometry", "VolDaughterName", "Not implemented.");
1151 return "";
1152}
1153
1154//_____________________________________________________________________________
1156 const char* /*volName*/, Int_t /*i*/) const
1157{
1159
1161 "TG4MCGeometry", "VolDaughterCopyNo", "Not implemented.");
1162 return 0;
1163}
1164
1165//_____________________________________________________________________________
1166Int_t TG4MCGeometry::VolId2Mate(Int_t /*id*/) const
1167{
1169
1170 TG4Globals::Exception("TG4MCGeometry", "VolId2Mate", "Not implemented.");
1171 return 0;
1172}
Definition of the TG4G3ControlVector class.
Definition of the TG4G3CutVector class.
Definition of the TG4G3Units class.
Definition of the TG4GeometryServices class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4Limits class.
Definition of the TG4MCGeometry class.
Definition of the TG4Medium class.
static G4double Length()
Definition TG4G3Units.h:81
static G4double MassDensity()
Definition TG4G3Units.h:117
G4VPhysicalVolume * GetWorld() const
G4String CutVolumePath(const G4String &volumePath, G4String &volName, G4int &copyNo) const
G4Material * FindMaterial(G4double a, G4double z, G4double density) const
G4int GetMediumId(G4LogicalVolume *lv) const
G4double * CreateG4doubleArray(Float_t *array, G4int size, G4bool copyValues=true) const
G4LogicalVolume * FindLogicalVolume(const G4String &name, G4bool silent=false) const
G4String CutName(const char *name) const
static TG4GeometryServices * Instance()
G4VPhysicalVolume * FindPhysicalVolume(const G4String &name, G4int copyNo, G4bool silent=false) const
TG4Limits * GetLimits(G4UserLimits *limits) const
G4VPhysicalVolume * FindDaughter(const G4String &name, G4int copyNo, G4LogicalVolume *mlv, G4bool silent=false) const
G4double GetEffA(G4Material *material) const
G4String CutMaterialName(const char *name) const
TG4MediumMap * GetMediumMap() const
void Convert(const G4Transform3D &transform, TGeoHMatrix &matrix) const
G4double GetEffZ(G4Material *material) const
static void Warning(const TString &className, const TString &methodName, const TString &text)
static void Exception(const TString &className, const TString &methodName, const TString &text)
Extended G4UserLimits class.
Definition TG4Limits.h:38
G4String GetName() const
Definition TG4Limits.h:129
G4double GetMaxUserStep() const
Definition TG4Limits.h:135
virtual Int_t VolId(const Text_t *volName) const
virtual void Gsbool(const char *onlyVolName, const char *manyVolName)
virtual void Material(Int_t &kmat, const char *name, Double_t a, Double_t z, Double_t dens, Double_t radl, Double_t absl, Float_t *buf, Int_t nwbuf)
virtual Bool_t GetMaterial(const TString &volumeName, TString &name, Int_t &imat, Double_t &a, Double_t &z, Double_t &density, Double_t &radl, Double_t &inter, TArrayD &par)
virtual const char * VolDaughterName(const char *volName, Int_t i) const
virtual void Gspos(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, const char *konly)
virtual void Gsposp(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, const char *konly, Double_t *upar, Int_t np)
virtual void Matrix(Int_t &krot, Double_t thetaX, Double_t phiX, Double_t thetaY, Double_t phiY, Double_t thetaZ, Double_t phiZ)
TG4GeometryServices * fGeometryServices
geometry services
virtual void Mixture(Int_t &kmat, const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat)
virtual void Gsdvt(const char *name, const char *mother, Double_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
virtual void Gsord(const char *name, Int_t iax)
virtual Int_t NofVolumes() const
virtual Int_t Gsvolu(const char *name, const char *shape, Int_t nmed, Double_t *upar, Int_t np)
virtual ~TG4MCGeometry()
virtual void Gsdvn(const char *name, const char *mother, Int_t ndiv, Int_t iaxis)
virtual void Gsdvn2(const char *name, const char *mother, Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed)
virtual Bool_t GetShape(const TString &volumePath, TString &shapeType, TArrayD &par)
virtual Int_t MediumId(const Text_t *mediumName) const
virtual Bool_t GetTransformation(const TString &volumePath, TGeoHMatrix &matrix)
virtual Int_t VolId2Mate(Int_t id) const
virtual void Medium(Int_t &kmed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin, Float_t *ubuf, Int_t nbuf)
virtual Bool_t GetMedium(const TString &volumeName, TString &name, Int_t &imed, Int_t &nmat, Int_t &isvol, Int_t &ifield, Double_t &fieldm, Double_t &tmaxfd, Double_t &stemax, Double_t &deemax, Double_t &epsil, Double_t &stmin, TArrayD &par)
virtual Int_t VolDaughterCopyNo(const char *volName, Int_t i) const
virtual const char * VolName(Int_t id) const
virtual void Gsdvt2(const char *name, const char *mother, Double_t step, Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx)
virtual Int_t NofVolDaughters(const char *volName) const
virtual void Ggclos()
TG4StringVector fMaterialNameVector
vector of material names sorted in the order of materials in G3Mat
The map of media to logical volumes.
TG4Medium * AddMedium(G4int mediumID, G4bool warn=true)
TG4Medium * GetMedium(G4int mediumID, G4bool warn=true) const
Helper class to keep medium data.
Definition TG4Medium.h:29
G4int GetID() const
Definition TG4Medium.h:84
void SetIfield(G4int ifield)
Definition TG4Medium.h:79
void SetName(const G4String &name)
Definition TG4Medium.cxx:55
Base class for defining the verbose level and a common messenger.
Definition TG4Verbose.h:36
virtual G4int VerboseLevel() const
Definition TG4Verbose.h:78