BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_TOF1.C
Go to the documentation of this file.
1//---------------------------
2
4
5// Detector's position
6const Double_t TOF1_Xpos = 0.0;
7const Double_t TOF1_Ypos = 0.0;
8const Double_t TOF1_Zpos = 440.0; // cm
9
10// Detector's construct parameters
14const Double_t GapSize_TOF1 = 100.0;
15
19
21{
22
23 // Load the necessary FairRoot libraries
24 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
25 bmnloadlibs(); // load libraries
26
27 // ------- Load media from media file -----------------------------------
28 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
29 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
30 TString geoPath = gSystem->Getenv("VMCWORKDIR");
31 TString medFile = geoPath + "/geometry/media.geo";
32 geoFace->setMediaFile(medFile);
33 geoFace->readMedia();
35 // --------------------------------------------------------------------------
36
37 // ------- Geometry file name (output) ----------------------------------
38 const TString geoDetectorName = "tof1";
39 const TString geoDetectorVersion = "v1";
40 geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
41 // --------------------------------------------------------------------------
42
43 // ----------------- Get and create the required media -----------------
44 FairGeoMedia* geoMedia = geoFace->getMedia();
45 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
46
47 FairGeoMedium* mAir = geoMedia->getMedium("air");
48 if (!mAir)
49 Fatal("Main", "FairMedium air not found");
50 geoBuild->createMedium(mAir);
51 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
52 if (!pMedAir)
53 Fatal("Main", "Medium air not found");
54
55 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
56 if (!mArCO27030)
57 Fatal("Main", "FairMedium arco27030 not found");
58 geoBuild->createMedium(mArCO27030);
59 TGeoMedium* pMedArCO27030 = gGeoMan->GetMedium("arco27030");
60 if (!pMedArCO27030)
61 Fatal("Main", "Medium arco27030 not found");
62
63 // --------------------------------------------------------------------------
64
65 // -------------- Create geometry and top volume -------------------------
66 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
67 gGeoMan->SetName(geoDetectorName + "_geom");
68 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
69 top->SetMedium(pMedAir);
70 gGeoMan->SetTopVolume(top);
71 // gGeoMan->SetTopVisible(1);
72 // --------------------------------------------------------------------------
73
74 // Define TOP Geometry
75 TGeoVolume* TOF1Top = new TGeoVolumeAssembly(geoDetectorName);
76 TOF1Top->SetMedium(pMedAir);
77
78 // Transformations (translations, rotations and scales)
79 TGeoTranslation* DetPos_trans = new TGeoTranslation("DetPos_trans", TOF1_Xpos, TOF1_Ypos, TOF1_Zpos);
80 // DetPos_trans->RegisterYourself();
81 TGeoTranslation* LeftModulePosTOF1_trans = new TGeoTranslation("LeftModulePosTOF1_trans", GapSize_TOF1, 0.0, 0.0);
82 // LeftModulePosTOF1_trans->RegisterYourself();
83 TGeoTranslation* RightModulePosTOF1_trans =
84 new TGeoTranslation("RightModulePosTOF1_trans", -GapSize_TOF1, 0.0, 0.0);
85 // RightModulePosTOF1_trans->RegisterYourself();
86
87 // Solids (shapes)
88 TGeoBBox* TOF1ContainerS = new TGeoBBox("TOF1ContainerS", ((XWidthOfModule_TOF1 * 2) + GapSize_TOF1) / 2,
90 TGeoBBox* TOF1ModuleS =
92 TGeoBBox* TOF1ActiveVolumeS = new TGeoBBox("TOF1ActiveVolumeS", XSizeOfActiveVolume_TOF1 / 2,
94
95 // Composite solids (shapes)
96
97 // Volumes
98 TGeoVolume* TOF1ContainerV = new TGeoVolume("TOF1ContainerV", TOF1ContainerS);
99 TOF1ContainerV->SetMedium(pMedAir);
100 // TOF1ContainerV->SetVisibility(kFALSE);
101
102 TGeoVolume* TOF1ModuleV = new TGeoVolume("TOF1ModuleV", TOF1ModuleS);
103 TOF1ModuleV->SetMedium(pMedAir);
104 TOF1ModuleV->SetLineColor(kBlue);
105 // TOF1ModuleV->SetTransparency(80);
106
107 TGeoVolume* TOF1ActiveVolumeV = new TGeoVolume("TOF1ActiveVolumeV", TOF1ActiveVolumeS);
108 TOF1ActiveVolumeV->SetMedium(pMedArCO27030);
109 TOF1ActiveVolumeV->SetLineColor(kGreen);
110
111 // Adding volumes to the TOP Volume
112 top->AddNode(TOF1Top, 1, DetPos_trans);
113 TOF1Top->AddNode(TOF1ContainerV, 1);
114
115 TOF1ContainerV->AddNode(TOF1ModuleV, 1, LeftModulePosTOF1_trans);
116 TOF1ContainerV->AddNode(TOF1ModuleV, 2, RightModulePosTOF1_trans);
117
118 TOF1ModuleV->AddNode(TOF1ActiveVolumeV, 1);
119
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}
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
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)
TGeoManager * gGeoMan
const Double_t GapSize_TOF1
const Double_t XSizeOfActiveVolume_TOF1
const Double_t YSizeOfActiveVolume_TOF1
const Double_t ZLengthOfModule_TOF1
const Double_t TOF1_Zpos
const Double_t ZSizeOfActiveVolume_TOF1
const Double_t TOF1_Xpos
const Double_t YHeightOfModule_TOF1
const Double_t TOF1_Ypos
const Double_t XWidthOfModule_TOF1
void create_rootgeom_TOF1()