BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_CSC_RunSpring2018.C
Go to the documentation of this file.
1/*
2 * Baranov D.
3 * 06.03.2019
4 * Use this macro to create ROOT geometry for the RunSpring2018 CSC (Cathode
5 * Strip Chamber)
6 * configuration (BM@N RUN-7)
7 *
8 * WARNING: all units is in cm!!!
9 *
10 */
11
12#include "TGeoMatrix.h"
13#include "TGeoVolume.h"
14#include "TString.h"
15
16// Set Parameters of CSC --------------------------------------------------------
17const Int_t NStations = 1; // stations in the detector
18const Int_t NMaxModules = 2; // max. number of modules in a station
19
20//(X-Y-Z)Positions of stations
21const Double_t XStationPositions[NStations] = {110.1895}; // geometry center
22const Double_t YStationPositions[NStations] = {2.21575}; // geometry center
23const Double_t ZStationPositions[NStations] = {411.57}; // outer side nearest to the target
24
25//(X-Y-Z)Shifts of modules in each station
26const Double_t XModuleShifts[NStations][NMaxModules] = { // centers of gas volume
27 {0.0, 0.0}};
28const Double_t YModuleShifts[NStations][NMaxModules] = { // centers of gas volume
29 {27.1875, -27.1875}};
30const Double_t ZModuleShifts[NStations][NMaxModules] = { // distances from st.side to mod.side
31 {1.25, 1.25}};
32
33// Sizes of elements (cm) -------------------------------------------------------
34
35// Gas volume sizes (module: half of station)
36const Double_t XGasSize = 113.0;
37const Double_t YGasSize = 54.375;
38const Double_t ZGasSize = 0.76;
39
40// Sensitive volume sizes (module: half of station)
41const Double_t XSensSize = 112.9;
42const Double_t YSensSize = 53.25; // 106.5/2
43const Double_t ZSensSize = 0.76;
44
45// Frame sizes
48const Double_t dZFrameSize = 3.26;
49
50// Side panel sizes
53
54//------------------------------------------------------------------------------
55
56// GeoManager
58
59// media
67
68class FairGeoMedia;
69class FairGeoBuilder;
70
71TGeoVolume* CreateStation(TString station_name);
72TGeoVolume* CreateModule(TString module_name);
73
74void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
75{
76
77 // air medium
78 FairGeoMedium* mAir = geoMedia->getMedium("air");
79 if (!mAir)
80 Fatal("Main", "FairMedium air not found");
81 geoBuild->createMedium(mAir);
82 pMedAir = gGeoManager->GetMedium("air");
83 if (!pMedAir)
84 Fatal("Main", "Medium air not found");
85
86 // carbon medium
87 FairGeoMedium* mCarbon = geoMedia->getMedium("carbon");
88 if (!mCarbon)
89 Fatal("Main", "FairMedium carbon not found");
90 geoBuild->createMedium(mCarbon);
91 pMedCarbon = gGeoManager->GetMedium("carbon");
92 if (!pMedCarbon)
93 Fatal("Main", "Medium carbon not found");
94
95 // fiberglass medium
96 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
97 if (!mFiberGlass)
98 Fatal("Main", "FairMedium fiberglass not found");
99 geoBuild->createMedium(mFiberGlass);
100 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
101 if (!pMedFiberGlass)
102 Fatal("Main", "Medium fiberglass not found");
103
104 // arco27020 medium
105 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
106 if (!mArCO27030)
107 Fatal("Main", "FairMedium arco27030 not found");
108 geoBuild->createMedium(mArCO27030);
109 pMedArCO27030 = gGeoManager->GetMedium("arco27030");
110 if (!pMedArCO27030)
111 Fatal("Main", "Medium arco27030 not found");
112
113 // ArgonIsobutane (75/25): Ar-iC4H10 medium
114 FairGeoMedium* mArgonIsobutane7525 = geoMedia->getMedium("ArgonIsobutane7525");
115 if (!mArgonIsobutane7525)
116 Fatal("Main", "FairMedium ArgonIsobutane7525 not found");
117 geoBuild->createMedium(mArgonIsobutane7525);
118 pMedArgonIsobutane7525 = gGeoManager->GetMedium("ArgonIsobutane7525");
120 Fatal("Main", "Medium ArgonIsobutane7525 not found");
121
122 // Rohacell medium
123 FairGeoMedium* mRohacell = geoMedia->getMedium("rohacellhf71");
124 if (!mRohacell)
125 Fatal("Main", "FairMedium rohacellhf71 not found");
126 geoBuild->createMedium(mRohacell);
127 pMedRohacell = gGeoManager->GetMedium("rohacellhf71");
128 if (!pMedRohacell)
129 Fatal("Main", "Medium rohacellhf71 not found");
130}
131
133{
134
135 // ---- set working directory --------------------------------------------
136 TString gPath = gSystem->Getenv("VMCWORKDIR");
137
138 // ------- Geometry file name (output) ----------------------------------
139 const TString geoDetectorName = "CSC";
140 const TString geoDetectorVersion = "RunSpring2018";
141 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
142
143 // ---- global geometry parameters ---------------------------------------
144 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
145 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
146
147 // ------- Load media from media file ----------------------------------
148 TString medFile = gPath + "/geometry/media.geo";
149 geoFace->setMediaFile(medFile);
150 geoFace->readMedia();
151 FairGeoMedia* geoMedia = geoFace->getMedia();
152 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
153
154 DefineRequiredMedia(geoMedia, geoBuild);
155 // -------------------------------------------------------------------------
156
157 // -------------- Create geometry and top volume ------------------------
158 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
159 gGeoMan->SetName(geoDetectorName + "_geom");
160 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
161 top->SetMedium(pMedAir);
162 gGeoMan->SetTopVolume(top);
163 // gGeoMan->SetTopVisible(1);
164 // -------------------------------------------------------------------------
165
166 // Define TOP Geometry
167 TGeoVolume* CSC = new TGeoVolumeAssembly(geoDetectorName);
168 CSC->SetMedium(pMedAir);
169
170 // station 0 (consisting of two modules)
171 if (1) {
172 Int_t stationNum = 0; // station number
173
174 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
175
176 TGeoVolume* module0 = CreateModule(TString("module0_") + station->GetName());
177 TGeoVolume* module1 = CreateModule(TString("module1_") + station->GetName());
178
179 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
180 module0_transform->SetTranslation(XModuleShifts[stationNum][0],
181 YModuleShifts[stationNum][0] + 0.5 * dYFrameSize,
182 ZModuleShifts[stationNum][0] + 0.5 * ZGasSize);
183
184 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
185 module1_transform->RotateX(180);
186 module1_transform->SetTranslation(XModuleShifts[stationNum][1],
187 YModuleShifts[stationNum][1] - 0.5 * dYFrameSize,
188 ZModuleShifts[stationNum][1] + 0.5 * ZGasSize);
189
190 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
191 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
192 ZStationPositions[stationNum]);
193
194 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform));
195 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform));
196
197 CSC->AddNode(station, 0, station_transform);
198 }
199
200 top->AddNode(CSC, 0);
202
203 // --------------- Finish -----------------------------------------------
204 gGeoMan->CloseGeometry();
205 gGeoMan->CheckOverlaps(0.0001);
206 gGeoMan->PrintOverlaps();
207 gGeoMan->Test();
208 // gGeoMan->RestoreMasterVolume();
209
210 TFile* geoFile = new TFile(geoFileName, "RECREATE");
211 top->Write();
212 geoFile->Close();
213 top->Draw("ogl");
214}
215
217{
218
219 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
220 stationA->SetMedium(pMedAir);
221
222 return stationA;
223}
224
226{
227
228 // shapes
229 TGeoShape* moduleS = new TGeoBBox("moduleS", (XGasSize + 2.0 * dXFrameSize) * 0.5, (YGasSize + dYFrameSize) * 0.5,
230 (ZGasSize + 4.0 * dZFiberglassPanel + 2.0 * dZHoneycombPanel) * 0.5);
231 TGeoShape* gasS = new TGeoBBox("gasS", XGasSize * 0.5, YGasSize * 0.5, ZGasSize * 0.5);
232 TGeoShape* sensS = new TGeoBBox("sensS", XSensSize * 0.5, YSensSize * 0.5, ZSensSize * 0.5);
233 TGeoShape* fiberglassS = new TGeoBBox("fiberglassS", XGasSize * 0.5, YGasSize * 0.5, dZFiberglassPanel * 0.5);
234 TGeoShape* honeycombS = new TGeoBBox("honeycombS", XGasSize * 0.5, YGasSize * 0.5, dZHoneycombPanel * 0.5);
235
236 TGeoShape* verticalframeS = new TGeoBBox("verticalframeS", dXFrameSize * 0.5, 0.5 * (YGasSize + dYFrameSize),
237 (ZGasSize + 4.0 * dZFiberglassPanel + 2.0 * dZHoneycombPanel) * 0.5);
238 TGeoShape* horizontalframeS = new TGeoBBox("horizontalframeS", XGasSize * 0.5, dYFrameSize * 0.5,
239 (ZGasSize + 4.0 * dZFiberglassPanel + 2.0 * dZHoneycombPanel) * 0.5);
240
241 // volumes
242 TGeoVolume* moduleV = new TGeoVolume(TString("moduleV_") + module_name, moduleS);
243 TGeoVolume* gasV = new TGeoVolume(TString("gasV_") + module_name, gasS);
244 TGeoVolume* sensV = new TGeoVolume(TString("CSCSensor_") + module_name, sensS);
245 TGeoVolume* fiberglassV = new TGeoVolume(TString("fiberglassV_") + module_name, fiberglassS);
246 TGeoVolume* honeycombV = new TGeoVolume(TString("honeycombV_") + module_name, honeycombS);
247 TGeoVolume* verticalframeV = new TGeoVolume(TString("verticalframeV_") + module_name, verticalframeS);
248 TGeoVolume* horizontalframeV = new TGeoVolume(TString("horizontalframeV_") + module_name, horizontalframeS);
249
250 // medium
251 if (pMedAir)
252 moduleV->SetMedium(pMedAir);
253 else
254 Fatal("Main", "Invalid medium for module volume!");
255
259 } else
260 Fatal("Main", "Invalid medium for module volumes!");
261
262 if (pMedFiberGlass) {
263 fiberglassV->SetMedium(pMedFiberGlass);
264 verticalframeV->SetMedium(pMedFiberGlass);
265 horizontalframeV->SetMedium(pMedFiberGlass);
266 } else
267 Fatal("Main", "Invalid medium for fiberglass volume!");
268
269 if (pMedRohacell)
270 honeycombV->SetMedium(pMedRohacell);
271 else
272 Fatal("Main", "Invalid medium for honeycomb volume!");
273
274 // visual parameters
275 moduleV->SetLineColor(TColor::GetColor("#cccccc"));
276 moduleV->SetTransparency(20);
277
278 gasV->SetLineColor(TColor::GetColor("#47ffca"));
279 gasV->SetTransparency(20);
280
281 sensV->SetLineColor(TColor::GetColor("#ff47ca"));
282 sensV->SetTransparency(20);
283
284 fiberglassV->SetLineColor(TColor::GetColor("#ff9933"));
285 fiberglassV->SetTransparency(20);
286
287 honeycombV->SetLineColor(TColor::GetColor("#ffff00"));
288 honeycombV->SetTransparency(20);
289
290 verticalframeV->SetLineColor(TColor::GetColor("#9999ff"));
291 verticalframeV->SetTransparency(20);
292
293 horizontalframeV->SetLineColor(TColor::GetColor("#9999ff"));
294 horizontalframeV->SetTransparency(20);
295
296 gasV->AddNode(sensV, 0, new TGeoTranslation(0.0, -0.5 * (YGasSize - YSensSize), 0.0));
297
298 moduleV->AddNode(gasV, 0, new TGeoTranslation(0.0, -0.5 * dYFrameSize, 0.0));
299
300 moduleV->AddNode(fiberglassV, 0,
301 new TGeoTranslation(0.0, -0.5 * dYFrameSize, -(0.5 * ZGasSize + 0.5 * dZFiberglassPanel)));
302 moduleV->AddNode(fiberglassV, 1,
303 new TGeoTranslation(0.0, -0.5 * dYFrameSize, +(0.5 * ZGasSize + 0.5 * dZFiberglassPanel)));
304
305 moduleV->AddNode(
306 honeycombV, 0,
307 new TGeoTranslation(0.0, -0.5 * dYFrameSize, -(0.5 * ZGasSize + dZFiberglassPanel + 0.5 * dZHoneycombPanel)));
308 moduleV->AddNode(
309 honeycombV, 1,
310 new TGeoTranslation(0.0, -0.5 * dYFrameSize, +(0.5 * ZGasSize + dZFiberglassPanel + 0.5 * dZHoneycombPanel)));
311
312 moduleV->AddNode(
313 fiberglassV, 2,
314 new TGeoTranslation(0.0, -0.5 * dYFrameSize,
316 moduleV->AddNode(
317 fiberglassV, 3,
318 new TGeoTranslation(0.0, -0.5 * dYFrameSize,
320
321 moduleV->AddNode(verticalframeV, 0, new TGeoTranslation(+(0.5 * XGasSize + 0.5 * dXFrameSize), 0.0, 0.0));
322 moduleV->AddNode(verticalframeV, 1, new TGeoTranslation(-(0.5 * XGasSize + 0.5 * dXFrameSize), 0.0, 0.0));
323
324 moduleV->AddNode(horizontalframeV, 0, new TGeoTranslation(0.0, +(0.5 * YGasSize), 0.0));
325
326 return moduleV;
327}
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 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 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]
TGeoMedium * pMedArCO27030
const Int_t NStations
TGeoMedium * pMedFiberGlass
const Double_t XStationPositions[NStations]
TGeoMedium * pMedCopper
TGeoMedium * pMedRohacell
const Double_t YSensSize
const Double_t ZSensSize
const Double_t YGasSize
const Double_t XGasSize
TGeoMedium * pMedArgonIsobutane7525
const Double_t XSensSize
const Double_t ZGasSize
void create_rootgeom_CSC_RunSpring2018()
TGeoVolume * CreateModule(TString module_name)
const Double_t dYFrameSize
TGeoVolume * CreateStation(TString station_name)
const Double_t dZFiberglassPanel
const Double_t dXFrameSize
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
const Double_t dZFrameSize
const Double_t dZHoneycombPanel