Skip to content
Merged
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
64 changes: 37 additions & 27 deletions PWGEM/Dilepton/Tasks/matchingMFT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <Framework/SliceCache.h>
#include <Framework/runDataProcessing.h>
#include <MCHTracking/TrackExtrap.h>
#include <MathUtils/Utils.h>
#include <ReconstructionDataFormats/GlobalFwdTrack.h>
#include <ReconstructionDataFormats/TrackFwd.h>

Expand All @@ -58,7 +57,6 @@
#include <cstdint>
#include <map>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -173,7 +171,7 @@ struct matchingMFT {
o2::analysis::MlResponseFwdTrack<float> mlResponseFwdTrack;

HistogramRegistry fRegistry{"fRegistry"};
static constexpr std::string_view muon_types[5] = {"MFTMCHMID/", "MFTMCHMIDOtherMatch/", "MFTMCH/", "MCHMID/", "MCH/"};
// static constexpr std::string_view muon_types[5] = {"MFTMCHMID/", "MFTMCHMIDOtherMatch/", "MFTMCH/", "MCHMID/", "MCH/"};

struct matchedCandidate {
float multFT0C{0};
Expand Down Expand Up @@ -218,9 +216,9 @@ struct matchingMFT {
cutsMlArr[i][0] = 0.0;
cutsMlArr[i][1] = cutsMl.value[i];
}
o2::framework::LabeledArray<double> cutsMl = {cutsMlArr.front().data(), nBinsMl, NClassesMl, labelsBins, labelsClasses};
o2::framework::LabeledArray<double> cutsMlTmp = {cutsMlArr.front().data(), nBinsMl, NClassesMl, labelsBins, labelsClasses};

mlResponseFwdTrack.configure(binsMl.value, cutsMl, cutDirMl, NClassesMl);
mlResponseFwdTrack.configure(binsMl.value, cutsMlTmp, cutDirMl, NClassesMl);
if (loadModelsFromCCDB) {
ccdbApi.init(ccdburl);
mlResponseFwdTrack.setModelPathsCCDB(onnxFileNames.value, ccdbApi, onnxPathsCCDB.value, timestampCCDB.value);
Expand All @@ -234,7 +232,7 @@ struct matchingMFT {
}

o2::ccdb::CcdbApi ccdbApi;
Service<o2::ccdb::BasicCCDBManager> ccdb;
Service<o2::ccdb::BasicCCDBManager> ccdb{};
int mRunNumber = -1;
float mBz = 0;
float mZShift = 0;
Expand All @@ -256,9 +254,9 @@ struct matchingMFT {
ccdb->get<TGeoManager>(geoPath);
}
o2::mch::TrackExtrap::setField();
const double centerMFT[3] = {0, 0, -61.4};
o2::field::MagneticField* field = dynamic_cast<o2::field::MagneticField*>(TGeoGlobalMagField::Instance()->GetField());
mBz = field->getBz(centerMFT); // Get field at centre of MFT
std::array<double, 3> centerMFT = {0, 0, -61.4};
auto field = dynamic_cast<o2::field::MagneticField*>(TGeoGlobalMagField::Instance()->GetField());
mBz = field->getBz(centerMFT.data()); // Get field at centre of MFT
LOGF(info, "Bz at center of MFT = %f kZG", mBz);

if (cfgApplyZShiftFromCCDB) {
Expand Down Expand Up @@ -317,7 +315,7 @@ struct matchingMFT {
fRegistry.add("MFTMCHMID/primary/correct/hPDCA_Rabs", "pDCA vs. Rabs;R at absorber end (cm);p #times DCA (GeV/c #upoint cm)", kTH2F, {{100, 0, 100}, {100, 0.0f, 1000}}, false);
fRegistry.add("MFTMCHMID/primary/correct/hChi2_Pt", "chi2;p_{T,#mu} (GeV/c);chi2/ndf", kTH2F, {{100, 0, 10}, {100, 0.0f, 10}}, false);
fRegistry.add("MFTMCHMID/primary/correct/hChi2MFT_Pt", "chi2 MFT/ndf;p_{T,#mu} (GeV/c);chi2 MFT/ndf", kTH2F, {{100, 0, 10}, {100, 0.0f, 10}}, false);
fRegistry.add("MFTMCHMID/primary/correct/hChi2MatchMCHMID_Pt", "chi2 match MCH-MID;p_{T,#mu} (GeV/c);chi2", kTH2F, {{100, 0, 10}, {100, 0.0f, 100}}, false);
fRegistry.add("MFTMCHMID/primary/correct/hChi2MatchMCHMID_Pt", "chi2 match MCH-MID;p_{T,#mu} (GeV/c);chi2", kTH2F, {{100, 0, 10}, {200, 0.0f, 20}}, false);
fRegistry.add("MFTMCHMID/primary/correct/hChi2MatchMCHMFT_Pt", "chi2 match MCH-MFT;p_{T,#mu} (GeV/c);chi2", kTH2F, {{100, 0, 10}, {100, 0.0f, 100}}, false);
fRegistry.add("MFTMCHMID/primary/correct/hDCAxy2D", "DCA x vs. y;DCA_{x} (cm);DCA_{y} (cm)", kTH2F, {{200, -0.1, 0.1}, {200, -0.1, +0.1}}, false);
fRegistry.add("MFTMCHMID/primary/correct/hDCAxy2DinSigma", "DCA x vs. y in sigma;DCA_{x} (#sigma);DCA_{y} (#sigma)", kTH2F, {{200, -10, 10}, {200, -10, +10}}, false);
Expand Down Expand Up @@ -574,7 +572,8 @@ struct matchingMFT {
float pt = propmuonAtPV.getPt();
float eta = propmuonAtPV.getEta();
float phi = propmuonAtPV.getPhi();
o2::math_utils::bringTo02Pi(phi);
// o2::math_utils::bringTo02Pi(phi);
phi = RecoDecay::constrainAngle(phi, 0, 1U);

float cXX = propmuonAtPV.getSigma2X();
float cYY = propmuonAtPV.getSigma2Y();
Expand Down Expand Up @@ -602,10 +601,11 @@ struct matchingMFT {
// float pDCA = propmuonAtPV.getP() * dcaXY;
float dxMP = 999.f, dyMP = 999.f;

pt = propmuonAtPV.getPt();
eta = propmuonAtPV.getEta();
phi = propmuonAtPV.getPhi();
o2::math_utils::bringTo02Pi(phi);
// pt = propmuonAtPV.getPt();
// eta = propmuonAtPV.getEta();
// phi = propmuonAtPV.getPhi();
// o2::math_utils::bringTo02Pi(phi);
// phi = RecoDecay::constrainAngle(phi, 0, 1U);

if constexpr (withMFTCov) {
auto mfttrackcov = mftCovs.rawIteratorAt(map_mfttrackcovs[mfttrack.globalIndex()]);
Expand All @@ -616,7 +616,8 @@ struct matchingMFT {
pt = globalMuonAtPV.getPt();
eta = globalMuonAtPV.getEta();
phi = globalMuonAtPV.getPhi();
o2::math_utils::bringTo02Pi(phi);
// o2::math_utils::bringTo02Pi(phi);
phi = RecoDecay::constrainAngle(phi, 0, 1U);

cXX = globalMuonAtPV.getSigma2X();
cYY = globalMuonAtPV.getSigma2Y();
Expand Down Expand Up @@ -644,11 +645,14 @@ struct matchingMFT {
float ptMatchedMCHMID = propmuonAtPV_Matched.getPt();
float etaMatchedMCHMID = propmuonAtPV_Matched.getEta();
float phiMatchedMCHMID = propmuonAtPV_Matched.getPhi();
o2::math_utils::bringTo02Pi(phiMatchedMCHMID);
// o2::math_utils::bringTo02Pi(phiMatchedMCHMID);
phi = RecoDecay::constrainAngle(phiMatchedMCHMID, 0, 1U);

float dpt = (ptMatchedMCHMID - pt) / pt;
float deta = etaMatchedMCHMID - eta;
float dphi = phiMatchedMCHMID - phi;
o2::math_utils::bringToPMPi(dphi);
// o2::math_utils::bringToPMPi(dphi);
dphi = RecoDecay::constrainAngle(dphi, -M_PI, 1U);

if (std::sqrt(std::pow(deta / maxDEta, 2) + std::pow(dphi / maxDPhi, 2)) > 1.f) {
return;
Expand Down Expand Up @@ -877,7 +881,8 @@ struct matchingMFT {
o2::dataformats::GlobalFwdTrack propmuonAtPV_Matched = propagateMuon(fwdtrack, fwdtrack, collision, propagationPoint::kToVertex, matchingZ, mBz, mZShift);
float etaMatchedMCHMID = propmuonAtPV_Matched.getEta();
float phiMatchedMCHMID = propmuonAtPV_Matched.getPhi();
o2::math_utils::bringTo02Pi(phiMatchedMCHMID);
// o2::math_utils::bringTo02Pi(phiMatchedMCHMID);
phiMatchedMCHMID = RecoDecay::constrainAngle(phiMatchedMCHMID, 0, 1U);

o2::dataformats::GlobalFwdTrack propmuonAtDCA_Matched = propagateMuon(fwdtrack, fwdtrack, collision, propagationPoint::kToDCA, matchingZ, mBz, mZShift);
float dcaX_Matched = propmuonAtDCA_Matched.getX() - collision.posX();
Expand Down Expand Up @@ -915,14 +920,16 @@ struct matchingMFT {
float pt = propmuonAtPV.getPt();
float eta = propmuonAtPV.getEta();
float phi = propmuonAtPV.getPhi();
o2::math_utils::bringTo02Pi(phi);
// o2::math_utils::bringTo02Pi(phi);
phi = RecoDecay::constrainAngle(phi, 0, 1U);
if (refitGlobalMuon) {
pt = propmuonAtPV_Matched.getP() * std::sin(2.f * std::atan(std::exp(-eta)));
}

float deta = etaMatchedMCHMID - eta;
float dphi = phiMatchedMCHMID - phi;
o2::math_utils::bringToPMPi(dphi);
// o2::math_utils::bringToPMPi(dphi);
dphi = RecoDecay::constrainAngle(dphi, -M_PI, 1U);
float dr = std::sqrt(deta * deta + dphi * dphi);
float chi2ndf = muon_tmp.chi2() / (2.f * (mchtrack.nClusters() + mfttrack.nClusters()) - 5.f);

Expand All @@ -942,6 +949,7 @@ struct matchingMFT {
mftsaAtMP.propagateToZhelix(matchingZ, mBz); // propagated to matching plane
float phiMFTatMP = RecoDecay::constrainAngle(mftsaAtMP.getPhi(), 0, 1U);

candidate.ptMCHMID = propmuonAtPV_Matched.getPt();
candidate.rSigned1Pt = mftsaAtMP.getInvQPt() / muonAtMP.getInvQPt();
candidate.dEta = mftsaAtMP.getEta() - muonAtMP.getEta();
candidate.dPhi = RecoDecay::constrainAngle(phiMFTatMP - phiMCHMIDatMP, -o2::constants::math::PIHalf, 1U);
Expand Down Expand Up @@ -1034,7 +1042,7 @@ struct matchingMFT {
if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) {
continue;
}
float centralities[5] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV(), collision.centNGlobal()};
std::array<float, 5> centralities = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV(), collision.centNGlobal()};
if (centralities[eventcuts.cfgCentEstimator] < eventcuts.cfgCentMin || eventcuts.cfgCentMax < centralities[eventcuts.cfgCentEstimator]) {
continue;
}
Expand All @@ -1052,7 +1060,8 @@ struct matchingMFT {

bool isPrimary = mcParticle.isPhysicalPrimary() || mcParticle.producedByGenerator();
float phiGen = mcParticle.phi();
o2::math_utils::bringTo02Pi(phiGen);
// o2::math_utils::bringTo02Pi(phiGen);
phiGen = RecoDecay::constrainAngle(phiGen, 0, 1U);

int ndf = 2 * mfttrack.nClusters() - 5;

Expand Down Expand Up @@ -1090,7 +1099,8 @@ struct matchingMFT {
float pt = trackPar.getPt();
float eta = trackPar.getEta();
float phi = trackPar.getPhi();
o2::math_utils::bringTo02Pi(phi);
// o2::math_utils::bringTo02Pi(phi);
phi = RecoDecay::constrainAngle(phi, 0, 1U);

if (pt < minPtMFTsa || maxPtMFTsa < pt) {
continue;
Expand Down Expand Up @@ -1197,7 +1207,7 @@ struct matchingMFT {
if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) {
continue;
}
float centralities[5] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV(), collision.centNGlobal()};
std::array<float, 5> centralities = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV(), collision.centNGlobal()};
if (centralities[eventcuts.cfgCentEstimator] < eventcuts.cfgCentMin || eventcuts.cfgCentMax < centralities[eventcuts.cfgCentEstimator]) {
continue;
}
Expand Down Expand Up @@ -1253,7 +1263,7 @@ struct matchingMFT {
if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) {
continue;
}
float centralities[5] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV(), collision.centNGlobal()};
std::array<float, 5> centralities = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV(), collision.centNGlobal()};
if (centralities[eventcuts.cfgCentEstimator] < eventcuts.cfgCentMin || eventcuts.cfgCentMax < centralities[eventcuts.cfgCentEstimator]) {
continue;
}
Expand Down Expand Up @@ -1316,7 +1326,7 @@ struct matchingMFT {
if (eventcuts.cfgRequireGoodRCT && !rctChecker.checkTable(collision)) {
continue;
}
float centralities[5] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV(), collision.centNGlobal()};
std::array<float, 5> centralities = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C(), collision.centNTPV(), collision.centNGlobal()};
if (centralities[eventcuts.cfgCentEstimator] < eventcuts.cfgCentMin || eventcuts.cfgCentMax < centralities[eventcuts.cfgCentEstimator]) {
continue;
}
Expand Down
Loading