7 {
8 _debug = debug;
9 gctx_ = gctx;
10
11
12
13 double rotationAngle = M_PI * 0.5;
14
15
16
17
18
19
20
21 Acts::Vector3 xPos1(cos(rotationAngle), 0., sin(rotationAngle));
22 Acts::Vector3 yPos1(0., 1., 0.);
23 Acts::Vector3 zPos1(-sin(rotationAngle), 0., cos(rotationAngle));
24
25 y_rot_.col(0) = xPos1;
26 y_rot_.col(1) = yPos1;
27 y_rot_.col(2) = zPos1;
28
29
30 Acts::Vector3 xPos2(1., 0., 0.);
31 Acts::Vector3 yPos2(0., cos(rotationAngle), sin(rotationAngle));
32 Acts::Vector3 zPos2(0., -sin(rotationAngle), cos(rotationAngle));
33
34 x_rot_.col(0) = xPos2;
35 x_rot_.col(1) = yPos2;
36 x_rot_.col(2) = zPos2;
37
38 G4GDMLParser parser;
39
40
41 parser.Read(
42 "/Users/pbutti/sw/ldmx-sw/Detectors/data/ldmx-det-v12/detector.gdml",
43 false);
44 G4VPhysicalVolume* fWorldPhysVol = parser.GetWorldVolume();
45 if (debug) {
46 std::cout << "World position" << std::endl;
47 std::cout << fWorldPhysVol->GetTranslation() << std::endl;
48 }
49
50 if (debug) std::cout << "Loop on world daughters" << std::endl;
51
52 _ECAL = findDaughterByName(fWorldPhysVol, "em_calorimeters_PV");
53
54 if (_ECAL) {
55 std::cout << _ECAL->GetName() << std::endl;
56 std::cout << _ECAL->GetTranslation() << std::endl;
57 std::cout << _ECAL->GetLogicalVolume()->GetNoDaughters() << std::endl;
58 }
59
60
61
62 if (_debug) {
63 std::cout << "Looking for later components" << std::endl;
64 }
65
66
67 std::vector<Acts::CuboidVolumeBuilder::LayerConfig> layersCfg;
68
69
70 std::vector<std::reference_wrapper<G4VPhysicalVolume>> components;
71 std::vector<std::shared_ptr<const Acts::Surface>> sensor_surfaces;
72
73
74 getComponentRing("_a_", "Si", components);
75
76 for (auto& component : components) {
78 }
79
80 for (int i = 0; i < sensor_surfaces.size(); i += 14) {
81 std::vector<std::shared_ptr<const Acts::Surface>> rings;
82 for (int j = 0; j < 14; j++) {
83 rings.push_back(sensor_surfaces.at(i + j));
84 }
85
86 Acts::CuboidVolumeBuilder::LayerConfig lyCfg = buildLayerConfig(rings);
87 layersCfg.push_back(lyCfg);
88 }
89
90 components.clear();
91 sensor_surfaces.clear();
92
93
94
95 getComponentRing("_a_", "Si", components);
96
97 for (auto& component : components) {
99 }
100
101 for (int i = 0; i < sensor_surfaces.size(); i += 14) {
102 std::vector<std::shared_ptr<const Acts::Surface>> rings;
103 for (int j = 0; j < 14; j++) {
104 rings.push_back(sensor_surfaces.at(i + j));
105 }
106
107 Acts::CuboidVolumeBuilder::LayerConfig lyCfg = buildLayerConfig(rings);
108 layersCfg.push_back(lyCfg);
109 }
110
111 components.clear();
112 sensor_surfaces.clear();
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 Acts::CuboidVolumeBuilder::VolumeConfig ecal_vcfg;
193
194
195 ecal_vcfg.position = {0., 0., 0.};
196 G4Box* ecal_box = (G4Box*)_ECAL->GetLogicalVolume()->GetSolid();
197
198
199
200 ecal_vcfg.length = {ecal_box->GetZHalfLength() * 2.,
201 ecal_box->GetXHalfLength() * 2.,
202 ecal_box->GetYHalfLength() * 2.};
203
204 ecal_vcfg.name = "Ecal_volume";
205 ecal_vcfg.layerCfg = layersCfg;
206
207
208 Acts::CuboidVolumeBuilder cvb;
209 Acts::CuboidVolumeBuilder::Config config;
210 config.position = {0., 0., 0.};
211 config.length = {2000, 2000, 2000};
212 config.volumeCfg = {ecal_vcfg};
213
214 cvb.setConfig(config);
215
216 Acts::TrackingGeometryBuilder::Config tgbCfg;
217 tgbCfg.trackingVolumeBuilders.push_back(
218 [=](const auto& cxt, const auto& inner, const auto&) {
219 return cvb.trackingVolume(cxt, inner, nullptr);
220 });
221 Acts::TrackingGeometryBuilder tgb(tgbCfg);
222 tGeometry_ = tgb.trackingGeometry(*gctx_);
223
224 dumpGeometry("./ecal_test/");
225}
std::shared_ptr< const Acts::Surface > convertHexToActsSurface(const G4VPhysicalVolume &phex)