Project
Loading...
Searching...
No Matches
FT3Module.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
16#include <TGeoManager.h>
17#include <TGeoMaterial.h>
18#include <TGeoMedium.h>
19#include <TGeoBBox.h>
20#include <TGeoMatrix.h>
21#include <Framework/Logger.h>
22#include <cmath>
23#include <iostream>
24#include <vector>
25#include <set>
26#include <algorithm>
27
28TGeoMaterial* FT3Module::siliconMat = nullptr;
29TGeoMedium* FT3Module::siliconMed = nullptr;
30
31TGeoMaterial* FT3Module::copperMat = nullptr;
32TGeoMedium* FT3Module::copperMed = nullptr;
33
34TGeoMaterial* FT3Module::kaptonMat = nullptr;
35TGeoMedium* FT3Module::kaptonMed = nullptr;
36
37TGeoMaterial* FT3Module::epoxyMat = nullptr;
38TGeoMedium* FT3Module::epoxyMed = nullptr;
39
40TGeoMaterial* FT3Module::AluminumMat = nullptr;
41TGeoMedium* FT3Module::AluminumMed = nullptr;
42
44{
45 LOG(debug) << "FT3Module: initialize_materials";
46 if (siliconMat) {
47 return;
48 }
49
50 TGeoManager* geoManager = gGeoManager;
51
52 auto* itsH = new TGeoElement("FT3_H", "Hydrogen", 1, 1.00794);
53 auto* itsC = new TGeoElement("FT3_C", "Carbon", 6, 12.0107);
54 auto* itsO = new TGeoElement("FT3_O", "Oxygen", 8, 15.994);
55
56 siliconMat = new TGeoMaterial("FT3_Silicon", 28.0855, 14, 2.33);
57 siliconMed = new TGeoMedium("FT3_Silicon", 1, siliconMat);
58
59 copperMat = new TGeoMaterial("FT3_Copper", 63.546, 29, 8.96);
60 copperMed = new TGeoMedium("FT3_Copper", 2, copperMat);
61
62 kaptonMat = new TGeoMaterial("FT3_Kapton", 13.84, 6.88, 1.346);
63 kaptonMed = new TGeoMedium("FT3_Kapton", 3, kaptonMat);
64
65 // Epoxy: C18 H19 O3
66 auto* itsEpoxy = new TGeoMixture("FT3_Epoxy", 3);
67 itsEpoxy->AddElement(itsC, 18);
68 itsEpoxy->AddElement(itsH, 19);
69 itsEpoxy->AddElement(itsO, 3);
70 itsEpoxy->SetDensity(2.186);
71
72 epoxyMed = new TGeoMedium("FT3_Epoxy", 4, itsEpoxy);
73 epoxyMat = epoxyMed->GetMaterial();
74
75 AluminumMat = new TGeoMaterial("Aluminum", 26.98, 13, 2.7);
76 AluminumMed = new TGeoMedium("Aluminum", 5, AluminumMat);
77 LOG(debug) << "FT3Module: done initialize_materials";
78}
79
80double calculate_y_circle(double x, double radius)
81{
82 return (x * x < radius * radius) ? std::sqrt(radius * radius - x * x) : 0;
83}
84
85void FT3Module::create_layout(double mZ, int layerNumber, int direction, double Rin, double Rout, double overlap, const std::string& face, const std::string& layout_type, TGeoVolume* motherVolume)
86{
87
88 LOG(debug) << "FT3Module: create_layout - Layer " << layerNumber << ", Direction " << direction << ", Face " << face;
89 TGeoManager* geoManager = gGeoManager;
90
92
93 // double sensor_width = 2.5;
94 // double sensor_height = 9.6;
95 // double active_width = 2.3;
96 // double active_height = 9.6;
97
98 double sensor_width = 5.0;
99 double sensor_height = 9.6;
100 double inactive_width = 0.2; // per side
101 double active_width = 4.6;
102 double active_height = 9.6;
103
104 double silicon_thickness = 0.01;
105 double copper_thickness = 0.006;
106 double kapton_thickness = 0.03;
107 double epoxy_thickness = 0.0012;
108
109 double carbonFiberThickness = 0.01;
110
111 double foamSpacingThickness = 0.5;
112
113 int dist_offset = 0;
114
115 double x_offset;
116 double y_offset;
117
118 double z_offset = (face == "front") ? -foamSpacingThickness / 2.0 - carbonFiberThickness : foamSpacingThickness / 2.0 + carbonFiberThickness;
119
120 // offset correction
121 if (sensor_height == 3.2 && sensor_width == 2.5) {
122 x_offset = 0.8;
123 y_offset = 1.5;
124 } else if (sensor_height == 19.2 && sensor_width == 5) {
125 x_offset = 0.7;
126 y_offset = 9;
127
128 } else {
129 x_offset = sensor_width / 2;
130 y_offset = sensor_height / 2;
131 }
132
133 double x_condition_min = 0;
134 double x_condition_max = 0;
135 double offset_Rin_lower = 0;
136 double offset_Rin_upper = 0;
137 bool adjust_bottom_y_pos = false;
138 bool adjust_bottom_y_neg = false;
139 double x_adjust_bottom_y_pos = 0;
140 double bottom_y_pos_value = 0;
141 double bottom_y_neg_value = 0;
142
143 if (Rin == 7 && sensor_height == 9.6 && sensor_width == 5) {
144 x_condition_min = -Rin - 2;
145 x_condition_max = Rin;
146 adjust_bottom_y_pos = true;
147 adjust_bottom_y_neg = true;
148 x_adjust_bottom_y_pos = 3.5;
149 bottom_y_pos_value = 3.5;
150 bottom_y_neg_value = -3.5;
151
152 dist_offset = 2;
153
154 } else if (Rin == 5 && sensor_height == 9.6 && sensor_width == 5) {
155 x_condition_min = -Rin - 6;
156 x_condition_max = Rin;
157 adjust_bottom_y_pos = true;
158 adjust_bottom_y_neg = true;
159 x_adjust_bottom_y_pos = 3.5;
160 bottom_y_pos_value = 3.5;
161 bottom_y_neg_value = -3.5;
162 } else if ((Rin == 5 || Rin == 7) && sensor_height == 19.2) {
163 x_condition_min = -Rin - 3;
164 x_condition_max = Rin - 0.2;
165 dist_offset = 2;
166 adjust_bottom_y_pos = false;
167 adjust_bottom_y_neg = false;
168 } else if (Rin == 5 && sensor_height == 3.2) {
169 x_condition_min = -(Rin + 2.6);
170 x_condition_max = Rin + 1.5;
171 adjust_bottom_y_pos = true;
172 adjust_bottom_y_neg = true;
173 x_adjust_bottom_y_pos = 3.5;
174 bottom_y_pos_value = 3.5;
175 bottom_y_neg_value = -3.5;
176 } else if (Rin == 7 && sensor_height == 3.2) {
177 x_condition_min = -Rin - 1;
178 x_condition_max = Rin - 0.2;
179 adjust_bottom_y_pos = true;
180 adjust_bottom_y_neg = true;
181 x_adjust_bottom_y_pos = 3.5;
182 bottom_y_pos_value = 3.5;
183 bottom_y_neg_value = -3.5;
184 } else if (Rin == 5 && sensor_height == 9.6 && sensor_width == 2.5) {
185 x_condition_min = -(Rin + 2.6);
186 x_condition_max = Rin;
187 adjust_bottom_y_pos = true;
188 adjust_bottom_y_neg = true;
189 x_adjust_bottom_y_pos = 3.5;
190 bottom_y_pos_value = 3.5;
191 bottom_y_neg_value = -3.5;
192 } else if (Rin == 7 && sensor_height == 9.6 && sensor_width == 2.5) {
193 x_condition_min = -Rin - 2.6;
194 x_condition_max = Rin + 1;
195 dist_offset = 2;
196 adjust_bottom_y_pos = true;
197 adjust_bottom_y_neg = true;
198 x_adjust_bottom_y_pos = 5.5;
199 bottom_y_pos_value = 3.5;
200 bottom_y_neg_value = -3.5;
201 } else {
202 std::cout << "Different config - to determine offsets needed." << std::endl;
203 x_condition_min = -Rin;
204 x_condition_max = Rin;
205 adjust_bottom_y_pos = false;
206 adjust_bottom_y_neg = false;
207 }
208
209 double Rin_offset = (sensor_height == 19.2) ? 1 : 0;
210 double Rout_offset = (sensor_height == 19.2) ? 1 : 0;
211
212 offset_Rin_lower = Rin - Rin_offset;
213 offset_Rin_upper = Rout + Rout_offset;
214
215 std::set<std::pair<double, double>> placed_sensors;
216 int sensor_count = 0;
217
218 int placementCounter = 0;
219 bool justSkipped = false;
220
221 std::vector<double> X_positions;
222 std::vector<int> justSkipped1;
223
224 if (sensor_width == 2.5) {
225 // logic for placement - x positions with complete overlap
226 if (face == "front") {
227 X_positions = {-63.4, -60.9, -54.2, -51.7, -45.0, -42.5, -35.8, -33.3, -26.6, -24.1, -17.4, -14.9,
228 -8.2, -5.7, 1.0, 3.5, 10.2, 12.7, 19.4, 21.9, 28.6, 31.1, 37.8, 40.3, 47.0, 49.5,
229 56.2, 58.7, 65.4};
230 justSkipped1 = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
231 } else if (face == "back") {
232 X_positions = {-65.5, -58.8, -56.3, -49.6, -47.1, -40.4, -37.9, -31.2, -28.7, -22.0, -19.5, -12.8,
233 -10.3, -3.6, -1.1, 5.6, 8.1, 14.8, 17.3, 24.0, 26.5, 33.2, 35.7, 42.4, 44.9,
234 51.6, 54.1, 60.8, 63.3};
235 justSkipped1 = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0};
236 }
237 } else {
238 // filling for sensors with 2x width, each row skipped
239 if (face == "front") {
240 X_positions = {-63.4, -54.2, -45, -35.8, -26.6, -17.4, -8.2, 1., 10.2, 19.4, 28.6, 37.8, 47., 56.2, 65.4};
241 justSkipped1 = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
242 } else if (face == "back") {
243 X_positions = {-58.8, -49.6, -40.4, -31.2, -22, -12.8, -3.6, 5.6, 14.8, 24, 33.2, 42.4, 51.6, 60.8};
244 justSkipped1 = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
245 }
246 }
247
248 if (layout_type == "rectangular") {
249
250 double x_start = -Rout;
251 double x_end = Rout;
252
253 std::vector<double> x_positions;
254 for (double x = x_start; x <= x_end; x += sensor_width) {
255 x_positions.push_back(x);
256 }
257
258 int rowCounter = 0;
259 const int rowsToAlternate = 2;
260
261 for (size_t i = 0; i < X_positions.size(); ++i) {
262
263 double x = X_positions[i];
264 bool justSkippedValue = justSkipped1[i];
265
266 std::vector<double> y_positions_positive;
267 std::vector<double> y_positions_negative;
268
269 for (double y = -Rout - Rin_offset; y <= Rout + Rin_offset; y += sensor_height) {
270 std::vector<std::pair<double, double>> corners = {
271 {x, y},
272 {x + sensor_width, y},
273 {x, y + sensor_height},
274 {x + sensor_width, y + sensor_height}};
275
276 bool within_bounds = std::all_of(corners.begin(), corners.end(), [&](const std::pair<double, double>& corner) {
277 double cx = corner.first;
278 double cy = corner.second;
279 return (offset_Rin_lower <= std::sqrt(cx * cx + cy * cy) && std::sqrt(cx * cx + cy * cy) <= offset_Rin_upper);
280 });
281
282 if (within_bounds) {
283 if (y >= 0) {
284 y_positions_positive.push_back(y);
285 } else {
286 y_positions_negative.push_back(y);
287 }
288 }
289 }
290
291 // adjust y positions near inner circle for positive y
292 if (x_condition_min <= x && x <= x_condition_max && !y_positions_positive.empty()) {
293 double first_y_pos = y_positions_positive.front();
294 double last_y_pos = y_positions_positive.back() - sensor_height;
295 double top_y_pos = std::min(calculate_y_circle(x, Rout), calculate_y_circle(x + sensor_width, Rout));
296 double bottom_y_pos = std::max(calculate_y_circle(x, Rin), calculate_y_circle(x + sensor_width, Rin));
297 double top_distance_pos = top_y_pos - last_y_pos;
298
299 if (adjust_bottom_y_pos && x > x_adjust_bottom_y_pos) {
300 bottom_y_pos = bottom_y_pos_value;
301 }
302
303 double bottom_distance_pos = first_y_pos - bottom_y_pos;
304
305 if (std::abs(top_distance_pos + bottom_distance_pos) >= sensor_height) {
306 for (auto& y : y_positions_positive) {
307 y -= bottom_distance_pos - 0.2;
308 }
309 y_positions_positive.push_back(y_positions_positive.back() + sensor_height);
310 }
311 }
312
313 // adjust y positions near inner circle for negative y
314 if (x_condition_min <= x && x <= x_condition_max && !y_positions_negative.empty()) {
315 double first_y_neg = y_positions_negative.front();
316 double last_y_neg = y_positions_negative.back() + sensor_height;
317 double top_y_neg = -std::min(calculate_y_circle(x, Rout), calculate_y_circle(x + sensor_width, Rout));
318 double bottom_y_neg = -std::max(calculate_y_circle(x, Rin), calculate_y_circle(x + sensor_width, Rin));
319 double top_distance_neg = -(top_y_neg - first_y_neg);
320
321 if (adjust_bottom_y_neg && x > x_adjust_bottom_y_pos) {
322 bottom_y_neg = bottom_y_neg_value;
323 }
324
325 double bottom_distance_neg = -(last_y_neg - bottom_y_neg);
326
327 top_distance_neg = std::abs(top_distance_neg);
328 bottom_distance_neg = std::abs(bottom_distance_neg);
329 std::sort(y_positions_negative.begin(), y_positions_negative.end());
330
331 if (std::abs(top_distance_neg + bottom_distance_neg) >= sensor_height) {
332 if (sensor_height == 19.2) {
333 for (auto& y : y_positions_negative) {
334 y -= bottom_distance_neg;
335 }
336 } else {
337 for (auto& y : y_positions_negative) {
338 y += bottom_distance_neg - 0.2;
339 }
340 }
341 y_positions_negative.push_back(y_positions_negative.front() - sensor_height);
342 }
343 }
344
345 // adjust positions for the rest of the disk
346 if ((x < x_condition_min || x > x_condition_max) && !y_positions_negative.empty() && !y_positions_positive.empty()) {
347 double first_y_neg = y_positions_negative.front();
348 double last_y_pos = y_positions_positive.back() + sensor_height;
349 double top_y_pos = std::min(calculate_y_circle(x, Rout), calculate_y_circle(x + sensor_width, Rout));
350 double bottom_y_pos = -top_y_pos;
351
352 double top_distance_pos = std::abs(top_y_pos - last_y_pos);
353 double bottom_distance_pos = std::abs(first_y_neg - bottom_y_pos);
354
355 if (top_distance_pos + bottom_distance_pos >= sensor_height) {
356 for (auto& y : y_positions_positive) {
357 y += top_distance_pos - 0.2;
358 }
359 for (auto& y : y_positions_negative) {
360 y += top_distance_pos - 0.2;
361 }
362 double new_y = y_positions_negative.front() - sensor_height;
363
364 if (static_cast<int>(new_y) > static_cast<int>(bottom_y_pos)) {
365 y_positions_negative.push_back(new_y);
366 }
367 }
368
369 // Make symmetric adjustments
370 std::sort(y_positions_negative.begin(), y_positions_negative.end());
371 std::sort(y_positions_positive.begin(), y_positions_positive.end());
372
373 double first_y_pos = y_positions_negative.front();
374
375 last_y_pos = y_positions_positive.back() + sensor_height;
376
377 top_y_pos = std::min(calculate_y_circle(x, Rout), calculate_y_circle(x + sensor_width, Rout));
378 bottom_y_pos = -top_y_pos;
379 top_distance_pos = std::abs(top_y_pos - last_y_pos);
380 bottom_distance_pos = std::abs(first_y_pos - bottom_y_pos);
381
382 double Lb = (bottom_distance_pos + top_distance_pos) / 2;
383
384 if (top_distance_pos < Lb) {
385 double shift = Lb - top_distance_pos;
386 for (auto& y : y_positions_negative) {
387 y -= shift;
388 }
389 for (auto& y : y_positions_positive) {
390 y -= shift;
391 }
392 } else if (top_distance_pos > Lb) {
393 double shift = top_distance_pos - Lb;
394 for (auto& y : y_positions_negative) {
395 y += shift;
396 }
397 for (auto& y : y_positions_positive) {
398 y += shift;
399 }
400 }
401 }
402
403 std::vector<double> y_positions = y_positions_positive;
404 y_positions.insert(y_positions.end(), y_positions_negative.begin(), y_positions_negative.end());
405
406 for (double y : y_positions) {
407
408 int SiColor;
409 double R_material_threshold = 0;
410
411 if (placed_sensors.find({x, y}) == placed_sensors.end()) {
412 placed_sensors.insert({x, y});
413 TGeoVolume* sensor;
414
415 double inactive_width = (sensor_width - active_width) / 2;
416 double left_inactive_x_shift;
417 double right_inactive_x_shift;
418 double active_x_shift_sensor;
419
420 if (face == "front") {
421
422 double active_x_shift, inactive_x_shift;
423
424 if (justSkippedValue) {
425 active_x_shift = x + inactive_width / 2;
426 active_x_shift_sensor = active_x_shift + inactive_width;
427
428 inactive_x_shift = x - active_width / 2 + inactive_width / 2;
429 } else {
430 active_x_shift = x - inactive_width / 2;
431 active_x_shift_sensor = active_x_shift - inactive_width;
432
433 inactive_x_shift = x + active_width / 2 - inactive_width / 2;
434 }
435
436 double inactive_x_shift_left, inactive_x_shift_right;
437
438 if (sensor_width == 5.0) {
439
440 inactive_x_shift_left = x - sensor_width / 2 + inactive_width;
441 inactive_x_shift_right = x + sensor_width / 2;
442 }
443
444 std::vector<std::pair<double, double>> corners_shifted = {
445 {x, y},
446 {x + sensor_width, y},
447 {x, y + sensor_height},
448 {x + sensor_width, y + sensor_height}};
449
450 bool within_bounds = true;
451 for (const auto& corner : corners_shifted) {
452 double cx = corner.first;
453 double cy = corner.second;
454 double dist = std::sqrt(cx * cx + cy * cy);
455
456 if (Rin > dist || dist >= Rout) {
457 within_bounds = false;
458 break;
459 }
460 }
461
462 if (within_bounds) {
463
464 double r_squared = (x + x_offset) * (x + x_offset) + (y + y_offset) * (y + y_offset);
465
466 if (r_squared < R_material_threshold * R_material_threshold) {
467 silicon_thickness = 0.005;
468 copper_thickness = 0.00475;
469 kapton_thickness = 0.03;
470 epoxy_thickness = 0.0012;
471
472 SiColor = kOrange;
473 } else {
474 silicon_thickness = 0.01;
475 copper_thickness = 0.006;
476 kapton_thickness = 0.03;
477 epoxy_thickness = 0.0012;
478
479 SiColor = kGreen;
480 }
481
482 if (sensor_width == 2.5) {
483 // silicon
484 std::string sensor_name = "FT3sensor_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
485 sensor = geoManager->MakeBox(sensor_name.c_str(), siliconMed, active_width / 2, active_height / 2, silicon_thickness / 2);
486 sensor->SetLineColor(SiColor);
487 sensor->SetFillColorAlpha(SiColor, 0.4);
488 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift_sensor + x_offset, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness - copper_thickness - epoxy_thickness - silicon_thickness / 2));
489
490 std::string inactive_name = "FT3inactive_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
491 sensor = geoManager->MakeBox(inactive_name.c_str(), siliconMed, (sensor_width - active_width) / 2, sensor_height / 2, silicon_thickness / 2);
492 sensor->SetLineColor(kRed);
493 sensor->SetFillColorAlpha(kRed, 1.0);
494 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + inactive_x_shift, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness - copper_thickness - epoxy_thickness - silicon_thickness / 2));
495
496 } else {
497
498 std::string sensor_name = "FT3sensor_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
499 sensor = geoManager->MakeBox(sensor_name.c_str(), siliconMed, active_width / 2, sensor_height / 2, silicon_thickness / 2);
500 sensor->SetLineColor(SiColor);
501 sensor->SetFillColorAlpha(SiColor, 0.4);
502 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + x + inactive_width / 2, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness - copper_thickness - epoxy_thickness - silicon_thickness / 2));
503
504 std::string inactive_name_left = "FT3inactive_left_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
505 sensor = geoManager->MakeBox(inactive_name_left.c_str(), siliconMed, inactive_width / 2, sensor_height / 2, silicon_thickness / 2);
506 sensor->SetLineColor(kRed);
507 sensor->SetFillColorAlpha(kRed, 1.0);
508 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + inactive_x_shift_left, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness - copper_thickness - epoxy_thickness - silicon_thickness / 2));
509
510 std::string inactive_name_right = "FT3inactive_right_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
511 sensor = geoManager->MakeBox(inactive_name_right.c_str(), siliconMed, inactive_width / 2, sensor_height / 2, silicon_thickness / 2);
512 sensor->SetLineColor(kRed);
513 sensor->SetFillColorAlpha(kRed, 1.0);
514 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + inactive_x_shift_right, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness - copper_thickness - epoxy_thickness - silicon_thickness / 2));
515 }
516
517 // silicon-to-FPC epoxy glue
518 std::string glue_up_name = "FT3glue_up_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
519 sensor = geoManager->MakeBox(glue_up_name.c_str(), epoxyMed, sensor_width / 2, sensor_height / 2, epoxy_thickness / 2);
520 sensor->SetLineColor(kBlue);
521 sensor->SetFillColorAlpha(kBlue, 1.0);
522 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + active_x_shift, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness - copper_thickness - epoxy_thickness / 2));
523
524 if (r_squared < R_material_threshold * R_material_threshold) {
525 std::string alu_name = "FT3aluminum_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
526 sensor = geoManager->MakeBox(alu_name.c_str(), AluminumMed, sensor_width / 2, sensor_height / 2, copper_thickness / 2);
527 sensor->SetLineColor(kBlack);
528 sensor->SetFillColorAlpha(kBlack, 0.4);
529 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift + x_offset, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness - copper_thickness / 2));
530
531 } else {
532 std::string copper_name = "FT3copper_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
533 sensor = geoManager->MakeBox(copper_name.c_str(), copperMed, sensor_width / 2, sensor_height / 2, copper_thickness / 2);
534 sensor->SetLineColor(kBlack);
535 sensor->SetFillColorAlpha(kBlack, 0.4);
536 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift + x_offset, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness - copper_thickness / 2));
537 }
538
539 // kapton
540 std::string fpc_name = "FT3fpc_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
541 sensor = geoManager->MakeBox(fpc_name.c_str(), kaptonMed, sensor_width / 2, sensor_height / 2, kapton_thickness / 2);
542 sensor->SetLineColor(kGreen);
543 sensor->SetFillColorAlpha(kGreen, 0.4);
544 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift + x_offset, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness / 2));
545
546 // FPC-to-support epoxy glue
547 std::string glue_down_name = "FT3glue_down_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
548 sensor = geoManager->MakeBox(glue_down_name.c_str(), epoxyMed, sensor_width / 2, sensor_height / 2, epoxy_thickness / 2);
549 sensor->SetLineColor(kBlue);
550 sensor->SetFillColorAlpha(kBlue, 1.0);
551 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + active_x_shift, y + y_offset, mZ + z_offset - epoxy_thickness / 2));
552 }
553 } else {
554 double x_shifted = x;
555 double inactive_x_shift, active_x_shift;
556 double active_x_shift_sensor;
557
558 if (justSkippedValue) {
559 active_x_shift = x + inactive_width / 2;
560 active_x_shift_sensor = active_x_shift + inactive_width;
561
562 inactive_x_shift = x - active_width / 2 + inactive_width / 2;
563 } else {
564 active_x_shift = x - inactive_width / 2;
565 active_x_shift_sensor = active_x_shift - inactive_width;
566
567 inactive_x_shift = x + active_width / 2 - inactive_width / 2;
568 }
569
570 double inactive_x_shift_left, inactive_x_shift_right;
571
572 if (sensor_width == 5.0) {
573
574 inactive_x_shift_left = x - sensor_width / 2 + inactive_width;
575 inactive_x_shift_right = x + sensor_width / 2;
576 }
577
578 std::vector<std::pair<double, double>> corners_shifted = {
579 {x_shifted, y},
580 {x_shifted + sensor_width, y},
581 {x_shifted, y + sensor_height},
582 {x_shifted + sensor_width, y + sensor_height}};
583
584 bool within_bounds = true;
585 for (const auto& corner : corners_shifted) {
586 double cx = corner.first;
587 double cy = corner.second;
588 double dist = std::sqrt(cx * cx + cy * cy);
589
590 if (Rin > dist + dist_offset || dist >= Rout) {
591 within_bounds = false;
592 break;
593 }
594 }
595
596 if (within_bounds) {
597
598 double r_squared = (x + x_offset) * (x + x_offset) + (y + y_offset) * (y + y_offset);
599
600 if (r_squared < R_material_threshold * R_material_threshold) {
601 silicon_thickness = 0.005;
602 copper_thickness = 0.00475; // thinner -> + replaced by alu
603 kapton_thickness = 0.03;
604 epoxy_thickness = 0.0006;
605
606 SiColor = kOrange;
607 } else {
608 silicon_thickness = 0.01;
609 copper_thickness = 0.006;
610 kapton_thickness = 0.03;
611 epoxy_thickness = 0.0012;
612
613 SiColor = kGreen;
614 }
615
616 // FPC-to-support epoxy glue
617 std::string glue_down_name = "FT3glue_down_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
618 sensor = geoManager->MakeBox(glue_down_name.c_str(), epoxyMed, sensor_width / 2, sensor_height / 2, epoxy_thickness / 2);
619 sensor->SetLineColor(kBlue);
620 sensor->SetFillColorAlpha(kBlue, 1.0);
621 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + active_x_shift, y + y_offset, mZ + z_offset + epoxy_thickness / 2));
622
623 // Kapton
624 std::string fpc_name = "FT3fpc_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
625 sensor = geoManager->MakeBox(fpc_name.c_str(), kaptonMed, sensor_width / 2, sensor_height / 2, kapton_thickness / 2);
626 sensor->SetLineColor(kGreen);
627 sensor->SetFillColorAlpha(kGreen, 0.4);
628 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift + x_offset, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness / 2));
629
630 if (r_squared < R_material_threshold * R_material_threshold) {
631 // replace copper with alu
632 std::string alu_name = "FT3aluminum_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
633 sensor = geoManager->MakeBox(alu_name.c_str(), AluminumMed, sensor_width / 2, sensor_height / 2, copper_thickness / 2);
634 sensor->SetLineColor(kBlack);
635 sensor->SetFillColorAlpha(kBlack, 0.4);
636 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift + x_offset, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness + copper_thickness / 2));
637
638 } else {
639 std::string copper_name = "FT3copper_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
640 sensor = geoManager->MakeBox(copper_name.c_str(), copperMed, sensor_width / 2, sensor_height / 2, copper_thickness / 2);
641 sensor->SetLineColor(kBlack);
642 sensor->SetFillColorAlpha(kBlack, 0.4);
643 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift + x_offset, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness + copper_thickness / 2));
644 }
645
646 // silicon-to-FPC epoxy glue
647 std::string glue_up_name = "FT3glue_up_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
648 sensor = geoManager->MakeBox(glue_up_name.c_str(), epoxyMed, sensor_width / 2, sensor_height / 2, epoxy_thickness / 2);
649 sensor->SetLineColor(kBlue);
650 sensor->SetFillColorAlpha(kBlue, 1.0);
651 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + active_x_shift, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness + copper_thickness + epoxy_thickness / 2));
652
653 if (sensor_width == 2.5) {
654
655 std::string sensor_name = "FT3sensor_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
656 sensor = geoManager->MakeBox(sensor_name.c_str(), siliconMed, active_width / 2, active_height / 2, silicon_thickness / 2);
657 sensor->SetLineColor(SiColor);
658 sensor->SetFillColorAlpha(SiColor, 0.4);
659 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift_sensor + x_offset, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness + copper_thickness + epoxy_thickness + silicon_thickness / 2));
660
661 std::string inactive_name = "FT3inactive_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
662 sensor = geoManager->MakeBox(inactive_name.c_str(), siliconMed, (sensor_width - active_width) / 2, sensor_height / 2, silicon_thickness / 2);
663 sensor->SetLineColor(kRed);
664 sensor->SetFillColorAlpha(kRed, 1.0);
665 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + inactive_x_shift, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness + copper_thickness + epoxy_thickness + silicon_thickness / 2));
666
667 } else {
668 // active (4.6 cm centered)
669 std::string sensor_name = "FT3sensor_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
670 sensor = geoManager->MakeBox(sensor_name.c_str(), siliconMed, active_width / 2, sensor_height / 2, silicon_thickness / 2);
671 sensor->SetLineColor(SiColor);
672 sensor->SetFillColorAlpha(SiColor, 0.4);
673 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + x_shifted + inactive_width / 2, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness + copper_thickness + epoxy_thickness + silicon_thickness / 2));
674
675 // left inactive strip
676 std::string inactive_name_left = "FT3inactive_left_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
677 sensor = geoManager->MakeBox(inactive_name_left.c_str(), siliconMed, inactive_width / 2, sensor_height / 2, silicon_thickness / 2);
678 sensor->SetLineColor(kRed);
679 sensor->SetFillColorAlpha(kRed, 1.0);
680 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + inactive_x_shift_left, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness + copper_thickness + epoxy_thickness + silicon_thickness / 2));
681
682 // right inactive strip
683 std::string inactive_name_right = "FT3inactive_right_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
684 sensor = geoManager->MakeBox(inactive_name_right.c_str(), siliconMed, inactive_width / 2, sensor_height / 2, silicon_thickness / 2);
685 sensor->SetLineColor(kRed);
686 sensor->SetFillColorAlpha(kRed, 1.0);
687 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + inactive_x_shift_right, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness + copper_thickness + epoxy_thickness + silicon_thickness / 2));
688 }
689 }
690 }
691 }
692 }
693
694 rowCounter++;
695 }
696 }
697 LOG(debug) << "FT3Module: done create_layout";
698}
699
700void FT3Module::createModule(double mZ, int layerNumber, int direction, double Rin, double Rout, double overlap, const std::string& face, const std::string& layout_type, TGeoVolume* motherVolume)
701{
702
703 LOG(debug) << "FT3Module: createModule - Layer " << layerNumber << ", Direction " << direction << ", Face " << face;
704 create_layout(mZ, layerNumber, direction, Rin, Rout, overlap, face, layout_type, motherVolume);
705 LOG(debug) << "FT3Module: done createModule";
706}
std::ostringstream debug
double calculate_y_circle(double x, double radius)
Definition FT3Module.cxx:80
Definition of the FT3Module class.
int32_t i
static TGeoMedium * epoxyMed
Definition FT3Module.h:33
static TGeoMaterial * epoxyMat
Definition FT3Module.h:32
static TGeoMedium * siliconMed
Definition FT3Module.h:27
static void createModule(double mZ, int layerNumber, int direction, double Rin, double Rout, double overlap, const std::string &face, const std::string &layout_type, TGeoVolume *motherVolume)
static TGeoMedium * copperMed
Definition FT3Module.h:29
static TGeoMaterial * kaptonMat
Definition FT3Module.h:30
static TGeoMaterial * copperMat
Definition FT3Module.h:28
static TGeoMaterial * siliconMat
Definition FT3Module.h:26
static TGeoMedium * AluminumMed
Definition FT3Module.h:35
static TGeoMedium * kaptonMed
Definition FT3Module.h:31
static TGeoMaterial * AluminumMat
Definition FT3Module.h:34
static void initialize_materials()
Definition FT3Module.cxx:43
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum GLuint GLint GLenum face
Definition glcorearb.h:3184
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"