14#include <TGeoManager.h>
20#include <TGeoVolume.h>
26 std::string layerName,
29 int nstaves) : mName(layerName),
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) {
40 TMath::TwoPi() / (
float)nstaves * iStave,
44 !layerNumber ? 59.8f : 61.75f,
49MIDLayer::Stave::Stave(std::string staveName,
57 int nModulesZ) : mName(staveName),
58 mRadDistance(radDistance),
62 mThickness(staveThickness),
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) {
77 !mLayer ? 49.9f : 61.75f);
81MIDLayer::Stave::Module::Module(std::string moduleName,
90 float barThickness) : mName(moduleName),
96 mBarSpacing(barSpacing),
98 mBarLength(barLength),
99 mBarThickness(barThickness)
101 mSensors.reserve(nBars);
102 LOGP(
debug,
"\t\t\tConstructing MIDModule: {}", mName);
103 for (
int iBar = 0; iBar < mNBars; ++iBar) {
109 !mLayer ? -59.8f : -52.f,
110 !mLayer ? 49.9f : 61.75f);
114MIDLayer::Stave::Module::Sensor::Sensor(std::string sensorName,
122 float sensorThickness,
123 float sensorSpacing) : mName(sensorName),
128 mModuleOffset(moduleOffset),
130 mLength(sensorLength),
131 mThickness(sensorThickness),
132 mSpacing(sensorSpacing)
134 LOGP(
debug,
"\t\t\t\tConstructing MIDSensor: {}", mName);
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);
147void MIDLayer::Stave::createStave(TGeoVolume* motherVolume)
149 LOGP(
debug,
"\tCreating MIDStave: {} layer: {}", mName, mLayer);
150 TGeoVolumeAssembly* staveVolume =
new TGeoVolumeAssembly(mName.c_str());
152 for (
auto& module : mModules) {
153 module.createModule(staveVolume);
156 TGeoCombiTrans* staveTrans =
new TGeoCombiTrans(mRadDistance * TMath::Cos(mRotAngle),
157 mRadDistance * TMath::Sin(mRotAngle),
159 new TGeoRotation(
"rot", 90 + mRotAngle * TMath::RadToDeg(), 0, 0));
160 motherVolume->AddNode(staveVolume, 0, staveTrans);
163void MIDLayer::Stave::Module::createModule(TGeoVolume* motherVolume)
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() );
171 for (
auto& sensor : mSensors) {
172 sensor.createSensor(moduleVolume);
174 TGeoCombiTrans* modTrans =
nullptr;
176 modTrans =
new TGeoCombiTrans(0, 0, mZOffset + mNumber * 2 * mBarLength + mBarLength,
nullptr);
178 modTrans =
new TGeoCombiTrans(0, 0, mZOffset + mNumber * 2 * sumWidth + sumWidth,
nullptr);
180 motherVolume->AddNode(moduleVolume, 0, modTrans);
183void MIDLayer::Stave::Module::Sensor::createSensor(TGeoVolume* motherVolume)
185 LOGP(
debug,
"\t\t\t\tCreating MIDSensor: {}", mName);
186 TGeoBBox* sensor =
nullptr;
188 sensor =
new TGeoBBox(mName.c_str(), mWidth, mThickness, mLength);
190 sensor =
new TGeoBBox(mName.c_str(), mLength, mThickness, mWidth);
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;
198 sensorTrans =
new TGeoTranslation(mModuleOffset + 2 * totWidth * mNumber + totWidth, 0, 0);
199 sensorVolume->SetLineColor(kAzure + 4);
200 sensorVolume->SetTransparency(50);
202 sensorTrans =
new TGeoTranslation(0, 0, mModuleOffset + 2 * totWidth * mNumber + totWidth);
203 sensorVolume->SetLineColor(kAzure + 4);
204 sensorVolume->SetTransparency(50);
206 motherVolume->AddNode(sensorVolume, 0, sensorTrans);
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)
void createLayer(TGeoVolume *motherVolume)
GLuint GLsizei GLsizei * length
GLenum GLuint GLint GLint layer