Skip to content

Commit d17d862

Browse files
authored
Fix MLOT digit residuals (#15200)
1 parent 859d892 commit d17d862

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

Detectors/Upgrades/ALICE3/TRK/macros/test/CheckDigits.C

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "SimulationDataFormat/IOMCTruthContainerView.h"
3232
#include "SimulationDataFormat/MCCompLabel.h"
3333
#include "DetectorsBase/GeometryManager.h"
34+
#include "ITSMFTSimulation/AlpideSimResponse.h"
35+
#include "CCDB/BasicCCDBManager.h"
3436

3537
#include "DataFormatsITSMFT/ROFRecord.h"
3638

@@ -98,6 +100,15 @@ void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile =
98100
SegmentationChip seg;
99101
// seg.Print();
100102

103+
// MLOT response plane: y = halfThickness - depthMax.
104+
float depthMax = (float)o2::trk::constants::apts::thickness; // fallback (no CCDB)
105+
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance();
106+
ccdbMgr.setURL("http://alice-ccdb.cern.ch");
107+
if (auto* alpResp = ccdbMgr.get<o2::itsmft::AlpideSimResponse>("IT3/Calib/APTSResponse")) {
108+
depthMax = alpResp->getDepthMax();
109+
}
110+
const float yPlaneMLOT = o2::trk::SegmentationChip::SiliconThicknessMLOT / 2.f - depthMax;
111+
const float yPlaneVD = -o2::trk::SegmentationChip::SiliconThicknessVD; // VD reference plane in local flat y
101112
// Hits
102113
TFile* hitFile = TFile::Open(hitfile.data());
103114
TTree* hitTree = (TTree*)hitFile->Get("o2sim");
@@ -254,23 +265,40 @@ void CheckDigits(std::string digifile = "trkdigits.root", std::string hitfile =
254265
auto xyzLocE = gman->getMatrixL2G(chipID) ^ (hit.GetPos()); // inverse conversion from global to local
255266
auto xyzLocS = gman->getMatrixL2G(chipID) ^ (hit.GetPosStart());
256267

257-
o2::math_utils::Vector3D<float> locH; /// Hit, average between start and end pos
258-
locH.SetCoordinates(0.5f * (xyzLocE.X() + xyzLocS.X()), 0.5f * (xyzLocE.Y() + xyzLocS.Y()), 0.5f * (xyzLocE.Z() + xyzLocS.Z()));
268+
// Hit local reference: Both VD and MLOT use response-plane interpolation (in flat local frame).
269+
// For VD, transform curved → flat first, then interpolate.
270+
o2::math_utils::Vector3D<float> locH; /// Hit reference (at response plane)
259271
o2::math_utils::Vector3D<float> locHS; /// Hit, start pos
260272
locHS.SetCoordinates(xyzLocS.X(), xyzLocS.Y(), xyzLocS.Z());
261273
o2::math_utils::Vector3D<float> locHE; /// Hit, end pos
262274
locHE.SetCoordinates(xyzLocE.X(), xyzLocE.Y(), xyzLocE.Z());
263275
o2::math_utils::Vector3D<float> locHF;
264276

277+
if (subDetID == 0) {
278+
// VD: Interpolate to VD reference plane in flat frame; apply same r to X and Z
279+
auto flatSta = seg.curvedToFlat(layer, locHS.X(), locHS.Y());
280+
auto flatEnd = seg.curvedToFlat(layer, locHE.X(), locHE.Y());
281+
float x0 = flatSta.X(), y0 = flatSta.Y(), z0 = locHS.Z();
282+
float dltx = flatEnd.X() - x0, dlty = flatEnd.Y() - y0, dltz = locHE.Z() - z0;
283+
float r = (std::abs(dlty) > 1e-9f) ? (yPlaneVD - y0) / dlty : 0.5f;
284+
locH.SetCoordinates(x0 + r * dltx, yPlaneVD, z0 + r * dltz);
285+
} else {
286+
// MLOT: Interpolate to response plane
287+
float x0 = locHS.X(), y0 = locHS.Y(), z0 = locHS.Z();
288+
float dltx = locHE.X() - x0, dlty = locHE.Y() - y0, dltz = locHE.Z() - z0;
289+
float r = (std::abs(dlty) > 1e-9f) ? (yPlaneMLOT - y0) / dlty : 0.5f;
290+
locH.SetCoordinates(x0 + r * dltx, yPlaneMLOT, z0 + r * dltz);
291+
}
292+
265293
int row = 0, col = 0;
266294
float xlc = 0., zlc = 0.;
267295

268296
if (subDetID == 0) {
269297
Float_t x_flat = 0.f, y_flat = 0.f;
270-
o2::math_utils::Vector2D<float> xyFlatH = seg.curvedToFlat(layer, locH.X(), locH.Y());
298+
// locH is already in flat frame from interpolation above; convert digit to flat for comparison
271299
o2::math_utils::Vector2D<float> xyFlatD = seg.curvedToFlat(layer, locD.X(), locD.Y());
272300
locDF.SetCoordinates(xyFlatD.X(), xyFlatD.Y(), locD.Z());
273-
locHF.SetCoordinates(xyFlatH.X(), xyFlatH.Y(), locH.Z());
301+
locHF.SetCoordinates(locH.X(), locH.Y(), locH.Z()); // locH already in flat frame
274302
seg.localToDetector(locHF.X(), locHF.Z(), row, col, subDetID, layer, disk);
275303
}
276304

0 commit comments

Comments
 (0)