From beeb94bb3a4cad886825770d3ed45f3a6a058b79 Mon Sep 17 00:00:00 2001 From: Hadi Hassan Date: Fri, 2 May 2025 16:02:14 +0300 Subject: [PATCH 1/2] Open the detector in the middle in x --- .../FOCAL/base/include/FOCALBase/Geometry.h | 6 ++ Detectors/FOCAL/base/src/Geometry.cxx | 10 +++ .../geometryFiles/geometry_Spaghetti.txt | 4 ++ Detectors/FOCAL/simulation/src/Detector.cxx | 72 +++++++++++++++---- 4 files changed, 78 insertions(+), 14 deletions(-) diff --git a/Detectors/FOCAL/base/include/FOCALBase/Geometry.h b/Detectors/FOCAL/base/include/FOCALBase/Geometry.h index 4938ebb1925dd..770c0aa3c1cf5 100644 --- a/Detectors/FOCAL/base/include/FOCALBase/Geometry.h +++ b/Detectors/FOCAL/base/include/FOCALBase/Geometry.h @@ -135,6 +135,9 @@ class Geometry bool getInsertFrontPadLayers() const { return mInsertFrontPadLayers; } bool getInsertHCalReadoutMaterial() const { return mInsertFrontHCalReadoutMaterial; } + float getDetectorOpeningRight() const { return mGlobal_DetectorOpening_Right; } + float getDetectorOpeningLeft() const { return mGlobal_DetectorOpening_Left; } + std::vector getFOCALMicroModule(int layer) const; const Composition* getComposition(int layer, int stack) const; std::string_view getTowerGapMaterial() const { return mGlobal_Gap_Material; } @@ -175,6 +178,9 @@ class Geometry float mWaferSizeX = 0.0; // Wafer X size float mWaferSizeY = 0.0; // Wafer Y size + float mGlobal_DetectorOpening_Right = 0.0; // detector opening in X + float mGlobal_DetectorOpening_Left = 0.0; // detector opening in Y + // PIX setup float mGlobal_Pixel_Size = 0.0; // pixel size float mGlobal_PIX_SizeX = 0.0; // sensor size X diff --git a/Detectors/FOCAL/base/src/Geometry.cxx b/Detectors/FOCAL/base/src/Geometry.cxx index 94d8c2cee049c..34df4c86262a6 100644 --- a/Detectors/FOCAL/base/src/Geometry.cxx +++ b/Detectors/FOCAL/base/src/Geometry.cxx @@ -350,6 +350,16 @@ void Geometry::setParameters(std::string geometryfile) mGlobal_FOCAL_Z0 = std::stof(tokens[1]); LOG(debug) << "Z-Location of the FoCAL is set to : " << mGlobal_FOCAL_Z0; } + + if (command.find("DetectorOpen_Right") != std::string::npos) { + mGlobal_DetectorOpening_Right = std::stof(tokens[1]); + LOG(debug) << "Detector opening on the right : " << mGlobal_DetectorOpening_Right; + } + + if (command.find("DetectorOpen_Left") != std::string::npos) { + mGlobal_DetectorOpening_Left = std::stof(tokens[1]); + LOG(debug) << "Detector opening on the left : " << mGlobal_DetectorOpening_Left; + } if (command.find("HCAL_TOWER_SIZE") != std::string::npos) { mGlobal_HCAL_Tower_Size = std::stof(tokens[1]); diff --git a/Detectors/FOCAL/simulation/geometryFiles/geometry_Spaghetti.txt b/Detectors/FOCAL/simulation/geometryFiles/geometry_Spaghetti.txt index 5209204cc5eca..31f6940224337 100644 --- a/Detectors/FOCAL/simulation/geometryFiles/geometry_Spaghetti.txt +++ b/Detectors/FOCAL/simulation/geometryFiles/geometry_Spaghetti.txt @@ -59,6 +59,10 @@ COMMAND_INSERT_PIX_AT_L9 GLOBAL_TOWER_TOLX 0.02 Air GLOBAL_TOWER_TOLY 0.8 Al GLOBAL_FOCAL_Z 763.5 +# Open the detector on the right and left in cm, +# can only work if the GLOBAL_HCAL_TOWER_NY is odd number and GLOBAL_HCAL_TOWER_NX is even number +# GLOBAL_DetectorOpen_Right 5 +# GLOBAL_DetectorOpen_Left 5 GLOBAL_Tower_NX 2 GLOBAL_Tower_NY 11 GLOBAL_MIDDLE_TOWER_OFFSET 5 diff --git a/Detectors/FOCAL/simulation/src/Detector.cxx b/Detectors/FOCAL/simulation/src/Detector.cxx index 08df253d49f83..dc71c1066afdf 100644 --- a/Detectors/FOCAL/simulation/src/Detector.cxx +++ b/Detectors/FOCAL/simulation/src/Detector.cxx @@ -539,6 +539,8 @@ void Detector::CreateHCALSpaghetti() } } + bool splitDet = mGeometry->getDetectorOpeningRight() > 0.0 || mGeometry->getDetectorOpeningLeft() > 0.0; + double TowerSize = mGeometry->getHCALTowerSize(); double CuBoxThickness = 0.3; // Thickness of the Cu box carrying capillary tubes @@ -598,25 +600,57 @@ void Detector::CreateHCALSpaghetti() Columns = 0; RowPos = 0.; Int_t NumTowers = 1; - for (Rows = 0; Rows < nTowersY; Rows++) { - float ColumnPos = 0.; - RowPos = Rows * TowerSize; - for (Columns = 0; Columns < nTowersX; Columns++) { - ColumnPos = Columns * TowerSize; - TGeoTranslation* trans = new TGeoTranslation(ColumnPos - SizeXHCAL / 2 + TowerSize / 2, RowPos - SizeYHCAL / 2 + TowerSize / 2, 0.); + if (splitDet) { + SizeXHCAL = SizeXHCAL / 2; - // Remove the Towers that overlaps with the beam pipe - Double_t RadialDistance = TMath::Power(trans->GetTranslation()[0], 2) + TMath::Power(trans->GetTranslation()[1], 2); + TGeoVolumeAssembly* volHalfHCAL = new TGeoVolumeAssembly("HalfHCAL"); - if (RadialDistance < MinRadius * MinRadius || TMath::Abs(trans->GetTranslation()[0]) > SizeXHCAL / 2) { - continue; + for (Rows = 0; Rows < nTowersY; Rows++) { + + float ColumnPos = 0.; + RowPos = Rows * TowerSize; + for (Columns = 0; Columns < nTowersX / 2; Columns++) { + ColumnPos = Columns * TowerSize; + TGeoTranslation* trans = new TGeoTranslation(ColumnPos - SizeXHCAL / 2 + TowerSize / 2, RowPos - SizeYHCAL / 2 + TowerSize / 2, 0.); + + // Shit the beampipe towers by TowerSize/2 + if (Rows == nTowersY / 2) { + trans->SetDx(trans->GetTranslation()[0] + TowerSize / 2); + } + + // Adding the Tower to the HCAL + volHalfHCAL->AddNode(volTowerHCAL, NumTowers, trans); + + NumTowers++; } + volHCAL->AddNode(volHalfHCAL, 1, new TGeoTranslation(SizeXHCAL / 2 + mGeometry->getDetectorOpeningRight(), 0, 0)); + TGeoRotation* rotFlipZ = new TGeoRotation(); + rotFlipZ->RotateY(180); // Flip around Y to reverse Z + TGeoCombiTrans* combHalf = new TGeoCombiTrans(-SizeXHCAL / 2 - mGeometry->getDetectorOpeningLeft(), 0., 0., rotFlipZ); + volHCAL->AddNode(volHalfHCAL, 2, combHalf); + } + } else { + for (Rows = 0; Rows < nTowersY; Rows++) { - // Adding the Tower to the HCAL - volHCAL->AddNode(volTowerHCAL, NumTowers, trans); + float ColumnPos = 0.; + RowPos = Rows * TowerSize; + for (Columns = 0; Columns < nTowersX; Columns++) { + ColumnPos = Columns * TowerSize; + TGeoTranslation* trans = new TGeoTranslation(ColumnPos - SizeXHCAL / 2 + TowerSize / 2, RowPos - SizeYHCAL / 2 + TowerSize / 2, 0.); - NumTowers++; + // Remove the Towers that overlaps with the beam pipe + Double_t RadialDistance = TMath::Power(trans->GetTranslation()[0], 2) + TMath::Power(trans->GetTranslation()[1], 2); + + if (RadialDistance < MinRadius * MinRadius || TMath::Abs(trans->GetTranslation()[0]) > SizeXHCAL / 2) { + continue; + } + + // Adding the Tower to the HCAL + volHCAL->AddNode(volTowerHCAL, NumTowers, trans); + + NumTowers++; + } } } @@ -791,6 +825,8 @@ void Detector::CreateECALGeometry() // this shifts all the pixel layers to the center near the beampipe double pixshift = geom->getTowerSizeX() - (geom->getGlobalPixelWaferSizeX() * geom->getNumberOfPIXsInX()); + bool splitDet = mGeometry->getDetectorOpeningRight() > 0.0 || mGeometry->getDetectorOpeningLeft() > 0.0; + float offset = pars[2]; // gMC->Gsvolu("EMSC1", "BOX", idtmed[3698], pars, 4);//Left towers (pixels shifted right) // gMC->Gsvolu("EMSC2", "BOX", idtmed[3698], pars, 4);//Right towers (pixels shifted left) @@ -977,9 +1013,13 @@ void Detector::CreateECALGeometry() // const auto towerCenter = geom->getGeoTowerCenter(number); //only ECAL part, second parameter = -1 by default // xp = std::get<0>towerCenter; // std::tie(xp, yp, zp) = geom->getGeoTowerCenter(number); - const auto [xp, yp, zp] = geom->getGeoTowerCenter(number); // only ECAL part, second parameter = -1 by default + auto [xp, yp, zp] = geom->getGeoTowerCenter(number); // only ECAL part, second parameter = -1 by default if (itowerx == 0) { + if (splitDet) { + xp -= geom->getDetectorOpeningLeft(); + } + TVirtualMC::GetMC()->Gspos("EMSC1", number + 1, "ECAL", xp, yp, 0, 0, "ONLY"); // Add the SiPad front volumes directly under the FOCAL volume if (geom->getInsertFrontPadLayers()) { @@ -992,6 +1032,10 @@ void Detector::CreateECALGeometry() } } if (itowerx == 1) { + if (splitDet) { + xp += geom->getDetectorOpeningRight(); + } + TVirtualMC::GetMC()->Gspos("EMSC2", number + 1, "ECAL", xp, yp, 0, 0, "ONLY"); // Add the SiPad front volumes directly under the FOCAL volume if (geom->getInsertFrontPadLayers()) { From 09959366d41a4c2f08051270f2fe2309616038e6 Mon Sep 17 00:00:00 2001 From: Hadi Hassan Date: Fri, 2 May 2025 16:07:48 +0300 Subject: [PATCH 2/2] Formatting --- Detectors/FOCAL/base/src/Geometry.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Detectors/FOCAL/base/src/Geometry.cxx b/Detectors/FOCAL/base/src/Geometry.cxx index 34df4c86262a6..db47816ba8537 100644 --- a/Detectors/FOCAL/base/src/Geometry.cxx +++ b/Detectors/FOCAL/base/src/Geometry.cxx @@ -350,7 +350,7 @@ void Geometry::setParameters(std::string geometryfile) mGlobal_FOCAL_Z0 = std::stof(tokens[1]); LOG(debug) << "Z-Location of the FoCAL is set to : " << mGlobal_FOCAL_Z0; } - + if (command.find("DetectorOpen_Right") != std::string::npos) { mGlobal_DetectorOpening_Right = std::stof(tokens[1]); LOG(debug) << "Detector opening on the right : " << mGlobal_DetectorOpening_Right; @@ -588,8 +588,8 @@ void Geometry::setParameters(std::string geometryfile) } } } // end for itowerY - } // end for itowerX - } // end else + } // end for itowerX + } // end else center_z += tmpComp.getThickness(); } // end loop over pad layer compositions LOG(debug) << "============ Created all pad layer compositions (" << mPadCompositionBase.size() << " volumes)";