BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_DCH_RunWinter2016.C
Go to the documentation of this file.
1//---------------------------
2// VERY PRELIMINARY! NO INNER STRUCTURE!!!
3//
4
6
7// Detector's position
8
9const Double_t DCH1_Xpos = 0.0;
10const Double_t DCH2_Xpos = 0.0;
11const Double_t DCH1_Ypos = 0.0;
12const Double_t DCH2_Ypos = 0.0;
13const Double_t DCH1_Zpos = 514.0;
14const Double_t DCH2_Zpos = 713.0;
15
16// Detector's construct parameters
17const Double_t ZLength_DCH1 = 26.5; // 20.0
20
24
26{
27
28 // Load the necessary FairRoot libraries
29 // gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
30 // bmnloadlibs(); // load libraries
31
32 // ------- Load media from media file -----------------------------------
33 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
34 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
35 TString geoPath = gSystem->Getenv("VMCWORKDIR");
36 TString medFile = geoPath + "/geometry/media.geo";
37 geoFace->setMediaFile(medFile);
38 geoFace->readMedia();
40 // --------------------------------------------------------------------------
41
42 // ------- Geometry file name (output) ----------------------------------
43 const TString geoDetectorName = "DCH";
44 const TString geoDetectorVersion = "RunWinter2016";
45 geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
46 // --------------------------------------------------------------------------
47
48 // ----------------- Get and create the required media -----------------
49 FairGeoMedia* geoMedia = geoFace->getMedia();
50 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
51
52 FairGeoMedium* mAir = geoMedia->getMedium("air");
53 if (!mAir)
54 Fatal("Main", "FairMedium air not found");
55 geoBuild->createMedium(mAir);
56 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
57 if (!pMedAir)
58 Fatal("Main", "Medium air not found");
59
60 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
61 if (!mArCO27030)
62 Fatal("Main", "FairMedium arco27030 not found");
63 geoBuild->createMedium(mArCO27030);
64 TGeoMedium* pMedArCO27030 = gGeoMan->GetMedium("arco27030");
65 if (!pMedArCO27030)
66 Fatal("Main", "Medium arco27030 not found");
67
68 // --------------------------------------------------------------------------
69
70 // -------------- Create geometry and top volume -------------------------
71 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
72 gGeoMan->SetName(geoDetectorName + "_geom");
73 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
74 top->SetMedium(pMedAir);
75 gGeoMan->SetTopVolume(top);
76 // gGeoMan->SetTopVisible(1);
77 // --------------------------------------------------------------------------
78
79 // Define TOP Geometry
80 TGeoVolume* DCH = new TGeoVolumeAssembly(geoDetectorName);
81 DCH->SetMedium(pMedAir);
82
83 // Transformations (translations, rotations and scales)
84 TGeoCombiTrans* combi1 =
85 new TGeoCombiTrans(DCH1_Xpos, DCH1_Ypos, DCH1_Zpos, new TGeoRotation("rot", 45 * 0.5, 0, 0));
86 TGeoCombiTrans* combi2 =
87 new TGeoCombiTrans(DCH2_Xpos, DCH2_Ypos, DCH2_Zpos, new TGeoRotation("rot", 45 * 0.5, 0, 0));
88
89 TGeoRotation* rot_Octagon = new TGeoRotation("rot_Octagon");
90 rot_Octagon->SetAngles(90, -22.5, 90, 67.5, 0, 0);
91
92 // Solids (shapes)
93 TGeoPgon* OctagonS = new TGeoPgon("OctagonS", 0, 360, 8, 2);
96
97 TGeoVolume* DCHDetV = new TGeoVolume("DCHDetV", OctagonS);
98 DCHDetV->SetMedium(pMedAir);
99 DCHDetV->SetLineColor(kBlue);
100 DCHDetV->SetTransparency(75);
101
102 TGeoPgon* OctagonPlaneS = new TGeoPgon("OctagonActivePlaneS", 0, 360, 8, 2);
105
106 TGeoVolume* DCHActivePlaneV = new TGeoVolume("DCHActivePlaneV", OctagonPlaneS);
107 DCHActivePlaneV->SetMedium(pMedArCO27030);
108 DCHActivePlaneV->SetLineColor(kBlue);
109 DCHActivePlaneV->SetTransparency(40);
110
111 for (Int_t iPlane = 1; iPlane <= 8; ++iPlane) {
112 TGeoTranslation t0(0.0, 0.0, ZLength_DCH1 / 8 * (iPlane - (8 + 1) / 2.0));
113 DCHDetV->AddNode(DCHActivePlaneV, iPlane - 1, new TGeoCombiTrans(t0));
114 }
115
116 // Adding volumes to the TOP Volume
117 DCH->AddNode(DCHDetV, 0, combi1);
118 DCH->AddNode(DCHDetV, 0, combi2);
119 top->AddNode(DCH, 0);
121
122 // --------------- Finish -----------------------------------------------
123 gGeoMan->CloseGeometry();
124 gGeoMan->CheckOverlaps(0.001);
125 gGeoMan->PrintOverlaps();
126 gGeoMan->Test();
127
128 TFile* geoFile = new TFile(geoFileName, "RECREATE");
129 top->Write();
130 geoFile->Close();
131 top->Draw("ogl");
132 // top->Draw("");
133}
int Int_t
double Double_t
constexpr Bool_t kTRUE
kBlue
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
#define gROOT
R__EXTERN TSystem * gSystem
void Close(Option_t *option="") override
virtual void DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax)
void SetAngles(Double_t phi, Double_t theta, Double_t psi)
void SetVisContainers(Bool_t flag=kTRUE) override
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
void Draw(Option_t *option="") override
void SetTransparency(Char_t transparency=0)
virtual void SetMedium(TGeoMedium *medium)
void SetLineColor(Color_t lcolor) override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
const Double_t DCH2_Zpos[numRunPeriods]
const Double_t SideLengthOfOctagon
const Double_t InnerRadiusOfOctagon
const Double_t DCH1_Zpos[numRunPeriods]
TGeoManager * gGeoMan
const Double_t DCH1_Xpos
const Double_t ZLength_DCH1
const Double_t DCH1_Ypos
const Double_t ZLength_DCH1ActiveVolume
const Double_t HoleSize_DCH1
const Double_t DCH2_Ypos
const Double_t DCH2_Xpos
const Double_t OuterRadiusOfOctagon
void create_rootgeom_DCH_RunWinter2016()