BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_LargeCSC_Run8.C
Go to the documentation of this file.
1/*
2 * Author: Baranov D.
3 * Created: 11.04.2022
4 * Use this macro to create ROOT geometry of Large CSC (Cathode
5 * Strip Chamber) detector for the RUN-8 configuration
6 *
7 * WARNING: all units is in cm!!!
8 *
9 */
10
11#include "TGeoMatrix.h"
12#include "TGeoVolume.h"
13#include "TString.h"
14
15// Set Parameters of CSC --------------------------------------------------------
16const Int_t NStations = 1; // stations in the detector
17const Int_t NMaxModules = 8; // max. number of modules in a station
18
19//(X-Y-Z)Positions of stations
20const Double_t XStationPositions[NStations] = {0.0 /*0*/}; // geometry center
21const Double_t YStationPositions[NStations] = {0.0 /*0*/}; // geometry center
22const Double_t ZStationPositions[NStations] = {800.0 /*0*/}; // outer side nearest to the target
23
24//(X-Y-Z)Shifts of modules in each station
26 // centers of gas volume
27 {+81.375 /*0*/, +27.125 /*1*/, -27.125 /*2*/, -81.375 /*3*/, +81.375 /*4*/, +27.125 /*5*/, -27.125 /*6*/,
28 -81.375 /*7*/} // station 0
29};
31 // centers of gas volume
32 {+36.5 /*0*/, +36.5 /*1*/, +36.5 /*2*/, +36.5 /*3*/, -36.5 /*4*/, -36.5 /*5*/, -36.5 /*6*/,
33 -36.5 /*7*/} // station 0
34};
36 // distances from st.side to mod.side
37 {1.25 /*0*/, 1.25 /*1*/, 1.25 /*2*/, 1.25 /*3*/, 1.25 /*4*/, 1.25 /*5*/, 1.25 /*6*/, 1.25 /*7*/} // station 0
38};
39
46
48 {WHOLE_MOD /*0*/, HOLED_LEFT_MOD /*1*/, HOLED_RIGHT_MOD /*2*/, WHOLE_MOD /*3*/, WHOLE_MOD /*4*/,
49 HOLED_RIGHT_MOD /*5*/, HOLED_LEFT_MOD /*6*/, WHOLE_MOD /*7*/} // station 0
50};
51
53 {false /*0*/, false /*1*/, false /*2*/, false /*3*/, true /*4*/, true /*5*/, true /*6*/, true /*7*/} // station 0
54};
55
57 {false /*0*/, false /*1*/, false /*2*/, false /*3*/, true /*4*/, true /*5*/, true /*6*/, true /*7*/} // station 0
58};
59
60// Sizes of elements (cm) -------------------------------------------------------
61
62// Gas volume sizes (module)
63const Double_t XGasSize = 54.25;
64const Double_t YGasSize = 73.0;
65const Double_t ZGasSize = 0.76;
66
67const Double_t BeamHole_XSize = 11.125;
68const Double_t BeamHole_YSize = 11.625;
69
70//------------------------------------------------------------------------------
71
72// GeoManager
74
75// media
83
84class FairGeoMedia;
85class FairGeoBuilder;
86
87TGeoVolume* CreateStation(TString station_name);
88TGeoVolume* CreateModule(TString module_name, ModuleType module_type);
89
90void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
91{
92
93 // air medium
94 FairGeoMedium* mAir = geoMedia->getMedium("air");
95 if (!mAir)
96 Fatal("Main", "FairMedium air not found");
97 geoBuild->createMedium(mAir);
98 pMedAir = gGeoManager->GetMedium("air");
99 if (!pMedAir)
100 Fatal("Main", "Medium air not found");
101
102 // carbon medium
103 FairGeoMedium* mCarbon = geoMedia->getMedium("carbon");
104 if (!mCarbon)
105 Fatal("Main", "FairMedium carbon not found");
106 geoBuild->createMedium(mCarbon);
107 pMedCarbon = gGeoManager->GetMedium("carbon");
108 if (!pMedCarbon)
109 Fatal("Main", "Medium carbon not found");
110
111 // fiberglass medium
112 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
113 if (!mFiberGlass)
114 Fatal("Main", "FairMedium fiberglass not found");
115 geoBuild->createMedium(mFiberGlass);
116 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
117 if (!pMedFiberGlass)
118 Fatal("Main", "Medium fiberglass not found");
119
120 // arco27020 medium
121 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
122 if (!mArCO27030)
123 Fatal("Main", "FairMedium arco27030 not found");
124 geoBuild->createMedium(mArCO27030);
125 pMedArCO27030 = gGeoManager->GetMedium("arco27030");
126 if (!pMedArCO27030)
127 Fatal("Main", "Medium arco27030 not found");
128
129 // ArgonIsobutane (75/25): Ar-iC4H10 medium
130 FairGeoMedium* mArgonIsobutane7525 = geoMedia->getMedium("ArgonIsobutane7525");
131 if (!mArgonIsobutane7525)
132 Fatal("Main", "FairMedium ArgonIsobutane7525 not found");
133 geoBuild->createMedium(mArgonIsobutane7525);
134 pMedArgonIsobutane7525 = gGeoManager->GetMedium("ArgonIsobutane7525");
136 Fatal("Main", "Medium ArgonIsobutane7525 not found");
137
138 // Rohacell medium
139 FairGeoMedium* mRohacell = geoMedia->getMedium("rohacellhf71");
140 if (!mRohacell)
141 Fatal("Main", "FairMedium rohacellhf71 not found");
142 geoBuild->createMedium(mRohacell);
143 pMedRohacell = gGeoManager->GetMedium("rohacellhf71");
144 if (!pMedRohacell)
145 Fatal("Main", "Medium rohacellhf71 not found");
146}
147
149{
150
151 // ---- set working directory --------------------------------------------
152 TString gPath = gSystem->Getenv("VMCWORKDIR");
153
154 // ------- Geometry file name (output) ----------------------------------
155 const TString geoDetectorName = "LargeCSC";
156 const TString geoDetectorVersion = "Run8";
157 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
158
159 // ---- global geometry parameters ---------------------------------------
160 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
161 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
162
163 // ------- Load media from media file ----------------------------------
164 TString medFile = gPath + "/geometry/media.geo";
165 geoFace->setMediaFile(medFile);
166 geoFace->readMedia();
167 FairGeoMedia* geoMedia = geoFace->getMedia();
168 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
169
170 DefineRequiredMedia(geoMedia, geoBuild);
171 // -------------------------------------------------------------------------
172
173 // -------------- Create geometry and top volume ------------------------
174 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
175 gGeoMan->SetName(geoDetectorName + "_geom");
176 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
177 top->SetMedium(pMedAir);
178 gGeoMan->SetTopVolume(top);
179 // gGeoMan->SetTopVisible(1);
180 // -------------------------------------------------------------------------
181
182 // Define TOP Geometry
183 TGeoVolume* CSC = new TGeoVolumeAssembly(geoDetectorName);
184 CSC->SetMedium(pMedAir);
185
186 for (Int_t istation = 0; istation < NStations; ++istation) {
187
188 Int_t stationNum = istation; // station number
189
190 TGeoVolume* station = CreateStation(Form("station%d", stationNum));
191
192 for (Int_t imod = 0; imod < NMaxModules; ++imod) {
193
194 TGeoVolume* module =
195 CreateModule(Form("module%d_%s", imod, station->GetName()), ModuleTypes[istation][imod]);
196
197 TGeoCombiTrans* module_transform = new TGeoCombiTrans(Form("transr_module%d_%s", imod, station->GetName()));
198
199 if (ModulesYRotations[istation][imod])
200 module_transform->RotateY(180.0);
201 if (ModulesXRotations[istation][imod])
202 module_transform->RotateX(180.0);
203
204 module_transform->SetTranslation(XModuleShifts[stationNum][imod], YModuleShifts[stationNum][imod],
205 ZModuleShifts[stationNum][imod] + 0.5 * ZGasSize);
206
207 station->AddNode(module, 0, module_transform);
208 }
209
210 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
211 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
212 ZStationPositions[stationNum]);
213
214 CSC->AddNode(station, 0, station_transform);
215 }
216
217 top->AddNode(CSC, 0);
219
220 // --------------- Finish -----------------------------------------------
221 gGeoMan->CloseGeometry();
222 gGeoMan->CheckOverlaps(0.0001);
223 gGeoMan->PrintOverlaps();
224 gGeoMan->Test();
225 // gGeoMan->RestoreMasterVolume();
226
227 TFile* geoFile = new TFile(geoFileName, "RECREATE");
228 top->Write();
229 geoFile->Close();
230 top->Draw("ogl");
231}
232
234{
235
236 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
237 stationA->SetMedium(pMedAir);
238
239 return stationA;
240}
241
242TGeoVolume* CreateModule(TString module_name, ModuleType module_type)
243{
244
245 // shapes
246 TGeoShape* moduleS = 0;
247
248 switch (module_type) {
249 case ModuleType::WHOLE_MOD: {
250 moduleS =
251 new TGeoBBox(Form("moduleS_%s", module_name.Data()), XGasSize * 0.5, YGasSize * 0.5, ZGasSize * 0.5);
252 break;
253 }
254 case ModuleType::HOLED_LEFT_MOD: {
255 moduleS = new TGeoXtru(2);
256 moduleS->SetName(Form("moduleS_%s", module_name.Data()));
257 Double_t x_pos[6] = {+XGasSize * 0.5,
258 -XGasSize * 0.5,
259 -XGasSize * 0.5,
260 -XGasSize * 0.5 + BeamHole_XSize,
261 -XGasSize * 0.5 + BeamHole_XSize,
262 +XGasSize * 0.5};
263 Double_t y_pos[6] = {
264 +YGasSize * 0.5, +YGasSize * 0.5, -YGasSize * 0.5 + BeamHole_YSize, -YGasSize * 0.5 + BeamHole_YSize,
265 -YGasSize * 0.5, -YGasSize * 0.5};
266 ((TGeoXtru*)moduleS)->DefinePolygon(6, x_pos, y_pos);
267 ((TGeoXtru*)moduleS)->DefineSection(0, -ZGasSize * 0.5);
268 ((TGeoXtru*)moduleS)->DefineSection(1, +ZGasSize * 0.5);
269 break;
270 }
271 case ModuleType::HOLED_RIGHT_MOD: {
272 moduleS = new TGeoXtru(2);
273 moduleS->SetName(Form("moduleS_%s", module_name.Data()));
274 Double_t x_pos[6] = {-XGasSize * 0.5,
275 -XGasSize * 0.5,
276 +XGasSize * 0.5,
277 +XGasSize * 0.5,
278 +XGasSize * 0.5 - BeamHole_XSize,
279 +XGasSize * 0.5 - BeamHole_XSize};
280 Double_t y_pos[6] = {-YGasSize * 0.5,
281 +YGasSize * 0.5,
282 +YGasSize * 0.5,
283 -YGasSize * 0.5 + BeamHole_YSize,
284 -YGasSize * 0.5 + BeamHole_YSize,
285 -YGasSize * 0.5};
286 ((TGeoXtru*)moduleS)->DefinePolygon(6, x_pos, y_pos);
287 ((TGeoXtru*)moduleS)->DefineSection(0, -ZGasSize * 0.5);
288 ((TGeoXtru*)moduleS)->DefineSection(1, +ZGasSize * 0.5);
289 break;
290 }
291 default:
292 Error("CreateModule()", "Incorrect module type selected!!!");
293 }
294
295 // volumes
296 TGeoVolume* moduleV = new TGeoVolume(Form("CSCSensor_%s", module_name.Data()), moduleS);
297
298 // medium
301 } else
302 Fatal("Main", "Invalid medium for moduleV volume!");
303
304 // volume visual property (transparency)
305 moduleV->SetLineColor(TColor::GetColor("#47ffca"));
306 moduleV->SetTransparency(30);
307
308 return moduleV;
309}
310//------------------------------------------------------------------------------
bool Bool_t
int Int_t
double Double_t
constexpr Bool_t kTRUE
void Error(const char *location, const char *msgfmt,...)
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
#define gROOT
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
static Int_t GetColor(const char *hexcolor)
void Close(Option_t *option="") override
void RotateY(Double_t angle) override
void RotateX(Double_t angle) override
void SetTranslation(const TGeoTranslation &tr)
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 void SetName(const char *name)
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
const char * Data() const
TGeoMedium * pMedAir
const Double_t YStationPositions[NStations]
TGeoMedium * pMedCarbon
TGeoManager * gGeoMan
const Int_t NMaxModules
const Double_t ZStationPositions[NStations]
TGeoMedium * pMedArCO27030
const Int_t NStations
TGeoMedium * pMedFiberGlass
const Double_t XStationPositions[NStations]
TGeoMedium * pMedCopper
ModuleType
const Bool_t ModulesYRotations[NStations][NMaxModules]
const Bool_t ModulesXRotations[NStations][NMaxModules]
TGeoMedium * pMedRohacell
const Double_t YGasSize
const Double_t XGasSize
TGeoMedium * pMedArgonIsobutane7525
const Double_t ZGasSize
@ WHOLE_MOD
@ HOLED_LEFT_MOD
const ModuleType ModuleTypes[NStations][NMaxModules]
const Double_t BeamHole_YSize
const Double_t BeamHole_XSize
void create_rootgeom_LargeCSC_Run8()
TGeoVolume * CreateModule(TString module_name, ModuleType module_type)
TGeoVolume * CreateStation(TString station_name)
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)