32#include "TGeoManager.h"
33#include "TGeoMatrix.h"
34#include "TGeoVolume.h"
41#include "TGeoSphere.h"
89 new TGeoManager(
"TGeo",
"Root geometry manager");
100 Double_t *doubleArray;
102 doubleArray =
new Double_t[size];
103 for (Int_t i = 0; i < size; i++)
104 doubleArray[i] = array[i];
107 doubleArray =
new Double_t[1];
120 Int_t l = strlen(name);
123 for (i = 0; i < l; i++)
124 vname[i] = toupper(name[i]);
125 for (i = l; i < 4; i++)
129 Int_t l = strlen(name);
132 for (Int_t i = 0; i < l; i++)
161 Double_t absl, Float_t *buf, Int_t nwbuf)
164 Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf);
187 Double_t absl, Double_t * , Int_t )
213 Mixture(kmat, name, da, dz, dens, nlmat, dwmat);
214 for (Int_t i = 0; i < TMath::Abs(nlmat); i++) {
246 for (i = 0; i < nlmat; i++) {
247 amol += a[i] * wmat[i];
249 for (i = 0; i < nlmat; i++) {
250 wmat[i] *= a[i] / amol;
280 Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin,
281 Float_t *ubuf, Int_t nbuf)
285 Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin, dubuf, nbuf);
313 Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin,
316 GetTGeoManager()->Medium(name, kmed, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
335 GetTGeoManager()->Matrix(krot, thex, phix, they, phiy, thez, phiz);
351 Int_t
id =
Gsvolu(name, shape, nmed, dupar, npar);
371 Vname(shape, vshape);
373 TGeoVolume *vol =
GetTGeoManager()->Volume(vname, vshape, nmed, upar, npar);
375 Fatal(
"Gsvolu",
"Could not create volume %s", name);
378 return vol->GetNumber();
397 Vname(mother, vmother);
399 GetTGeoManager()->Division(vname, vmother, iaxis, ndiv, 0, 0, 0,
"n");
415 Vname(mother, vmother);
417 GetTGeoManager()->Division(vname, vmother, iaxis, ndiv, c0i, 0, numed,
"nx");
437 Vname(mother, vmother);
439 GetTGeoManager()->Division(vname, vmother, iaxis, 0, 0, step, numed,
"s");
460 Vname(mother, vmother);
462 GetTGeoManager()->Division(vname, vmother, iaxis, 0, c0, step, numed,
"sx");
502 Int_t irot,
const char *konly)
504 TString only = konly;
506 Bool_t isOnly = kFALSE;
507 if (only.Contains(
"only"))
512 Vname(mother, vmother);
515 GetTGeoManager()->Node(vname, nr, vmother, x, y, z, irot, isOnly, upar);
524 Int_t irot,
const char *konly, Float_t *upar, Int_t np)
527 Gsposp(name, nr, mother, x, y, z, irot, konly, dupar, np);
537 Int_t irot,
const char *konly, Double_t *upar, Int_t np)
539 TString only = konly;
541 Bool_t isOnly = kFALSE;
542 if (only.Contains(
"only"))
547 Vname(mother, vmother);
549 GetTGeoManager()->Node(vname, nr, vmother, x, y, z, irot, isOnly, upar, np);
560 printf(
"VolId: Volume %s not found\n", name);
574 return medium->GetId();
576 printf(
"MediumId: Medium %s not found\n", name);
588 Error(
"VolName",
"volume with id=%d does not exist",
id);
591 return volume->GetName();
600 return GetTGeoManager()->GetListOfUVolumes()->GetEntriesFast() - 1;
612 Error(
"NofVolDaughters",
"Volume %s not found.", volName);
616 return volume->GetNdaughters();
628 Error(
"VolDaughterName",
"Volume %s not found.", volName);
633 if (i < 0 || i >= volume->GetNdaughters()) {
634 Error(
"VolDaughterName",
"Volume %s Index out of limits", volName);
639 return volume->GetNode(i)->GetVolume()->GetName();
651 Error(
"VolDaughterName",
"Volume %s not found.", volName);
656 if (i < 0 || i >= volume->GetNdaughters()) {
657 Error(
"VolDaughterName",
"Volume %s Index out of limits", volName);
662 return volume->GetNode(i)->GetNumber();
673 Error(
"VolId2Mate",
"volume with id=%d does not exist",
id);
676 TGeoMedium *med = volume->GetMedium();
740 TGeoShape *shape = vol->GetShape();
741 TClass *class_type = shape->IsA();
742 if (class_type == TGeoBBox::Class()) {
746 TGeoBBox *box = (TGeoBBox *)shape;
747 par.AddAt(box->GetDX(), 0);
748 par.AddAt(box->GetDY(), 1);
749 par.AddAt(box->GetDZ(), 2);
752 if (class_type == TGeoTrd1::Class()) {
756 TGeoTrd1 *trd1 = (TGeoTrd1 *)shape;
757 par.AddAt(trd1->GetDx1(), 0);
758 par.AddAt(trd1->GetDx2(), 1);
759 par.AddAt(trd1->GetDy(), 2);
760 par.AddAt(trd1->GetDz(), 3);
763 if (class_type == TGeoTrd2::Class()) {
767 TGeoTrd2 *trd2 = (TGeoTrd2 *)shape;
768 par.AddAt(trd2->GetDx1(), 0);
769 par.AddAt(trd2->GetDx2(), 1);
770 par.AddAt(trd2->GetDy1(), 2);
771 par.AddAt(trd2->GetDy2(), 3);
772 par.AddAt(trd2->GetDz(), 4);
775 if (class_type == TGeoTrap::Class()) {
779 TGeoTrap *trap = (TGeoTrap *)shape;
780 Double_t tth = TMath::Tan(trap->GetTheta() * TMath::DegToRad());
781 par.AddAt(trap->GetDz(), 0);
782 par.AddAt(tth * TMath::Cos(trap->GetPhi() * TMath::DegToRad()), 1);
783 par.AddAt(tth * TMath::Sin(trap->GetPhi() * TMath::DegToRad()), 2);
784 par.AddAt(trap->GetH1(), 3);
785 par.AddAt(trap->GetBl1(), 4);
786 par.AddAt(trap->GetTl1(), 5);
787 par.AddAt(TMath::Tan(trap->GetAlpha1() * TMath::DegToRad()), 6);
788 par.AddAt(trap->GetH2(), 7);
789 par.AddAt(trap->GetBl2(), 8);
790 par.AddAt(trap->GetTl2(), 9);
791 par.AddAt(TMath::Tan(trap->GetAlpha2() * TMath::DegToRad()), 10);
794 if (class_type == TGeoTube::Class()) {
798 TGeoTube *tube = (TGeoTube *)shape;
799 par.AddAt(tube->GetRmin(), 0);
800 par.AddAt(tube->GetRmax(), 1);
801 par.AddAt(tube->GetDz(), 2);
804 if (class_type == TGeoTubeSeg::Class()) {
808 TGeoTubeSeg *tubs = (TGeoTubeSeg *)shape;
809 par.AddAt(tubs->GetRmin(), 0);
810 par.AddAt(tubs->GetRmax(), 1);
811 par.AddAt(tubs->GetDz(), 2);
812 par.AddAt(tubs->GetPhi1(), 3);
813 par.AddAt(tubs->GetPhi2(), 4);
816 if (class_type == TGeoCone::Class()) {
820 TGeoCone *cone = (TGeoCone *)shape;
821 par.AddAt(cone->GetDz(), 0);
822 par.AddAt(cone->GetRmin1(), 1);
823 par.AddAt(cone->GetRmax1(), 2);
824 par.AddAt(cone->GetRmin2(), 3);
825 par.AddAt(cone->GetRmax2(), 4);
828 if (class_type == TGeoConeSeg::Class()) {
832 TGeoConeSeg *cons = (TGeoConeSeg *)shape;
833 par.AddAt(cons->GetDz(), 0);
834 par.AddAt(cons->GetRmin1(), 1);
835 par.AddAt(cons->GetRmax1(), 2);
836 par.AddAt(cons->GetRmin2(), 3);
837 par.AddAt(cons->GetRmax2(), 4);
838 par.AddAt(cons->GetPhi1(), 5);
839 par.AddAt(cons->GetPhi2(), 6);
842 if (class_type == TGeoSphere::Class()) {
846 TGeoSphere *sphe = (TGeoSphere *)shape;
847 par.AddAt(sphe->GetRmin(), 0);
848 par.AddAt(sphe->GetRmax(), 1);
849 par.AddAt(sphe->GetTheta1(), 2);
850 par.AddAt(sphe->GetTheta2(), 3);
851 par.AddAt(sphe->GetPhi1(), 4);
852 par.AddAt(sphe->GetPhi2(), 5);
855 if (class_type == TGeoPara::Class()) {
859 TGeoPara *para = (TGeoPara *)shape;
860 par.AddAt(para->GetX(), 0);
861 par.AddAt(para->GetY(), 1);
862 par.AddAt(para->GetZ(), 2);
863 par.AddAt(para->GetTxy(), 3);
864 par.AddAt(para->GetTxz(), 4);
865 par.AddAt(para->GetTyz(), 5);
868 if (class_type == TGeoPgon::Class()) {
870 TGeoPgon *pgon = (TGeoPgon *)shape;
871 Int_t nz = pgon->GetNz();
872 const Double_t *rmin = pgon->GetRmin();
873 const Double_t *rmax = pgon->GetRmax();
874 const Double_t *z = pgon->GetZ();
877 par.AddAt(pgon->GetPhi1(), 0);
878 par.AddAt(pgon->GetDphi(), 1);
879 par.AddAt(pgon->GetNedges(), 2);
880 par.AddAt(pgon->GetNz(), 3);
881 for (Int_t i = 0; i < nz; i++) {
882 par.AddAt(z[i], 4 + 3 * i);
883 par.AddAt(rmin[i], 4 + 3 * i + 1);
884 par.AddAt(rmax[i], 4 + 3 * i + 2);
888 if (class_type == TGeoPcon::Class()) {
890 TGeoPcon *pcon = (TGeoPcon *)shape;
891 Int_t nz = pcon->GetNz();
892 const Double_t *rmin = pcon->GetRmin();
893 const Double_t *rmax = pcon->GetRmax();
894 const Double_t *z = pcon->GetZ();
897 par.AddAt(pcon->GetPhi1(), 0);
898 par.AddAt(pcon->GetDphi(), 1);
899 par.AddAt(pcon->GetNz(), 2);
900 for (Int_t i = 0; i < nz; i++) {
901 par.AddAt(z[i], 3 + 3 * i);
902 par.AddAt(rmin[i], 3 + 3 * i + 1);
903 par.AddAt(rmax[i], 3 + 3 * i + 2);
907 if (class_type == TGeoEltu::Class()) {
911 TGeoEltu *eltu = (TGeoEltu *)shape;
912 par.AddAt(eltu->GetA(), 0);
913 par.AddAt(eltu->GetB(), 1);
914 par.AddAt(eltu->GetDz(), 2);
917 if (class_type == TGeoHype::Class()) {
921 TGeoHype *hype = (TGeoHype *)shape;
922 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0., kTRUE)), 0);
923 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0., kFALSE)), 1);
924 par.AddAt(hype->GetDZ(), 2);
925 par.AddAt(hype->GetStIn(), 3);
926 par.AddAt(hype->GetStOut(), 4);
929 if (class_type == TGeoGtra::Class()) {
933 TGeoGtra *trap = (TGeoGtra *)shape;
934 Double_t tth = TMath::Tan(trap->GetTheta() * TMath::DegToRad());
935 par.AddAt(trap->GetDz(), 0);
936 par.AddAt(tth * TMath::Cos(trap->GetPhi() * TMath::DegToRad()), 1);
937 par.AddAt(tth * TMath::Sin(trap->GetPhi() * TMath::DegToRad()), 2);
938 par.AddAt(trap->GetH1(), 3);
939 par.AddAt(trap->GetBl1(), 4);
940 par.AddAt(trap->GetTl1(), 5);
941 par.AddAt(TMath::Tan(trap->GetAlpha1() * TMath::DegToRad()), 6);
942 par.AddAt(trap->GetH2(), 7);
943 par.AddAt(trap->GetBl2(), 8);
944 par.AddAt(trap->GetTl2(), 9);
945 par.AddAt(TMath::Tan(trap->GetAlpha2() * TMath::DegToRad()), 10);
946 par.AddAt(trap->GetTwistAngle(), 11);
949 if (class_type == TGeoCtub::Class()) {
953 TGeoCtub *ctub = (TGeoCtub *)shape;
954 const Double_t *lx = ctub->GetNlow();
955 const Double_t *tx = ctub->GetNhigh();
956 par.AddAt(ctub->GetRmin(), 0);
957 par.AddAt(ctub->GetRmax(), 1);
958 par.AddAt(ctub->GetDz(), 2);
959 par.AddAt(ctub->GetPhi1(), 3);
960 par.AddAt(ctub->GetPhi2(), 4);
966 par.AddAt(tx[2], 10);
969 Error(
"GetShape",
"Getting shape parameters for shape %s not implemented", shape->ClassName());
995 Double_t &dens, Double_t &radl, Double_t &inter, TArrayD &par)
1000 TGeoMedium *med = vol->GetMedium();
1003 TGeoMaterial *mat = med->GetMaterial();
1004 imat = mat->GetUniqueID();
1005 name = mat->GetName();
1006 name = name.Strip(TString::kTrailing,
'$');
1009 dens = mat->GetDensity();
1010 radl = mat->GetRadLen();
1011 inter = mat->GetIntLen();
1041 Int_t &ifield, Double_t &fieldm, Double_t &tmaxfd, Double_t &stemax, Double_t &deemax,
1042 Double_t &epsil, Double_t &stmin, TArrayD &par)
1044 TGeoVolume *vol =
GetTGeoManager()->GetVolume(volumeName.Data());
1047 TGeoMedium *med = vol->GetMedium();
1050 TGeoMaterial *mat = med->GetMaterial();
1051 nmat = mat->GetUniqueID();
1052 imed = med->GetId();
1053 name = med->GetName();
1054 name = name.Strip(TString::kTrailing,
'$');
1056 isvol = (Int_t)med->GetParam(0);
1057 ifield = (Int_t)med->GetParam(1);
1058 fieldm = med->GetParam(2);
1059 tmaxfd = med->GetParam(3);
1060 stemax = med->GetParam(4);
1061 deemax = med->GetParam(5);
1062 epsil = med->GetParam(6);
1063 stmin = med->GetParam(7);
Implementation of the TVirtualMCGeometry interface for building TGeo geometry.
virtual Int_t VolId(const char *volName) const
Return the unique numeric identifier for volume name.
virtual Int_t VolId2Mate(Int_t id) const
Return material number for a given volume id.
virtual void Gsdvt(const char *name, const char *mother, Double_t step, Int_t iaxis, Int_t numed, Int_t ndvmx)
Create a new volume by dividing an existing one.
virtual Bool_t GetShape(const TString &volumePath, TString &shapeType, TArrayD &par)
Returns the shape and its parameters for the volume specified by volumeName.
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, Float_t *upar, Int_t np)
Place a copy of generic volume name with user number nr inside mother, with its parameters upar(1....
virtual Int_t NofVolumes() const
Return total number of volumes in the geometry.
virtual void Mixture(Int_t &kmat, const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nlmat, Float_t *wmat)
Define a mixture or a compound with a number kmat composed by the basic nlmat materials defined by ar...
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)
Define a medium.
virtual void Gsord(const char *name, Int_t iax)
Flag volume name whose contents will have to be ordered along axis iax, by setting the search flag to...
virtual void Matrix(Int_t &krot, Double_t thetaX, Double_t phiX, Double_t thetaY, Double_t phiY, Double_t thetaZ, Double_t phiZ)
Define a rotation matrix.
virtual void Gsdvn(const char *name, const char *mother, Int_t ndiv, Int_t iaxis)
Create a new volume by dividing an existing one.
virtual void Gsdvt2(const char *name, const char *mother, Double_t step, Int_t iaxis, Double_t c0, Int_t numed, Int_t ndvmx)
Create a new volume by dividing an existing one.
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)
Position a volume into an existing one.
static TGeoMCGeometry * fgInstance
Singleton instance.
virtual Int_t VolDaughterCopyNo(const char *volName, Int_t i) const
Return the copyNo of i-th daughters of the volume specified by volName According to A.
virtual Int_t NofVolDaughters(const char *volName) const
Return number of daughters of the volume specified by volName According to A.
void Vname(const char *name, char *vname) const
Convert name to upper case.
virtual const char * VolDaughterName(const char *volName, Int_t i) const
Return the name of i-th daughters of the volume specified by volName According to A.
virtual Bool_t GetTransformation(const TString &volumePath, TGeoHMatrix &matrix)
Return the transformation matrix between the volume specified by the path volumePath and the Top or m...
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)
Returns the Material and its parameters for the volume specified by volumeName.
Bool_t fG3CompatibleVolumeNames
Option to convert volumes names to be compatible with G3.
TGeoManager * GetTGeoManager() const
Return TGeoManager global pointer.
virtual Int_t Gsvolu(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t np)
Create a new volume.
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)
Returns the Medium and its parameters for the volume specified by volumeName.
virtual const char * VolName(Int_t id) const
Return the volume name given the volume identifier.
virtual Int_t MediumId(const char *mediumName) const
Return the unique numeric identifier for medium name.
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)
Define a material.
virtual void Gsdvn2(const char *name, const char *mother, Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed)
Create a new volume by dividing an existing one.
virtual ~TGeoMCGeometry()
Destructor.
TGeoMCGeometry()
Default constructor.
Double_t * CreateDoubleArray(Float_t *array, Int_t size) const
Convert Float_t* array to Double_t*, !! The new array has to be deleted by user.
Interface to Monte Carlo geometry construction.