Project
Loading...
Searching...
No Matches
MIDLayer.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 <TGeoManager.h>
15#include <TMath.h>
16
17#include "Framework/Logger.h"
18
19#include <TGeoTube.h>
20#include <TGeoVolume.h>
21#include <TGeoBBox.h>
22
23namespace o2::mi3
24{
25MIDLayer::MIDLayer(int layerNumber,
26 std::string layerName,
27 float rInn,
28 float length,
29 int nstaves) : mName(layerName),
30 mRadius(rInn),
31 mLength(length),
32 mNumber(layerNumber),
33 mNStaves(nstaves)
34{
35 mStaves.reserve(nstaves);
36 LOGP(debug, "Constructing MIDLayer: {} with inner radius: {}, length: {} cm and {} staves", mName, mRadius, mLength, mNStaves);
37 for (int iStave = 0; iStave < mNStaves; ++iStave) {
38 mStaves.emplace_back(GeometryTGeo::composeSymNameStave(layerNumber, iStave),
39 mRadius,
40 TMath::TwoPi() / (float)nstaves * iStave,
41 mNumber,
42 iStave,
43 mLength,
44 !layerNumber ? 59.8f : 61.75f,
45 0.5f);
46 }
47}
48
49MIDLayer::Stave::Stave(std::string staveName,
50 float radDistance,
51 float rotAngle,
52 int layer,
53 int number,
54 float staveLength,
55 float staveWidth,
56 float staveThickness,
57 int nModulesZ) : mName(staveName),
58 mRadDistance(radDistance),
59 mRotAngle(rotAngle),
60 mLength(staveLength),
61 mWidth(staveWidth),
62 mThickness(staveThickness),
63 mLayer(layer),
64 mNumber(number),
65 mNModulesZ(nModulesZ)
66{
67 // Staves are ideal shapes made of air including the modules, for now.
68 LOGP(debug, "\t\tConstructing MIDStave: {} layer: {} at angle {}", mName, mLayer, mRotAngle * TMath::RadToDeg());
69 mModules.reserve(nModulesZ);
70 for (int iModule = 0; iModule < mNModulesZ; ++iModule) {
71 mModules.emplace_back(GeometryTGeo::composeSymNameModule(mLayer, mNumber, iModule),
72 mLayer,
73 mNumber,
74 iModule,
75 !mLayer ? 23 : 20,
76 -staveLength,
77 !mLayer ? 49.9f : 61.75f);
78 }
79}
80
81MIDLayer::Stave::Module::Module(std::string moduleName,
82 int layer,
83 int stave,
84 int number,
85 int nBars,
86 float zOffset,
87 float barLength,
88 float barSpacing,
89 float barWidth,
90 float barThickness) : mName(moduleName),
91 mNBars(nBars),
92 mLayer(layer),
93 mStave(stave),
94 mNumber(number),
95 mZOffset(zOffset),
96 mBarSpacing(barSpacing),
97 mBarWidth(barWidth),
98 mBarLength(barLength),
99 mBarThickness(barThickness)
100{
101 mSensors.reserve(nBars);
102 LOGP(debug, "\t\t\tConstructing MIDModule: {}", mName);
103 for (int iBar = 0; iBar < mNBars; ++iBar) {
104 mSensors.emplace_back(GeometryTGeo::composeSymNameSensor(mLayer, mStave, mNumber, iBar),
105 mLayer,
106 mStave,
107 mNumber,
108 iBar,
109 !mLayer ? -59.8f : -52.f, // offset
110 !mLayer ? 49.9f : 61.75f); // sensor length
111 }
112}
113
114MIDLayer::Stave::Module::Sensor::Sensor(std::string sensorName,
115 int layer,
116 int stave,
117 int module,
118 int number,
119 float moduleOffset,
120 float sensorLength,
121 float sensorWidth,
122 float sensorThickness,
123 float sensorSpacing) : mName(sensorName),
124 mLayer(layer),
125 mStave(stave),
126 mModule(module),
127 mNumber(number),
128 mModuleOffset(moduleOffset),
129 mWidth(sensorWidth),
130 mLength(sensorLength),
131 mThickness(sensorThickness),
132 mSpacing(sensorSpacing)
133{
134 LOGP(debug, "\t\t\t\tConstructing MIDSensor: {}", mName);
135}
136
137void MIDLayer::createLayer(TGeoVolume* motherVolume)
138{
139 LOGP(debug, "Creating MIDLayer: {}", mName);
140 TGeoVolumeAssembly* layerVolume = new TGeoVolumeAssembly(mName.c_str());
141 motherVolume->AddNode(layerVolume, 0);
142 for (auto& stave : mStaves) {
143 stave.createStave(layerVolume);
144 }
145}
146
147void MIDLayer::Stave::createStave(TGeoVolume* motherVolume)
148{
149 LOGP(debug, "\tCreating MIDStave: {} layer: {}", mName, mLayer);
150 TGeoVolumeAssembly* staveVolume = new TGeoVolumeAssembly(mName.c_str());
151 // Create the modules
152 for (auto& module : mModules) {
153 module.createModule(staveVolume);
154 }
155
156 TGeoCombiTrans* staveTrans = new TGeoCombiTrans(mRadDistance * TMath::Cos(mRotAngle),
157 mRadDistance * TMath::Sin(mRotAngle),
158 0,
159 new TGeoRotation("rot", 90 + mRotAngle * TMath::RadToDeg(), 0, 0));
160 motherVolume->AddNode(staveVolume, 0, staveTrans);
161}
162
163void MIDLayer::Stave::Module::createModule(TGeoVolume* motherVolume)
164{
165 // Module is an air box with floating bars inside for the moment
166 auto sumWidth = ((mBarWidth * 2 + mBarSpacing) * mNBars) / 2;
167 LOGP(debug, "\t\t\tCreating MIDModule: {} with ", mName);
168 TGeoVolumeAssembly* moduleVolume = new TGeoVolumeAssembly(mName.c_str() /*, module, airMed*/);
169
170 // Create the bars
171 for (auto& sensor : mSensors) {
172 sensor.createSensor(moduleVolume);
173 }
174 TGeoCombiTrans* modTrans = nullptr;
175 if (!mLayer) {
176 modTrans = new TGeoCombiTrans(0, 0, mZOffset + mNumber * 2 * mBarLength + mBarLength, nullptr);
177 } else {
178 modTrans = new TGeoCombiTrans(0, 0, mZOffset + mNumber * 2 * sumWidth + sumWidth, nullptr);
179 }
180 motherVolume->AddNode(moduleVolume, 0, modTrans);
181}
182
183void MIDLayer::Stave::Module::Sensor::createSensor(TGeoVolume* motherVolume)
184{
185 LOGP(debug, "\t\t\t\tCreating MIDSensor: {}", mName);
186 TGeoBBox* sensor = nullptr;
187 if (!mLayer) {
188 sensor = new TGeoBBox(mName.c_str(), mWidth, mThickness, mLength);
189 } else {
190 sensor = new TGeoBBox(mName.c_str(), mLength, mThickness, mWidth);
191 }
192 auto* polyMed = gGeoManager->GetMedium("MI3_POLYSTYRENE");
193 TGeoVolume* sensorVolume = new TGeoVolume(mName.c_str(), sensor, polyMed);
194 sensorVolume->SetVisibility(true);
195 auto totWidth = mWidth + mSpacing / 2;
196 TGeoTranslation* sensorTrans = nullptr;
197 if (!mLayer) {
198 sensorTrans = new TGeoTranslation(mModuleOffset + 2 * totWidth * mNumber + totWidth, 0, 0);
199 sensorVolume->SetLineColor(kAzure + 4);
200 sensorVolume->SetTransparency(50);
201 } else {
202 sensorTrans = new TGeoTranslation(0, 0, mModuleOffset + 2 * totWidth * mNumber + totWidth);
203 sensorVolume->SetLineColor(kAzure + 4);
204 sensorVolume->SetTransparency(50);
205 }
206 motherVolume->AddNode(sensorVolume, 0, sensorTrans);
207}
208} // namespace o2::mi3
std::ostringstream debug
static const char * composeSymNameSensor(const int layer, const int stave, const int module, const int sensor)
static const char * composeSymNameModule(const int layer, const int stave, const int module)
static const char * composeSymNameStave(const int layer, const int stave)
MIDLayer()=default
void createLayer(TGeoVolume *motherVolume)
Definition MIDLayer.cxx:137
GLuint GLsizei GLsizei * length
Definition glcorearb.h:790
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310