Skip to content

Commit 40ae21c

Browse files
committed
move materials into separate header with constants, and define the getMedium file there instead for contained structure
1 parent 440983a commit 40ae21c

8 files changed

Lines changed: 208 additions & 154 deletions

File tree

‎Detectors/Upgrades/ALICE3/TRKFT3/FT3/simulation/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
o2_add_library(FT3Simulation
1313
SOURCES
14+
src/FT3Materials.cxx
1415
src/FT3Module.cxx
1516
src/FT3Layer.cxx
1617
src/Detector.cxx
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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+
12+
13+
/// \file FT3Materials.h
14+
/// \brief Materials of the FT3 detector, and access to the media made from them
15+
16+
#ifndef FT3MATERIALS_H
17+
#define FT3MATERIALS_H
18+
19+
#include <array>
20+
#include <unordered_map>
21+
#include <TColor.h>
22+
23+
class TGeoMedium;
24+
25+
namespace o2::ft3
26+
{
27+
namespace Materials
28+
{
29+
// The name FT3 registers itself under with the MaterialManager. getMedium()
30+
// looks media up under this key, so it has to be the same name the Detector
31+
// hands to DetImpl<Detector>.
32+
constexpr const char* moduleName = "FT3";
33+
34+
/*
35+
* Materials of the FT3 detector.
36+
*
37+
* Everything the simulation needs to know about a material lives in the
38+
* materials map below, keyed by its FT3-local ID: composition, density,
39+
* transport parameters and the colour its volumes are drawn in.
40+
* Detector::createMaterials() registers the whole map with the MaterialManager,
41+
* and FT3Module/FT3Layer reach the media through getMedium() below, so no ID,
42+
* density or colour is ever written out by hand.
43+
*/
44+
enum class MaterialID : unsigned {
45+
Air = 1,
46+
Silicon,
47+
Copper,
48+
Kapton,
49+
CarbonFiber,
50+
Epoxy,
51+
Aluminum,
52+
Foam,
53+
Water
54+
};
55+
56+
// Transport parameters of a medium, in the order expected by Detector::Medium()
57+
struct TrackingParams {
58+
float tmaxfd; // maximum field-induced angular deviation per step, degrees
59+
float stemax; // maximum step length, cm
60+
float deemax; // maximum fractional energy loss per step
61+
float epsil; // tracking precision, cm
62+
float stmin; // minimum step length, cm
63+
};
64+
65+
constexpr TrackingParams sensitiveTracking = {0.1f, 0.0075f, 0.1f, 1.0e-4f, 0.0f};
66+
constexpr TrackingParams passiveTracking = {0.1f, 1.0f, 0.1f, 1.0e-4f, 0.0f};
67+
68+
// Maximum number of elements any of the mixtures below is built from
69+
constexpr unsigned maxMaterialComponents = 4;
70+
using ComponentArray = std::array<float, maxMaterialComponents>;
71+
72+
struct MaterialProperties {
73+
const char* name;
74+
int colour; // ROOT colour every volume made of this material is drawn in
75+
float density; // g/cm3
76+
// Radiation and nuclear interaction length, cm. Only single elements carry
77+
// them: Mixture() derives both from the composition and takes no such
78+
// arguments. A non-positive value lets the transport engine compute it.
79+
float radl;
80+
float absl;
81+
int nComponents; // 0: single element; > 0: mixture by weight; < 0: mixture by atom count
82+
ComponentArray a; // mass numbers; only a[0] is used for a single element
83+
ComponentArray z; // atomic numbers; only z[0] is used for a single element
84+
ComponentArray w; // weight fractions or atom counts; unused for a single element
85+
TrackingParams tracking;
86+
};
87+
88+
/*
89+
* Silicon, copper and carbon fibre are shared with TRK and are kept numerically
90+
* identical to its SILICON$, COPPER$ and CARBONFIBER$ (TRK Detector::createMaterials()),
91+
* down to the radiation lengths. Kapton, epoxy and aluminium have no TRK
92+
* counterpart: TRK models the flex as the effective FPC$ mixture instead.
93+
*/
94+
inline const std::unordered_map<MaterialID, MaterialProperties> materials = {
95+
// Air volumes get their colour set individually where they are built
96+
{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}},
97+
{MaterialID::Silicon, {"Silicon", kGreen, 2.33f, 9.36f, 999.0f, 0, {28.086f}, {14.0f}, {}, sensitiveTracking}},
98+
// Copper planes of the end-of-stave cards: X0 = 1.436 cm
99+
{MaterialID::Copper, {"Copper", kOrange, 8.96f, 1.436f, 999.0f, 0, {63.546f}, {29.0f}, {}, passiveTracking}},
100+
// Kapton: C22 H10 N2 O5, by weight fraction. Also the cooling pipe material.
101+
{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}},
102+
// Carbon fibre: density tuned so X0 ~ 27 cm, as in TRK
103+
// TODO: Check with Rene the exact type of carbon fiber
104+
{MaterialID::CarbonFiber, {"CarbonFiber", kGray + 1, 1.45f, 27.0f, 999.0f, 0, {12.0107f}, {6.0f}, {}, passiveTracking}},
105+
// Epoxy: C18 H19 O3, by atom count (negative nComponents)
106+
{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}},
107+
// No TRK counterpart; X0 and lambda are left to the transport engine
108+
{MaterialID::Aluminum, {"Aluminum", kBlack, 2.7f, 0.0f, 0.0f, 0, {26.98f}, {13.0f}, {}, passiveTracking}},
109+
// Carbon foam core of the disk separation layer
110+
{MaterialID::Foam, {"Foam", kBlack, 0.17f, 0.0f, 0.0f, 0, {12.0107f}, {6.0f}, {}, passiveTracking}},
111+
// Coolant inside the kapton pipes
112+
{MaterialID::Water, {"Water", kBlue, 1.064f, 0.0f, 0.0f, 0, {18.01528f}, {8.0f}, {}, passiveTracking}}};
113+
// The inactive rim of a sensor is made of silicon as well, but is drawn
114+
// separately so that it can be told apart from the active area.
115+
const int SiInactiveColor = kRed;
116+
} // namespace Materials
117+
118+
/// Retrieve one of the media registered by Detector::createMaterials().
119+
///
120+
/// A free function rather than a member of Detector: the media live in the
121+
/// MaterialManager singleton keyed by Materials::moduleName, not in the
122+
/// detector object, so the lookup needs no Detector instance.
123+
TGeoMedium* getMedium(Materials::MaterialID id);
124+
} // namespace o2::ft3
125+
126+
#endif // FT3MATERIALS_H

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <string>
2121
#include <vector>
2222

23+
#include "FT3Simulation/FT3Materials.h"
2324
#include "FT3Simulation/FT3ModuleConstants.h"
2425

2526
// define types for y positions, second element is the stack height
@@ -29,18 +30,12 @@ using PosNegPositionTypes = std::pair<PositionTypes, PositionTypes>;
2930
// define type of the y position range: First pair is (min, max) for positive y
3031
using PositionRangeType = std::pair<std::pair<double, double>, std::pair<double, double>>;
3132
namespace Constants = o2::ft3::ModuleConstants;
33+
namespace Materials = o2::ft3::Materials;
3234

3335
class FT3Module
3436
{
3537

3638
public:
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);
43-
4439
const char* mDetName;
4540

4641
static void createModule(

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

Lines changed: 2 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111

1212
/// \file FT3ModuleConstants.h
1313
/// \brief Definition of various constants for tiling the modules of sensors
14+
///
15+
/// The materials themselves live in FT3Materials.h.
1416

1517
#ifndef FT3MODULECONSTANTS_H
1618
#define FT3MODULECONSTANTS_H
1719

18-
#include <array>
19-
#include <unordered_map>
2020
#include <vector>
2121
#include <map>
22-
#include <TColor.h>
2322
#include <TMath.h>
2423

2524
namespace o2::ft3::ModuleConstants
@@ -102,89 +101,6 @@ inline const double z_offsetStave(double x_midpoint_spacing)
102101
(2 - x_midpoint_spacing / (sensor2x1_width / 2 + staveSensorGap));
103102
}
104103

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.
186-
const int SiInactiveColor = kRed;
187-
188104
// Struct for stave position configuration (varies between ML/OT)
189105
struct StaveConfig {
190106
const unsigned isML; // whether this config is for ML or OT

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

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

2525
// FairRoot includes
2626
#include "FairDetector.h" // for FairDetector
@@ -56,7 +56,7 @@ using o2::trkft3::Hit;
5656

5757
//_________________________________________________________________________________________________
5858
Detector::Detector()
59-
: o2::base::DetImpl<Detector>("FT3", kTRUE),
59+
: o2::base::DetImpl<Detector>(Materials::moduleName, kTRUE),
6060
mTrackData(),
6161
mHits(o2::utils::createSimVector<o2::trkft3::Hit>())
6262
{
@@ -348,7 +348,7 @@ void Detector::buildFT3Scoping()
348348

349349
//_________________________________________________________________________________________________
350350
Detector::Detector(bool active)
351-
: o2::base::DetImpl<Detector>("FT3", active),
351+
: o2::base::DetImpl<Detector>(Materials::moduleName, active),
352352
mTrackData(),
353353
mHits(o2::utils::createSimVector<o2::trkft3::Hit>())
354354
{
@@ -497,20 +497,20 @@ void Detector::createMaterials()
497497
float fieldm = 10.0;
498498
o2::base::Detector::initFieldTrackingParams(ifield, fieldm);
499499

500-
// Every FT3 material is described by the map in FT3ModuleConstants.h: name,
500+
// Every FT3 material is described by the map in FT3Materials.h: name,
501501
// composition, density, radiation length, transport parameters and display
502502
// colour, keyed by its MaterialID. FT3Module and FT3Layer retrieve the media
503503
// from the MaterialManager by the same ID, so nothing is written out twice.
504-
for (const auto& [materialID, material] : ModuleConstants::materials) {
504+
for (const auto& [materialID, material] : Materials::materials) {
505505
const int id = static_cast<int>(materialID);
506506
if (material.nComponents == 0) {
507507
o2::base::Detector::Material(id, material.name, material.a[0], material.z[0], material.density,
508508
material.radl, material.absl);
509509
} else {
510510
// 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;
511+
Materials::ComponentArray a = material.a;
512+
Materials::ComponentArray z = material.z;
513+
Materials::ComponentArray w = material.w;
514514
o2::base::Detector::Mixture(id, material.name, a.data(), z.data(), material.density, material.nComponents, w.data());
515515
}
516516
const auto& tracking = material.tracking;

0 commit comments

Comments
 (0)