VMC Version 2.0
Loading...
Searching...
No Matches
TGeoMCGeometry.cxx
Go to the documentation of this file.
1
2// -----------------------------------------------------------------------
3// Copyright (C) 2019 CERN and copyright holders of VMC Project.
4// This software is distributed under the terms of the GNU General Public
5// License v3 (GPL Version 3), copied verbatim in the file "LICENSE".
6//
7// See https://github.com/vmc-project/vmc for full licensing information.
8// -----------------------------------------------------------------------
9
10// Authors: Alice collaboration 25/06/2002
11
12/*************************************************************************
13 * Copyright (C) 2006, Rene Brun and Fons Rademakers. *
14 * Copyright (C) 2002, ALICE Experiment at CERN. *
15 * All rights reserved. *
16 * *
17 * For the licensing terms see $ROOTSYS/LICENSE. *
18 * For the list of contributors see $ROOTSYS/README/CREDITS. *
19 *************************************************************************/
20
27#include <ctype.h>
28#include "TError.h"
29#include "TArrayD.h"
30
31#include "TGeoMCGeometry.h"
32#include "TGeoManager.h"
33#include "TGeoMatrix.h"
34#include "TGeoVolume.h"
35#include "TGeoArb8.h"
36#include "TGeoTrd1.h"
37#include "TGeoTrd2.h"
38#include "TGeoTube.h"
39#include "TGeoCone.h"
40#include "TGeoPgon.h"
41#include "TGeoSphere.h"
42#include "TGeoPara.h"
43#include "TGeoEltu.h"
44#include "TGeoHype.h"
45#include "TMath.h"
46
48
50
55
56TGeoMCGeometry::TGeoMCGeometry(const char *name, const char *title, Bool_t g3CompatibleVolumeNames)
57 : TVirtualMCGeometry(name, title), fG3CompatibleVolumeNames(g3CompatibleVolumeNames)
58{
59}
60
65
66TGeoMCGeometry::TGeoMCGeometry() : TVirtualMCGeometry(), fG3CompatibleVolumeNames(kFALSE) {}
67
72
74{
75 fgInstance = 0;
76}
77
78//
79// private methods
80//
81
85
87{
88 if (!gGeoManager)
89 new TGeoManager("TGeo", "Root geometry manager");
90
91 return gGeoManager;
92}
93
97
98Double_t *TGeoMCGeometry::CreateDoubleArray(Float_t *array, Int_t size) const
99{
100 Double_t *doubleArray;
101 if (size > 0) {
102 doubleArray = new Double_t[size];
103 for (Int_t i = 0; i < size; i++)
104 doubleArray[i] = array[i];
105 } else {
106 // doubleArray = 0;
107 doubleArray = new Double_t[1];
108 }
109 return doubleArray;
110}
111
116
117void TGeoMCGeometry::Vname(const char *name, char *vname) const
118{
120 Int_t l = strlen(name);
121 Int_t i;
122 l = l < 4 ? l : 4;
123 for (i = 0; i < l; i++)
124 vname[i] = toupper(name[i]);
125 for (i = l; i < 4; i++)
126 vname[i] = ' ';
127 vname[4] = 0;
128 } else {
129 Int_t l = strlen(name);
130 if (l >= 79)
131 l = 79;
132 for (Int_t i = 0; i < l; i++)
133 vname[i] = name[i];
134 vname[l] = 0;
135 }
136}
137
138//
139// public methods
140//
141
159
160void TGeoMCGeometry::Material(Int_t &kmat, const char *name, Double_t a, Double_t z, Double_t dens, Double_t radl,
161 Double_t absl, Float_t *buf, Int_t nwbuf)
162{
163 Double_t *dbuf = CreateDoubleArray(buf, nwbuf);
164 Material(kmat, name, a, z, dens, radl, absl, dbuf, nwbuf);
165 delete[] dbuf;
166}
167
185
186void TGeoMCGeometry::Material(Int_t &kmat, const char *name, Double_t a, Double_t z, Double_t dens, Double_t radl,
187 Double_t absl, Double_t * /*buf*/, Int_t /*nwbuf*/)
188{
189 GetTGeoManager()->Material(name, a, z, dens, kmat, radl, absl);
190}
191
205
206void TGeoMCGeometry::Mixture(Int_t &kmat, const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nlmat,
207 Float_t *wmat)
208{
209 Double_t *da = CreateDoubleArray(a, TMath::Abs(nlmat));
210 Double_t *dz = CreateDoubleArray(z, TMath::Abs(nlmat));
211 Double_t *dwmat = CreateDoubleArray(wmat, TMath::Abs(nlmat));
212
213 Mixture(kmat, name, da, dz, dens, nlmat, dwmat);
214 for (Int_t i = 0; i < TMath::Abs(nlmat); i++) {
215 a[i] = da[i];
216 z[i] = dz[i];
217 wmat[i] = dwmat[i];
218 }
219
220 delete[] da;
221 delete[] dz;
222 delete[] dwmat;
223}
224
238
239void TGeoMCGeometry::Mixture(Int_t &kmat, const char *name, Double_t *a, Double_t *z, Double_t dens, Int_t nlmat,
240 Double_t *wmat)
241{
242 if (nlmat < 0) {
243 nlmat = -nlmat;
244 Double_t amol = 0;
245 Int_t i;
246 for (i = 0; i < nlmat; i++) {
247 amol += a[i] * wmat[i];
248 }
249 for (i = 0; i < nlmat; i++) {
250 wmat[i] *= a[i] / amol;
251 }
252 }
253 GetTGeoManager()->Mixture(name, a, z, dens, nlmat, wmat, kmat);
254}
255
278
279void TGeoMCGeometry::Medium(Int_t &kmed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm,
280 Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin,
281 Float_t *ubuf, Int_t nbuf)
282{
283 // printf("Creating mediuma: %s, numed=%d, nmat=%d\n",name,kmed,nmat);
284 Double_t *dubuf = CreateDoubleArray(ubuf, nbuf);
285 Medium(kmed, name, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin, dubuf, nbuf);
286 delete[] dubuf;
287}
288
311
312void TGeoMCGeometry::Medium(Int_t &kmed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm,
313 Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin,
314 Double_t * /*ubuf*/, Int_t /*nbuf*/)
315{
316 GetTGeoManager()->Medium(name, kmed, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
317}
318
330
331void TGeoMCGeometry::Matrix(Int_t &krot, Double_t thex, Double_t phix, Double_t they, Double_t phiy, Double_t thez,
332 Double_t phiz)
333{
334 krot = GetTGeoManager()->GetListOfMatrices()->GetEntriesFast();
335 GetTGeoManager()->Matrix(krot, thex, phix, they, phiy, thez, phiz);
336}
337
347
348Int_t TGeoMCGeometry::Gsvolu(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar)
349{
350 Double_t *dupar = CreateDoubleArray(upar, npar);
351 Int_t id = Gsvolu(name, shape, nmed, dupar, npar);
352 delete[] dupar;
353 return id;
354}
355
365
366Int_t TGeoMCGeometry::Gsvolu(const char *name, const char *shape, Int_t nmed, Double_t *upar, Int_t npar)
367{
368 char vname[80];
369 Vname(name, vname);
370 char vshape[5];
371 Vname(shape, vshape);
372
373 TGeoVolume *vol = GetTGeoManager()->Volume(vname, vshape, nmed, upar, npar);
374 if (!vol) {
375 Fatal("Gsvolu", "Could not create volume %s", name);
376 return -1;
377 }
378 return vol->GetNumber();
379}
380
391
392void TGeoMCGeometry::Gsdvn(const char *name, const char *mother, Int_t ndiv, Int_t iaxis)
393{
394 char vname[80];
395 Vname(name, vname);
396 char vmother[80];
397 Vname(mother, vmother);
398
399 GetTGeoManager()->Division(vname, vmother, iaxis, ndiv, 0, 0, 0, "n");
400}
401
409
410void TGeoMCGeometry::Gsdvn2(const char *name, const char *mother, Int_t ndiv, Int_t iaxis, Double_t c0i, Int_t numed)
411{
412 char vname[80];
413 Vname(name, vname);
414 char vmother[80];
415 Vname(mother, vmother);
416
417 GetTGeoManager()->Division(vname, vmother, iaxis, ndiv, c0i, 0, numed, "nx");
418}
430
431void TGeoMCGeometry::Gsdvt(const char *name, const char *mother, Double_t step, Int_t iaxis, Int_t numed,
432 Int_t /*ndvmx*/)
433{
434 char vname[80];
435 Vname(name, vname);
436 char vmother[80];
437 Vname(mother, vmother);
438
439 GetTGeoManager()->Division(vname, vmother, iaxis, 0, 0, step, numed, "s");
440}
441
453
454void TGeoMCGeometry::Gsdvt2(const char *name, const char *mother, Double_t step, Int_t iaxis, Double_t c0, Int_t numed,
455 Int_t /*ndvmx*/)
456{
457 char vname[80];
458 Vname(name, vname);
459 char vmother[80];
460 Vname(mother, vmother);
461
462 GetTGeoManager()->Division(vname, vmother, iaxis, 0, c0, step, numed, "sx");
463}
464
480
481void TGeoMCGeometry::Gsord(const char * /*name*/, Int_t /*iax*/)
482{
483 // TBC - keep this function
484 // nothing to be done for TGeo //xx
485}
486
500
501void TGeoMCGeometry::Gspos(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z,
502 Int_t irot, const char *konly)
503{
504 TString only = konly;
505 only.ToLower();
506 Bool_t isOnly = kFALSE;
507 if (only.Contains("only"))
508 isOnly = kTRUE;
509 char vname[80];
510 Vname(name, vname);
511 char vmother[80];
512 Vname(mother, vmother);
513
514 Double_t *upar = 0;
515 GetTGeoManager()->Node(vname, nr, vmother, x, y, z, irot, isOnly, upar);
516}
517
522
523void TGeoMCGeometry::Gsposp(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z,
524 Int_t irot, const char *konly, Float_t *upar, Int_t np)
525{
526 Double_t *dupar = CreateDoubleArray(upar, np);
527 Gsposp(name, nr, mother, x, y, z, irot, konly, dupar, np);
528 delete[] dupar;
529}
530
535
536void TGeoMCGeometry::Gsposp(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z,
537 Int_t irot, const char *konly, Double_t *upar, Int_t np)
538{
539 TString only = konly;
540 only.ToLower();
541 Bool_t isOnly = kFALSE;
542 if (only.Contains("only"))
543 isOnly = kTRUE;
544 char vname[80];
545 Vname(name, vname);
546 char vmother[80];
547 Vname(mother, vmother);
548
549 GetTGeoManager()->Node(vname, nr, vmother, x, y, z, irot, isOnly, upar, np);
550}
551
555
556Int_t TGeoMCGeometry::VolId(const char *name) const
557{
558 Int_t uid = GetTGeoManager()->GetUID(name);
559 if (uid < 0) {
560 printf("VolId: Volume %s not found\n", name);
561 return 0;
562 }
563 return uid;
564}
565
569
570Int_t TGeoMCGeometry::MediumId(const char *name) const
571{
572 TGeoMedium *medium = GetTGeoManager()->GetMedium(name);
573 if (medium)
574 return medium->GetId();
575
576 printf("MediumId: Medium %s not found\n", name);
577 return 0;
578}
579
583
584const char *TGeoMCGeometry::VolName(Int_t id) const
585{
586 TGeoVolume *volume = GetTGeoManager()->GetVolume(id);
587 if (!volume) {
588 Error("VolName", "volume with id=%d does not exist", id);
589 return "NULL";
590 }
591 return volume->GetName();
592}
593
597
599{
600 return GetTGeoManager()->GetListOfUVolumes()->GetEntriesFast() - 1;
601}
602
606
607Int_t TGeoMCGeometry::NofVolDaughters(const char *volName) const
608{
609 TGeoVolume *volume = GetTGeoManager()->GetVolume(volName);
610
611 if (!volume) {
612 Error("NofVolDaughters", "Volume %s not found.", volName);
613 return 0;
614 }
615
616 return volume->GetNdaughters();
617}
618
622
623const char *TGeoMCGeometry::VolDaughterName(const char *volName, Int_t i) const
624{
625 // Get volume
626 TGeoVolume *volume = GetTGeoManager()->GetVolume(volName);
627 if (!volume) {
628 Error("VolDaughterName", "Volume %s not found.", volName);
629 return "";
630 }
631
632 // Check index
633 if (i < 0 || i >= volume->GetNdaughters()) {
634 Error("VolDaughterName", "Volume %s Index out of limits", volName);
635 return "";
636 }
637
638 // Return node's volume name
639 return volume->GetNode(i)->GetVolume()->GetName();
640}
641
645
646Int_t TGeoMCGeometry::VolDaughterCopyNo(const char *volName, Int_t i) const
647{
648 // Get volume
649 TGeoVolume *volume = GetTGeoManager()->GetVolume(volName);
650 if (!volume) {
651 Error("VolDaughterName", "Volume %s not found.", volName);
652 return 0;
653 }
654
655 // Check index
656 if (i < 0 || i >= volume->GetNdaughters()) {
657 Error("VolDaughterName", "Volume %s Index out of limits", volName);
658 return 0;
659 }
660
661 // Return node's copyNo
662 return volume->GetNode(i)->GetNumber();
663}
664
668
669Int_t TGeoMCGeometry::VolId2Mate(Int_t id) const
670{
671 TGeoVolume *volume = GetTGeoManager()->GetVolume(id);
672 if (!volume) {
673 Error("VolId2Mate", "volume with id=%d does not exist", id);
674 return 0;
675 }
676 TGeoMedium *med = volume->GetMedium();
677 if (!med)
678 return 0;
679 return med->GetId();
680}
681
702
703Bool_t TGeoMCGeometry::GetTransformation(const TString &volumePath, TGeoHMatrix &mat)
704{
705 // We have to preserve the modeler state
706 GetTGeoManager()->PushPath();
707 if (!GetTGeoManager()->cd(volumePath.Data())) {
708 GetTGeoManager()->PopPath();
709 return kFALSE;
710 }
711 mat = *GetTGeoManager()->GetCurrentMatrix();
712 GetTGeoManager()->PopPath();
713 return kTRUE;
714}
727
728Bool_t TGeoMCGeometry::GetShape(const TString &volumePath, TString &shapeType, TArrayD &par)
729{
730 Int_t npar;
731 GetTGeoManager()->PushPath();
732 if (!GetTGeoManager()->cd(volumePath.Data())) {
733 GetTGeoManager()->PopPath();
734 return kFALSE;
735 }
736 TGeoVolume *vol = GetTGeoManager()->GetCurrentVolume();
737 GetTGeoManager()->PopPath();
738 if (!vol)
739 return kFALSE;
740 TGeoShape *shape = vol->GetShape();
741 TClass *class_type = shape->IsA();
742 if (class_type == TGeoBBox::Class()) {
743 shapeType = "BOX";
744 npar = 3;
745 par.Set(npar);
746 TGeoBBox *box = (TGeoBBox *)shape;
747 par.AddAt(box->GetDX(), 0);
748 par.AddAt(box->GetDY(), 1);
749 par.AddAt(box->GetDZ(), 2);
750 return kTRUE;
751 }
752 if (class_type == TGeoTrd1::Class()) {
753 shapeType = "TRD1";
754 npar = 4;
755 par.Set(npar);
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);
761 return kTRUE;
762 }
763 if (class_type == TGeoTrd2::Class()) {
764 shapeType = "TRD2";
765 npar = 5;
766 par.Set(npar);
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);
773 return kTRUE;
774 }
775 if (class_type == TGeoTrap::Class()) {
776 shapeType = "TRAP";
777 npar = 11;
778 par.Set(npar);
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);
792 return kTRUE;
793 }
794 if (class_type == TGeoTube::Class()) {
795 shapeType = "TUBE";
796 npar = 3;
797 par.Set(npar);
798 TGeoTube *tube = (TGeoTube *)shape;
799 par.AddAt(tube->GetRmin(), 0);
800 par.AddAt(tube->GetRmax(), 1);
801 par.AddAt(tube->GetDz(), 2);
802 return kTRUE;
803 }
804 if (class_type == TGeoTubeSeg::Class()) {
805 shapeType = "TUBS";
806 npar = 5;
807 par.Set(npar);
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);
814 return kTRUE;
815 }
816 if (class_type == TGeoCone::Class()) {
817 shapeType = "CONE";
818 npar = 5;
819 par.Set(npar);
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);
826 return kTRUE;
827 }
828 if (class_type == TGeoConeSeg::Class()) {
829 shapeType = "CONS";
830 npar = 7;
831 par.Set(npar);
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);
840 return kTRUE;
841 }
842 if (class_type == TGeoSphere::Class()) {
843 shapeType = "SPHE";
844 npar = 6;
845 par.Set(npar);
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);
853 return kTRUE;
854 }
855 if (class_type == TGeoPara::Class()) {
856 shapeType = "PARA";
857 npar = 6;
858 par.Set(npar);
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);
866 return kTRUE;
867 }
868 if (class_type == TGeoPgon::Class()) {
869 shapeType = "PGON";
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();
875 npar = 4 + 3 * nz;
876 par.Set(npar);
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);
885 }
886 return kTRUE;
887 }
888 if (class_type == TGeoPcon::Class()) {
889 shapeType = "PCON";
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();
895 npar = 3 + 3 * nz;
896 par.Set(npar);
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);
904 }
905 return kTRUE;
906 }
907 if (class_type == TGeoEltu::Class()) {
908 shapeType = "ELTU";
909 npar = 3;
910 par.Set(npar);
911 TGeoEltu *eltu = (TGeoEltu *)shape;
912 par.AddAt(eltu->GetA(), 0);
913 par.AddAt(eltu->GetB(), 1);
914 par.AddAt(eltu->GetDz(), 2);
915 return kTRUE;
916 }
917 if (class_type == TGeoHype::Class()) {
918 shapeType = "HYPE";
919 npar = 5;
920 par.Set(npar);
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);
927 return kTRUE;
928 }
929 if (class_type == TGeoGtra::Class()) {
930 shapeType = "GTRA";
931 npar = 12;
932 par.Set(npar);
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);
947 return kTRUE;
948 }
949 if (class_type == TGeoCtub::Class()) {
950 shapeType = "CTUB";
951 npar = 11;
952 par.Set(npar);
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);
961 par.AddAt(lx[0], 5);
962 par.AddAt(lx[1], 6);
963 par.AddAt(lx[2], 7);
964 par.AddAt(tx[0], 8);
965 par.AddAt(tx[1], 9);
966 par.AddAt(tx[2], 10);
967 return kTRUE;
968 }
969 Error("GetShape", "Getting shape parameters for shape %s not implemented", shape->ClassName());
970 return kFALSE;
971}
972
993
994Bool_t TGeoMCGeometry::GetMaterial(const TString &volumeName, TString &name, Int_t &imat, Double_t &a, Double_t &z,
995 Double_t &dens, Double_t &radl, Double_t &inter, TArrayD &par)
996{
997 TGeoVolume *vol = GetTGeoManager()->GetVolume(volumeName.Data());
998 if (!vol)
999 return kFALSE;
1000 TGeoMedium *med = vol->GetMedium();
1001 if (!med)
1002 return kFALSE;
1003 TGeoMaterial *mat = med->GetMaterial();
1004 imat = mat->GetUniqueID();
1005 name = mat->GetName();
1006 name = name.Strip(TString::kTrailing, '$');
1007 a = mat->GetA();
1008 z = mat->GetZ();
1009 dens = mat->GetDensity();
1010 radl = mat->GetRadLen();
1011 inter = mat->GetIntLen(); // WARNING: THIS IS NOT COMPUTED NATIVELY BY TGEO
1012 par.Set(0); // NO USER PARAMETERS STORED IN TGEO
1013 return kTRUE;
1014}
1015
1039
1040Bool_t TGeoMCGeometry::GetMedium(const TString &volumeName, TString &name, Int_t &imed, Int_t &nmat, Int_t &isvol,
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)
1043{
1044 TGeoVolume *vol = GetTGeoManager()->GetVolume(volumeName.Data());
1045 if (!vol)
1046 return kFALSE;
1047 TGeoMedium *med = vol->GetMedium();
1048 if (!med)
1049 return kFALSE;
1050 TGeoMaterial *mat = med->GetMaterial();
1051 nmat = mat->GetUniqueID();
1052 imed = med->GetId();
1053 name = med->GetName();
1054 name = name.Strip(TString::kTrailing, '$');
1055 par.Set(0); // NO USER PARAMETERS IN TGEO
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);
1064 return kTRUE;
1065}
ClassImp(TGeoMCGeometry)
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.