BmnRoot
Loading...
Searching...
No Matches
create_rootgeom_TOF400_RUN6.c
Go to the documentation of this file.
1//**************************************************************************************
2
4{
5 // Load the necessary FairRoot libraries
6 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
7 bmnloadlibs(); // load libraries
8
9 // ------- Load media from media file --------------------------------
10 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
11 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
12 TString geoPath = gSystem->Getenv("VMCWORKDIR");
13 TString medFile = geoPath + "/geometry/media.geo";
14 geoFace->setMediaFile(medFile);
15 geoFace->readMedia();
16 gGeoMan = gGeoManager;
17
18 // ------- Geometry file name (output) -------------------------------
19 const TString geoDetectorName = "TOF400";
20 const TString geoDetectorVersion = "RUN6";
21 const TString geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
22
23 // ----------------- Get and create the required media --------------
24 FairGeoMedia* geoMedia = geoFace->getMedia();
25 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
26
27 // Air
28 FairGeoMedium* matAir = geoMedia->getMedium("air");
29 if (!matAir) Fatal("Main", "FairMedium air not found");
30 geoBuild->createMedium(matAir);
31 TGeoMedium* medAir = gGeoMan->GetMedium("air");
32 if (!medAir) Fatal("Main", "Medium air not found");
33
34 // Polypropylene
35 FairGeoMedium* matPprop = geoMedia->getMedium("polypropylene");
36 if (!matPprop) Fatal("Main", "FairMedium polypropylene not found");
37 geoBuild->createMedium(matPprop);
38 TGeoMedium* medPprop = gGeoMan->GetMedium("polypropylene");
39 if (!medPprop) Fatal("Main", "Medium polypropylene not found");
40
41 // lead
42 FairGeoMedium* matPb = geoMedia->getMedium("lead");
43 if (!matPb) Fatal("Main", "FairMedium lead not found");
44 geoBuild->createMedium(matPb);
45 TGeoMedium* medPb = gGeoMan->GetMedium("lead");
46 if (!medPb) Fatal("Main", "Medium lead not found");
47
48 // aluminium
49 FairGeoMedium* matAl = geoMedia->getMedium("aluminium");
50 if (!matAl) Fatal("Main", "FairMedium aluminium not found");
51 geoBuild->createMedium(matAl);
52 TGeoMedium* medAl = gGeoMan->GetMedium("aluminium");
53 if (!medAl) Fatal("Main", "Medium aluminium not found");
54
55 // RPCglass
56 FairGeoMedium* matGlass = geoMedia->getMedium("RPCglass");
57 if (!matGlass) Fatal("Main", "FairMedium RPCglass not found");
58 geoBuild->createMedium(matGlass);
59 TGeoMedium* medGlass = gGeoMan->GetMedium("RPCglass");
60 if (!medGlass) Fatal("Main", "Medium RPCglass not found");
61
62 // RPCgas
63 FairGeoMedium* matGas = geoMedia->getMedium("RPCgas");
64 if (!matGas) Fatal("Main", "FairMedium RPCgas not found");
65 geoBuild->createMedium(matGas);
66 TGeoMedium* medGas = gGeoMan->GetMedium("RPCgas");
67 if (!medGas) Fatal("Main", "Medium RPCgas not found");
68
69 // G10
70 FairGeoMedium* matG10 = geoMedia->getMedium("G10");
71 if (!matG10) Fatal("Main", "FairMedium G10 not found");
72 geoBuild->createMedium(matG10);
73 TGeoMedium* medG10 = gGeoMan->GetMedium("G10");
74 if (!medG10) Fatal("Main", "Medium G10 not found");
75
76 // ----------------------------------------- Create geometry and top volume -----------------------------------------------
77 gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom");
78 gGeoMan->SetName(geoDetectorName + "_geom");
79 TGeoVolume* top = new TGeoVolumeAssembly("TOP"); // TOP VOLUME
80 top->SetMedium(medAir);
81 gGeoMan->SetTopVolume(top);
82 gGeoMan->SetTopVisible(1);
83 gGeoMan->SetVisLevel(7);
84
85 // --------------------------------------- Define TOP Geometry ------------------------------------
86 TGeoVolume* topTof = new TGeoVolumeAssembly(geoDetectorName);
87 topTof->SetMedium(medAir);
88
89 TGeoVolume* vDetector = new TGeoVolumeAssembly("tof1Detector");
90 vDetector->SetMedium(medAir);
91
92 const double DetXsize = 60.; // [cm]
93 const double DetYsize = 30.; // [cm]
94 const double DetZsize = 3.0; // [cm]
95 // --------------------- Create strip ------------------
96 const float stripGasX = 1., stripGasY = DetYsize, stripGasZ = 0.3; // [cm]
97 TGeoBBox *sStripGas = new TGeoBBox(stripGasX / 2., stripGasY / 2., stripGasZ / 2.);
98 sStripGas->SetName("StripGas");
99 TGeoVolume *vStripGas = new TGeoVolume("tof1StripActiveGasV", sStripGas, medGas);
100 vStripGas->SetLineColor(kRed);
101
102
103 // --------------------- Create Glass plates ------------------
104 const float detGlassX = DetXsize, detGlassY = DetYsize, detGlassZ = 0.618 / 2.; // [cm] 6.18 mm / 2 plate
105 TGeoBBox *sDetGlass = new TGeoBBox(detGlassX / 2., detGlassY / 2., detGlassZ / 2.);
106 sDetGlass->SetName("DetectorGlass");
107 TGeoVolume *vDetGlass = new TGeoVolume("tof1DetGlassV", sDetGlass, medGlass);
108 vDetGlass->SetLineColor(kYellow);
109
110 // --------------------- Create G10 plates ------------------
111 const float detPlateX = DetXsize, detPlateY = DetYsize, detPlateZ = 0.64 / 2.; // [cm] 6.4 mm / 2 plate
112 TGeoBBox *sDetPlate = new TGeoBBox(detPlateX / 2., detPlateY / 2., detPlateZ / 2.);
113 sDetPlate->SetName("DetectorPlate");
114 TGeoVolume *vDetPlate = new TGeoVolume("tof1DetPlateV", sDetPlate, medG10);
115 vDetPlate->SetLineColor(kBlue);
116
117 // --------------------------------------- Assemble detector
118
119 // Add strips
120 const int NStrips = 48; // 24 strips group
121 const double StripStep = 1.25; // [cm]
122 for (int i = 0; i < NStrips; i++)
123 {
124 vDetector->AddNode(vStripGas, i + 1, new TGeoTranslation("", -DetXsize / 2. + StripStep / 2. + i * StripStep, 0., 0.));
125 }
126
127 // Add Glass plates
128 vDetector->AddNode(vDetGlass, 1, new TGeoTranslation("", 0., 0., -stripGasZ / 2. - detGlassZ / 2.));
129 vDetector->AddNode(vDetGlass, 2, new TGeoTranslation("", 0., 0., +stripGasZ / 2. + detGlassZ / 2.));
130
131 // Add G10 plates
132 vDetector->AddNode(vDetPlate, 1, new TGeoTranslation("", 0., 0., -DetZsize / 2. + detPlateZ / 2.));
133 vDetector->AddNode(vDetPlate, 2, new TGeoTranslation("", 0., 0., +DetZsize / 2. - detPlateZ / 2.));
134
135 // -------------------------------------- Install Detectors
136 const double tofZgap = 0.86; // 8.6 mm between detectors
137 const double tofYoverlap = 3.0; // 30 mm detectors overlap at X direction
138
139 const double tofXgap = 0.; // [cm] RUN5, part1
140 //const double tofXgap = 2. * 24.4; // [cm] RUN5, part2
141 const double tofZ_1box = 454.8.; // [cm] :
142 const double tofZ_2box = 442.6.; // [cm] :
143
144 double tofX = tofXgap / 2. + DetXsize / 2.;
145 double tofZshift = tofZgap + DetZsize;
146
147 // first box
148 topTof->AddNode(vDetector, 1, new TGeoTranslation("t1", +tofX+55.2+27.17, -3.48 + 2 * DetYsize - 2 * tofYoverlap, tofZ_1box + tofZshift)); // right side, x > 0
149 topTof->AddNode(vDetector, 2, new TGeoTranslation("t1", +tofX+55.2+27.17, -3.48 + DetYsize - tofYoverlap, tofZ_1box));
150 topTof->AddNode(vDetector, 3, new TGeoTranslation("t1", +tofX+55.2+27.17, -3.48, tofZ_1box + tofZshift));
151 topTof->AddNode(vDetector, 4, new TGeoTranslation("t1", +tofX+55.2+27.17, -3.48 - DetYsize + tofYoverlap, tofZ_1box));
152 topTof->AddNode(vDetector, 5, new TGeoTranslation("t1", +tofX+55.2+27.17, -3.48 - 2 * DetYsize + 2 * tofYoverlap, tofZ_1box + tofZshift));
153
154 //second box
155 topTof->AddNode(vDetector, 6, new TGeoTranslation("t1", +tofX+32.96, -3.48 + 2 * DetYsize - 2 * tofYoverlap, tofZ_2box + tofZshift)); // right side, x > 0
156 topTof->AddNode(vDetector, 7, new TGeoTranslation("t1", +tofX+32.96, -3.48 + DetYsize - tofYoverlap, tofZ_2box));
157 topTof->AddNode(vDetector, 8, new TGeoTranslation("t1", +tofX+32.96, -3.48, tofZ_2box + tofZshift));
158 topTof->AddNode(vDetector, 9, new TGeoTranslation("t1", +tofX+32.96, -3.48 - DetYsize + tofYoverlap, tofZ_2box));
159 topTof->AddNode(vDetector, 10, new TGeoTranslation("t1", +tofX+32.96, -3.48 - 2 * DetYsize + 2 * tofYoverlap, tofZ_2box + tofZshift));
160
161 //topTof->AddNode(vDetector, 4, new TGeoTranslation("t1", -tofX, 0., tofZ + tofZshift)); // left side, x < 0
162 //topTof->AddNode(vDetector, 5, new TGeoTranslation("t1", -tofX, +DetYsize -tofYoverlap, tofZ - tofZshift));
163 //topTof->AddNode(vDetector, 6, new TGeoTranslation("t1", -tofX, -DetYsize +tofYoverlap, tofZ - tofZshift));
164
165
166 // ------------------ Adding the TOP Volume --------------------------
167 top->AddNode(topTof, 1, new TGeoTranslation("tw", 0., 0., 0.));
168
169 // --------------- Finish --------------------------------------------
170 top->SetVisContainers(kTRUE);
171
172 gGeoMan->CloseGeometry();
173 gGeoMan->CheckOverlaps(0.001);
174 gGeoMan->PrintOverlaps();
175 gGeoMan->Test();
176
177 TFile* geoFile = new TFile(geoFileName, "RECREATE");
178 top->Write();
179 geoFile->Close();
180
181 top->Draw("ogl");
182 gGeoMan->Browse(new TBrowser);
183}
int i
Definition P4_F32vec4.h:22
void MakeBMNROOT_TOFv3()