BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_ECAL_v1.C
Go to the documentation of this file.
1
2// ECAL = 8x7x9x215
3// ECAL = 8 SuperModules
4// SuperModule = 7 Modules
5// Module = 9 ADCmodules
6// ADCmodule = X:4cm x Y:4cm x Z:215 layers * (0.045 Pb + 0.15 Sci)
7// front steel cover ---PIPEC FIXME
8// ADCmodules == modules in the code
9//
10// TString geoFileName = "bmnGeoEcal.root";
11//________________________________________________________________________________
12
13//
14// ECAL Position and rotation in BM@N
15Double_t ecalX = -175; //-175; //-55 //ecalX = -167.18
16Double_t ecalY = 12.4; // 12.4; //12.4 //ecalY = 13.155;
17Double_t ecalZ = 283.1; // 283.1; //283.1 //ecalZ = 263.437;
18Double_t rotationAngle = -20; //-20; // 10; //rotationAngle = -15.;
19 //________________________________________________________________________________
20 // ECAL Parameters
21int Xmodules = 24; // X modules = ADCmodules
22int Ymodules = 21;
23int Zlayers = 215;
24Double_t thickPb = 0.030; // lead
25Double_t thickSci = 0.15; // scintilator
26Double_t thickSteel = 0.2; // front cover FIXME
27Double_t thickPaint = 0.0075; // paint
32
33//________________________________________________________________________________
35{
36
37 // gStyle->SetCanvasPreferGL(true);
38 // gSystem->Load("libGeom");
39 // Load the necessary FairRoot libraries
40 // gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
41 // bmnloadlibs();
42
43 // TGeoRotation *rot = new TGeoRotation("rot1", rotationAngle, 0., 0.);
44 // TGeoRotation *rot = new TGeoRotation("rot1", 0., rotationAngle, 0.);
45 // TGeoRotation *rot = new TGeoRotation("rot1", 0., 0., rotationAngle);
46
47 TGeoRotation* rot = new TGeoRotation("rot1", 0., 0., 0.);
48 rot->Print();
50 TGeoCombiTrans* combi1 = new TGeoCombiTrans(ecalX, ecalY, ecalZ, rot);
51 // GeoManager
52 TGeoManager* gGeoMan = NULL; // TGeoManager *geom = new TGeoManager("geom", "ECAL geometry");
53 // ------- Load media from media file -----------------------------------
54 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
55 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
56 TString geoPath = gSystem->Getenv("VMCWORKDIR");
57 TString medFile = geoPath + "/geometry/media.geo";
58 geoFace->setMediaFile(medFile);
59 geoFace->readMedia();
60 gGeoMan = gGeoManager;
61
62 // Geometry file name (output) ----------------------------------
63 const TString geoDetectorName = "ECALlalyoPOS5";
64 const TString geoDetectorVersion = "v1";
65 const TString geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
66 cout << geoFileName << endl;
67
68 //--- define some media
69 FairGeoMedia* geoMedia = geoFace->getMedia();
70 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
71
72 FairGeoMedium* mvacuum = geoMedia->getMedium("vacuum");
73 if (!mvacuum)
74 Fatal("Main", "FairMedium vacuum not found");
75 geoBuild->createMedium(mvacuum);
76 TGeoMedium* pvacuum = gGeoMan->GetMedium("vacuum");
77 if (!pvacuum)
78 Fatal("Main", "Medium vacuum not found");
79
80 FairGeoMedium* mFscScint = geoMedia->getMedium("FscScint");
81 if (!mFscScint)
82 Fatal("Main", "FairMedium FscScint not found");
83 geoBuild->createMedium(mFscScint);
84 TGeoMedium* pFscScint = gGeoMan->GetMedium("FscScint");
85 if (!pFscScint)
86 Fatal("Main", "Medium FscScint not found");
87
88 FairGeoMedium* mPb = geoMedia->getMedium("lead");
89 if (!mPb)
90 Fatal("Main", "FairMedium Pb not found");
91 geoBuild->createMedium(mPb);
92 TGeoMedium* pPb = gGeoMan->GetMedium("lead");
93 if (!pPb)
94 Fatal("Main", "Medium Pb not found");
95
96 FairGeoMedium* msteel = geoMedia->getMedium("air"); // FIXME
97 if (!msteel)
98 Fatal("Main", "FairMedium steel not found"); // FIXME
99 geoBuild->createMedium(msteel);
100 TGeoMedium* psteel = gGeoMan->GetMedium("air"); // FIXME
101 if (!psteel)
102 Fatal("Main", "Medium steel not found"); // FIXME
103
104 FairGeoMedium* mTiO2 = geoMedia->getMedium("TiO2");
105 if (!mTiO2)
106 Fatal("Main", "FairMedium TiO2 not found");
107 geoBuild->createMedium(mTiO2);
108 TGeoMedium* pTiO2 = gGeoMan->GetMedium("TiO2");
109 if (!pTiO2)
110 Fatal("Main", "Medium TiO2 not found");
111 //------------------------- VOLUMES -----------------------------------------
112
113 // -------------- Create geometry and top volume -------------------------
114 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
115 top->SetMedium(pvacuum); // FIXME
116 top->SetLineColor(kBlue);
117 top->SetVisibility(kTRUE);
118 top->SetTransparency(100);
119
120 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
121 gGeoMan->SetName("ECALgeom");
122 gGeoMan->SetTopVolume(top);
123 gGeoMan->SetTopVisible(0);
124
125 TGeoVolume* ecal =
126 gGeoMan->MakeBox("ecal", pvacuum, Xmodules * modwidth / 2, Ymodules * modheight / 2, modlength / 2);
127 ecal->SetVisibility(kTRUE); // kFALSE
128 ecal->SetTransparency(100);
129 // combi1->RotateY(rotationAngle);
130 top->AddNode(ecal, 0, combi1);
131
132 TGeoVolume* module = gGeoMan->MakeBox("mod", pvacuum, modwidth / 2, modheight / 2, modlength / 2);
133 module->SetVisibility(kTRUE); // kFALSE
134 module->SetTransparency(100);
135 module->SetLineColor(kRed);
136 module->SetLineWidth(0);
137 TGeoVolume* layerPb = gGeoMan->MakeBox("layPb", pPb, modwidth / 2, modheight / 2, thickPb / 2);
138 layerPb->SetVisibility(kTRUE); // kFALSE
139 layerPb->SetLineColor(kBlue);
140 layerPb->SetLineWidth(0);
141 layerPb->SetTransparency(100);
142
143 TGeoVolume* layerPaint = gGeoMan->MakeBox("layPaint", pTiO2, modwidth / 2, modheight / 2, thickPaint / 2);
144 layerPaint->SetVisibility(kTRUE); // kFALSE
145 layerPaint->SetLineColor(kWhite);
146 layerPaint->SetLineWidth(0);
147 layerPaint->SetTransparency(100);
148
149 TGeoVolume* layerSci = gGeoMan->MakeBox("laySci", pFscScint, modwidth / 2, modheight / 2, thickSci / 2);
150 layerSci->SetLineColor(kWhite + 1);
151 layerSci->SetTransparency(100);
152 TGeoVolume* covSteel = gGeoMan->MakeBox("covSteel", air, modwidth / 2, modheight / 2, thickSteel / 2); // FIXME
153 covSteel->SetVisibility(kTRUE); // kFALSE
154 covSteel->SetLineColor(kWhite);
155 covSteel->SetTransparency(100);
156
157 //------------------ STRUCTURE -----------------------------------------
158 module->AddNode(covSteel, 0, new TGeoTranslation(0, 0, thickSteel / 2 - modlength / 2));
159 Double_t z;
160 // Zlayers = 1;
161 Int_t nlay;
162 for (int zlayer = 0; zlayer < Zlayers; zlayer++) {
163 z = thickSteel + thickPbSciPaint * zlayer;
164 // TString layerNamePb = TString::Format("layerPb%d",zlayer);
165 // TString layerNameSci = TString::Format("layerSci%d",zlayer);
166 module->AddNode(layerPaint, nlay, new TGeoTranslation(0, 0, z + thickPaint / 2 - modlength / 2));
167 module->AddNode(layerPb, nlay, new TGeoTranslation(0, 0, z + thickPaint + thickPb / 2 - modlength / 2));
168 module->AddNode(layerPaint, nlay,
169 new TGeoTranslation(0, 0, z + thickPaint + thickPb + thickPaint / 2 - modlength / 2));
170 module->AddNode(
171 layerSci, zlayer,
172 new TGeoTranslation(0, 0, z + thickPaint + thickPb + thickPaint + thickSci / 2 - modlength / 2));
173 }
174
175 int nmod = 0;
176 // Xmodules = 1;
177 // Ymodules = 1;
178 Double_t x0 = modwidth * Xmodules / 2 - modwidth / 2;
179 Double_t y0 = modheight * Ymodules / 2 - modheight / 2;
180 for (int xmod = 0; xmod < Xmodules; xmod++) {
181 for (int ymod = 0; ymod < Ymodules; ymod++) {
182 TString moduleName = TString::Format("mod_X:%d_Y:%d", xmod, ymod);
183
184 module->SetName(moduleName);
185 cout << module->GetName() << endl;
186 ecal->AddNode(module, nmod++, new TGeoTranslation(x0 - modwidth * xmod, -y0 + modheight * ymod, 0));
187 } // ymod
188 } // xmod
189
191 gGeoMan->CloseGeometry();
192 gGeoMan->CheckOverlaps(0.001);
193 gGeoMan->PrintOverlaps();
194 gGeoMan->Test();
195 gGeoMan->SetVisLevel(3);
196 // gGeoMan->SetVisOption(1);
197 TFile* geoFile = new TFile(geoFileName, "RECREATE");
198 top->Write();
199 geoFile->Close();
200 top->Draw("ogl");
201}
int Int_t
double Double_t
constexpr Bool_t kTRUE
kWhite
kBlue
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
void SetVisibility(Bool_t vis=kTRUE) override
void SetLineWidth(Width_t lwidth) 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 Format(const char *fmt,...)
Double_t thickPaint
Double_t modheight
Double_t thickPb
Double_t thickSci
void createEcalGeo1()
Double_t modwidth
Double_t rotationAngle
Double_t thickPbSciPaint
Double_t ecalX
Double_t modlength
Double_t thickSteel
Double_t ecalZ
Double_t ecalY