BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_GEMS_RunSpring2018_misAlign.C
Go to the documentation of this file.
1/*
2 * Baranov D.
3 * 16.05.2018
4 * Use this macro to create ROOT geometry for the RunSpring2017 configuration (BM@N RUN-7)
5 *
6 */
7
8#include <TClonesArray.h>
9#include <TFile.h>
10#include <TRandom.h>
11#include <TRandom2.h>
12#include <TTree.h>
13#include <fstream>
14#include <string.h>
15#include <string>
16
17using namespace std;
18// Set Parameters of GEMS -------------------------------------------------------
19const Int_t NStations = 6; // stations in the detector
20const Int_t NMaxModules = 2; // max. number of modules in a station
21
22//(X-Y-Z)Positions of stations (sensitive volumes)
23const Double_t XStationPositions[NStations] = {+0.5390, +0.7025, +1.9925, +3.0860, +3.7980, +4.5815};
24const Double_t YStationPositions[NStations] = {+15.99873, +16.20573, +16.36073, +16.40473, +16.09373, +16.45473};
25const Double_t ZStationPositions[NStations] = {+39.702, +64.535, +112.649, +135.330, +160.6635, +183.668};
26
27//(X-Y-Z)Shifts of modules in each station
28Double_t XModuleShifts[NStations][NMaxModules] = {{163.2 * 0.25, -163.2 * 0.25}, {163.2 * 0.25, -163.2 * 0.25},
29 {163.2 * 0.25, -163.2 * 0.25}, {163.2 * 0.25, -163.2 * 0.25},
30 {163.2 * 0.25, -163.2 * 0.25}, {163.2 * 0.25, -163.2 * 0.25}};
31Double_t YModuleShifts[NStations][NMaxModules] = {{0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0},
32 {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}};
33Double_t ZModuleShifts[NStations][NMaxModules] = {{0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0},
34 {0.0, 0.0}, {0.0, 0.0}, {0.0, 0.0}};
35
36// GEM plane sizes (66x41 type) -------------------------------------------------
40
44//------------------------------------------------------------------------------
45
46// GEM plane sizes (163x45 type) ------------------------------------------------
50
54//------------------------------------------------------------------------------
55
56// GeoManager
58
59// media
65
66class FairGeoMedia;
67class FairGeoBuilder;
68
69TGeoVolume* CreateStation(TString station_name);
70TGeoVolume* CreateModule_Station66x41(TString module_name, Double_t xsize, Double_t ysize, Double_t zsize);
73 Double_t xsize,
74 Double_t ysize,
75 Double_t zsize,
76 Double_t hole_radius);
78 Double_t dx,
79 Double_t dy,
80 Double_t dz,
81 Double_t hole_radius);
84
85void createNewXML(Double_t*** mis, TString in, TString out)
86{
87 ifstream input;
88 input.open(in.Data(), ios::in);
89
90 FILE* output = fopen(out.Data(), "w");
91
92 Int_t stat = -1, mod = -1;
93 Int_t statCounter = -1;
94
95 for (string line; getline(input, line);) {
96 TString str = TString(line.c_str());
97
98 if (str.Contains("<Module")) {
99 statCounter++;
100 if (statCounter % 2 == 0)
101 stat++;
102 mod++;
103
104 TString tmp = TString::Format("xShift=\"%G\" yShift=\"%G\" zShift=\"%G\"", mis[stat][mod][0],
105 mis[stat][mod][1], mis[stat][mod][2]);
106 str.ReplaceAll("xShift=\"0.0\" yShift=\"0.0\" zShift=\"0.0\"", tmp);
107 }
108 if (mod == 1)
109 mod = -1;
110
111 fprintf(output, "%s\n", str.Data());
112 }
113 fclose(output);
114}
115
117{
118 FILE* file = fopen("introducedMisalign.dat", "w");
119 gRandom->SetSeed(11);
120 Double_t*** misAlign = new Double_t**[NStations];
121 for (Int_t iStat = 0; iStat < NStations; iStat++) {
122 misAlign[iStat] = new Double_t*[NMaxModules];
123 for (Int_t iMod = 0; iMod < NMaxModules; iMod++) {
124 misAlign[iStat][iMod] = new Double_t[3];
125 for (Int_t iPar = 0; iPar < 3; iPar++) {
126 misAlign[iStat][iMod][iPar] = gRandom->Gaus(0., (iPar == 0) ? sigX : (iPar == 1) ? sigY : sigZ);
127 fprintf(file, "Stat %d Mod %d Par %d %G\n", iStat, iMod, iPar, misAlign[iStat][iMod][iPar]);
128 }
129 }
130 }
131 fclose(file);
132
133 // Fill ROOT-container with misalign.
134 TFile* f = new TFile("misAlignment.root", "RECREATE");
135 TTree* outTree = new TTree("cbmsim", "cbmsim");
136 TClonesArray* misalign = new TClonesArray("BmnGemAlignCorrections");
137 outTree->Branch("BmnGemAlignCorrections", &misalign);
138 for (Int_t iStat = 0; iStat < NStations; iStat++)
139 for (Int_t iMod = 0; iMod < NMaxModules; iMod++)
140 new ((*misalign)[misalign->GetEntriesFast()]) BmnGemAlignCorrections(
141 iStat, iMod, TVector3(misAlign[iStat][iMod][0], misAlign[iStat][iMod][1], misAlign[iStat][iMod][2]));
142 outTree->Fill();
143 outTree->Write();
144 f->Close();
145
146 return misAlign;
147}
148
149void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
150{
151
152 // air medium
153 FairGeoMedium* mAir = geoMedia->getMedium("air");
154 if (!mAir)
155 Fatal("Main", "FairMedium air not found");
156 geoBuild->createMedium(mAir);
157 pMedAir = gGeoManager->GetMedium("air");
158 if (!pMedAir)
159 Fatal("Main", "Medium air not found");
160
161 // carbon medium
162 FairGeoMedium* mCarbon = geoMedia->getMedium("carbon");
163 if (!mCarbon)
164 Fatal("Main", "FairMedium carbon not found");
165 geoBuild->createMedium(mCarbon);
166 pMedCarbon = gGeoManager->GetMedium("carbon");
167 if (!pMedCarbon)
168 Fatal("Main", "Medium carbon not found");
169
170 // fiberglass medium
171 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
172 if (!mFiberGlass)
173 Fatal("Main", "FairMedium fiberglass not found");
174 geoBuild->createMedium(mFiberGlass);
175 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
176 if (!pMedFiberGlass)
177 Fatal("Main", "Medium fiberglass not found");
178
179 // arco27020 medium
180 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
181 if (!mArCO27030)
182 Fatal("Main", "FairMedium arco27030 not found");
183 geoBuild->createMedium(mArCO27030);
184 pMedArCO27030 = gGeoManager->GetMedium("arco27030");
185 if (!pMedArCO27030)
186 Fatal("Main", "Medium arco27030 not found");
187}
188
190 Double_t sigY,
191 Double_t sigZ,
192 TString geoVersion = "RunSpring2018_misAlign",
193 TString xmlMisalign = "GemRunSpring2018_misAlign.xml")
194{
195
196 // ---- set working directory --------------------------------------------
197 TString gPath = gSystem->Getenv("VMCWORKDIR");
198
199 // Add generated misalignment to GEM geometry
200 for (Int_t iStat = 0; iStat < NStations; iStat++)
201 for (Int_t iMod = 0; iMod < NMaxModules; iMod++) {
202 Double_t* tmp = generateMisalign(sigX, sigY, sigZ)[iStat][iMod];
203 XModuleShifts[iStat][iMod] += tmp[0];
204 YModuleShifts[iStat][iMod] += tmp[1];
205 ZModuleShifts[iStat][iMod] += tmp[2];
206 }
207
208 // Generate new XML-file according to introduced misalignment
209 const TString xmlPath = gPath + "/parameters/gem/XMLConfigs/";
210 createNewXML(generateMisalign(sigX, sigY, sigZ), xmlPath + "GemRunSpring2018.xml", xmlPath + xmlMisalign);
211
212 // ------- Geometry file name (output) ----------------------------------
213 const TString geoDetectorName = "GEMS";
214 const TString geoDetectorVersion = geoVersion;
215 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
216
217 // ---- global geometry parameters ---------------------------------------
218 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
219 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
220
221 // ------- Load media from media file ----------------------------------
222 TString medFile = gPath + "/geometry/media.geo";
223 geoFace->setMediaFile(medFile);
224 geoFace->readMedia();
225 FairGeoMedia* geoMedia = geoFace->getMedia();
226 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
227
228 DefineRequiredMedia(geoMedia, geoBuild);
229 // -------------------------------------------------------------------------
230
231 // -------------- Create geometry and top volume -------------------------
232 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
233 gGeoMan->SetName(geoDetectorName + "_geom");
234 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
235 top->SetMedium(pMedAir);
236 gGeoMan->SetTopVolume(top);
237 // gGeoMan->SetTopVisible(1);
238 // --------------------------------------------------------------------------
239
240 // Define TOP Geometry
241 TGeoVolume* GEMS = new TGeoVolumeAssembly(geoDetectorName);
242 GEMS->SetMedium(pMedAir);
243
244 // TGeoVolume *target = gGeoMan->MakeSphere("target", 0, 0, 5.0);
245 // GEMS->AddNode(target, 0, new TGeoTranslation(0.0, 0.0, -647.476));
246
247 // station 0 (big 163x45 GEM consisting two modules)
248 if (1) {
249 Int_t stationNum = 0; // station number
250
251 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
252 TGeoVolume* module0 =
255 TGeoVolume* module1 =
258 TGeoVolume* frame0 =
261 TGeoVolume* frame1 =
264
265 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
266 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
267 ZModuleShifts[stationNum][0] + ZModuleSize_Station163x45 * 0.5);
268
269 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
270 module1_transform->ReflectX(true);
271 module1_transform->SetTranslation(XModuleShifts[stationNum][1], YModuleShifts[stationNum][1],
272 ZModuleShifts[stationNum][1] + ZModuleSize_Station163x45 * 0.5);
273
274 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
275 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
276 ZStationPositions[stationNum]);
277
278 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform)); // module
279 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform)); // module
280
281 station->AddNode(frame0, 0, new TGeoCombiTrans(*module0_transform)); // frame
282 station->AddNode(frame1, 0, new TGeoCombiTrans(*module1_transform)); // frame
283
284 GEMS->AddNode(station, 0, station_transform);
285 }
286
287 // station 1 (big 163x45 GEM consisting two modules)
288 if (1) {
289 Int_t stationNum = 1; // station number
290
291 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
292 TGeoVolume* module0 =
295 TGeoVolume* module1 =
298 TGeoVolume* frame0 =
301 TGeoVolume* frame1 =
304
305 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
306 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
307 ZModuleShifts[stationNum][0] + ZModuleSize_Station163x45 * 0.5);
308
309 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
310 module1_transform->ReflectX(true);
311 module1_transform->SetTranslation(XModuleShifts[stationNum][1], YModuleShifts[stationNum][1],
312 ZModuleShifts[stationNum][1] + ZModuleSize_Station163x45 * 0.5);
313
314 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
315 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
316 ZStationPositions[stationNum]);
317
318 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform)); // module
319 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform)); // module
320
321 station->AddNode(frame0, 0, new TGeoCombiTrans(*module0_transform)); // frame
322 station->AddNode(frame1, 0, new TGeoCombiTrans(*module1_transform)); // frame
323
324 GEMS->AddNode(station, 0, station_transform);
325 }
326
327 // station 2 (big 163x45 GEM consisting two modules)
328 if (1) {
329 Int_t stationNum = 2; // station number
330
331 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
332 TGeoVolume* module0 =
335 TGeoVolume* module1 =
338 TGeoVolume* frame0 =
341 TGeoVolume* frame1 =
344
345 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
346 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
347 ZModuleShifts[stationNum][0] + ZModuleSize_Station163x45 * 0.5);
348
349 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
350 module1_transform->ReflectX(true);
351 module1_transform->SetTranslation(XModuleShifts[stationNum][1], YModuleShifts[stationNum][1],
352 ZModuleShifts[stationNum][1] + ZModuleSize_Station163x45 * 0.5);
353
354 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
355 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
356 ZStationPositions[stationNum]);
357
358 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform)); // module
359 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform)); // module
360
361 station->AddNode(frame0, 0, new TGeoCombiTrans(*module0_transform)); // frame
362 station->AddNode(frame1, 0, new TGeoCombiTrans(*module1_transform)); // frame
363
364 GEMS->AddNode(station, 0, station_transform);
365 }
366
367 // station 3 (big 163x45 GEM consisting two modules)
368 if (1) {
369 Int_t stationNum = 3; // station number
370
371 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
372 TGeoVolume* module0 =
375 TGeoVolume* module1 =
378 TGeoVolume* frame0 =
381 TGeoVolume* frame1 =
384
385 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
386 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
387 ZModuleShifts[stationNum][0] + ZModuleSize_Station163x45 * 0.5);
388
389 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
390 module1_transform->ReflectX(true);
391 module1_transform->SetTranslation(XModuleShifts[stationNum][1], YModuleShifts[stationNum][1],
392 ZModuleShifts[stationNum][1] + ZModuleSize_Station163x45 * 0.5);
393
394 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
395 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
396 ZStationPositions[stationNum]);
397
398 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform)); // module
399 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform)); // module
400
401 station->AddNode(frame0, 0, new TGeoCombiTrans(*module0_transform)); // frame
402 station->AddNode(frame1, 0, new TGeoCombiTrans(*module1_transform)); // frame
403
404 GEMS->AddNode(station, 0, station_transform);
405 }
406
407 // station 4 (big 163x45 GEM consisting two modules)
408 if (1) {
409 Int_t stationNum = 4; // station number
410
411 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
412 TGeoVolume* module0 =
415 TGeoVolume* module1 =
418 TGeoVolume* frame0 =
421 TGeoVolume* frame1 =
424
425 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
426 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
427 ZModuleShifts[stationNum][0] + ZModuleSize_Station163x45 * 0.5);
428
429 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
430 module1_transform->ReflectX(true);
431 module1_transform->SetTranslation(XModuleShifts[stationNum][1], YModuleShifts[stationNum][1],
432 ZModuleShifts[stationNum][1] + ZModuleSize_Station163x45 * 0.5);
433
434 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
435 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
436 ZStationPositions[stationNum]);
437
438 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform)); // module
439 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform)); // module
440
441 station->AddNode(frame0, 0, new TGeoCombiTrans(*module0_transform)); // frame
442 station->AddNode(frame1, 0, new TGeoCombiTrans(*module1_transform)); // frame
443
444 GEMS->AddNode(station, 0, station_transform);
445 }
446
447 // station 5 (big 163x45 GEM consisting two modules)
448 if (1) {
449 Int_t stationNum = 5; // station number
450
451 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
452 TGeoVolume* module0 =
455 TGeoVolume* module1 =
458 TGeoVolume* frame0 =
461 TGeoVolume* frame1 =
464
465 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
466 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
467 ZModuleShifts[stationNum][0] + ZModuleSize_Station163x45 * 0.5);
468
469 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
470 module1_transform->ReflectX(true);
471 module1_transform->SetTranslation(XModuleShifts[stationNum][1], YModuleShifts[stationNum][1],
472 ZModuleShifts[stationNum][1] + ZModuleSize_Station163x45 * 0.5);
473
474 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
475 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
476 ZStationPositions[stationNum]);
477
478 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform)); // module
479 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform)); // module
480
481 station->AddNode(frame0, 0, new TGeoCombiTrans(*module0_transform)); // frame
482 station->AddNode(frame1, 0, new TGeoCombiTrans(*module1_transform)); // frame
483
484 GEMS->AddNode(station, 0, station_transform);
485 }
486
487 top->AddNode(GEMS, 0);
489
490 // --------------- Finish -----------------------------------------------
491 gGeoMan->CloseGeometry();
492 gGeoMan->CheckOverlaps(0.0001);
493 gGeoMan->PrintOverlaps();
494 gGeoMan->Test();
495 // gGeoMan->RestoreMasterVolume();
496
497 TFile* geoFile = new TFile(geoFileName, "RECREATE");
498 top->Write();
499 geoFile->Close();
500 // top->Draw("ogl");
501}
502//------------------------------------------------------------------------------
503
505{
506
507 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
508 stationA->SetMedium(pMedAir);
509
510 return stationA;
511}
512
514{
515
516 // module shape
517 TGeoShape* moduleS = new TGeoBBox("moduleS", xsize * 0.5, ysize * 0.5, zsize * 0.5);
518
519 // module volume
520 TGeoVolume* moduleV = new TGeoVolume(module_name, moduleS);
521
522 // medium
523 if (pMedArCO27030)
524 moduleV->SetMedium(pMedArCO27030);
525 else
526 Fatal("Main", "Invalid medium for sensitive modules!");
527
528 // visual parameters
529 moduleV->SetLineColor(TColor::GetColor("#ff47ca"));
530 moduleV->SetTransparency(20);
531
532 return moduleV;
533}
534
536{
537
538 // frame shapes
539 TGeoShape* vertical_frameS =
540 new TGeoBBox("vertical_frameS", dx * 0.5, YModuleSize_Station66x41 * 0.5 + dy, dz * 0.5);
541 TGeoShape* horizontal_frameS =
542 new TGeoBBox("horizontal_frameS", XModuleSize_Station66x41 * 0.5, dy * 0.5, dz * 0.5);
543
544 // frame volumes
545 TGeoVolume* composite_frameV = new TGeoVolumeAssembly(frame_name);
546 TGeoVolume* vertical_frameV = new TGeoVolume(frame_name + "_vertical_frameV", vertical_frameS);
547 TGeoVolume* horizontal_frameV = new TGeoVolume(frame_name + "_horizontal_frameV", horizontal_frameS);
548
549 // media
550 TGeoMedium* frame_medium = pMedCarbon; // set medium
551 if (pMedCarbon) {
552 vertical_frameV->SetMedium(frame_medium);
553 horizontal_frameV->SetMedium(frame_medium);
554 } else
555 Fatal("Main", "Invalid medium for frames!");
556 if (pMedAir) {
557 composite_frameV->SetMedium(pMedAir);
558 } else
559 Fatal("Main", "Invalid medium for frames!");
560
561 // visual parameters
562 vertical_frameV->SetLineColor(TColor::GetColor("#9999ff"));
563 horizontal_frameV->SetLineColor(TColor::GetColor("#9999ff"));
564
565 // frame part positions in the frame
566 TGeoCombiTrans* left_vertical_frame_position = new TGeoCombiTrans();
567 left_vertical_frame_position->SetTranslation(XModuleSize_Station66x41 * 0.5 + dXFrame_Station66x41 * 0.5, 0.0, 0.0);
568
569 TGeoCombiTrans* right_vertical_frame_position = new TGeoCombiTrans();
570 right_vertical_frame_position->SetTranslation(-XModuleSize_Station66x41 * 0.5 - dXFrame_Station66x41 * 0.5, 0.0,
571 0.0);
572
573 TGeoCombiTrans* bottom_horizontal_frame_position = new TGeoCombiTrans();
574 bottom_horizontal_frame_position->SetTranslation(0.0, YModuleSize_Station66x41 * 0.5 + dYFrame_Station66x41 * 0.5,
575 0.0);
576
577 TGeoCombiTrans* lower_horizontal_frame_position = new TGeoCombiTrans();
578 lower_horizontal_frame_position->SetTranslation(0.0, -YModuleSize_Station66x41 * 0.5 - dYFrame_Station66x41 * 0.5,
579 0.0);
580
581 composite_frameV->AddNode(vertical_frameV, 0, left_vertical_frame_position);
582 composite_frameV->AddNode(vertical_frameV, 1, right_vertical_frame_position);
583 composite_frameV->AddNode(horizontal_frameV, 0, bottom_horizontal_frame_position);
584 composite_frameV->AddNode(horizontal_frameV, 1, lower_horizontal_frame_position);
585
586 return composite_frameV;
587}
588
590 Double_t xsize,
591 Double_t ysize,
592 Double_t zsize,
593 Double_t hole_radius)
594{
595
596 // module shapes
597 TGeoShape* module_partS = new TGeoBBox("module_partS", xsize * 0.5, ysize * 0.5, zsize * 0.5);
598 TGeoShape* holeS = new TGeoTube("holeS", 0.0, hole_radius, zsize * 0.5 + 0.01);
599
600 gRandom->SetSeed(0);
601 Int_t uniqueId = gRandom->Integer(10000);
602 TGeoTranslation* hole_module_trans = new TGeoTranslation(
603 TString("hole_module_trans_") + TString::Itoa(uniqueId, 10), -xsize * 0.5, -ysize * 0.5, 0.0);
604
605 hole_module_trans->RegisterYourself();
606
607 TString bool_expression_module = TString(module_partS->GetName()) + TString(" - ") + TString(holeS->GetName())
608 + TString(":") + TString(hole_module_trans->GetName());
609 TGeoCompositeShape* moduleS = new TGeoCompositeShape(bool_expression_module);
610
611 // module volume
612 TGeoVolume* moduleV = new TGeoVolume(module_name, moduleS);
613
614 // medium
615 if (pMedArCO27030)
616 moduleV->SetMedium(pMedArCO27030);
617 else
618 Fatal("Main", "Invalid medium for sensitive modules!");
619
620 // visual parameters
621 moduleV->SetLineColor(TColor::GetColor("#ff47ca"));
622 moduleV->SetTransparency(20);
623
624 return moduleV;
625}
626
628 Double_t dx,
629 Double_t dy,
630 Double_t dz,
631 Double_t hole_radius)
632{
633
634 // frame shapes
635 TGeoShape* vertical_frameS =
636 new TGeoBBox("vertical_frameS", dx * 0.5, YModuleSize_Station163x45 * 0.5 + dy, dz * 0.5);
637 TGeoShape* horizontal_upper_frameS =
638 new TGeoBBox("horizontal_upper_frameS", XModuleSize_Station163x45 * 0.5, dy * 0.5, dz * 0.5);
639 TGeoShape* horizontal_bottom_frameS = new TGeoBBox(
640 "horizontal_upper_frameS", XModuleSize_Station163x45 * 0.5 - hole_radius * 0.5, dy * 0.5, dz * 0.5);
641
642 // frame volumes
643 TGeoVolume* composite_frameV = new TGeoVolumeAssembly(frame_name);
644 TGeoVolume* vertical_frameV = new TGeoVolume(frame_name + "_vertical_frameV", vertical_frameS);
645 TGeoVolume* horizontal_upper_frameV =
646 new TGeoVolume(frame_name + "_horizontal_upper_frameV", horizontal_upper_frameS);
647 TGeoVolume* horizontal_bottom_frameV =
648 new TGeoVolume(frame_name + "_horizontal_bottom_frameV", horizontal_bottom_frameS);
649
650 // media
651 TGeoMedium* frame_medium = pMedCarbon; // set medium
652 if (pMedCarbon) {
653 vertical_frameV->SetMedium(frame_medium);
654 horizontal_upper_frameV->SetMedium(frame_medium);
655 horizontal_bottom_frameV->SetMedium(frame_medium);
656 } else
657 Fatal("Main", "Invalid medium for frames!");
658 if (pMedAir) {
659 composite_frameV->SetMedium(pMedAir);
660 } else
661 Fatal("Main", "Invalid medium for frames!");
662
663 // visual parameters
664 vertical_frameV->SetLineColor(TColor::GetColor("#9999ff"));
665 horizontal_upper_frameV->SetLineColor(TColor::GetColor("#9999ff"));
666 horizontal_bottom_frameV->SetLineColor(TColor::GetColor("#9999ff"));
667
668 // frame part positions in the frame
669 TGeoCombiTrans* left_vertical_frame_position = new TGeoCombiTrans();
670 left_vertical_frame_position->SetTranslation(XModuleSize_Station163x45 * 0.5 + dXFrame_Station163x45 * 0.5, 0.0,
671 0.0);
672
673 TGeoCombiTrans* upper_horizontal_frame_position = new TGeoCombiTrans();
674 upper_horizontal_frame_position->SetTranslation(0.0, YModuleSize_Station163x45 * 0.5 + dYFrame_Station163x45 * 0.5,
675 0.0);
676
677 TGeoCombiTrans* bottom_horizontal_frame_position = new TGeoCombiTrans();
678 bottom_horizontal_frame_position->SetTranslation(
679 hole_radius * 0.5, -YModuleSize_Station163x45 * 0.5 - dYFrame_Station163x45 * 0.5, 0.0);
680
681 composite_frameV->AddNode(vertical_frameV, 0, left_vertical_frame_position);
682 composite_frameV->AddNode(horizontal_upper_frameV, 0, upper_horizontal_frame_position);
683 composite_frameV->AddNode(horizontal_bottom_frameV, 0, bottom_horizontal_frame_position);
684
685 return composite_frameV;
686}
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 TRandom * gRandom
R__EXTERN TSystem * gSystem
static Int_t GetColor(const char *hexcolor)
void Close(Option_t *option="") override
void ReflectX(Bool_t leftside, Bool_t rotonly=kFALSE) override
void SetTranslation(const TGeoTranslation &tr)
virtual void RegisterYourself()
const char * GetName() const override
void SetVisContainers(Bool_t flag=kTRUE) override
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
void SetTransparency(Char_t transparency=0)
virtual void SetMedium(TGeoMedium *medium)
void SetLineColor(Color_t lcolor) override
const char * GetName() const override
Int_t GetEntriesFast() const
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,...)
static TString Itoa(Int_t value, Int_t base)
virtual Int_t Fill()
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
const Double_t dYFrame_Station163x45
const Double_t dXFrame_Station66x41
const Double_t dZFrame_Station66x41
const Double_t ZModuleSize_Station66x41
const Double_t YStationPositions[NStations]
const Double_t dYFrame_Station66x41
const Double_t ZModuleSize_Station163x45
const Double_t dXFrame_Station163x45
const Double_t YModuleSize_Station163x45
Double_t XModuleShifts[NStations][NMaxModules]
const Double_t dZFrame_Station163x45
const Double_t ZStationPositions[NStations]
Double_t ZModuleShifts[NStations][NMaxModules]
const Double_t YModuleSize_Station66x41
const Double_t XModuleSize_Station163x45
const Double_t XModuleSize_Station66x41
const Double_t XStationPositions[NStations]
Double_t YModuleShifts[NStations][NMaxModules]
TGeoVolume * CreateModule_Station66x41(TString module_name, Double_t xsize, Double_t ysize, Double_t zsize)
TGeoVolume * CreateFrameForModule_Station163x45(TString frame_name, Double_t dx, Double_t dy, Double_t dz, Double_t hole_radius)
void create_rootgeom_GEMS_RunSpring2018_misAlign(Double_t sigX, Double_t sigY, Double_t sigZ, TString geoVersion="RunSpring2018_misAlign", TString xmlMisalign="GemRunSpring2018_misAlign.xml")
TGeoVolume * CreateStation(TString station_name)
TGeoVolume * CreateModule_Station163x45(TString module_name, Double_t xsize, Double_t ysize, Double_t zsize, Double_t hole_radius)
Double_t *** generateMisalign(Double_t, Double_t, Double_t)
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
TGeoVolume * CreateFrameForModule_Station66x41(TString frame_name, Double_t dx, Double_t dy, Double_t dz)
void createNewXML(Double_t ***, TString, TString)
Definition json.hpp:4446