Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITS3: Fix matrix generation in helper class #13895

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 46 additions & 60 deletions Detectors/ITSMFT/ITS/base/src/GeometryTGeo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -420,33 +420,20 @@ TGeoHMatrix* GeometryTGeo::extractMatrixSensor(int index) const
static int chipInGlo{0};

// account for the difference between physical sensitive layer (where charge collection is simulated) and effective sensor thicknesses
// in the ITS3 case this accounted by specialized functions
double delta = Segmentation::SensorLayerThickness - Segmentation::SensorLayerThicknessEff;
#ifdef ENABLE_UPGRADES
if (mIsLayerITS3[getLayer(index)]) {
delta = its3::SegmentationSuperAlpide::mSensorLayerThickness - its3::SegmentationSuperAlpide::mSensorLayerThicknessEff;
}
#endif

static TGeoTranslation tra(0., 0.5 * delta, 0.);

#ifdef ENABLE_UPGRADES // only apply for non ITS3 OB layers
if (!mIsLayerITS3[getLayer(index)]) {
matTmp *= tra;
}
#else
matTmp *= tra;
#endif

return &matTmp;
}

//__________________________________________________________________________
const o2::math_utils::Transform3D GeometryTGeo::getT2LMatrixITS3(int isn, float alpha)
{
// create for sensor isn the TGeo matrix for Tracking to Local frame transformations
static TGeoHMatrix t2l;
t2l.Clear();
t2l.RotateZ(alpha * RadToDeg()); // rotate in direction of normal to the tangent to the cylinder
const TGeoHMatrix& matL2G = getMatrixL2G(isn);
const auto& matL2Gi = matL2G.Inverse();
t2l.MultiplyLeft(&matL2Gi);
return Mat3D(t2l);
}

//__________________________________________________________________________
void GeometryTGeo::Build(int loadTrans)
{
Expand Down Expand Up @@ -492,23 +479,6 @@ void GeometryTGeo::Build(int loadTrans)
mLastChipIndex[i] = numberOfChips - 1;
}

LOGP(debug, "Summary of extracted Geometry:");
LOGP(debug, " There are {} Layers and {} HalfBarrels", mNumberOfLayers, mNumberOfHalfBarrels);
for (int i = 0; i < mNumberOfLayers; i++) {
LOGP(debug, " Layer {}: {:*^30}", i, "START");
LOGP(debug, " - mNumberOfStaves={}", mNumberOfStaves[i]);
LOGP(debug, " - mNumberOfChipsPerStave={}", mNumberOfChipsPerStave[i]);
LOGP(debug, " - mNumberOfHalfStaves={}", mNumberOfHalfStaves[i]);
LOGP(debug, " - mNumberOfChipsPerHalfStave={}", mNumberOfChipsPerHalfStave[i]);
LOGP(debug, " - mNumberOfModules={}", mNumberOfModules[i]);
LOGP(debug, " - mNumberOfChipsPerModules={}", mNumberOfChipsPerModule[i]);
LOGP(debug, " - mNumberOfChipsPerLayer={}", mNumberOfChipsPerLayer[i]);
LOGP(debug, " - mNumberOfChipsPerHalfBarrel={}", mNumberOfChipsPerHalfBarrel[i]);
LOGP(debug, " - mLastChipIndex={}", mLastChipIndex[i]);
LOGP(debug, " Layer {}: {:*^30}", i, "END");
}
LOGP(debug, "In total there {} chips registered", numberOfChips);

#ifdef ENABLE_UPGRADES
if (std::any_of(mIsLayerITS3.cbegin(), mIsLayerITS3.cend(), [](auto b) { return b; })) {
LOGP(info, "Found active IT3 layers -> Renaming Detector ITS to IT3");
Expand Down Expand Up @@ -880,34 +850,30 @@ void GeometryTGeo::extractSensorXAlpha(int isn, float& x, float& alp)

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

#ifdef ENABLE_UPGRADES
if (mIsLayerITS3[iLayer]) {
// We need to calcualte the line tangent at the mid-point in the geometry
if (int iLayer = getLayer(isn); mIsLayerITS3[iLayer]) {
// For a TGeoTubeSeg the local coordinate system is defined at the origin
// of the circle of the side, since in our implementation we rotated the geometry a bit
const auto radius = o2::its3::constants::radii[iLayer];
const auto phi1 = o2::its3::constants::tile::width / radius;
const auto phi2 = o2::its3::constants::pixelarray::width / radius + phi1;
const auto phi3 = (phi2 - phi1) / 2.; // mid-point in phi
const auto x = radius * std::cos(phi3);
const auto y = radius * std::sin(phi3);
// For the tangent we make the parametric line equation y = m * x - c
const auto m = x / y;
const auto c = y - m * x;
// Now we can given any x calulate points along this line, we pick points far away,
// the calculation of the normal should work then below.
locA[1] = m * locA[0] + c;
locB[1] = m * locB[0] + c;
}
#endif

matL2G->LocalToMaster(locA, gloA);
matL2G->LocalToMaster(locB, gloB);
double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
double xp = gloB[0] - dx * t, yp = gloB[1] - dy * t;
x = Sqrt(xp * xp + yp * yp);
alp = ATan2(yp, xp);
locA[0] = radius * std::cos(phi3);
locA[1] = radius * std::sin(phi3);
matL2G->LocalToMaster(locA, gloA);
xp = gloA[0];
yp = gloA[1];
} else {
matL2G->LocalToMaster(locA, gloA);
matL2G->LocalToMaster(locB, gloB);
double dx = gloB[0] - gloA[0], dy = gloB[1] - gloA[1];
double t = (gloB[0] * dx + gloB[1] * dy) / (dx * dx + dy * dy);
xp = gloB[0] - dx * t;
yp = gloB[1] - dy * t;
}
x = std::hypot(xp, yp);
alp = std::atan2(yp, xp);
o2::math_utils::bringTo02Pi(alp);
}

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

//__________________________________________________________________________
const o2::math_utils::Transform3D GeometryTGeo::getT2LMatrixITS3(int isn, float alpha)
{
// create for sensor isn the TGeo matrix for Tracking to Local frame transformations with correction for effective thickness
static TGeoHMatrix t2l;
t2l.Clear();
t2l.RotateZ(alpha * RadToDeg()); // rotate in direction of normal to the tangent to the cylinder
const TGeoHMatrix& matL2G = getMatrixL2G(isn);
const auto& matL2Gi = matL2G.Inverse();
t2l.MultiplyLeft(&matL2Gi);
// TODO FS
// correction for effective sensor thickness; disabled for now since this does not work
// but the bias by not using in this should be very small
// static TGeoTranslation tra;
// tra.SetDx(SuperSegmentation::mSensorLayerThicknessCorr * std::cos(alpha));
// tra.SetDy(SuperSegmentation::mSensorLayerThicknessCorr * std::sin(alpha));
// t2l *= tra;
return Mat3D(t2l);
}

//__________________________________________________________________________
int GeometryTGeo::extractVolumeCopy(const char* name, const char* prefix) const
{
Expand Down
6 changes: 3 additions & 3 deletions Detectors/ITSMFT/ITS/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Detector::Detector(Bool_t active, TString name)
} else {
mLayerName[j].Form("%s%d", GeometryTGeo::getITSSensorPattern(), j); // See V3Layer
}
LOGP(info, "{}: mLayerName={}", j, mLayerName[j].Data());
LOGP(debug, "{}: mLayerName={}", j, mLayerName[j].Data());
}

if (mNumberLayers > 0) { // if not, we'll Fatal-ize in CreateGeometry
Expand Down Expand Up @@ -723,8 +723,8 @@ void Detector::defineLayer(Int_t nlay, Double_t phi0, Double_t r, Int_t nstav, I
// Return:
// none.

LOG(info) << "L# " << nlay << " Phi:" << phi0 << " R:" << r << " Nst:" << nstav << " Nunit:" << nunit
<< " Lthick:" << lthick << " Dthick:" << dthick << " DetID:" << dettypeID << " B:" << buildLevel;
LOG(debug) << "L# " << nlay << " Phi:" << phi0 << " R:" << r << " Nst:" << nstav << " Nunit:" << nunit
<< " Lthick:" << lthick << " Dthick:" << dthick << " DetID:" << dettypeID << " B:" << buildLevel;

if (nlay >= mNumberLayers || nlay < 0) {
LOG(error) << "Wrong layer number " << nlay;
Expand Down
Loading