BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_CSC_Run8.C
Go to the documentation of this file.
1/*
2 * Baranov D.
3 * 12.04.2021
4 * Use this macro to create ROOT geometry of 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 = 4; // stations in the detector
17const Int_t NMaxModules = 2; // max. number of modules in a station
18
19//(X-Y-Z)Positions of stations
20const Double_t XStationPositions[NStations] = {110.0 /*0*/, -110.0 /*1*/, 130.0 /*2*/,
21 -130.0 /*3*/}; // geometry center
22const Double_t YStationPositions[NStations] = {0.0 /*0*/, 0.0 /*1*/, 0.0 /*2*/, 0.0 /*3*/}; // geometry center
23const Double_t ZStationPositions[NStations] = {410.0 /*0*/, 410.0 /*1*/, 470.0 /*2*/,
24 470.0 /*3*/}; // outer side nearest to the target
25
26//(X-Y-Z)Shifts of modules in each station
28 // centers of gas volume
29 {0.0, 0.0}, // station 0
30 {0.0, 0.0}, // station 1
31 {0.0, 0.0}, // station 2
32 {0.0, 0.0} // station 3
33};
35 // centers of gas volume
36 {27.1875, -27.1875}, // station 0
37 {27.1875, -27.1875}, // station 1
38 {27.1875, -27.1875}, // station 2
39 {27.1875, -27.1875} // station 3
40};
42 // distances from st.side to mod.side
43 {1.25, 1.25}, // station 0
44 {1.25, 1.25}, // station 0
45 {1.25, 1.25}, // station 0
46 {1.25, 1.25} // station 0
47};
48
49// Sizes of elements (cm) -------------------------------------------------------
50
51// Gas volume sizes (module: half of station)
52const Double_t XGasSize = 113.0;
53const Double_t YGasSize = 54.375;
54const Double_t ZGasSize = 0.76;
55
56// Sensitive volume sizes (module: half of station)
57const Double_t XSensSize = 112.9;
58const Double_t YSensSize = 53.25; // 106.5*0.5
59const Double_t ZSensSize = 0.76;
60//------------------------------------------------------------------------------
61
62// GeoManager
64
65// media
73
74class FairGeoMedia;
75class FairGeoBuilder;
76
77TGeoVolume* CreateStation(TString station_name);
78TGeoVolume* CreateModule(TString module_name);
79
80void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
81{
82
83 // air medium
84 FairGeoMedium* mAir = geoMedia->getMedium("air");
85 if (!mAir)
86 Fatal("Main", "FairMedium air not found");
87 geoBuild->createMedium(mAir);
88 pMedAir = gGeoManager->GetMedium("air");
89 if (!pMedAir)
90 Fatal("Main", "Medium air not found");
91
92 // carbon medium
93 FairGeoMedium* mCarbon = geoMedia->getMedium("carbon");
94 if (!mCarbon)
95 Fatal("Main", "FairMedium carbon not found");
96 geoBuild->createMedium(mCarbon);
97 pMedCarbon = gGeoManager->GetMedium("carbon");
98 if (!pMedCarbon)
99 Fatal("Main", "Medium carbon not found");
100
101 // fiberglass medium
102 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
103 if (!mFiberGlass)
104 Fatal("Main", "FairMedium fiberglass not found");
105 geoBuild->createMedium(mFiberGlass);
106 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
107 if (!pMedFiberGlass)
108 Fatal("Main", "Medium fiberglass not found");
109
110 // arco27020 medium
111 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
112 if (!mArCO27030)
113 Fatal("Main", "FairMedium arco27030 not found");
114 geoBuild->createMedium(mArCO27030);
115 pMedArCO27030 = gGeoManager->GetMedium("arco27030");
116 if (!pMedArCO27030)
117 Fatal("Main", "Medium arco27030 not found");
118
119 // ArgonIsobutane (75/25): Ar-iC4H10 medium
120 FairGeoMedium* mArgonIsobutane7525 = geoMedia->getMedium("ArgonIsobutane7525");
121 if (!mArgonIsobutane7525)
122 Fatal("Main", "FairMedium ArgonIsobutane7525 not found");
123 geoBuild->createMedium(mArgonIsobutane7525);
124 pMedArgonIsobutane7525 = gGeoManager->GetMedium("ArgonIsobutane7525");
126 Fatal("Main", "Medium ArgonIsobutane7525 not found");
127
128 // Rohacell medium
129 FairGeoMedium* mRohacell = geoMedia->getMedium("rohacellhf71");
130 if (!mRohacell)
131 Fatal("Main", "FairMedium rohacellhf71 not found");
132 geoBuild->createMedium(mRohacell);
133 pMedRohacell = gGeoManager->GetMedium("rohacellhf71");
134 if (!pMedRohacell)
135 Fatal("Main", "Medium rohacellhf71 not found");
136}
137
139{
140
141 // ---- set working directory --------------------------------------------
142 TString gPath = gSystem->Getenv("VMCWORKDIR");
143
144 // ------- Geometry file name (output) ----------------------------------
145 const TString geoDetectorName = "CSC";
146 const TString geoDetectorVersion = "Run8";
147 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
148
149 // ---- global geometry parameters ---------------------------------------
150 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
151 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
152
153 // ------- Load media from media file ----------------------------------
154 TString medFile = gPath + "/geometry/media.geo";
155 geoFace->setMediaFile(medFile);
156 geoFace->readMedia();
157 FairGeoMedia* geoMedia = geoFace->getMedia();
158 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
159
160 DefineRequiredMedia(geoMedia, geoBuild);
161 // -------------------------------------------------------------------------
162
163 // -------------- Create geometry and top volume ------------------------
164 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
165 gGeoMan->SetName(geoDetectorName + "_geom");
166 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
167 top->SetMedium(pMedAir);
168 gGeoMan->SetTopVolume(top);
169 // gGeoMan->SetTopVisible(1);
170 // -------------------------------------------------------------------------
171
172 // Define TOP Geometry
173 TGeoVolume* CSC = new TGeoVolumeAssembly(geoDetectorName);
174 CSC->SetMedium(pMedAir);
175
176 for (Int_t istation = 0; istation < NStations; ++istation) {
177
178 Int_t stationNum = istation; // station number
179
180 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
181
182 TGeoVolume* module0 = CreateModule(TString("module0_") + station->GetName());
183 TGeoVolume* module1 = CreateModule(TString("module1_") + station->GetName());
184
185 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
186 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
187 ZModuleShifts[stationNum][0] + 0.5 * ZGasSize);
188
189 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
190 module1_transform->RotateZ(180);
191 module1_transform->SetTranslation(XModuleShifts[stationNum][1], YModuleShifts[stationNum][1],
192 ZModuleShifts[stationNum][1] + 0.5 * ZGasSize);
193
194 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
195 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
196 ZStationPositions[stationNum]);
197
198 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform));
199 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform));
200
201 CSC->AddNode(station, 0, station_transform);
202 }
203
204 top->AddNode(CSC, 0);
206
207 // --------------- Finish -----------------------------------------------
208 gGeoMan->CloseGeometry();
209 gGeoMan->CheckOverlaps(0.0001);
210 gGeoMan->PrintOverlaps();
211 gGeoMan->Test();
212 // gGeoMan->RestoreMasterVolume();
213
214 TFile* geoFile = new TFile(geoFileName, "RECREATE");
215 top->Write();
216 geoFile->Close();
217 top->Draw("ogl");
218}
219
221{
222
223 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
224 stationA->SetMedium(pMedAir);
225
226 return stationA;
227}
228
230{
231
232 // shapes
233 TGeoShape* moduleS =
234 new TGeoBBox(TString("moduleS") += TString("_") + module_name, XGasSize * 0.5, YGasSize * 0.5, ZGasSize * 0.5);
235 TGeoShape* sensS =
236 new TGeoBBox(TString("sensS") += TString("_") + module_name, XSensSize * 0.5, YSensSize * 0.5, ZSensSize * 0.5);
237
238 // volumes
239 TGeoVolume* moduleV = new TGeoVolume(TString("moduleV") += TString("_") + module_name, moduleS);
240 TGeoVolume* sensV = new TGeoVolume(TString("CSCSensor") += TString("_") + module_name, sensS);
241
242 // medium
246 } else
247 Fatal("Main", "Invalid medium for moduleV and sensV volumes!");
248
249 // volume visual property (transparency)
250 moduleV->SetLineColor(TColor::GetColor("#47ffca"));
251 moduleV->SetTransparency(30);
252 sensV->SetLineColor(TColor::GetColor("#ff47ca"));
253 sensV->SetTransparency(30);
254
255 TGeoCombiTrans* sensV_transf[1];
256 sensV_transf[0] = new TGeoCombiTrans();
257 sensV_transf[0]->SetDx(0.0);
258 sensV_transf[0]->SetDy(-(YGasSize - YSensSize) * 0.5);
259 sensV_transf[0]->SetDz(0.0);
260
261 moduleV->AddNode(sensV, 0, sensV_transf[0]);
262
263 return moduleV;
264}
265//------------------------------------------------------------------------------
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 SetDz(Double_t dz) override
void SetDy(Double_t dy) override
void SetDx(Double_t dx) 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]
TGeoMedium * pMedArCO27030
const Int_t NStations
TGeoMedium * pMedFiberGlass
const Double_t XStationPositions[NStations]
TGeoMedium * pMedCopper
TGeoVolume * CreateModule(TString module_name)
TGeoMedium * pMedRohacell
const Double_t YSensSize
const Double_t ZSensSize
const Double_t YGasSize
void create_rootgeom_CSC_Run8()
const Double_t XGasSize
TGeoVolume * CreateStation(TString station_name)
TGeoMedium * pMedArgonIsobutane7525
const Double_t XSensSize
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
const Double_t ZGasSize