Project
Loading...
Searching...
No Matches
Geometry.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#include "Station1Geometry.h"
15#include "Station2Geometry.h"
16#include "Station345Geometry.h"
17#include "Materials.h"
18#include <iostream>
19#include <TGeoPhysicalNode.h>
20#include <fmt/format.h>
21#include "TGeoVolume.h"
22#include "TGeoManager.h"
23#include "Framework/Logger.h"
24
25namespace impl
26{
27void addAlignableVolumesHalfChamber(TGeoManager& geom, int hc, std::string& parent)
28{
29 //
30 // Add alignable volumes for a half chamber and its daughters
31 //
32 std::vector<std::vector<int>> DEofHC{{100, 103},
33 {101, 102},
34 {200, 203},
35 {201, 202},
36 {300, 303},
37 {301, 302},
38 {400, 403},
39 {401, 402},
40 {500, 501, 502, 503, 504, 514, 515, 516, 517},
41 {505, 506, 507, 508, 509, 510, 511, 512, 513},
42 {600, 601, 602, 603, 604, 614, 615, 616, 617},
43 {605, 606, 607, 608, 609, 610, 611, 612, 613},
44 {700, 701, 702, 703, 704, 705, 706, 720, 721, 722, 723, 724, 725},
45 {707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719},
46 {800, 801, 802, 803, 804, 805, 806, 820, 821, 822, 823, 824, 825},
47 {807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819},
48 {900, 901, 902, 903, 904, 905, 906, 920, 921, 922, 923, 924, 925},
49 {907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919},
50 {1000, 1001, 1002, 1003, 1004, 1005, 1006, 1020, 1021, 1022, 1023, 1024, 1025},
51 {1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019}};
52
53 for (int i = 0; i < DEofHC[hc].size(); i++) {
54 std::string volPathName = o2::mch::geo::volumePathName(DEofHC[hc][i]);
55
56 TString path = Form("%s%s", parent.c_str(), volPathName.c_str());
57 TString sname = Form("MCH/HC%d/DE%d", hc, DEofHC[hc][i]);
58
59 LOG(debug) << "Add " << sname << " <-> " << path;
60
61 if (!geom.SetAlignableEntry(sname.Data(), path.Data())) {
62 LOG(fatal) << "Unable to set alignable entry ! " << sname << " : " << path;
63 }
64 }
65
66 return;
67}
68
69} // namespace impl
70
71namespace o2::mch::geo
72{
73
74void createGeometry(TGeoManager& geom, TGeoVolume& topVolume)
75{
77
78 auto volYOUT1 = geom.GetVolume("YOUT1");
79
80 createStation1Geometry((volYOUT1) ? *volYOUT1 : topVolume);
81 createStation2Geometry((volYOUT1) ? *volYOUT1 : topVolume);
82
83 createStation345Geometry(topVolume);
84}
85
86std::vector<TGeoVolume*> getSensitiveVolumes()
87{
88 auto st1 = getStation1SensitiveVolumes();
89 auto st2 = getStation2SensitiveVolumes();
90 auto st345 = getStation345SensitiveVolumes();
91
92 auto vol = st1;
93 vol.insert(vol.end(), st2.begin(), st2.end());
94 vol.insert(vol.end(), st345.begin(), st345.end());
95
96 return vol;
97}
98
99void addAlignableVolumes(TGeoManager& geom)
100{
101 if (!geom.IsClosed()) {
102 geom.CloseGeometry();
103 }
104
105 LOG(info) << "Add MCH alignable volumes";
106
107 for (int hc = 0; hc < 20; hc++) {
108 int nCh = hc / 2 + 1;
109
110 std::string volPathName = geom.GetTopVolume()->GetName();
111
112 if (nCh <= 4 && geom.GetVolume("YOUT1")) {
113 volPathName += "/YOUT1_1/";
114 } else if ((nCh == 5 || nCh == 6) && geom.GetVolume("DDIP")) {
115 volPathName += "/DDIP_1/";
116 } else if (nCh >= 7 && geom.GetVolume("YOUT2")) {
117 volPathName += "/YOUT2_1/";
118 } else {
119 volPathName += "/";
120 }
121
122 std::string path = fmt::format("{0}SC{1}{2}{3}_{4}", volPathName.c_str(), nCh < 10 ? "0" : "", nCh, hc % 2 ? "O" : "I", hc);
123 std::string sname = fmt::format("MCH/HC{}", hc);
124
125 LOG(debug) << sname << " <-> " << path;
126
127 auto ae = geom.SetAlignableEntry(sname.c_str(), path.c_str());
128 if (!ae) {
129 LOG(fatal) << "Unable to set alignable entry ! " << sname << " : " << path;
130 }
131
132 Int_t lastUID = 0;
133
134 impl::addAlignableVolumesHalfChamber(geom, hc, volPathName);
135 }
136
137 return;
138}
139
140} // namespace o2::mch::geo
int32_t i
Implementation of the MID materials definitions.
Interface for MCH geometry creation.
Implementation of the station 1 geometry.
Implementation of the station 2 geometry.
Implementation of the slat-stations geometry.
std::ostringstream debug
GLsizei const GLchar *const * path
Definition glcorearb.h:3591
void addAlignableVolumesHalfChamber(TGeoManager &geom, int hc, std::string &parent)
Definition Geometry.cxx:27
get the local-to-global transformation for a given detection element
Definition Geometry.h:25
void addAlignableVolumes(TGeoManager &geom)
Definition Geometry.cxx:99
std::string volumePathName(int deId)
void createGeometry(TGeoManager &geom, TGeoVolume &topVolume)
Definition Geometry.cxx:74
std::vector< TGeoVolume * > getSensitiveVolumes()
Definition Geometry.cxx:86
void createStation345Geometry(TGeoVolume &topVolume)
void createStation2Geometry(TGeoVolume &topVolume)
void createStation1Geometry(TGeoVolume &topVolume)
std::vector< TGeoVolume * > getStation2SensitiveVolumes()
void createMaterials()
Definition Materials.cxx:91
vector< TGeoVolume * > getStation345SensitiveVolumes()
std::vector< TGeoVolume * > getStation1SensitiveVolumes()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"