BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_DCH1.C
Go to the documentation of this file.
1//---------------------------
2
4
5// Detector's position
6const Double_t tanpipeangle = 0.3 / 5.7; // tangent of pipe angle
7// const Double_t DCH1_Xpos = 0.0;
8const Double_t DCH1_Ypos = 0.0;
9const Double_t DCH1_Zpos = 550.0; // cm
11
12// Detector's construct parameters
13// const Double_t XYRadius_DCH1 = 144.84;
17
20
23
25{
26
27 // Load the necessary FairRoot libraries
28 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
29 bmnloadlibs(); // load libraries
30
31 // ------- Load media from media file -----------------------------------
32 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
33 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
34 TString geoPath = gSystem->Getenv("VMCWORKDIR");
35 TString medFile = geoPath + "/geometry/media.geo";
36 geoFace->setMediaFile(medFile);
37 geoFace->readMedia();
39 // --------------------------------------------------------------------------
40
41 // ------- Geometry file name (output) ----------------------------------
42 const TString geoDetectorName = "dch1";
43 const TString geoDetectorVersion = "v1";
44 geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
45 // --------------------------------------------------------------------------
46
47 // ----------------- Get and create the required media -----------------
48 FairGeoMedia* geoMedia = geoFace->getMedia();
49 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
50
51 FairGeoMedium* mAir = geoMedia->getMedium("air");
52 if (!mAir)
53 Fatal("Main", "FairMedium air not found");
54 geoBuild->createMedium(mAir);
55 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
56 if (!pMedAir)
57 Fatal("Main", "Medium air not found");
58
59 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
60 if (!mArCO27030)
61 Fatal("Main", "FairMedium arco27030 not found");
62 geoBuild->createMedium(mArCO27030);
63 TGeoMedium* pMedArCO27030 = gGeoMan->GetMedium("arco27030");
64 if (!pMedArCO27030)
65 Fatal("Main", "Medium arco27030 not found");
66
67 // --------------------------------------------------------------------------
68
69 // -------------- Create geometry and top volume -------------------------
70 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
71 gGeoMan->SetName(geoDetectorName + "_geom");
72 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
73 top->SetMedium(pMedAir);
74 gGeoMan->SetTopVolume(top);
75 // gGeoMan->SetTopVisible(1);
76 // --------------------------------------------------------------------------
77
78 // Define TOP Geometry
79 TGeoVolume* DCH1Top = new TGeoVolumeAssembly(geoDetectorName);
80 DCH1Top->SetMedium(pMedAir);
81
82 // Transformations (translations, rotations and scales)
83 TGeoTranslation* DetPos_trans = new TGeoTranslation("DetPos_trans", DCH1_Xpos, DCH1_Ypos, DCH1_Zpos);
84 // SetPos_trans->RegisterYourself();
85
86 TGeoRotation* rot_Octagon = new TGeoRotation("rot_Octagon");
87 // rot_RB->SetAngles(90, -45, 90, 45, 0, 0);
88 rot_Octagon->SetAngles(90, -22.5, 90, 67.5, 0, 0);
89 rot_Octagon->RegisterYourself();
90
91 // Solids (shapes)
92 TGeoPgon* OctagonS = new TGeoPgon("OctagonS", 0, 360, 8, 2);
93 OctagonS->DefineSection(0, -ZLength_DCH1 / 2, 0.0, InnerRadiusOfOctagon);
94 OctagonS->DefineSection(1, ZLength_DCH1 / 2, 0.0, InnerRadiusOfOctagon);
95
96 // TGeoBBox *DCH1ContainerS = new TGeoBBox("DCH1ContainerS", InnerRadiusOfOctagon + 0.01, InnerRadiusOfOctagon +
97 // 0.01, ZLength_DCH1/2 + 0.01);
98 TGeoBBox* DCH1ContainerS =
100 // TGeoTube *DCH1ActiveVolumeS = new TGeoTube(MinRadiusOfActiveVolume, MaxRadiusOfActiveVolume, ZLength_DCH1/2 -
101 // 0.01);
102 TGeoTube* DCH1ActiveVolumeS =
104 // TGeoBBox *DCH1HoleS = new TGeoBBox("DCH1HoleS", HoleSize_DCH1/2, HoleSize_DCH1/2, ZLength_DCH1/2 + 0.1);
105 TGeoBBox* DCH1HoleS = new TGeoBBox("DCH1HoleS", HoleSize_DCH1 / 2, HoleSize_DCH1 / 2, ZLength_DCH1 / 2);
106
107 // Composite solids (shapes)
108 TGeoCompositeShape* DCH1DetS = new TGeoCompositeShape("DCH1DetS", "OctagonS:rot_Octagon-DCH1HoleS");
109
110 // Volumes
111 TGeoVolume* DCH1ContainerV = new TGeoVolume("DCH1ContainerV", DCH1ContainerS);
112 DCH1ContainerV->SetMedium(pMedAir);
113 // DCH1ContainerV->SetVisibility(kFALSE);
114
115 TGeoVolume* DCH1DetV = new TGeoVolume("DCH1DetV", DCH1DetS);
116 DCH1DetV->SetMedium(pMedAir);
117 DCH1DetV->SetLineColor(kBlue);
118
119 TGeoVolume* DCH1ActiveVolumeV = new TGeoVolume("DCH1ActiveVolumeV", DCH1ActiveVolumeS);
120 DCH1ActiveVolumeV->SetMedium(pMedArCO27030);
121 DCH1ActiveVolumeV->SetLineColor(kGreen);
122
123 // Adding volumes to the TOP Volume
124 top->AddNode(DCH1Top, 1, DetPos_trans);
125 DCH1Top->AddNode(DCH1ContainerV, 1);
126 DCH1ContainerV->AddNode(DCH1DetV, 1);
127 // DCH1DetV->AddNode(DCH1ActiveVolumeV, 1);
128 DCH1DetV->AddNode(DCH1ActiveVolumeV, 1, new TGeoTranslation(0., 0., -7.8));
129 DCH1DetV->AddNode(DCH1ActiveVolumeV, 2, new TGeoTranslation(0., 0., -6.6));
130 DCH1DetV->AddNode(DCH1ActiveVolumeV, 3, new TGeoTranslation(0., 0., -3.0));
131 DCH1DetV->AddNode(DCH1ActiveVolumeV, 4, new TGeoTranslation(0., 0., -1.8));
132 DCH1DetV->AddNode(DCH1ActiveVolumeV, 5, new TGeoTranslation(0., 0., 1.8));
133 DCH1DetV->AddNode(DCH1ActiveVolumeV, 6, new TGeoTranslation(0., 0., 3.0));
134 DCH1DetV->AddNode(DCH1ActiveVolumeV, 7, new TGeoTranslation(0., 0., 6.6));
135 DCH1DetV->AddNode(DCH1ActiveVolumeV, 8, new TGeoTranslation(0., 0., 7.8));
136
138
139 // --------------- Finish -----------------------------------------------
140 gGeoMan->CloseGeometry();
141 gGeoMan->CheckOverlaps(0.001);
142 gGeoMan->PrintOverlaps();
143 gGeoMan->Test();
144
145 TFile* geoFile = new TFile(geoFileName, "RECREATE");
146 top->Write();
147 geoFile->Close();
148 // top->Draw("ogl");
149 top->Draw("");
150}
double Double_t
constexpr Bool_t kTRUE
kGreen
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 RegisterYourself()
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
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 MaxRadiusOfActiveVolume
const Double_t SideLengthOfOctagon
const Double_t InnerRadiusOfOctagon
const Double_t MinRadiusOfActiveVolume
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 tanpipeangle
const Double_t ZLength_DCH1ActiveVolume
const Double_t HoleSize_DCH1
void create_rootgeom_DCH1()