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 = 1.0;
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 double Rin_offset = (sensor_height == 19.2) ? 1 : 0;
144 double Rout_offset = (sensor_height == 19.2) ? 1 : 0;
145
146 if (Rin == 7 && sensor_height == 9.6 && sensor_width == 5) {
147 x_condition_min = -Rin - 2;
148 x_condition_max = Rin;
149 adjust_bottom_y_pos = true;
150 adjust_bottom_y_neg = true;
151 x_adjust_bottom_y_pos = 3.5;
152 bottom_y_pos_value = 3.5;
153 bottom_y_neg_value = -3.5;
154
155 dist_offset = 2;
156
157 } else if (Rin == 5 && sensor_height == 9.6 && sensor_width == 5) {
158 x_condition_min = -Rin - 6;
159 x_condition_max = Rin;
160 adjust_bottom_y_pos = true;
161 adjust_bottom_y_neg = true;
162 x_adjust_bottom_y_pos = 3.5;
163 bottom_y_pos_value = 3.5;
164 bottom_y_neg_value = -3.5;
165 } else if ((Rin == 5 || Rin == 7) && sensor_height == 19.2) {
166 x_condition_min = -Rin - 3;
167 x_condition_max = Rin - 0.2;
168 dist_offset = 2;
169 adjust_bottom_y_pos = false;
170 adjust_bottom_y_neg = false;
171 } else if (Rin == 5 && sensor_height == 3.2) {
172 x_condition_min = -(Rin + 2.6);
173 x_condition_max = Rin + 1.5;
174 adjust_bottom_y_pos = true;
175 adjust_bottom_y_neg = true;
176 x_adjust_bottom_y_pos = 3.5;
177 bottom_y_pos_value = 3.5;
178 bottom_y_neg_value = -3.5;
179 } else if (Rin == 7 && sensor_height == 3.2) {
180 x_condition_min = -Rin - 1;
181 x_condition_max = Rin - 0.2;
182 adjust_bottom_y_pos = true;
183 adjust_bottom_y_neg = true;
184 x_adjust_bottom_y_pos = 3.5;
185 bottom_y_pos_value = 3.5;
186 bottom_y_neg_value = -3.5;
187 } else if (Rin == 5 && sensor_height == 9.6 && sensor_width == 2.5) {
188 x_condition_min = -(Rin + 2.6);
189 x_condition_max = Rin;
190 adjust_bottom_y_pos = true;
191 adjust_bottom_y_neg = true;
192 x_adjust_bottom_y_pos = 3.5;
193 bottom_y_pos_value = 3.5;
194 bottom_y_neg_value = -3.5;
195 } else if (Rin == 7 && sensor_height == 9.6 && sensor_width == 2.5) {
196 x_condition_min = -Rin - 2.6;
197 x_condition_max = Rin + 1;
198 dist_offset = 2;
199 adjust_bottom_y_pos = true;
200 adjust_bottom_y_neg = true;
201 x_adjust_bottom_y_pos = 5.5;
202 bottom_y_pos_value = 3.5;
203 bottom_y_neg_value = -3.5;
204 } else if (Rin == 20 && sensor_height == 9.6 && sensor_width == 5.0) {
205 x_condition_min = -Rin - 4;
206 x_condition_max = Rin;
207 dist_offset = 2;
208 adjust_bottom_y_pos = false;
209 adjust_bottom_y_neg = false;
210 x_adjust_bottom_y_pos = 3.5;
211 bottom_y_pos_value = 3.5;
212 bottom_y_neg_value = -3.5;
213 } else {
214 LOG(warning) << "Different config - to determine offsets needed for " << "Rin = " << Rin << " ; sensor_height = " << sensor_height << " ; sensor_width = " << sensor_width << " layer " << layerNumber;
215 x_condition_min = -Rin - sensor_width;
216 x_condition_max = Rin;
217 adjust_bottom_y_pos = false;
218 adjust_bottom_y_neg = false;
219 }
220
221 offset_Rin_lower = Rin - Rin_offset;
222 offset_Rin_upper = Rout + Rout_offset;
223
224 std::set<std::pair<double, double>> placed_sensors;
225 int sensor_count = 0;
226
227 int placementCounter = 0;
228 bool justSkipped = false;
229
230 std::vector<double> X_positions;
231 std::vector<int> justSkipped1;
232
233 if (sensor_width == 2.5) {
234 // logic for placement - x positions with complete overlap
235 if (face == "front") {
236 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,
237 -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,
238 56.2, 58.7, 65.4};
239 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};
240 } else if (face == "back") {
241 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,
242 -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,
243 51.6, 54.1, 60.8, 63.3};
244 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};
245 }
246 } else {
247 if (Rin == 20) { // v3 paving, rough attempt
248 float overlap = 0.3;
249 // NB: these are left edges
250 float X_start = -2.0 - 13.5 * (sensor_width - overlap);
251 float X_start_pos = 2.0 - 0.5 * (sensor_width - overlap);
252 if (face == "back") {
253 X_start += (sensor_width - overlap);
254 X_start_pos += (sensor_width - overlap);
255 }
256 while (X_start < -2) {
257 X_positions.push_back(X_start);
258 justSkipped1.push_back(1);
259 X_start += 2 * (sensor_width - overlap);
260 }
261 while (X_start_pos < Rout + x_offset - sensor_width) {
262 X_positions.push_back(X_start_pos);
263 justSkipped1.push_back(1);
264 X_start_pos += 2 * (sensor_width - overlap);
265 }
266 } else {
267 // filling for sensors with 2x width, each row skipped
268 if (face == "front") {
269 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};
270 justSkipped1 = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
271 } else if (face == "back") {
272 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};
273 justSkipped1 = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
274 }
275 }
276 }
277
278 if (layout_type == "rectangular") {
279
280 double x_start = -Rout;
281 double x_end = Rout;
282
283 std::vector<double> x_positions;
284 for (double x = x_start; x <= x_end; x += sensor_width) {
285 x_positions.push_back(x);
286 }
287
288 int rowCounter = 0;
289 const int rowsToAlternate = 2;
290
291 for (size_t i = 0; i < X_positions.size(); ++i) {
292
293 double x = X_positions[i];
294 bool justSkippedValue = justSkipped1[i];
295
296 std::vector<double> y_positions_positive;
297 std::vector<double> y_positions_negative;
298
299 for (double y = -Rout - Rin_offset; y <= Rout + Rin_offset; y += sensor_height) {
300 std::vector<std::pair<double, double>> corners = {
301 {x, y},
302 {x + sensor_width, y},
303 {x, y + sensor_height},
304 {x + sensor_width, y + sensor_height}};
305
306 bool within_bounds = std::all_of(corners.begin(), corners.end(), [&](const std::pair<double, double>& corner) {
307 double cx = corner.first;
308 double cy = corner.second;
309 return (offset_Rin_lower <= std::sqrt(cx * cx + cy * cy) && std::sqrt(cx * cx + cy * cy) <= offset_Rin_upper);
310 });
311
312 if (within_bounds) {
313 if (y >= 0) {
314 y_positions_positive.push_back(y);
315 } else {
316 y_positions_negative.push_back(y);
317 }
318 }
319 }
320
321 // adjust y positions near inner circle for positive y
322 if (x_condition_min <= x && x <= x_condition_max && !y_positions_positive.empty()) {
323 double first_y_pos = y_positions_positive.front();
324 double last_y_pos = y_positions_positive.back() - sensor_height;
325 double top_y_pos = std::min(calculate_y_circle(x, Rout), calculate_y_circle(x + sensor_width, Rout));
326 double bottom_y_pos = std::max(calculate_y_circle(x, Rin), calculate_y_circle(x + sensor_width, Rin));
327 double top_distance_pos = top_y_pos - last_y_pos;
328
329 if (adjust_bottom_y_pos && x > x_adjust_bottom_y_pos) {
330 bottom_y_pos = bottom_y_pos_value;
331 }
332
333 double bottom_distance_pos = first_y_pos - bottom_y_pos;
334
335 if (std::abs(top_distance_pos + bottom_distance_pos) >= sensor_height) {
336 for (auto& y : y_positions_positive) {
337 y -= bottom_distance_pos - 0.2;
338 }
339 y_positions_positive.push_back(y_positions_positive.back() + sensor_height);
340 }
341 }
342
343 // adjust y positions near inner circle for negative y
344 if (x_condition_min <= x && x <= x_condition_max && !y_positions_negative.empty()) {
345 double first_y_neg = y_positions_negative.front();
346 double last_y_neg = y_positions_negative.back() + sensor_height;
347 double top_y_neg = -std::min(calculate_y_circle(x, Rout), calculate_y_circle(x + sensor_width, Rout));
348 double bottom_y_neg = -std::max(calculate_y_circle(x, Rin), calculate_y_circle(x + sensor_width, Rin));
349 double top_distance_neg = -(top_y_neg - first_y_neg);
350
351 if (adjust_bottom_y_neg && x > x_adjust_bottom_y_pos) {
352 bottom_y_neg = bottom_y_neg_value;
353 }
354
355 double bottom_distance_neg = -(last_y_neg - bottom_y_neg);
356
357 top_distance_neg = std::abs(top_distance_neg);
358 bottom_distance_neg = std::abs(bottom_distance_neg);
359 std::sort(y_positions_negative.begin(), y_positions_negative.end());
360
361 if (std::abs(top_distance_neg + bottom_distance_neg) >= sensor_height) {
362 if (sensor_height == 19.2) {
363 for (auto& y : y_positions_negative) {
364 y -= bottom_distance_neg;
365 }
366 } else {
367 for (auto& y : y_positions_negative) {
368 y += bottom_distance_neg - 0.2;
369 }
370 }
371 y_positions_negative.push_back(y_positions_negative.front() - sensor_height);
372 }
373 }
374
375 // adjust positions for the rest of the disk
376 if ((x < x_condition_min || x > x_condition_max) && !y_positions_negative.empty() && !y_positions_positive.empty()) {
377 double first_y_neg = y_positions_negative.front();
378 double last_y_pos = y_positions_positive.back() + sensor_height;
379 double top_y_pos = std::min(calculate_y_circle(x, Rout), calculate_y_circle(x + sensor_width, Rout));
380 double bottom_y_pos = -top_y_pos;
381
382 double top_distance_pos = std::abs(top_y_pos - last_y_pos);
383 double bottom_distance_pos = std::abs(first_y_neg - bottom_y_pos);
384
385 if (top_distance_pos + bottom_distance_pos >= sensor_height) {
386 for (auto& y : y_positions_positive) {
387 y += top_distance_pos - 0.2;
388 }
389 for (auto& y : y_positions_negative) {
390 y += top_distance_pos - 0.2;
391 }
392 double new_y = y_positions_negative.front() - sensor_height;
393
394 if (static_cast<int>(new_y) > static_cast<int>(bottom_y_pos)) {
395 y_positions_negative.push_back(new_y);
396 }
397 }
398
399 // Make symmetric adjustments
400 std::sort(y_positions_negative.begin(), y_positions_negative.end());
401 std::sort(y_positions_positive.begin(), y_positions_positive.end());
402
403 double first_y_pos = y_positions_negative.front();
404
405 last_y_pos = y_positions_positive.back() + sensor_height;
406
407 top_y_pos = std::min(calculate_y_circle(x, Rout), calculate_y_circle(x + sensor_width, Rout));
408 bottom_y_pos = -top_y_pos;
409 top_distance_pos = std::abs(top_y_pos - last_y_pos);
410 bottom_distance_pos = std::abs(first_y_pos - bottom_y_pos);
411
412 double Lb = (bottom_distance_pos + top_distance_pos) / 2;
413
414 if (top_distance_pos < Lb) {
415 double shift = Lb - top_distance_pos;
416 for (auto& y : y_positions_negative) {
417 y -= shift;
418 }
419 for (auto& y : y_positions_positive) {
420 y -= shift;
421 }
422 } else if (top_distance_pos > Lb) {
423 double shift = top_distance_pos - Lb;
424 for (auto& y : y_positions_negative) {
425 y += shift;
426 }
427 for (auto& y : y_positions_positive) {
428 y += shift;
429 }
430 }
431 }
432
433 std::vector<double> y_positions = y_positions_positive;
434 y_positions.insert(y_positions.end(), y_positions_negative.begin(), y_positions_negative.end());
435
436 for (double y : y_positions) {
437
438 int SiColor;
439 double R_material_threshold = 0;
440
441 if (placed_sensors.find({x, y}) == placed_sensors.end()) {
442 placed_sensors.insert({x, y});
443 TGeoVolume* sensor;
444
445 double inactive_width = (sensor_width - active_width) / 2;
446 double left_inactive_x_shift;
447 double right_inactive_x_shift;
448 double active_x_shift_sensor;
449
450 if (face == "front") {
451
452 double active_x_shift, inactive_x_shift;
453
454 if (justSkippedValue) {
455 active_x_shift = x + inactive_width / 2;
456 active_x_shift_sensor = active_x_shift + inactive_width;
457
458 inactive_x_shift = x - active_width / 2 + inactive_width / 2;
459 } else {
460 active_x_shift = x - inactive_width / 2;
461 active_x_shift_sensor = active_x_shift - inactive_width;
462
463 inactive_x_shift = x + active_width / 2 - inactive_width / 2;
464 }
465
466 double inactive_x_shift_left, inactive_x_shift_right;
467
468 if (sensor_width == 5.0) {
469
470 inactive_x_shift_left = x - sensor_width / 2 + inactive_width;
471 inactive_x_shift_right = x + sensor_width / 2;
472 }
473
474 std::vector<std::pair<double, double>> corners_shifted = {
475 {x, y},
476 {x + sensor_width, y},
477 {x, y + sensor_height},
478 {x + sensor_width, y + sensor_height}};
479
480 bool within_bounds = true;
481 for (const auto& corner : corners_shifted) {
482 double cx = corner.first;
483 double cy = corner.second;
484 double dist = std::sqrt(cx * cx + cy * cy);
485
486 if (Rin > dist || dist >= Rout) {
487 within_bounds = false;
488 break;
489 }
490 }
491
492 if (within_bounds) {
493
494 double r_squared = (x + x_offset) * (x + x_offset) + (y + y_offset) * (y + y_offset);
495
496 if (r_squared < R_material_threshold * R_material_threshold) {
497 silicon_thickness = 0.005;
498 copper_thickness = 0.00475;
499 kapton_thickness = 0.03;
500 epoxy_thickness = 0.0012;
501
502 SiColor = kOrange;
503 } else {
504 silicon_thickness = 0.01;
505 copper_thickness = 0.006;
506 kapton_thickness = 0.03;
507 epoxy_thickness = 0.0012;
508
509 SiColor = kGreen;
510 }
511
512 if (sensor_width == 2.5) {
513 // silicon
514 std::string sensor_name = "FT3Sensor_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
515 sensor = geoManager->MakeBox(sensor_name.c_str(), siliconMed, active_width / 2, active_height / 2, silicon_thickness / 2);
516 sensor->SetLineColor(SiColor);
517 sensor->SetFillColorAlpha(SiColor, 0.4);
518 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));
519
520 std::string inactive_name = "FT3inactive_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
521 sensor = geoManager->MakeBox(inactive_name.c_str(), siliconMed, (sensor_width - active_width) / 2, sensor_height / 2, silicon_thickness / 2);
522 sensor->SetLineColor(kRed);
523 sensor->SetFillColorAlpha(kRed, 1.0);
524 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));
525
526 } else {
527
528 std::string sensor_name = "FT3Sensor_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
529 sensor = geoManager->MakeBox(sensor_name.c_str(), siliconMed, active_width / 2, sensor_height / 2, silicon_thickness / 2);
530 sensor->SetLineColor(SiColor);
531 sensor->SetFillColorAlpha(SiColor, 0.4);
532 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));
533
534 std::string inactive_name_left = "FT3inactive_left_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
535 sensor = geoManager->MakeBox(inactive_name_left.c_str(), siliconMed, inactive_width / 2, sensor_height / 2, silicon_thickness / 2);
536 sensor->SetLineColor(kRed);
537 sensor->SetFillColorAlpha(kRed, 1.0);
538 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));
539
540 std::string inactive_name_right = "FT3inactive_right_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
541 sensor = geoManager->MakeBox(inactive_name_right.c_str(), siliconMed, inactive_width / 2, sensor_height / 2, silicon_thickness / 2);
542 sensor->SetLineColor(kRed);
543 sensor->SetFillColorAlpha(kRed, 1.0);
544 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));
545 }
546
547 // silicon-to-FPC epoxy glue
548 std::string glue_up_name = "FT3glue_up_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
549 sensor = geoManager->MakeBox(glue_up_name.c_str(), epoxyMed, sensor_width / 2, sensor_height / 2, epoxy_thickness / 2);
550 sensor->SetLineColor(kBlue);
551 sensor->SetFillColorAlpha(kBlue, 1.0);
552 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));
553
554 if (r_squared < R_material_threshold * R_material_threshold) {
555 std::string alu_name = "FT3aluminum_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
556 sensor = geoManager->MakeBox(alu_name.c_str(), AluminumMed, sensor_width / 2, sensor_height / 2, copper_thickness / 2);
557 sensor->SetLineColor(kBlack);
558 sensor->SetFillColorAlpha(kBlack, 0.4);
559 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));
560
561 } else {
562 std::string copper_name = "FT3copper_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
563 sensor = geoManager->MakeBox(copper_name.c_str(), copperMed, sensor_width / 2, sensor_height / 2, copper_thickness / 2);
564 sensor->SetLineColor(kBlack);
565 sensor->SetFillColorAlpha(kBlack, 0.4);
566 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));
567 }
568
569 // kapton
570 std::string fpc_name = "FT3fpc_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
571 sensor = geoManager->MakeBox(fpc_name.c_str(), kaptonMed, sensor_width / 2, sensor_height / 2, kapton_thickness / 2);
572 sensor->SetLineColor(kGreen);
573 sensor->SetFillColorAlpha(kGreen, 0.4);
574 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift + x_offset, y + y_offset, mZ + z_offset - epoxy_thickness - kapton_thickness / 2));
575
576 // FPC-to-support epoxy glue
577 std::string glue_down_name = "FT3glue_down_front_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
578 sensor = geoManager->MakeBox(glue_down_name.c_str(), epoxyMed, sensor_width / 2, sensor_height / 2, epoxy_thickness / 2);
579 sensor->SetLineColor(kBlue);
580 sensor->SetFillColorAlpha(kBlue, 1.0);
581 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(x_offset + active_x_shift, y + y_offset, mZ + z_offset - epoxy_thickness / 2));
582 }
583 } else {
584 double x_shifted = x;
585 double inactive_x_shift, active_x_shift;
586 double active_x_shift_sensor;
587
588 if (justSkippedValue) {
589 active_x_shift = x + inactive_width / 2;
590 active_x_shift_sensor = active_x_shift + inactive_width;
591
592 inactive_x_shift = x - active_width / 2 + inactive_width / 2;
593 } else {
594 active_x_shift = x - inactive_width / 2;
595 active_x_shift_sensor = active_x_shift - inactive_width;
596
597 inactive_x_shift = x + active_width / 2 - inactive_width / 2;
598 }
599
600 double inactive_x_shift_left, inactive_x_shift_right;
601
602 if (sensor_width == 5.0) {
603
604 inactive_x_shift_left = x - sensor_width / 2 + inactive_width;
605 inactive_x_shift_right = x + sensor_width / 2;
606 }
607
608 std::vector<std::pair<double, double>> corners_shifted = {
609 {x_shifted, y},
610 {x_shifted + sensor_width, y},
611 {x_shifted, y + sensor_height},
612 {x_shifted + sensor_width, y + sensor_height}};
613
614 bool within_bounds = true;
615 for (const auto& corner : corners_shifted) {
616 double cx = corner.first;
617 double cy = corner.second;
618 double dist = std::sqrt(cx * cx + cy * cy);
619
620 if (Rin > dist + dist_offset || dist >= Rout) {
621 within_bounds = false;
622 break;
623 }
624 }
625
626 if (within_bounds) {
627
628 double r_squared = (x + x_offset) * (x + x_offset) + (y + y_offset) * (y + y_offset);
629
630 if (r_squared < R_material_threshold * R_material_threshold) {
631 silicon_thickness = 0.005;
632 copper_thickness = 0.00475; // thinner -> + replaced by alu
633 kapton_thickness = 0.03;
634 epoxy_thickness = 0.0006;
635
636 SiColor = kOrange;
637 } else {
638 silicon_thickness = 0.01;
639 copper_thickness = 0.006;
640 kapton_thickness = 0.03;
641 epoxy_thickness = 0.0012;
642
643 SiColor = kGreen;
644 }
645
646 // FPC-to-support epoxy glue
647 std::string glue_down_name = "FT3glue_down_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
648 sensor = geoManager->MakeBox(glue_down_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 / 2));
652
653 // Kapton
654 std::string fpc_name = "FT3fpc_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
655 sensor = geoManager->MakeBox(fpc_name.c_str(), kaptonMed, sensor_width / 2, sensor_height / 2, kapton_thickness / 2);
656 sensor->SetLineColor(kGreen);
657 sensor->SetFillColorAlpha(kGreen, 0.4);
658 motherVolume->AddNode(sensor, sensor_count++, new TGeoTranslation(active_x_shift + x_offset, y + y_offset, mZ + z_offset + epoxy_thickness + kapton_thickness / 2));
659
660 if (r_squared < R_material_threshold * R_material_threshold) {
661 // replace copper with alu
662 std::string alu_name = "FT3aluminum_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
663 sensor = geoManager->MakeBox(alu_name.c_str(), AluminumMed, sensor_width / 2, sensor_height / 2, copper_thickness / 2);
664 sensor->SetLineColor(kBlack);
665 sensor->SetFillColorAlpha(kBlack, 0.4);
666 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));
667
668 } else {
669 std::string copper_name = "FT3copper_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
670 sensor = geoManager->MakeBox(copper_name.c_str(), copperMed, sensor_width / 2, sensor_height / 2, copper_thickness / 2);
671 sensor->SetLineColor(kBlack);
672 sensor->SetFillColorAlpha(kBlack, 0.4);
673 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));
674 }
675
676 // silicon-to-FPC epoxy glue
677 std::string glue_up_name = "FT3glue_up_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
678 sensor = geoManager->MakeBox(glue_up_name.c_str(), epoxyMed, sensor_width / 2, sensor_height / 2, epoxy_thickness / 2);
679 sensor->SetLineColor(kBlue);
680 sensor->SetFillColorAlpha(kBlue, 1.0);
681 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));
682
683 if (sensor_width == 2.5) {
684
685 std::string sensor_name = "FT3Sensor_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
686 sensor = geoManager->MakeBox(sensor_name.c_str(), siliconMed, active_width / 2, active_height / 2, silicon_thickness / 2);
687 sensor->SetLineColor(SiColor);
688 sensor->SetFillColorAlpha(SiColor, 0.4);
689 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));
690
691 std::string inactive_name = "FT3inactive_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
692 sensor = geoManager->MakeBox(inactive_name.c_str(), siliconMed, (sensor_width - active_width) / 2, sensor_height / 2, silicon_thickness / 2);
693 sensor->SetLineColor(kRed);
694 sensor->SetFillColorAlpha(kRed, 1.0);
695 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));
696
697 } else {
698 // active (4.6 cm centered)
699 std::string sensor_name = "FT3Sensor_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
700 sensor = geoManager->MakeBox(sensor_name.c_str(), siliconMed, active_width / 2, sensor_height / 2, silicon_thickness / 2);
701 sensor->SetLineColor(SiColor);
702 sensor->SetFillColorAlpha(SiColor, 0.4);
703 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));
704
705 // left inactive strip
706 std::string inactive_name_left = "FT3inactive_left_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
707 sensor = geoManager->MakeBox(inactive_name_left.c_str(), siliconMed, inactive_width / 2, sensor_height / 2, silicon_thickness / 2);
708 sensor->SetLineColor(kRed);
709 sensor->SetFillColorAlpha(kRed, 1.0);
710 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));
711
712 // right inactive strip
713 std::string inactive_name_right = "FT3inactive_right_back_" + std::to_string(layerNumber) + "_" + std::to_string(direction) + "_" + std::to_string(sensor_count);
714 sensor = geoManager->MakeBox(inactive_name_right.c_str(), siliconMed, inactive_width / 2, sensor_height / 2, silicon_thickness / 2);
715 sensor->SetLineColor(kRed);
716 sensor->SetFillColorAlpha(kRed, 1.0);
717 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));
718 }
719 }
720 }
721 }
722 }
723
724 rowCounter++;
725 }
726 }
727 LOG(debug) << "FT3Module: done create_layout";
728}
729
730void 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)
731{
732
733 LOG(debug) << "FT3Module: createModule - Layer " << layerNumber << ", Direction " << direction << ", Face " << face;
734 create_layout(mZ, layerNumber, direction, Rin, Rout, overlap, face, layout_type, motherVolume);
735 LOG(debug) << "FT3Module: done createModule";
736}
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"