Skip to content

Commit 253228f

Browse files
committed
ITS: ITS3 matrix generation fix + demoting&removal of logging
Signed-off-by: Felix Schlepper <[email protected]>
1 parent 702979b commit 253228f

File tree

1 file changed

+46
-60
lines changed

1 file changed

+46
-60
lines changed

Detectors/ITSMFT/ITS/base/src/GeometryTGeo.cxx

Lines changed: 46 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -420,33 +420,20 @@ TGeoHMatrix* GeometryTGeo::extractMatrixSensor(int index) const
420420
static int chipInGlo{0};
421421

422422
// account for the difference between physical sensitive layer (where charge collection is simulated) and effective sensor thicknesses
423+
// in the ITS3 case this accounted by specialized functions
423424
double delta = Segmentation::SensorLayerThickness - Segmentation::SensorLayerThicknessEff;
424-
#ifdef ENABLE_UPGRADES
425-
if (mIsLayerITS3[getLayer(index)]) {
426-
delta = its3::SegmentationSuperAlpide::mSensorLayerThickness - its3::SegmentationSuperAlpide::mSensorLayerThicknessEff;
427-
}
428-
#endif
429-
430425
static TGeoTranslation tra(0., 0.5 * delta, 0.);
431-
426+
#ifdef ENABLE_UPGRADES // only apply for non ITS3 OB layers
427+
if (!mIsLayerITS3[getLayer(index)]) {
428+
matTmp *= tra;
429+
}
430+
#else
432431
matTmp *= tra;
432+
#endif
433433

434434
return &matTmp;
435435
}
436436

437-
//__________________________________________________________________________
438-
const o2::math_utils::Transform3D GeometryTGeo::getT2LMatrixITS3(int isn, float alpha)
439-
{
440-
// create for sensor isn the TGeo matrix for Tracking to Local frame transformations
441-
static TGeoHMatrix t2l;
442-
t2l.Clear();
443-
t2l.RotateZ(alpha * RadToDeg()); // rotate in direction of normal to the tangent to the cylinder
444-
const TGeoHMatrix& matL2G = getMatrixL2G(isn);
445-
const auto& matL2Gi = matL2G.Inverse();
446-
t2l.MultiplyLeft(&matL2Gi);
447-
return Mat3D(t2l);
448-
}
449-
450437
//__________________________________________________________________________
451438
void GeometryTGeo::Build(int loadTrans)
452439
{
@@ -492,23 +479,6 @@ void GeometryTGeo::Build(int loadTrans)
492479
mLastChipIndex[i] = numberOfChips - 1;
493480
}
494481

495-
LOGP(debug, "Summary of extracted Geometry:");
496-
LOGP(debug, " There are {} Layers and {} HalfBarrels", mNumberOfLayers, mNumberOfHalfBarrels);
497-
for (int i = 0; i < mNumberOfLayers; i++) {
498-
LOGP(debug, " Layer {}: {:*^30}", i, "START");
499-
LOGP(debug, " - mNumberOfStaves={}", mNumberOfStaves[i]);
500-
LOGP(debug, " - mNumberOfChipsPerStave={}", mNumberOfChipsPerStave[i]);
501-
LOGP(debug, " - mNumberOfHalfStaves={}", mNumberOfHalfStaves[i]);
502-
LOGP(debug, " - mNumberOfChipsPerHalfStave={}", mNumberOfChipsPerHalfStave[i]);
503-
LOGP(debug, " - mNumberOfModules={}", mNumberOfModules[i]);
504-
LOGP(debug, " - mNumberOfChipsPerModules={}", mNumberOfChipsPerModule[i]);
505-
LOGP(debug, " - mNumberOfChipsPerLayer={}", mNumberOfChipsPerLayer[i]);
506-
LOGP(debug, " - mNumberOfChipsPerHalfBarrel={}", mNumberOfChipsPerHalfBarrel[i]);
507-
LOGP(debug, " - mLastChipIndex={}", mLastChipIndex[i]);
508-
LOGP(debug, " Layer {}: {:*^30}", i, "END");
509-
}
510-
LOGP(debug, "In total there {} chips registered", numberOfChips);
511-
512482
#ifdef ENABLE_UPGRADES
513483
if (std::any_of(mIsLayerITS3.cbegin(), mIsLayerITS3.cend(), [](auto b) { return b; })) {
514484
LOGP(info, "Found active IT3 layers -> Renaming Detector ITS to IT3");
@@ -880,34 +850,30 @@ void GeometryTGeo::extractSensorXAlpha(int isn, float& x, float& alp)
880850

881851
const TGeoHMatrix* matL2G = extractMatrixSensor(isn);
882852
double locA[3] = {-100., 0., 0.}, locB[3] = {100., 0., 0.}, gloA[3], gloB[3];
883-
int iLayer = getLayer(isn);
853+
double xp{0}, yp{0};
884854

885-
#ifdef ENABLE_UPGRADES
886-
if (mIsLayerITS3[iLayer]) {
887-
// We need to calcualte the line tangent at the mid-point in the geometry
855+
if (int iLayer = getLayer(isn); mIsLayerITS3[iLayer]) {
856+
// For a TGeoTubeSeg the local coordinate system is defined at the origin
857+
// of the circle of the side, since in our implementation we rotated the geometry a bit
888858
const auto radius = o2::its3::constants::radii[iLayer];
889859
const auto phi1 = o2::its3::constants::tile::width / radius;
890860
const auto phi2 = o2::its3::constants::pixelarray::width / radius + phi1;
891861
const auto phi3 = (phi2 - phi1) / 2.; // mid-point in phi
892-
const auto x = radius * std::cos(phi3);
893-
const auto y = radius * std::sin(phi3);
894-
// For the tangent we make the parametric line equation y = m * x - c
895-
const auto m = x / y;
896-
const auto c = y - m * x;
897-
// Now we can given any x calulate points along this line, we pick points far away,
898-
// the calculation of the normal should work then below.
899-
locA[1] = m * locA[0] + c;
900-
locB[1] = m * locB[0] + c;
901-
}
902-
#endif
903-
904-
matL2G->LocalToMaster(locA, gloA);
905-
matL2G->LocalToMaster(locB, gloB);
906-
double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
907-
double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
908-
double xp = gloB[0] - dx * t, yp = gloB[1] - dy * t;
909-
x = Sqrt(xp * xp + yp * yp);
910-
alp = ATan2(yp, xp);
862+
locA[0] = radius * std::cos(phi3);
863+
locA[1] = radius * std::sin(phi3);
864+
matL2G->LocalToMaster(locA, gloA);
865+
xp = gloA[0];
866+
yp = gloA[1];
867+
} else {
868+
matL2G->LocalToMaster(locA, gloA);
869+
matL2G->LocalToMaster(locB, gloB);
870+
double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
871+
double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
872+
xp = gloB[0] - dx * t;
873+
yp = gloB[1] - dy * t;
874+
}
875+
x = std::hypot(xp, yp);
876+
alp = std::atan2(yp, xp);
911877
o2::math_utils::bringTo02Pi(alp);
912878
}
913879

@@ -926,6 +892,26 @@ TGeoHMatrix& GeometryTGeo::createT2LMatrix(int isn)
926892
return t2l;
927893
}
928894

895+
//__________________________________________________________________________
896+
const o2::math_utils::Transform3D GeometryTGeo::getT2LMatrixITS3(int isn, float alpha)
897+
{
898+
// create for sensor isn the TGeo matrix for Tracking to Local frame transformations with correction for effective thickness
899+
static TGeoHMatrix t2l;
900+
t2l.Clear();
901+
t2l.RotateZ(alpha * RadToDeg()); // rotate in direction of normal to the tangent to the cylinder
902+
const TGeoHMatrix& matL2G = getMatrixL2G(isn);
903+
const auto& matL2Gi = matL2G.Inverse();
904+
t2l.MultiplyLeft(&matL2Gi);
905+
// TODO FS
906+
// correction for effective sensor thickness; disabled for now since this does not work
907+
// but the bias by not using in this should be very small
908+
// static TGeoTranslation tra;
909+
// tra.SetDx(SuperSegmentation::mSensorLayerThicknessCorr * std::cos(alpha));
910+
// tra.SetDy(SuperSegmentation::mSensorLayerThicknessCorr * std::sin(alpha));
911+
// t2l *= tra;
912+
return Mat3D(t2l);
913+
}
914+
929915
//__________________________________________________________________________
930916
int GeometryTGeo::extractVolumeCopy(const char* name, const char* prefix) const
931917
{

0 commit comments

Comments
 (0)