Skip to content

Commit 440983a

Browse files
committed
Make medium creation in FT3 defined and executed more centrally
1 parent 8329295 commit 440983a

6 files changed

Lines changed: 173 additions & 227 deletions

File tree

‎Detectors/Upgrades/ALICE3/TRKFT3/FT3/simulation/include/FT3Simulation/FT3Layer.h‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,11 @@ class FT3Layer : public TObject
5959
/// \param motherVolume the TGeoVolume owing the volume structure
6060
virtual void createLayer(TGeoVolume* motherVolume);
6161

62-
static void initialize_mat();
63-
6462
// create layer for disk support
6563
void createSeparationLayer(TGeoVolume* motherVolume, const std::string& separationLayerName);
6664
void createSeparationLayer_waterCooling(TGeoVolume* motherVolume, const std::string& separationLayerName);
6765
void createReferenceCircles(TGeoVolume* motherVolume, const std::string& name);
6866

69-
static TGeoMaterial* carbonFiberMat;
70-
static TGeoMedium* medCarbonFiber;
71-
72-
static TGeoMixture* kaptonMat;
73-
static TGeoMedium* kaptonMed;
74-
75-
static TGeoMaterial* waterMat;
76-
static TGeoMedium* waterMed;
77-
78-
static TGeoMaterial* foamMat;
79-
static TGeoMedium* medFoam;
80-
8167
private:
8268
Int_t mLayerNumber = -1; ///< Current layer number
8369
Int_t mDirection; ///< Layer direction 0=Forward 1 = Backward

‎Detectors/Upgrades/ALICE3/TRKFT3/FT3/simulation/include/FT3Simulation/FT3Module.h‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef FT3MODULE_H
1616
#define FT3MODULE_H
1717

18+
#include <TGeoMedium.h>
1819
#include <TGeoVolume.h>
1920
#include <string>
2021
#include <vector>
@@ -33,19 +34,12 @@ class FT3Module
3334
{
3435

3536
public:
36-
static void initialize_materials();
37-
static TGeoMaterial* siliconMat;
38-
static TGeoMedium* siliconMed;
39-
static TGeoMaterial* copperMat;
40-
static TGeoMedium* copperMed;
41-
static TGeoMixture* kaptonMat;
42-
static TGeoMedium* kaptonMed;
43-
static TGeoMaterial* epoxyMat;
44-
static TGeoMedium* epoxyMed;
45-
static TGeoMaterial* AluminumMat;
46-
static TGeoMedium* AluminumMed;
47-
static TGeoMaterial* carbonFiberMat;
48-
static TGeoMedium* carbonFiberMed;
37+
/*
38+
* The media themselves are created by Detector::createMaterials() from the
39+
* table in FT3ModuleConstants.h, before the geometry is built. This only
40+
* looks them up again in the MaterialManager by their MaterialID.
41+
*/
42+
static TGeoMedium* getMedium(Constants::MaterialID id);
4943

5044
const char* mDetName;
5145

‎Detectors/Upgrades/ALICE3/TRKFT3/FT3/simulation/include/FT3Simulation/FT3ModuleConstants.h‎

Lines changed: 94 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#ifndef FT3MODULECONSTANTS_H
1616
#define FT3MODULECONSTANTS_H
1717

18+
#include <array>
19+
#include <unordered_map>
1820
#include <vector>
1921
#include <map>
2022
#include <TColor.h>
@@ -29,17 +31,19 @@ namespace o2::ft3::ModuleConstants
2931
* When stacking 2x1 modules, there is a 0.2mm gap between them. By default, we assume this
3032
* gap to be ABOVE the most recently placed module.
3133
*
32-
* |<- 25mm ->|<- 25mm ->|
34+
* |<- 25mm ->||<- 25mm ->|
3335
* _______________________
34-
* ----------------------- 0.2mm gap above
35-
* | | | | |
36-
* | | | | |
37-
* | | | | |
38-
* | | | | | 29mm sensor height
39-
* | | | | |
40-
* | | | | |
36+
* ------------------------ 0.2mm gap above
37+
* | | || | |
38+
* | | || | |
39+
* | | || | |
40+
* | | || | | 29mm sensor height
41+
* | | || | |
42+
* | | || | |
4143
* ------------------------
42-
*
44+
* ^
45+
* |
46+
* 0.2mm gap in the middle
4347
*/
4448
// First set all layout constants for the rest of the function
4549
const double single_sensor_width = 2.5;
@@ -98,12 +102,88 @@ inline const double z_offsetStave(double x_midpoint_spacing)
98102
(2 - x_midpoint_spacing / (sensor2x1_width / 2 + staveSensorGap));
99103
}
100104

101-
const int SiColor = kGreen;
105+
/*
106+
* Materials of the FT3 module.
107+
*
108+
* Everything the simulation needs to know about a material lives in the
109+
* materials map below, keyed by its FT3-local ID: composition, density,
110+
* transport parameters and the colour its volumes are drawn in.
111+
* Detector::createMaterials() registers the whole map with the MaterialManager,
112+
* and FT3Module/FT3Layer look the media up again by MaterialID, so no ID,
113+
* density or colour is ever written out by hand.
114+
*/
115+
enum class MaterialID : unsigned {
116+
Air = 1,
117+
Silicon,
118+
Copper,
119+
Kapton,
120+
CarbonFiber,
121+
Epoxy,
122+
Aluminum,
123+
Foam,
124+
Water
125+
};
126+
127+
// Transport parameters of a medium, in the order expected by Detector::Medium()
128+
struct TrackingParams {
129+
float tmaxfd; // maximum field-induced angular deviation per step, degrees
130+
float stemax; // maximum step length, cm
131+
float deemax; // maximum fractional energy loss per step
132+
float epsil; // tracking precision, cm
133+
float stmin; // minimum step length, cm
134+
};
135+
136+
constexpr TrackingParams sensitiveTracking = {0.1f, 0.0075f, 0.1f, 1.0e-4f, 0.0f};
137+
constexpr TrackingParams passiveTracking = {0.1f, 1.0f, 0.1f, 1.0e-4f, 0.0f};
138+
139+
// Maximum number of elements any of the mixtures below is built from
140+
constexpr unsigned maxMaterialComponents = 4;
141+
using ComponentArray = std::array<float, maxMaterialComponents>;
142+
143+
struct MaterialProperties {
144+
const char* name;
145+
int colour; // ROOT colour every volume made of this material is drawn in
146+
float density; // g/cm3
147+
// Radiation and nuclear interaction length, cm. Only single elements carry
148+
// them: Mixture() derives both from the composition and takes no such
149+
// arguments. A non-positive value lets the transport engine compute it.
150+
float radl;
151+
float absl;
152+
int nComponents; // 0: single element; > 0: mixture by weight; < 0: mixture by atom count
153+
ComponentArray a; // mass numbers; only a[0] is used for a single element
154+
ComponentArray z; // atomic numbers; only z[0] is used for a single element
155+
ComponentArray w; // weight fractions or atom counts; unused for a single element
156+
TrackingParams tracking;
157+
};
158+
159+
/*
160+
* Silicon, copper and carbon fibre are shared with TRK and are kept numerically
161+
* identical to its SILICON$, COPPER$ and CARBONFIBER$ (TRK Detector::createMaterials()),
162+
* down to the radiation lengths. Kapton, epoxy and aluminium have no TRK
163+
* counterpart: TRK models the flex as the effective FPC$ mixture instead.
164+
*/
165+
inline const std::unordered_map<MaterialID, MaterialProperties> materials = {
166+
// Air volumes get their colour set individually where they are built
167+
{MaterialID::Air, {"AIR$", kWhite, 1.20479e-3f, 0.0f, 0.0f, 4, {12.0107f, 14.0067f, 15.9994f, 39.948f}, {6.0f, 7.0f, 8.0f, 18.0f}, {0.000124f, 0.755267f, 0.231781f, 0.012827f}, passiveTracking}},
168+
{MaterialID::Silicon, {"SILICON$", kGreen, 2.33f, 9.36f, 999.0f, 0, {28.086f}, {14.0f}, {}, sensitiveTracking}},
169+
// Copper planes of the end-of-stave cards: X0 = 1.436 cm
170+
{MaterialID::Copper, {"COPPER$", kOrange, 8.96f, 1.436f, 999.0f, 0, {63.546f}, {29.0f}, {}, passiveTracking}},
171+
// Kapton: C22 H10 N2 O5, by weight fraction. Also the cooling pipe material.
172+
{MaterialID::Kapton, {"KAPTON$", kYellow, 1.346f, 0.0f, 0.0f, 4, {12.0107f, 1.00794f, 14.0067f, 15.999f}, {6.0f, 1.0f, 7.0f, 8.0f}, {0.5641f, 0.2564f, 0.0513f, 0.1282f}, passiveTracking}},
173+
// Carbon fibre: density tuned so X0 ~ 27 cm, as in TRK
174+
// TODO: Check with Rene the exact type of carbon fiber
175+
{MaterialID::CarbonFiber, {"CARBONFIBER$", kGray + 1, 1.45f, 27.0f, 999.0f, 0, {12.0107f}, {6.0f}, {}, passiveTracking}},
176+
// Epoxy: C18 H19 O3, by atom count (negative nComponents)
177+
{MaterialID::Epoxy, {"EPOXY$", kBlue, 2.186f, 0.0f, 0.0f, -3, {12.0107f, 1.00794f, 15.999f}, {6.0f, 1.0f, 8.0f}, {18.0f, 19.0f, 3.0f}, passiveTracking}},
178+
// No TRK counterpart; X0 and lambda are left to the transport engine
179+
{MaterialID::Aluminum, {"ALUMINUM$", kBlack, 2.7f, 0.0f, 0.0f, 0, {26.98f}, {13.0f}, {}, passiveTracking}},
180+
// Carbon foam core of the disk separation layer
181+
{MaterialID::Foam, {"FOAM$", kBlack, 0.17f, 0.0f, 0.0f, 0, {12.0107f}, {6.0f}, {}, passiveTracking}},
182+
// Coolant inside the kapton pipes
183+
{MaterialID::Water, {"WATER$", kBlue, 1.064f, 0.0f, 0.0f, 0, {18.01528f}, {8.0f}, {}, passiveTracking}}};
184+
// The inactive rim of a sensor is made of silicon as well, but is drawn
185+
// separately so that it can be told apart from the active area.
102186
const int SiInactiveColor = kRed;
103-
const int glueColor = kBlue;
104-
const int CuColor = kOrange;
105-
const int kaptonColor = kYellow;
106-
const int carbonFiberColor = kGray + 1;
107187

108188
// Struct for stave position configuration (varies between ML/OT)
109189
struct StaveConfig {

‎Detectors/Upgrades/ALICE3/TRKFT3/FT3/simulation/src/Detector.cxx‎

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "FT3Base/FT3BaseParam.h"
2121
#include "FT3Base/GeometryTGeo.h"
2222
#include "FT3Simulation/FT3Layer.h"
23+
#include "FT3Simulation/FT3ModuleConstants.h"
2324

2425
// FairRoot includes
2526
#include "FairDetector.h" // for FairDetector
@@ -39,6 +40,7 @@
3940

4041
#include <fairlogger/Logger.h> // for LOG, LOG_IF
4142

43+
#include <array>
4244
#include <cstdio> // for NULL, snprintf
4345

4446
#define MAX_SENSORS 2000
@@ -495,29 +497,26 @@ void Detector::createMaterials()
495497
float fieldm = 10.0;
496498
o2::base::Detector::initFieldTrackingParams(ifield, fieldm);
497499

498-
float tmaxfdSi = 0.1; // .10000E+01; // Degree
499-
float stemaxSi = 0.0075; // .10000E+01; // cm
500-
float deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
501-
float epsilSi = 1.0E-4; // .10000E+01;
502-
float stminSi = 0.0; // cm "Default value used"
503-
504-
float tmaxfdAir = 0.1; // .10000E+01; // Degree
505-
float stemaxAir = .10000E+01; // cm
506-
float deemaxAir = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
507-
float epsilAir = 1.0E-4; // .10000E+01;
508-
float stminAir = 0.0; // cm "Default value used"
509-
510-
// AIR
511-
float aAir[4] = {12.0107, 14.0067, 15.9994, 39.948};
512-
float zAir[4] = {6., 7., 8., 18.};
513-
float wAir[4] = {0.000124, 0.755267, 0.231781, 0.012827};
514-
float dAir = 1.20479E-3;
515-
516-
o2::base::Detector::Mixture(1, "AIR$", aAir, zAir, dAir, 4, wAir);
517-
o2::base::Detector::Medium(1, "AIR$", 1, 0, ifield, fieldm, tmaxfdAir, stemaxAir, deemaxAir, epsilAir, stminAir);
518-
519-
o2::base::Detector::Material(3, "SILICON$", 0.28086E+02, 0.14000E+02, 0.23300E+01, 0.93600E+01, 0.99900E+03);
520-
o2::base::Detector::Medium(3, "SILICON$", 3, 0, ifield, fieldm, tmaxfdSi, stemaxSi, deemaxSi, epsilSi, stminSi);
500+
// Every FT3 material is described by the map in FT3ModuleConstants.h: name,
501+
// composition, density, radiation length, transport parameters and display
502+
// colour, keyed by its MaterialID. FT3Module and FT3Layer retrieve the media
503+
// from the MaterialManager by the same ID, so nothing is written out twice.
504+
for (const auto& [materialID, material] : ModuleConstants::materials) {
505+
const int id = static_cast<int>(materialID);
506+
if (material.nComponents == 0) {
507+
o2::base::Detector::Material(id, material.name, material.a[0], material.z[0], material.density,
508+
material.radl, material.absl);
509+
} else {
510+
// Mixture() takes non-const pointers, so hand it copies of the table rows
511+
ModuleConstants::ComponentArray a = material.a;
512+
ModuleConstants::ComponentArray z = material.z;
513+
ModuleConstants::ComponentArray w = material.w;
514+
o2::base::Detector::Mixture(id, material.name, a.data(), z.data(), material.density, material.nComponents, w.data());
515+
}
516+
const auto& tracking = material.tracking;
517+
o2::base::Detector::Medium(id, material.name, id, 0, ifield, fieldm, tracking.tmaxfd, tracking.stemax,
518+
tracking.deemax, tracking.epsil, tracking.stmin);
519+
}
521520
}
522521

523522
//_________________________________________________________________________________________________

0 commit comments

Comments
 (0)