BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_SiBT_Run9.C
Go to the documentation of this file.
1/*
2 * Use this macro to create basic ROOT geometry of Silicon Beam Tracker (SiBT)
3 * for the RUN-9 configuration (3 stations)
4 *
5 * Author: Baranov D.
6 * Created: 25.04.2025
7 *
8 * WARNING: all units is in cm!!!
9 */
10
11// Set Parameters of SiBT --------------------------------------------------------
12const Int_t NStations = 3; // stations in the detector
13const Int_t NMaxModules = 1; // max. number of modules in a station
14
15// X-position of geometrical center of sensor
17 +0.002, // st. 0 (+0.002 + 0.0)
18 -0.258, // st. 1 (+0.012 + (-0.27))
19 +0.097 // st. 2 (+0.137 + (-0.04))
20};
21
22// Y-position of geometrical center of sensor
24 +0.084, // st. 0 (-0.006 + 0.09)
25 -0.003, // st. 1 (+0.027 + (-0.03))
26 +0.105 // st. 2 (+0.095 + 0.01)
27};
28
29// Z-position of sensor side, closest to the beam
31 -283.39, // st. 0 (-283.060 - 0.33)
32 -183.386, // st. 1 (-183.276 - 0.11)
33 -84.397 // st. 2 (-84.087 - 0.31)
34};
35
36//(X-Y-Z)Shifts of modules in each station
38 {0.0}, // st. 0
39 {0.0}, // st. 1
40 {0.0} // st. 2
41};
43 {0.0}, // st. 0
44 {0.0}, // st. 1
45 {0.0} // st. 2
46};
48 {0.0}, // st. 0
49 {0.0}, // st. 1
50 {0.0} // st. 2
51};
52
53// Rotations of stations around Z (deg.)
55 {+0.1020}, // st. 0 (-(90-90.102))
56 {-30.005}, // st. 1 (-(90-59.995))
57 {-59.944} // st. 2 (-(90-30.560))
58};
59
60// Sizes of elements (cm) -------------------------------------------------------
61
62// Sensor sizes
63const Double_t XSensSize = 6.08; // cm
64const Double_t YSensSize = 6.08; // cm
65const Double_t ZSensSize = 0.018; // cm
66//------------------------------------------------------------------------------
67
68// GeoManager
70
71// media
76
77class FairGeoMedia;
78class FairGeoBuilder;
79
80TGeoVolume* CreateStation(TString station_name);
81TGeoVolume* CreateModule(TString module_name);
82
83void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
84{
85
86 // air medium
87 FairGeoMedium* mAir = geoMedia->getMedium("air");
88 if (!mAir)
89 Fatal("Main", "FairMedium air not found");
90 geoBuild->createMedium(mAir);
91 pMedAir = gGeoManager->GetMedium("air");
92 if (!pMedAir)
93 Fatal("Main", "Medium air not found");
94
95 // carbon medium
96 FairGeoMedium* mCarbon = geoMedia->getMedium("carbon");
97 if (!mCarbon)
98 Fatal("Main", "FairMedium carbon not found");
99 geoBuild->createMedium(mCarbon);
100 pMedCarbon = gGeoManager->GetMedium("carbon");
101 if (!pMedCarbon)
102 Fatal("Main", "Medium carbon not found");
103
104 // fiberglass medium
105 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
106 if (!mFiberGlass)
107 Fatal("Main", "FairMedium fiberglass not found");
108 geoBuild->createMedium(mFiberGlass);
109 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
110 if (!pMedFiberGlass)
111 Fatal("Main", "Medium fiberglass not found");
112
113 // silicon medium
114 FairGeoMedium* mSilicon = geoMedia->getMedium("silicon");
115 if (!mSilicon)
116 Fatal("Main", "FairMedium silicon not found");
117 geoBuild->createMedium(mSilicon);
118 pMedSilicon = gGeoManager->GetMedium("silicon");
119 if (!pMedSilicon)
120 Fatal("Main", "Medium silicon not found");
121}
122
124{
125
126 // ---- set working directory --------------------------------------------
127 TString gPath = gSystem->Getenv("VMCWORKDIR");
128
129 // ------- Geometry file name (output) ----------------------------------
130 const TString geoDetectorName = "SiBT";
131 const TString geoDetectorVersion = "Run9";
132 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
133
134 // ---- global geometry parameters ---------------------------------------
135 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
136 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
137
138 // ------- Load media from media file ----------------------------------
139 TString medFile = gPath + "/geometry/media.geo";
140 geoFace->setMediaFile(medFile);
141 geoFace->readMedia();
142 FairGeoMedia* geoMedia = geoFace->getMedia();
143 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
144
145 DefineRequiredMedia(geoMedia, geoBuild);
146 // -------------------------------------------------------------------------
147
148 // -------------- Create geometry and top volume ------------------------
149 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
150 gGeoMan->SetName(geoDetectorName + "_geom");
151 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
152 top->SetMedium(pMedAir);
153 gGeoMan->SetTopVolume(top);
154 // gGeoMan->SetTopVisible(1);
155 // -------------------------------------------------------------------------
156
157 // Define TOP Geometry
158 TGeoVolume* SiBT = new TGeoVolumeAssembly(geoDetectorName);
159 SiBT->SetMedium(pMedAir);
160
161 for (Int_t istation = 0; istation < NStations; ++istation) {
162
163 Int_t stationNum = istation; // station number
164
165 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
166
167 TGeoVolume* module0 = CreateModule(TString("module0_") + station->GetName());
168
169 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
170 module0_transform->RotateZ(ZStationRotations[stationNum][0]);
171 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
172 ZModuleShifts[stationNum][0] + 0.5 * ZSensSize);
173
174 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
175 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
176 ZStationPositions[stationNum]);
177
178 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform));
179
180 SiBT->AddNode(station, 0, station_transform);
181 }
182
183 top->AddNode(SiBT, 0);
185
186 // --------------- Finish -----------------------------------------------
187 gGeoMan->CloseGeometry();
188 gGeoMan->CheckOverlaps(0.0001);
189 gGeoMan->PrintOverlaps();
190 gGeoMan->Test();
191 // gGeoMan->RestoreMasterVolume();
192
193 TFile* geoFile = new TFile(geoFileName, "RECREATE");
194 top->Write();
195 geoFile->Close();
196 top->Draw("ogl");
197}
198
200{
201
202 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
203 stationA->SetMedium(pMedAir);
204
205 return stationA;
206}
207
209{
210
211 // shapes
212 TGeoShape* moduleS = new TGeoBBox(TString("moduleS") += TString("_") + module_name, XSensSize * 0.5,
213 YSensSize * 0.5, ZSensSize * 0.5);
214
215 // volumes
216 TGeoVolume* moduleV = new TGeoVolume(TString("SiBTSensor") += TString("_") + module_name, moduleS);
217
218 // medium
219 if (pMedSilicon) {
220 moduleV->SetMedium(pMedSilicon);
221 } else
222 Fatal("Main", "Invalid medium for moduleV volumes!");
223
224 // volume visual property
225 moduleV->SetLineColor(TColor::GetColor("#ff47ca"));
226 moduleV->SetTransparency(30);
227
228 return moduleV;
229}
230//------------------------------------------------------------------------------
int Int_t
double Double_t
constexpr Bool_t kTRUE
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
#define gROOT
R__EXTERN TSystem * gSystem
static Int_t GetColor(const char *hexcolor)
void Close(Option_t *option="") override
void SetTranslation(const TGeoTranslation &tr)
void RotateZ(Double_t angle) 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
void SetTransparency(Char_t transparency=0)
virtual void SetMedium(TGeoMedium *medium)
void SetLineColor(Color_t lcolor) override
const char * GetName() const override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
static TString Itoa(Int_t value, Int_t base)
TGeoMedium * pMedAir
const Double_t YStationPositions[NStations]
TGeoMedium * pMedCarbon
TGeoManager * gGeoMan
const Int_t NMaxModules
const Double_t ZStationPositions[NStations]
const Int_t NStations
TGeoMedium * pMedFiberGlass
const Double_t XStationPositions[NStations]
const Double_t YSensSize
const Double_t ZSensSize
const Double_t XSensSize
const Double_t ZStationRotations[NStations][NMaxModules]
TGeoMedium * pMedSilicon
TGeoVolume * CreateModule(TString module_name)
TGeoVolume * CreateStation(TString station_name)
void create_rootgeom_SiBT_Run9()
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)