Skip to content

Commit 8307e6a

Browse files
authored
Merge 01309a0 into sapling-pr-archive-ktf
2 parents 97b5500 + 01309a0 commit 8307e6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2096
-226
lines changed

Detectors/FOCAL/base/include/FOCALBase/Geometry.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class Geometry
135135
bool getInsertFrontPadLayers() const { return mInsertFrontPadLayers; }
136136
bool getInsertHCalReadoutMaterial() const { return mInsertFrontHCalReadoutMaterial; }
137137

138+
float getDetectorOpeningRight() const { return mGlobal_DetectorOpening_Right; }
139+
float getDetectorOpeningLeft() const { return mGlobal_DetectorOpening_Left; }
140+
138141
std::vector<const Composition*> getFOCALMicroModule(int layer) const;
139142
const Composition* getComposition(int layer, int stack) const;
140143
std::string_view getTowerGapMaterial() const { return mGlobal_Gap_Material; }
@@ -175,6 +178,9 @@ class Geometry
175178
float mWaferSizeX = 0.0; // Wafer X size
176179
float mWaferSizeY = 0.0; // Wafer Y size
177180

181+
float mGlobal_DetectorOpening_Right = 0.0; // detector opening in X
182+
float mGlobal_DetectorOpening_Left = 0.0; // detector opening in Y
183+
178184
// PIX setup
179185
float mGlobal_Pixel_Size = 0.0; // pixel size
180186
float mGlobal_PIX_SizeX = 0.0; // sensor size X

Detectors/FOCAL/base/src/Geometry.cxx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,16 @@ void Geometry::setParameters(std::string geometryfile)
351351
LOG(debug) << "Z-Location of the FoCAL is set to : " << mGlobal_FOCAL_Z0;
352352
}
353353

354+
if (command.find("DetectorOpen_Right") != std::string::npos) {
355+
mGlobal_DetectorOpening_Right = std::stof(tokens[1]);
356+
LOG(debug) << "Detector opening on the right : " << mGlobal_DetectorOpening_Right;
357+
}
358+
359+
if (command.find("DetectorOpen_Left") != std::string::npos) {
360+
mGlobal_DetectorOpening_Left = std::stof(tokens[1]);
361+
LOG(debug) << "Detector opening on the left : " << mGlobal_DetectorOpening_Left;
362+
}
363+
354364
if (command.find("HCAL_TOWER_SIZE") != std::string::npos) {
355365
mGlobal_HCAL_Tower_Size = std::stof(tokens[1]);
356366
LOG(debug) << "The size of the HCAL readout tower will be : " << mGlobal_HCAL_Tower_Size;
@@ -578,8 +588,8 @@ void Geometry::setParameters(std::string geometryfile)
578588
}
579589
}
580590
} // end for itowerY
581-
} // end for itowerX
582-
} // end else
591+
} // end for itowerX
592+
} // end else
583593
center_z += tmpComp.getThickness();
584594
} // end loop over pad layer compositions
585595
LOG(debug) << "============ Created all pad layer compositions (" << mPadCompositionBase.size() << " volumes)";

Detectors/FOCAL/simulation/geometryFiles/geometry_Spaghetti.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ COMMAND_INSERT_PIX_AT_L9
5959
GLOBAL_TOWER_TOLX 0.02 Air
6060
GLOBAL_TOWER_TOLY 0.8 Al
6161
GLOBAL_FOCAL_Z 763.5
62+
# Open the detector on the right and left in cm,
63+
# can only work if the GLOBAL_HCAL_TOWER_NY is odd number and GLOBAL_HCAL_TOWER_NX is even number
64+
# GLOBAL_DetectorOpen_Right 5
65+
# GLOBAL_DetectorOpen_Left 5
6266
GLOBAL_Tower_NX 2
6367
GLOBAL_Tower_NY 11
6468
GLOBAL_MIDDLE_TOWER_OFFSET 5

Detectors/FOCAL/simulation/src/Detector.cxx

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void Detector::ConstructGeometry()
451451
}
452452

453453
float pars[4];
454-
pars[0] = (mGeometry->getFOCALSizeX() + 2 * mGeometry->getMiddleTowerOffset()) / 2;
454+
pars[0] = (mGeometry->getFOCALSizeX() + 2 * mGeometry->getMiddleTowerOffset() + mGeometry->getDetectorOpeningRight() + mGeometry->getDetectorOpeningLeft()) / 2;
455455
pars[1] = mGeometry->getFOCALSizeY() / 2;
456456
pars[2] = mGeometry->getFOCALSizeZ() / 2;
457457
// Add space to place 2 SiPad layers in front of ECAL
@@ -539,6 +539,8 @@ void Detector::CreateHCALSpaghetti()
539539
}
540540
}
541541

542+
bool splitDet = mGeometry->getDetectorOpeningRight() > 0.0 || mGeometry->getDetectorOpeningLeft() > 0.0;
543+
542544
double TowerSize = mGeometry->getHCALTowerSize();
543545
double CuBoxThickness = 0.3; // Thickness of the Cu box carrying capillary tubes
544546

@@ -598,25 +600,57 @@ void Detector::CreateHCALSpaghetti()
598600
Columns = 0;
599601
RowPos = 0.;
600602
Int_t NumTowers = 1;
601-
for (Rows = 0; Rows < nTowersY; Rows++) {
602603

603-
float ColumnPos = 0.;
604-
RowPos = Rows * TowerSize;
605-
for (Columns = 0; Columns < nTowersX; Columns++) {
606-
ColumnPos = Columns * TowerSize;
607-
TGeoTranslation* trans = new TGeoTranslation(ColumnPos - SizeXHCAL / 2 + TowerSize / 2, RowPos - SizeYHCAL / 2 + TowerSize / 2, 0.);
604+
if (splitDet) {
605+
SizeXHCAL = SizeXHCAL / 2;
608606

609-
// Remove the Towers that overlaps with the beam pipe
610-
Double_t RadialDistance = TMath::Power(trans->GetTranslation()[0], 2) + TMath::Power(trans->GetTranslation()[1], 2);
607+
TGeoVolumeAssembly* volHalfHCAL = new TGeoVolumeAssembly("HalfHCAL");
611608

612-
if (RadialDistance < MinRadius * MinRadius || TMath::Abs(trans->GetTranslation()[0]) > SizeXHCAL / 2) {
613-
continue;
609+
for (Rows = 0; Rows < nTowersY; Rows++) {
610+
611+
float ColumnPos = 0.;
612+
RowPos = Rows * TowerSize;
613+
for (Columns = 0; Columns < nTowersX / 2; Columns++) {
614+
ColumnPos = Columns * TowerSize;
615+
TGeoTranslation* trans = new TGeoTranslation(ColumnPos - SizeXHCAL / 2 + TowerSize / 2, RowPos - SizeYHCAL / 2 + TowerSize / 2, 0.);
616+
617+
// Shit the beampipe towers by TowerSize/2
618+
if (Rows == nTowersY / 2) {
619+
trans->SetDx(trans->GetTranslation()[0] + TowerSize / 2);
620+
}
621+
622+
// Adding the Tower to the HCAL
623+
volHalfHCAL->AddNode(volTowerHCAL, NumTowers, trans);
624+
625+
NumTowers++;
614626
}
627+
volHCAL->AddNode(volHalfHCAL, 1, new TGeoTranslation(SizeXHCAL / 2 + mGeometry->getDetectorOpeningRight(), 0, 0));
628+
TGeoRotation* rotFlipZ = new TGeoRotation();
629+
rotFlipZ->RotateY(180); // Flip around Y to reverse Z
630+
TGeoCombiTrans* combHalf = new TGeoCombiTrans(-SizeXHCAL / 2 - mGeometry->getDetectorOpeningLeft(), 0., 0., rotFlipZ);
631+
volHCAL->AddNode(volHalfHCAL, 2, combHalf);
632+
}
633+
} else {
634+
for (Rows = 0; Rows < nTowersY; Rows++) {
615635

616-
// Adding the Tower to the HCAL
617-
volHCAL->AddNode(volTowerHCAL, NumTowers, trans);
636+
float ColumnPos = 0.;
637+
RowPos = Rows * TowerSize;
638+
for (Columns = 0; Columns < nTowersX; Columns++) {
639+
ColumnPos = Columns * TowerSize;
640+
TGeoTranslation* trans = new TGeoTranslation(ColumnPos - SizeXHCAL / 2 + TowerSize / 2, RowPos - SizeYHCAL / 2 + TowerSize / 2, 0.);
618641

619-
NumTowers++;
642+
// Remove the Towers that overlaps with the beam pipe
643+
Double_t RadialDistance = TMath::Power(trans->GetTranslation()[0], 2) + TMath::Power(trans->GetTranslation()[1], 2);
644+
645+
if (RadialDistance < MinRadius * MinRadius || TMath::Abs(trans->GetTranslation()[0]) > SizeXHCAL / 2) {
646+
continue;
647+
}
648+
649+
// Adding the Tower to the HCAL
650+
volHCAL->AddNode(volTowerHCAL, NumTowers, trans);
651+
652+
NumTowers++;
653+
}
620654
}
621655
}
622656

@@ -791,6 +825,8 @@ void Detector::CreateECALGeometry()
791825
// this shifts all the pixel layers to the center near the beampipe
792826
double pixshift = geom->getTowerSizeX() - (geom->getGlobalPixelWaferSizeX() * geom->getNumberOfPIXsInX());
793827

828+
bool splitDet = mGeometry->getDetectorOpeningRight() > 0.0 || mGeometry->getDetectorOpeningLeft() > 0.0;
829+
794830
float offset = pars[2];
795831
// gMC->Gsvolu("EMSC1", "BOX", idtmed[3698], pars, 4);//Left towers (pixels shifted right)
796832
// gMC->Gsvolu("EMSC2", "BOX", idtmed[3698], pars, 4);//Right towers (pixels shifted left)
@@ -948,7 +984,7 @@ void Detector::CreateECALGeometry()
948984
// Place the towers in the ECAL
949985
// --- Place the ECAL in FOCAL
950986
float fcal_pars[4];
951-
fcal_pars[0] = (geom->getFOCALSizeX() + 2. * geom->getMiddleTowerOffset()) / 2.;
987+
fcal_pars[0] = (geom->getFOCALSizeX() + 2. * geom->getMiddleTowerOffset() + mGeometry->getDetectorOpeningRight() + mGeometry->getDetectorOpeningLeft()) / 2.;
952988
fcal_pars[1] = geom->getFOCALSizeY() / 2.;
953989
fcal_pars[2] = geom->getECALSizeZ() / 2.;
954990
fcal_pars[3] = 0.;
@@ -977,9 +1013,13 @@ void Detector::CreateECALGeometry()
9771013
// const auto towerCenter = geom->getGeoTowerCenter(number); //only ECAL part, second parameter = -1 by default
9781014
// xp = std::get<0>towerCenter;
9791015
// std::tie(xp, yp, zp) = geom->getGeoTowerCenter(number);
980-
const auto [xp, yp, zp] = geom->getGeoTowerCenter(number); // only ECAL part, second parameter = -1 by default
1016+
auto [xp, yp, zp] = geom->getGeoTowerCenter(number); // only ECAL part, second parameter = -1 by default
9811017

9821018
if (itowerx == 0) {
1019+
if (splitDet) {
1020+
xp -= geom->getDetectorOpeningLeft();
1021+
}
1022+
9831023
TVirtualMC::GetMC()->Gspos("EMSC1", number + 1, "ECAL", xp, yp, 0, 0, "ONLY");
9841024
// Add the SiPad front volumes directly under the FOCAL volume
9851025
if (geom->getInsertFrontPadLayers()) {
@@ -992,6 +1032,10 @@ void Detector::CreateECALGeometry()
9921032
}
9931033
}
9941034
if (itowerx == 1) {
1035+
if (splitDet) {
1036+
xp += geom->getDetectorOpeningRight();
1037+
}
1038+
9951039
TVirtualMC::GetMC()->Gspos("EMSC2", number + 1, "ECAL", xp, yp, 0, 0, "ONLY");
9961040
// Add the SiPad front volumes directly under the FOCAL volume
9971041
if (geom->getInsertFrontPadLayers()) {
Binary file not shown.

Detectors/ITSMFT/common/simulation/include/ITSMFTSimulation/AlpideSimResponse.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class AlpideRespSimMat
3838
static int constexpr getNPix() { return NPix; }
3939

4040
AlpideRespSimMat() = default;
41-
~AlpideRespSimMat() = default;
41+
virtual ~AlpideRespSimMat() = default;
4242

4343
void adopt(const AlpideRespSimMat& src, bool flipRow = false, bool flipCol = false)
4444
{
@@ -69,7 +69,7 @@ class AlpideRespSimMat
6969
private:
7070
std::array<float, MatSize> data;
7171

72-
ClassDefNV(AlpideRespSimMat, 1);
72+
ClassDef(AlpideRespSimMat, 1);
7373
};
7474

7575
/*
@@ -91,6 +91,7 @@ class AlpideSimResponse
9191
int getDepthBin(float pos) const;
9292
std::string composeDataName(int colBin, int rowBin);
9393

94+
protected:
9495
int mNBinCol = 0; /// number of bins in X(col direction)
9596
int mNBinRow = 0; /// number of bins in Y(row direction)
9697
int mNBinDpt = 0; /// number of bins in Z(sensor dept)

Detectors/Upgrades/ITS3/base/include/ITS3Base/SegmentationMosaix.h

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
/// \file SegmentationMosaix.h
1313
/// \brief Definition of the SegmentationMosaix class
1414
/// \author [email protected]
15+
/// \author [email protected]
1516

1617
#ifndef ALICEO2_ITS3_SEGMENTATIONMOSAIX_H_
1718
#define ALICEO2_ITS3_SEGMENTATIONMOSAIX_H_
1819

19-
#include <type_traits>
20-
2120
#include "MathUtils/Cartesian.h"
2221
#include "ITS3Base/SpecsV2.h"
2322

@@ -43,24 +42,22 @@ class SegmentationMosaix
4342
// 3. The detector coordinate system. Defined by the row and column segmentation
4443
// defined at the upper edge in the flat coord.
4544

46-
// row,col=0
47-
// |
48-
// v
49-
// x----------------------x
50-
// | | |
51-
// | | |
52-
// | | | ^ x
53-
// | | | |
54-
// | | | |
55-
// | | | |
56-
// |-----------X----------| X marks (x,z)=(0,0) X----> z
57-
// | | |
45+
// O----------------------|
5846
// | | |
47+
// | | | ^ x
48+
// | | | |
49+
// | | | |
50+
// | | | |
51+
// | | | X----> z X marks (x,z)=(0,0)
52+
// |-----------X----------|
53+
// | | | O----> col O marks (row,col)=(0,0)
54+
// | | | |
55+
// | | | |
56+
// | | | v
57+
// | | | row
5958
// | | |
60-
// | | |
61-
// | | |
62-
// | | |
63-
// x----------------------x
59+
// |----------------------|
60+
6461
public:
6562
constexpr SegmentationMosaix(int layer) : mRadius(static_cast<float>(constants::radiiMiddle[layer])) {}
6663
constexpr ~SegmentationMosaix() = default;
@@ -79,7 +76,6 @@ class SegmentationMosaix
7976
static constexpr float PitchCol{constants::pixelarray::pixels::mosaix::pitchZ};
8077
static constexpr float PitchRow{constants::pixelarray::pixels::mosaix::pitchX};
8178
static constexpr float SensorLayerThickness{constants::totalThickness};
82-
static constexpr float NominalYShift{constants::nominalYShift};
8379

8480
/// Transformation from the curved surface to a flat surface.
8581
/// Additionally a shift in the flat coordinates must be applied because
@@ -102,10 +98,10 @@ class SegmentationMosaix
10298
// stack
10399
float dist = std::hypot(xCurved, yCurved);
104100
float phi = std::atan2(yCurved, xCurved);
105-
xFlat = (mRadius * phi) - WidthH;
106101
// the y position is in the silicon volume however we need the chip volume (silicon+metalstack)
107102
// this is accounted by a y shift
108-
yFlat = dist - mRadius + NominalYShift;
103+
xFlat = WidthH - mRadius * phi;
104+
yFlat = dist - mRadius;
109105
}
110106

111107
/// Transformation from the flat surface to a curved surface
@@ -122,11 +118,12 @@ class SegmentationMosaix
122118
{
123119
// MUST align the flat surface with the curved surface with the original pixel array is on and account for metal
124120
// stack
121+
float dist = yFlat + mRadius;
122+
float phi = (WidthH - xFlat) / mRadius;
125123
// the y position is in the chip volume however we need the silicon volume
126124
// this is accounted by a -y shift
127-
float dist = yFlat - NominalYShift + mRadius;
128-
xCurved = dist * std::cos((xFlat + WidthH) / mRadius);
129-
yCurved = dist * std::sin((xFlat + WidthH) / mRadius);
125+
xCurved = dist * std::cos(phi);
126+
yCurved = dist * std::sin(phi);
130127
}
131128

132129
/// Transformation from Geant detector centered local coordinates (cm) to
@@ -142,8 +139,11 @@ class SegmentationMosaix
142139
/// \param int iCol Detector z cell coordinate.
143140
constexpr bool localToDetector(float const xRow, float const zCol, int& iRow, int& iCol) const noexcept
144141
{
142+
if (!isValidLoc(xRow, zCol)) {
143+
return false;
144+
}
145145
localToDetectorUnchecked(xRow, zCol, iRow, iCol);
146-
if (!isValid(iRow, iCol)) {
146+
if (!isValidDet(iRow, iCol)) {
147147
iRow = iCol = -1;
148148
return false;
149149
}
@@ -167,49 +167,54 @@ class SegmentationMosaix
167167
/// center of the sensitive volume.
168168
/// If iRow and or iCol is outside of the segmentation range a value of -0.5*Dx()
169169
/// or -0.5*Dz() is returned.
170-
constexpr bool detectorToLocal(int const iRow, int const iCol, float& xRow, float& zCol) const noexcept
170+
bool detectorToLocal(float const row, float const col, float& xRow, float& zCol) const noexcept
171171
{
172-
if (!isValid(iRow, iCol)) {
172+
if (!isValidDet(row, col)) {
173173
return false;
174174
}
175-
detectorToLocalUnchecked(iRow, iCol, xRow, zCol);
176-
return isValid(xRow, zCol);
175+
detectorToLocalUnchecked(row, col, xRow, zCol);
176+
return isValidLoc(xRow, zCol);
177177
}
178178

179179
// Same as detectorToLocal w.o. checks.
180180
// We position ourself in the middle of the pixel.
181-
constexpr void detectorToLocalUnchecked(int const iRow, int const iCol, float& xRow, float& zCol) const noexcept
181+
void detectorToLocalUnchecked(float const row, float const col, float& xRow, float& zCol) const noexcept
182182
{
183-
xRow = -(static_cast<float>(iRow) + 0.5f) * PitchRow + WidthH;
184-
zCol = (static_cast<float>(iCol) + 0.5f) * PitchCol - LengthH;
183+
xRow = -(row + 0.5f) * PitchRow + WidthH;
184+
zCol = (col + 0.5f) * PitchCol - LengthH;
185185
}
186186

187-
bool detectorToLocal(int const row, int const col, math_utils::Point3D<float>& loc) const noexcept
187+
bool detectorToLocal(float const row, float const col, math_utils::Point3D<float>& loc) const noexcept
188188
{
189189
float xRow{0.}, zCol{0.};
190190
if (!detectorToLocal(row, col, xRow, zCol)) {
191191
return false;
192192
}
193-
loc.SetCoordinates(xRow, NominalYShift, zCol);
193+
loc.SetCoordinates(xRow, 0.0f, zCol);
194194
return true;
195195
}
196196

197-
void detectorToLocalUnchecked(int const row, int const col, math_utils::Point3D<float>& loc) const noexcept
197+
void detectorToLocalUnchecked(float const row, float const col, math_utils::Point3D<float>& loc) const noexcept
198198
{
199199
float xRow{0.}, zCol{0.};
200200
detectorToLocalUnchecked(row, col, xRow, zCol);
201-
loc.SetCoordinates(xRow, NominalYShift, zCol);
201+
loc.SetCoordinates(xRow, 0.0f, zCol);
202202
}
203203

204204
private:
205+
// Check local coordinates (cm) validity.
205206
template <typename T>
206-
[[nodiscard]] constexpr bool isValid(T const row, T const col) const noexcept
207+
constexpr bool isValidLoc(T const x, T const z) const noexcept
207208
{
208-
if constexpr (std::is_floating_point_v<T>) { // compares in local coord.
209-
return (-WidthH < row && row < WidthH && -LengthH < col && col < LengthH);
210-
} else { // compares in rows/cols
211-
return !static_cast<bool>(row < 0 || row >= static_cast<int>(NRows) || col < 0 || col >= static_cast<int>(NCols));
212-
}
209+
return (-WidthH < x && x < WidthH && -LengthH < z && z < LengthH);
210+
}
211+
212+
// Check detector coordinates validity.
213+
template <typename T>
214+
constexpr bool isValidDet(T const row, T const col) const noexcept
215+
{
216+
return (row >= 0 && row < static_cast<T>(NRows) &&
217+
col >= 0 && col < static_cast<T>(NCols));
213218
}
214219

215220
float mRadius;

0 commit comments

Comments
 (0)