-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathbuild_geometry.C
More file actions
263 lines (225 loc) · 6.85 KB
/
build_geometry.C
File metadata and controls
263 lines (225 loc) · 6.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include "TGeoManager.h"
#include "TString.h"
#include "TSystem.h"
#include "DetectorsPassive/Cave.h"
#include "DetectorsPassive/Magnet.h"
#include "DetectorsPassive/Dipole.h"
#include "DetectorsPassive/Compensator.h"
#include "DetectorsPassive/Absorber.h"
#include "DetectorsPassive/Shil.h"
#include "DetectorsPassive/Hall.h"
#include "DetectorsPassive/Pipe.h"
#include <Field/MagneticField.h>
#include <TPCSimulation/Detector.h>
#include <ITSSimulation/Detector.h>
#include <MFTSimulation/Detector.h>
#include <MCHSimulation/Detector.h>
#include <MIDSimulation/Detector.h>
#include <EMCALSimulation/Detector.h>
#include <TOFSimulation/Detector.h>
#include <TRDSimulation/Detector.h>
#include <FT0Simulation/Detector.h>
#include <FV0Simulation/Detector.h>
#include <FDDSimulation/Detector.h>
#include <HMPIDSimulation/Detector.h>
#include <PHOSSimulation/Detector.h>
#include <CPVSimulation/Detector.h>
#include <ZDCSimulation/Detector.h>
#include <DetectorsPassive/Cave.h>
#include <DetectorsPassive/FrameStructure.h>
#include <SimConfig/SimConfig.h>
#include "FairRunSim.h"
#include <FairLogger.h>
#include <algorithm>
#endif
#ifdef ENABLE_UPGRADES
#include <ITS3Simulation/Detector.h>
#include <TRKSimulation/Detector.h>
#include <Alice3DetectorsPassive/Pipe.h>
#endif
void finalize_geometry(FairRunSim* run);
bool isActivated(std::string s)
{
// access user configuration for list of wanted modules
auto& modulelist = o2::conf::SimConfig::Instance().getActiveDetectors();
auto active = std::find(modulelist.begin(), modulelist.end(), s) != modulelist.end();
if (active) {
LOG(INFO) << "Activating " << s << " module";
}
return active;
}
// a "factory" like macro to instantiate the O2 geometry
void build_geometry(FairRunSim* run = nullptr)
{
bool geomonly = (run == nullptr);
// minimal macro to test setup of the geometry
auto& confref = o2::conf::SimConfig::Instance();
TString dir = getenv("VMCWORKDIR");
TString geom_dir = dir + "/Detectors/Geometry/";
gSystem->Setenv("GEOMPATH", geom_dir.Data());
TString tut_configdir = dir + "/Detectors/gconfig";
gSystem->Setenv("CONFIG_DIR", tut_configdir.Data());
// Create simulation run if it does not exist
if (run == nullptr) {
run = new FairRunSim();
run->SetOutputFile("foo.root"); // Output file
run->SetName("TGeant3"); // Transport engine
}
// Create media
run->SetMaterials("media.geo"); // Materials
// we need a field to properly init the media
auto field = o2::field::MagneticField::createNominalField(confref.getConfigData().mField);
run->SetField(field);
// Create geometry
// we always need the cave
o2::passive::Cave* cave = new o2::passive::Cave("CAVE");
// adjust size depending on content
cave->includeZDC(isActivated("ZDC"));
// the experiment hall (cave)
cave->SetGeometryFileName("cave.geo");
run->AddModule(cave);
// the experimental hall
if (isActivated("HALL")) {
auto hall = new o2::passive::Hall("HALL", "Experimental Hall");
run->AddModule(hall);
}
// the magnet
if (isActivated("MAG")) {
// the frame structure to support other detectors
auto magnet = new o2::passive::Magnet("MAG", "L3 Magnet");
run->AddModule(magnet);
}
// the dipole
if (isActivated("DIPO")) {
auto dipole = new o2::passive::Dipole("DIPO", "Alice Dipole");
run->AddModule(dipole);
}
// the compensator dipole
if (isActivated("COMP")) {
run->AddModule(new o2::passive::Compensator("COMP", "Alice Compensator Dipole"));
}
// beam pipe
if (isActivated("PIPE")) {
#ifdef ENABLE_UPGRADES
if (isActivated("IT3")) {
run->AddModule(new o2::passive::Pipe("PIPE", "Beam pipe", 1.6f, 0.05f));
} else {
run->AddModule(new o2::passive::Pipe("PIPE", "Beam pipe"));
}
#else
run->AddModule(new o2::passive::Pipe("PIPE", "Beam pipe"));
#endif
}
#ifdef ENABLE_UPGRADES
// upgraded beampipe at the interaction point (IP)
if (isActivated("A3IP")) {
run->AddModule(new o2::passive::Alice3Pipe("A3IP", "Alice 3 beam pipe", 0.48f, 0.015f, 44.4f, 3.7f, 0.1f, 44.4f));
}
#endif
// the absorber
if (isActivated("ABSO")) {
// the frame structure to support other detectors
auto abso = new o2::passive::Absorber("ABSO", "Absorber");
run->AddModule(abso);
}
// the shil
if (isActivated("SHIL")) {
auto shil = new o2::passive::Shil("SHIL", "Small angle beam shield");
run->AddModule(shil);
}
if (isActivated("TOF") || isActivated("TRD") || isActivated("FRAME")) {
// the frame structure to support other detectors
auto frame = new o2::passive::FrameStructure("FRAME", "Frame");
run->AddModule(frame);
}
if (isActivated("TOF")) {
// TOF
auto tof = new o2::tof::Detector(true);
run->AddModule(tof);
}
if (isActivated("TRD")) {
// TRD
auto trd = new o2::trd::Detector(true);
run->AddModule(trd);
}
if (isActivated("TPC")) {
// tpc
auto tpc = new o2::tpc::Detector(true);
run->AddModule(tpc);
}
#ifdef ENABLE_UPGRADES
if (isActivated("IT3")) {
// ITS3
auto its3 = new o2::its3::Detector(true);
run->AddModule(its3);
}
if (isActivated("TRK")) {
// ALICE 3 TRK
auto trk = new o2::trk::Detector(true);
run->AddModule(trk);
}
#endif
if (isActivated("ITS")) {
// its
auto its = new o2::its::Detector(true);
run->AddModule(its);
}
if (isActivated("MFT")) {
// mft
auto mft = new o2::mft::Detector();
run->AddModule(mft);
}
if (isActivated("MCH")) {
// mch
run->AddModule(new o2::mch::Detector(true));
}
if (isActivated("MID")) {
// mid
run->AddModule(new o2::mid::Detector(true));
}
if (isActivated("EMC")) {
// emcal
run->AddModule(new o2::emcal::Detector(true));
}
if (isActivated("PHS")) {
// phos
run->AddModule(new o2::phos::Detector(true));
}
if (isActivated("CPV")) {
// cpv
run->AddModule(new o2::cpv::Detector(true));
}
if (isActivated("FT0")) {
// FIT-T0
run->AddModule(new o2::ft0::Detector(true));
}
if (isActivated("FV0")) {
// FIT-V0
run->AddModule(new o2::fv0::Detector(true));
}
if (isActivated("FDD")) {
// FIT-FDD
run->AddModule(new o2::fdd::Detector(true));
}
if (isActivated("HMP")) {
// HMP
run->AddModule(new o2::hmpid::Detector(true));
}
if (isActivated("ZDC")) {
// ZDC
run->AddModule(new o2::zdc::Detector(true));
}
if (geomonly) {
run->Init();
}
}