Skip to content

Commit 558da00

Browse files
mcoquet642Maurice Coquet
andauthored
[PWGDQ] Loading z shift of fwdtracks from ccdb (#14369)
Co-authored-by: Maurice Coquet <mcoquet@alicecerno2.cern.ch>
1 parent 60a6ced commit 558da00

File tree

4 files changed

+53
-15
lines changed

4 files changed

+53
-15
lines changed

PWGDQ/Core/VarManager.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ bool VarManager::fgUsedVars[VarManager::kNVars] = {false};
3030
bool VarManager::fgUsedKF = false;
3131
float VarManager::fgMagField = 0.5;
3232
float VarManager::fgzMatching = -77.5;
33+
float VarManager::fgzShiftFwd = 0.0;
3334
float VarManager::fgValues[VarManager::kNVars] = {0.0f};
3435
float VarManager::fgTPCInterSectorBoundary = 1.0; // cm
3536
int VarManager::fgITSROFbias = 0;

PWGDQ/Core/VarManager.h

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,12 @@ class VarManager : public TObject
10521052
return fgzMatching;
10531053
}
10541054

1055+
// Set z shift for forward tracks
1056+
static void SetZShift(float z)
1057+
{
1058+
fgzShiftFwd = z;
1059+
}
1060+
10551061
// Setup the 2 prong KFParticle
10561062
static void SetupTwoProngKFParticle(float magField)
10571063
{
@@ -1333,6 +1339,7 @@ class VarManager : public TObject
13331339

13341340
static float fgMagField;
13351341
static float fgzMatching;
1342+
static float fgzShiftFwd;
13361343
static float fgCenterOfMassEnergy; // collision energy
13371344
static float fgMassofCollidingParticle; // mass of the colliding particle
13381345
static float fgTPCInterSectorBoundary; // TPC inter-sector border size at the TPC outer radius, in cm
@@ -1474,7 +1481,7 @@ KFPVertex VarManager::createKFPVertexFromCollision(const T& collision)
14741481
template <typename T, typename C>
14751482
o2::dataformats::GlobalFwdTrack VarManager::PropagateMuon(const T& muon, const C& collision, const int endPoint)
14761483
{
1477-
o2::track::TrackParCovFwd fwdtrack = FwdToTrackPar(muon, muon);
1484+
o2::track::TrackParCovFwd fwdtrack = o2::aod::fwdtrackutils::getTrackParCovFwdShift(muon, fgzShiftFwd, muon);
14781485
o2::dataformats::GlobalFwdTrack propmuon;
14791486
if (static_cast<int>(muon.trackType()) > 2) {
14801487
o2::dataformats::GlobalFwdTrack track;
@@ -1502,12 +1509,8 @@ o2::dataformats::GlobalFwdTrack VarManager::PropagateMuon(const T& muon, const C
15021509
propmuon.setCovariances(proptrack.getCovariances());
15031510

15041511
} else if (static_cast<int>(muon.trackType()) < 2) {
1505-
double centerMFT[3] = {0, 0, -61.4};
1506-
o2::field::MagneticField* field = static_cast<o2::field::MagneticField*>(TGeoGlobalMagField::Instance()->GetField());
1507-
auto Bz = field->getBz(centerMFT); // Get field at centre of MFT
1508-
auto geoMan = o2::base::GeometryManager::meanMaterialBudget(muon.x(), muon.y(), muon.z(), collision.posX(), collision.posY(), collision.posZ());
1509-
auto x2x0 = static_cast<float>(geoMan.meanX2X0);
1510-
fwdtrack.propagateToVtxhelixWithMCS(collision.posZ(), {collision.posX(), collision.posY()}, {collision.covXX(), collision.covYY()}, Bz, x2x0);
1512+
std::array<double, 3> dcaInfOrig{999.f, 999.f, 999.f};
1513+
fwdtrack.propagateToDCAhelix(fgMagField, {collision.posX(), collision.posY(), collision.posZ()}, dcaInfOrig);
15111514
propmuon.setParameters(fwdtrack.getParameters());
15121515
propmuon.setZ(fwdtrack.getZ());
15131516
propmuon.setCovariances(fwdtrack.getCovariances());
@@ -1610,14 +1613,15 @@ void VarManager::FillGlobalMuonRefit(T1 const& muontrack, T2 const& mfttrack, co
16101613
double py = propmuon.getP() * sin(M_PI / 2 - atan(mfttrack.tgl())) * sin(mfttrack.phi());
16111614
double pz = propmuon.getP() * cos(M_PI / 2 - atan(mfttrack.tgl()));
16121615
double pt = std::sqrt(std::pow(px, 2) + std::pow(py, 2));
1613-
values[kX] = mfttrack.x();
1614-
values[kY] = mfttrack.y();
1615-
values[kZ] = mfttrack.z();
1616-
values[kTgl] = mfttrack.tgl();
1616+
auto mftprop = o2::aod::fwdtrackutils::getTrackParCovFwdShift(mfttrack, fgzShiftFwd);
1617+
values[kX] = mftprop.getX();
1618+
values[kY] = mftprop.getY();
1619+
values[kZ] = mftprop.getZ();
1620+
values[kTgl] = mftprop.getTgl();
16171621
values[kPt] = pt;
16181622
values[kPz] = pz;
1619-
values[kEta] = mfttrack.eta();
1620-
values[kPhi] = mfttrack.phi();
1623+
values[kEta] = mftprop.getEta();
1624+
values[kPhi] = mftprop.getPhi();
16211625
}
16221626
}
16231627

@@ -1630,7 +1634,7 @@ void VarManager::FillGlobalMuonRefitCov(T1 const& muontrack, T2 const& mfttrack,
16301634
if constexpr ((MuonfillMap & MuonCov) > 0) {
16311635
if constexpr ((MFTfillMap & MFTCov) > 0) {
16321636
o2::dataformats::GlobalFwdTrack propmuon = PropagateMuon(muontrack, collision);
1633-
o2::track::TrackParCovFwd mft = FwdToTrackPar(mfttrack, mftcov);
1637+
auto mft = o2::aod::fwdtrackutils::getTrackParCovFwdShift(mfttrack, fgzShiftFwd, mftcov);
16341638

16351639
o2::dataformats::GlobalFwdTrack globalRefit = o2::aod::fwdtrackutils::refitGlobalMuonCov(propmuon, mft);
16361640
values[kX] = globalRefit.getX();
@@ -2695,7 +2699,7 @@ void VarManager::FillTrack(T const& track, float* values)
26952699
values[kMuonTimeRes] = track.trackTimeRes();
26962700
}
26972701
// Quantities based on the muon covariance table
2698-
if constexpr ((fillMap & ReducedMuonCov) > 0 || (fillMap & MuonCov) > 0 || (fillMap & MuonCovRealign) > 0) {
2702+
if constexpr ((fillMap & ReducedMuonCov) > 0) {
26992703
values[kX] = track.x();
27002704
values[kY] = track.y();
27012705
values[kZ] = track.z();
@@ -2716,6 +2720,29 @@ void VarManager::FillTrack(T const& track, float* values)
27162720
values[kMuonC1Pt2Tgl] = track.c1PtTgl();
27172721
values[kMuonC1Pt21Pt2] = track.c1Pt21Pt2();
27182722
}
2723+
if constexpr ((fillMap & MuonCov) > 0 || (fillMap & MuonCovRealign) > 0) {
2724+
auto muonTrack = o2::aod::fwdtrackutils::getTrackParCovFwdShift(track, fgzShiftFwd, track);
2725+
auto muonCov = muonTrack.getCovariances();
2726+
values[kX] = muonTrack.getX();
2727+
values[kY] = muonTrack.getY();
2728+
values[kZ] = muonTrack.getZ();
2729+
values[kTgl] = muonTrack.getTgl();
2730+
values[kMuonCXX] = muonCov(0, 0);
2731+
values[kMuonCXY] = muonCov(0, 1);
2732+
values[kMuonCYY] = muonCov(1, 1);
2733+
values[kMuonCPhiX] = muonCov(2, 0);
2734+
values[kMuonCPhiY] = muonCov(2, 1);
2735+
values[kMuonCPhiPhi] = muonCov(2, 2);
2736+
values[kMuonCTglX] = muonCov(3, 0);
2737+
values[kMuonCTglY] = muonCov(3, 1);
2738+
values[kMuonCTglPhi] = muonCov(3, 2);
2739+
values[kMuonCTglTgl] = muonCov(3, 3);
2740+
values[kMuonC1Pt2X] = muonCov(4, 0);
2741+
values[kMuonC1Pt2Y] = muonCov(4, 1);
2742+
values[kMuonC1Pt2Phi] = muonCov(4, 2);
2743+
values[kMuonC1Pt2Tgl] = muonCov(4, 3);
2744+
values[kMuonC1Pt21Pt2] = muonCov(4, 4);
2745+
}
27192746

27202747
// Quantities based on the pair table(s)
27212748
if constexpr ((fillMap & Pair) > 0) {

PWGDQ/TableProducer/tableMakerMC_withAssoc.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ struct TableMakerMC {
207207
Configurable<std::string> fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
208208
Configurable<std::string> fGeoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
209209
Configurable<std::string> fGrpMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
210+
Configurable<std::string> fZShiftPath{"zShiftPath", "Users/m/mcoquet/ZShift", "CCDB path for z shift to apply to forward tracks"};
210211
Configurable<std::string> fGrpMagPathRun2{"grpmagPathRun2", "GLO/GRP/GRP", "CCDB path of the GRPObject (Usage for Run 2)"};
211212
Configurable<int64_t> timestampCCDB{"timestampCCDB", -1, "timestamp of the ONNX file for ML model used to query in CCDB"};
212213
} fConfigCCDB;
@@ -1179,10 +1180,14 @@ struct TableMakerMC {
11791180
}
11801181
} else {
11811182
fGrpMag = fCCDB->getForTimeStamp<o2::parameters::GRPMagField>(fConfigCCDB.fGrpMagPath, bcs.begin().timestamp());
1183+
auto* fZShift = fCCDB->getForTimeStamp<std::vector<float>>(fConfigCCDB.fZShiftPath, bcs.begin().timestamp());
11821184
if (fGrpMag != nullptr) {
11831185
o2::base::Propagator::initFieldFromGRP(fGrpMag);
11841186
VarManager::SetMagneticField(fGrpMag->getNominalL3Field());
11851187
}
1188+
if (fZShift != nullptr && !fZShift->empty()) {
1189+
VarManager::SetZShift((*fZShift)[0]);
1190+
}
11861191
if (fConfigVariousOptions.fPropMuon) {
11871192
VarManager::SetupMuonMagField();
11881193
}

PWGDQ/TableProducer/tableMaker_withAssoc.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ struct TableMaker {
241241
Configurable<int64_t> fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"};
242242
Configurable<std::string> fConfigGeoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
243243
Configurable<std::string> fConfigGrpMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
244+
Configurable<std::string> fZShiftPath{"zShiftPath", "Users/m/mcoquet/ZShift", "CCDB path for z shift to apply to forward tracks"};
244245
Configurable<std::string> fConfigGrpMagPathRun2{"grpmagPathRun2", "GLO/GRP/GRP", "CCDB path of the GRPObject (Usage for Run 2)"};
245246
} fConfigCCDB;
246247

@@ -1480,10 +1481,14 @@ struct TableMaker {
14801481
}
14811482
} else {
14821483
fGrpMag = fCCDB->getForTimeStamp<o2::parameters::GRPMagField>(fConfigCCDB.fConfigGrpMagPath, bcs.begin().timestamp());
1484+
auto* fZShift = fCCDB->getForTimeStamp<std::vector<float>>(fConfigCCDB.fZShiftPath, bcs.begin().timestamp());
14831485
if (fGrpMag != nullptr) {
14841486
o2::base::Propagator::initFieldFromGRP(fGrpMag);
14851487
VarManager::SetMagneticField(fGrpMag->getNominalL3Field());
14861488
}
1489+
if (fZShift != nullptr && !fZShift->empty()) {
1490+
VarManager::SetZShift((*fZShift)[0]);
1491+
}
14871492
if (fConfigVariousOptions.fPropMuon) {
14881493
VarManager::SetupMuonMagField();
14891494
}

0 commit comments

Comments
 (0)