-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathbuild_geometry.C
More file actions
272 lines (232 loc) · 7.46 KB
/
build_geometry.C
File metadata and controls
272 lines (232 loc) · 7.46 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
264
265
266
267
268
269
270
271
272
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// 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>
#include "DetectorsCommonDataFormats/UpgradesStatus.h"
#include <DetectorsBase/SimFieldUtils.h>
#endif
#ifdef ENABLE_UPGRADES
#include <ITS3Simulation/Detector.h>
#include <TRKSimulation/Detector.h>
#include <FT3Simulation/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().getActiveModules();
auto active = std::find(modulelist.begin(), modulelist.end(), s) != modulelist.end();
if (active) {
LOG(info) << "Activating " << s << " module";
}
return active;
}
bool isReadout(std::string s)
{
// access user configuration for list of wanted modules
auto& modulelist = o2::conf::SimConfig::Instance().getReadoutDetectors();
auto active = std::find(modulelist.begin(), modulelist.end(), s) != modulelist.end();
if (active) {
LOG(info) << "Reading out " << s << " detector";
}
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
run->SetField(o2::base::SimFieldUtils::createMagField());
// 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", !isActivated("TRK"), 0.48f, 0.015f, 1000.f, 3.7f, 0.05f, 1000.f));
}
#endif
// the absorber
if (isActivated("ABSO")) {
// the frame structure to support other detectors
run->AddModule(new o2::passive::Absorber("ABSO", "Absorber"));
}
// the shil
if (isActivated("SHIL")) {
run->AddModule(new o2::passive::Shil("SHIL", "Small angle beam shield"));
}
if (isActivated("TOF") || isActivated("TRD") || isActivated("FRAME")) {
// the frame structure to support other detectors
run->AddModule(new o2::passive::FrameStructure("FRAME", "Frame"));
}
if (isActivated("TOF")) {
// TOF
run->AddModule(new o2::tof::Detector(isReadout("TOF")));
}
if (isActivated("TRD")) {
// TRD
run->AddModule(new o2::trd::Detector(isReadout("TRD")));
}
if (isActivated("TPC")) {
// tpc
run->AddModule(new o2::tpc::Detector(isReadout("TPC")));
}
#ifdef ENABLE_UPGRADES
if (isActivated("IT3")) {
// ITS3
run->AddModule(new o2::its3::Detector(isReadout("IT3")));
}
if (isActivated("TRK")) {
// ALICE 3 TRK
run->AddModule(new o2::trk::Detector(isReadout("TRK")));
}
if (isActivated("FT3")) {
// ALICE 3 FT3
run->AddModule(new o2::ft3::Detector(isReadout("FT3")));
}
#endif
if (isActivated("ITS")) {
// its
run->AddModule(new o2::its::Detector(isReadout("ITS")));
}
if (isActivated("MFT")) {
// mft
run->AddModule(new o2::mft::Detector(isReadout("MFT")));
}
if (isActivated("MCH")) {
// mch
run->AddModule(new o2::mch::Detector(isReadout("MCH")));
}
if (isActivated("MID")) {
// mid
run->AddModule(new o2::mid::Detector(isReadout("MID")));
}
if (isActivated("EMC")) {
// emcal
run->AddModule(new o2::emcal::Detector(isReadout("EMC")));
}
if (isActivated("PHS")) {
// phos
run->AddModule(new o2::phos::Detector(isReadout("PHS")));
}
if (isActivated("CPV")) {
// cpv
run->AddModule(new o2::cpv::Detector(isReadout("CPV")));
}
if (isActivated("FT0")) {
// FIT-T0
run->AddModule(new o2::ft0::Detector(isReadout("FT0")));
}
if (isActivated("FV0")) {
// FIT-V0
run->AddModule(new o2::fv0::Detector(isReadout("FV0")));
}
if (isActivated("FDD")) {
// FIT-FDD
run->AddModule(new o2::fdd::Detector(isReadout("FDD")));
}
if (isActivated("HMP")) {
// HMP
run->AddModule(new o2::hmpid::Detector(isReadout("HMP")));
}
if (isActivated("ZDC")) {
// ZDC
run->AddModule(new o2::zdc::Detector(isReadout("ZDC")));
}
if (geomonly) {
run->Init();
}
}