14#include <TGeoManager.h>
20#include <TGeoVolume.h>
26 std::string layerName,
33 int nBars) : mName(layerName),
37 mStaveWidth(staveWidth),
40 mNModulesZ(nModulesZ),
43 mStaves.reserve(nstaves);
44 LOGP(
debug,
"Constructing MIDLayer: {} with inner radius: {}, length: {} cm, {} staves and {} modules/stave", mName, mRadius, mLength, mNStaves, mNModulesZ);
45 for (
int iStave = 0; iStave < mNStaves; ++iStave) {
48 TMath::TwoPi() / (
float)nstaves * iStave,
52 !(layerNumber % 2) ? 59.8f : 61.75f,
59MIDLayer::Stave::Stave(std::string staveName,
68 int nBars) : mName(staveName),
69 mRadDistance(radDistance),
73 mThickness(staveThickness),
79 int effNBars = (nBars < 0) ? (!(mLayer % 2) ? 23 : 20) : nBars;
80 float moduleOffset = -effNBars * 5.2f / 2.f;
82 LOGP(
debug,
"\t\tConstructing MIDStave: {} layer: {} at angle {} nBars={}", mName, mLayer, mRotAngle * TMath::RadToDeg(), effNBars);
83 mModules.reserve(nModulesZ);
84 for (
int iModule = 0; iModule < mNModulesZ; ++iModule) {
91 !(mLayer % 2) ? 49.9f : 61.75f);
95MIDLayer::Stave::Module::Module(std::string moduleName,
104 float barThickness) : mName(moduleName),
110 mBarSpacing(barSpacing),
112 mBarLength(barLength),
113 mBarThickness(barThickness)
115 mSensors.reserve(nBars);
116 LOGP(
debug,
"\t\t\tConstructing MIDModule: {}", mName);
117 for (
int iBar = 0; iBar < mNBars; ++iBar) {
123 -mNBars * 5.2f / 2.f,
124 !(mLayer % 2) ? 49.9f : 61.75f);
128MIDLayer::Stave::Module::Sensor::Sensor(std::string sensorName,
136 float sensorThickness,
137 float sensorSpacing) : mName(sensorName),
142 mModuleOffset(moduleOffset),
144 mLength(sensorLength),
145 mThickness(sensorThickness),
146 mSpacing(sensorSpacing)
148 LOGP(
debug,
"\t\t\t\tConstructing MIDSensor: {}", mName);
153 LOGP(
debug,
"Creating MIDLayer: {} at zOffset={} cm", mName, mZOffset);
154 TGeoVolumeAssembly* layerVolume =
new TGeoVolumeAssembly(mName.c_str());
155 if (mZOffset != 0.f) {
156 motherVolume->AddNode(layerVolume, 0,
new TGeoTranslation(0, 0, mZOffset));
158 motherVolume->AddNode(layerVolume, 0);
160 for (
auto& stave : mStaves) {
161 stave.createStave(layerVolume);
165void MIDLayer::Stave::createStave(TGeoVolume* motherVolume)
167 LOGP(
debug,
"\tCreating MIDStave: {} layer: {}", mName, mLayer);
168 TGeoVolumeAssembly* staveVolume =
new TGeoVolumeAssembly(mName.c_str());
170 for (
auto& module : mModules) {
171 module.createModule(staveVolume);
174 TGeoCombiTrans* staveTrans =
new TGeoCombiTrans(mRadDistance * TMath::Cos(mRotAngle),
175 mRadDistance * TMath::Sin(mRotAngle),
177 new TGeoRotation(
"rot", 90 + mRotAngle * TMath::RadToDeg(), 0, 0));
178 motherVolume->AddNode(staveVolume, 0, staveTrans);
181void MIDLayer::Stave::Module::createModule(TGeoVolume* motherVolume)
184 auto sumWidth = ((mBarWidth * 2 + mBarSpacing) * mNBars) / 2;
185 LOGP(
debug,
"\t\t\tCreating MIDModule: {} with ", mName);
186 TGeoVolumeAssembly* moduleVolume =
new TGeoVolumeAssembly(mName.c_str() );
189 for (
auto& sensor : mSensors) {
190 sensor.createSensor(moduleVolume);
192 TGeoCombiTrans* modTrans =
nullptr;
194 modTrans =
new TGeoCombiTrans(0, 0, mZOffset + mNumber * 2 * mBarLength + mBarLength,
nullptr);
196 modTrans =
new TGeoCombiTrans(0, 0, mZOffset + mNumber * 2 * sumWidth + sumWidth,
nullptr);
198 motherVolume->AddNode(moduleVolume, 0, modTrans);
201void MIDLayer::Stave::Module::Sensor::createSensor(TGeoVolume* motherVolume)
203 LOGP(
debug,
"\t\t\t\tCreating MIDSensor: {}", mName);
206 sensor =
new TGeoBBox(mName.c_str(), mWidth, mThickness, mLength);
208 sensor =
new TGeoBBox(mName.c_str(), mLength, mThickness, mWidth);
210 auto* polyMed = gGeoManager->GetMedium(
"MI3_POLYSTYRENE");
212 auto volName = Form(
"MIDSensor_L%d_S%d_M%d_B%d", mLayer, mStave, mNumber, mNumber);
213 TGeoVolume* sensorVolume =
new TGeoVolume(volName, sensor, polyMed);
214 sensorVolume->SetVisibility(
true);
215 auto totWidth = mWidth + mSpacing / 2;
216 TGeoTranslation* sensorTrans =
nullptr;
218 sensorTrans =
new TGeoTranslation(mModuleOffset + 2 * totWidth * mNumber + totWidth, 0, 0);
219 sensorVolume->SetLineColor(kAzure + 4);
220 sensorVolume->SetTransparency(50);
222 sensorTrans =
new TGeoTranslation(0, 0, mModuleOffset + 2 * totWidth * mNumber + totWidth);
223 sensorVolume->SetLineColor(kAzure + 4);
224 sensorVolume->SetTransparency(50);
226 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