BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_ECAL_v2.C
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * File: create_rootgeom_ECAL_v2.C
4 * Last modified: 09-08-2019 by Petr Alekseev <pnaleks@gmail.com>
5 *
6 * Example of use:
7 * root -l '$VMCWORKDIR/macro/geometry/create_rootgeom_ECAL_v2.C(7,4)'
8 * This will generate root geometry file
9 * $VMCWORKDIR/geometry/ECAL_v2_run7_pos4.root
10 ******************************************************************************/
11
12#include "../run/bmnloadlibs.C"
13#include "TFile.h"
14#include "TGeoManager.h"
15#include "TGeoMedium.h"
16#include "TGeoVolume.h"
17
18//________________________________________________________________________________
19// ECAL = 8x7x9x215
20// ECAL = 8 SuperModules
21// SuperModule = 7 Modules
22// Module = 9 ADCmodules
23// ADCmodule = X:4cm x Y:4cm x Z:215 layers * (0.045 Pb + 0.15 Sci)
24// front steel cover ---PIPEC FIXME
25// ADCmodules == modules in the code
26
27//________________________________________________________________________________
28// ECAL Position and rotation in BM@N
29Double_t ecalX = -175; //-175; //-55 //ecalX = -167.18
30Double_t ecalY = 12.4; // 12.4; //12.4 //ecalY = 13.155;
31Double_t ecalZ = 283.1; // 283.1; //283.1 //ecalZ = 263.437;
32Double_t rotationAngle = -20; //-20; //10; //rotationAngle = -15.;
33
35{
36 if (run == 7) {
37 switch (pos) {
38 case 1:
39 ecalX = -44;
40 ecalY = 12.4;
41 ecalZ = 843.1;
42 rotationAngle = 0;
43 return;
44 case 2:
45 ecalX = -175;
46 ecalY = 12.4;
47 ecalZ = 883.1;
48 rotationAngle = -10;
49 return;
50 case 3:
51 ecalX = -175;
52 ecalY = 12.4;
53 ecalZ = 283.1;
54 rotationAngle = -10;
55 return;
56 case 4:
57 ecalX = -55;
58 ecalY = 12.4;
59 ecalZ = 283.1;
60 rotationAngle = -10;
61 return;
62 case 5:
63 ecalX = -175;
64 ecalY = 12.4;
65 ecalZ = 283.1;
66 rotationAngle = -20;
67 return;
68 }
69 }
70 Fatal("Main", "ECAL run %d position %d is not defined in " __FILE__, run, pos);
71}
72
73//________________________________________________________________________________
74// ECAL Parameters
75int Xmodules = 24; // X modules = ADCmodules
76int Ymodules = 21;
77int Zlayers = 215;
78Double_t thickPb = 0.030; // lead
79Double_t thickSci = 0.15; // scintilator
80Double_t thickSteel = 0.2; // front cover FIXME
81Double_t thickPaint = 0.0075; // paint
86
87// media ============================================
88struct
89{
100
101TGeoMedium* DefineMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild, const char* name)
102{
103 FairGeoMedium* pFairGeoMedium = geoMedia->getMedium(name);
104 if (!pFairGeoMedium)
105 Fatal("Main", "FairMedium %s not found", name);
106 geoBuild->createMedium(pFairGeoMedium);
107 TGeoMedium* pTGeoMedium = gGeoManager->GetMedium(name);
108 if (!pTGeoMedium)
109 Fatal("Main", "Medium %s not found", name);
110 return pTGeoMedium;
111}
112
113void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
114{
115
116 mMed.vacuum = DefineMedia(geoMedia, geoBuild, "vacuum");
117 // mMed.air = DefineMedia(geoMedia, geoBuild, "air");
118 // mMed.iron = DefineMedia(geoMedia, geoBuild, "iron");
119 // mMed.tyvec = DefineMedia(geoMedia, geoBuild, "tyvec_ZDC");
120 mMed.lead = DefineMedia(geoMedia, geoBuild, "lead");
121 // mMed.scint = DefineMedia(geoMedia, geoBuild, "polystyrene"); // medium polystyrene (Scint.)
122 mMed.scint = DefineMedia(geoMedia, geoBuild, "FscScint"); // medium FscScint (Scint.)
123 // mMed.slot = DefineMedia(geoMedia, geoBuild, "plasticWLS_ZDC"); // medium plastic (slot)
124 // mMed.steel = DefineMedia(geoMedia, geoBuild, "steel");
125 mMed.steel = DefineMedia(geoMedia, geoBuild, "steel");
126 mMed.TiO2 = DefineMedia(geoMedia, geoBuild, "TiO2");
127
128} // DefineRequiredMedia
129
130///
131/// \param[in] run BMN run number (only run 7 is currently supported)
132/// \param[in] pos ECAL position in the run (five positions for run 7 are defined)
133///
135{
136
137 bmnloadlibs(); // load libraries
138
139 // ---- set working directory --------------------------------------------
140 TString gPath = gSystem->Getenv("VMCWORKDIR");
141
142 // ---- Geometry file name (output) ----------------------------------------
143 const TString geoDetectorName = "ECAL";
144 const TString geoDetectorVersion = "v2";
145 TString geoFileName;
146 geoFileName.Form("%s/geometry/%s_%s_run%d_pos%d.root", gPath.Data(), geoDetectorName.Data(),
147 geoDetectorVersion.Data(), run, pos);
148 cout << geoFileName << endl;
149
150 SetEcalPosition(run, pos);
151 // TGeoRotation *rot = new TGeoRotation("rot1", rotationAngle, 0., 0.);
152 // TGeoRotation *rot = new TGeoRotation("rot1", 0., rotationAngle, 0.);
153 // TGeoRotation *rot = new TGeoRotation("rot1", 0., 0., rotationAngle);
154
155 TGeoRotation* rot = new TGeoRotation("rot1", 0., 0., 0.);
156 rot->Print();
158
159 TGeoCombiTrans* combi1 = new TGeoCombiTrans(ecalX, ecalY, ecalZ, rot);
160
161 // ---- global geometry parameters ---------------------------------------
162 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
163 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
164
165 // ------- Load media from media file ----------------------------------
166 TString medFile = gPath + "/geometry/media.geo";
167 geoFace->setMediaFile(medFile);
168 geoFace->readMedia();
169 FairGeoMedia* geoMedia = geoFace->getMedia();
170 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
171 geoMedia->list();
172 geoMedia->print();
173 DefineRequiredMedia(geoMedia, geoBuild);
174
175 // ------------------------ VOLUMES ----------------------------------------
176
177 // -------------- Create geometry and global top volume -----------------
178
179 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
180 top->SetMedium(mMed.air); // ??? it was vacuum ???
181 // top->SetLineColor(kBlue);
182 // top->SetVisibility(kTRUE);
183 // top->SetTransparency(100);
184
185 gGeoManager = (TGeoManager*)gROOT->FindObject("FAIRGeom");
186 gGeoManager->SetName(geoDetectorName + "_geom");
187 gGeoManager->SetTopVolume(top);
188 // gGeoManager->SetTopVisible(1);
189
190 TGeoVolume* ecal =
191 gGeoManager->MakeBox("ecal", mMed.vacuum, Xmodules * modwidth / 2, Ymodules * modheight / 2, modlength / 2);
192 // ecal->SetVisibility(kTRUE);
193 // ecal->SetTransparency(100);
194 // combi1->RotateY(rotationAngle);
195 top->AddNode(ecal, 0, combi1);
196
197 TGeoVolume* module = gGeoManager->MakeBox("mod", mMed.vacuum, modwidth / 2, modheight / 2, modlength / 2);
198 // module->SetVisibility(kTRUE);
199 // module->SetTransparency(100);
200 // module->SetLineColor(kRed);
201 // module->SetLineWidth(0);
202
203 TGeoVolume* layerPb = gGeoManager->MakeBox("layPb", mMed.lead, modwidth / 2, modheight / 2, thickPb / 2);
204 // layerPb->SetVisibility(kTRUE);
205 // layerPb->SetLineColor(kBlue);
206 // layerPb->SetLineWidth(0);
207 // layerPb->SetTransparency(100);
208
209 TGeoVolume* layerPaint = gGeoManager->MakeBox("layPaint", mMed.TiO2, modwidth / 2, modheight / 2, thickPaint / 2);
210 // layerPaint->SetVisibility(kTRUE);
211 // layerPaint->SetLineColor(kWhite);
212 // layerPaint->SetLineWidth(0);
213 // layerPaint->SetTransparency(100);
214
215 TGeoVolume* layerSci = gGeoManager->MakeBox("laySci", mMed.scint, modwidth / 2, modheight / 2, thickSci / 2);
216 // layerSci->SetLineColor(kWhite+1);
217 // layerSci->SetTransparency(100);
218
219 TGeoVolume* covSteel = gGeoManager->MakeBox("covSteel", mMed.air, modwidth / 2, modheight / 2,
220 thickSteel / 2); // ??? should be steel ???
221 // covSteel->SetVisibility(kTRUE);
222 // covSteel->SetLineColor(kWhite);
223 // covSteel->SetTransparency(100);
224
225 // ------------------ STRUCTURE -------------------------------------------
226 module->AddNode(covSteel, 0, new TGeoTranslation(0, 0, thickSteel / 2 - modlength / 2));
227 Double_t z;
228 // Zlayers = 1;
229 Int_t nlay;
230 for (int zlayer = 0; zlayer < Zlayers; zlayer++) {
231 z = thickSteel + thickPbSciPaint * zlayer;
232 // TString layerNamePb = TString::Format("layerPb%d",zlayer);
233 // TString layerNameSci = TString::Format("layerSci%d",zlayer);
234 module->AddNode(layerPaint, nlay, new TGeoTranslation(0, 0, z + thickPaint / 2 - modlength / 2));
235 module->AddNode(layerPb, nlay, new TGeoTranslation(0, 0, z + thickPaint + thickPb / 2 - modlength / 2));
236 module->AddNode(layerPaint, nlay,
237 new TGeoTranslation(0, 0, z + thickPaint + thickPb + thickPaint / 2 - modlength / 2));
238 module->AddNode(
239 layerSci, zlayer,
240 new TGeoTranslation(0, 0, z + thickPaint + thickPb + thickPaint + thickSci / 2 - modlength / 2));
241 }
242
243 int nmod = 0;
244 // Xmodules = 1;
245 // Ymodules = 1;
246 Double_t x0 = modwidth * Xmodules / 2 - modwidth / 2;
247 Double_t y0 = modheight * Ymodules / 2 - modheight / 2;
248 for (int xmod = 0; xmod < Xmodules; xmod++) {
249 for (int ymod = 0; ymod < Ymodules; ymod++) {
250 TString moduleName = TString::Format("mod_X:%d_Y:%d", xmod, ymod);
251 module->SetName(moduleName);
252 cout << module->GetName() << endl;
253 ecal->AddNode(module, nmod++, new TGeoTranslation(x0 - modwidth * xmod, -y0 + modheight * ymod, 0));
254 } // ymod
255 } // xmod
256
258 gGeoManager->CloseGeometry();
259 gGeoManager->CheckOverlaps(0.001);
260 gGeoManager->PrintOverlaps();
261 gGeoManager->Test();
262 // gGeoMan->SetVisLevel(3);
263 // gGeoMan->SetVisOption(1);
264 TFile* geoFile = new TFile(geoFileName, "RECREATE");
265 top->Write();
266 geoFile->Close();
267 // top->Draw("ogl");
268}
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
void Close(Option_t *option="") override
void Print(Option_t *option="") const override
void RotateY(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="")
virtual void SetMedium(TGeoMedium *medium)
const char * GetName() const override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
const char * Data() const
static TString Format(const char *fmt,...)
void Form(const char *fmt,...)
Double_t thickPaint
Double_t modheight
Double_t thickPb
Double_t thickSci
Double_t modwidth
Double_t rotationAngle
Double_t thickPbSciPaint
Double_t ecalX
Double_t modlength
Double_t thickSteel
Double_t ecalZ
Double_t ecalY
TGeoMedium * iron
TGeoMedium * tyvec
TGeoMedium * lead
TGeoMedium * steel
TGeoMedium * TiO2
TGeoMedium * air
TGeoMedium * vacuum
TGeoMedium * scint
TGeoMedium * DefineMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild, const char *name)
void SetEcalPosition(Int_t run, Int_t pos)
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
void create_rootgeom_ECAL_v2(Int_t run, Int_t pos)