Skip to content

Commit b7b652a

Browse files
committed
Added dca computation and filters analysis to process findable. Added necessary track propagation dependencies
1 parent 539046d commit b7b652a

File tree

1 file changed

+128
-51
lines changed

1 file changed

+128
-51
lines changed

PWGLF/TableProducer/Strangeness/sigmaminustask.cxx

Lines changed: 128 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@
1515

1616
#include "PWGLF/DataModel/LFKinkDecayTables.h"
1717

18+
#include "Common/Core/trackUtilities.h"
1819
#include "Common/DataModel/EventSelection.h"
1920
#include "Common/DataModel/PIDResponse.h"
2021

22+
#include "CCDB/BasicCCDBManager.h"
23+
#include "DataFormatsParameters/GRPMagField.h"
24+
#include "DataFormatsParameters/GRPObject.h"
25+
#include "DetectorsBase/GeometryManager.h"
26+
#include "DetectorsBase/Propagator.h"
2127
#include "Framework/AnalysisTask.h"
2228
#include "Framework/runDataProcessing.h"
2329
#include "ReconstructionDataFormats/PID.h"
30+
#include "ReconstructionDataFormats/Track.h"
2431

2532
using namespace o2;
2633
using namespace o2::framework;
@@ -52,21 +59,43 @@ struct sigmaminustask {
5259

5360
Configurable<bool> fillOutputTree{"fillOutputTree", true, "If true, fill the output tree with Kink candidates"};
5461

55-
// Configurables for findable tracks (see kinkBuilder.cxx)
56-
Configurable<float> KBminPtMoth{"KBminPtMoth", 0.5, "Minimum pT of the mother"};
57-
Configurable<float> KBmaxPhiDiff{"KBmaxPhiDiff", 100, "Max phi difference between the kink daughter and the mother"};
58-
Configurable<float> KBetaMax{"KBetaMax", 1., "Max eta for both mother and daughter"};
59-
Configurable<float> KBnTPCClusMinDaug{"KBnTPCClusMinDaug", 80, "Min daug NTPC clusters"};
60-
Configurable<float> KBradiusCut{"KBradiusCut", 19.6213f, "Min reconstructed decay radius of the mother"};
61-
Configurable<float> KBdcaMothPv{"KBdcaMothPv", 0.1f, "Max DCA of the mother to PV"};
62-
Configurable<float> KBdcaDaugPv{"KBdcaDaugPv", 0.1f, "Max DCA of the daughter to PV"};
62+
// Configurables for findable tracks (kinkBuilder.cxx efficiency)
63+
Configurable<float> minPtMothKB{"minPtMothKB", 0.5f, "Minimum pT of the mother"};
64+
Configurable<float> maxPhiDiffKB{"maxPhiDiffKB", 100.0f, "Max phi difference between the kink daughter and the mother"};
65+
Configurable<float> maxZDiffKB{"maxZDiffKB", 20.0f, "Max z difference between the kink daughter and the mother"};
66+
Configurable<float> etaMaxKB{"etaMaxKB", 1.0f, "Max eta for both mother and daughter"};
67+
Configurable<float> nTPCClusMinDaugKB{"nTPCClusMinDaugKB", 80, "Min daug NTPC clusters"};
68+
Configurable<float> radiusCutKB{"radiusCutKB", 19.6213f, "Min reconstructed decay radius of the mother"};
69+
Configurable<float> maxDcaMothPvKB{"maxDcaMothPvKB", 0.1f, "Max DCA of the mother to PV"};
70+
Configurable<float> minDcaDaugPvKB{"minDcaDaugPvKB", 0.1f, "Min DCA of the daughter to PV"};
6371

6472
Preslice<aod::KinkCands> mPerCol = aod::track::collisionId;
6573

74+
// Constants
6675
float radToDeg = o2::constants::math::Rad2Deg;
6776

77+
// Services CCDB
78+
Service<o2::ccdb::BasicCCDBManager> ccdb;
79+
Configurable<std::string> ccdbPath{"ccdbPath", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
80+
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
81+
Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
82+
Configurable<int> cfgMaterialCorrection{"cfgMaterialCorrection", static_cast<int>(o2::base::Propagator::MatCorrType::USEMatCorrLUT), "Type of material correction"};
83+
84+
// Runtime variables
85+
int mRunNumber = 0;
86+
float mBz = 0.0f;
87+
o2::base::MatLayerCylSet* matLUT = nullptr;
88+
6889
void init(InitContext const&)
6990
{
91+
// Initialize CCDB
92+
ccdb->setURL(ccdbPath);
93+
ccdb->setCaching(true);
94+
ccdb->setLocalObjectValidityChecking();
95+
ccdb->setFatalWhenNull(true);
96+
97+
matLUT = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>("GLO/Param/MatLUT"));
98+
7099
// Axes
71100
const AxisSpec ptAxis{100, -10, 10, "#it{p}_{T} (GeV/#it{c})"};
72101
const AxisSpec ptUnsignedAxis{100, 0, 10, "#it{p}_{T} (GeV/#it{c})"};
@@ -76,7 +105,7 @@ struct sigmaminustask {
76105
const AxisSpec xiMassAxis{100, 1.2, 1.6, "m_{#Xi} (GeV/#it{c}^{2})"};
77106
const AxisSpec pdgAxis{10001, -5000, 5000, "PDG code"};
78107
const AxisSpec vertexZAxis{100, -15., 15., "vrtx_{Z} [cm]"};
79-
const AxisSpec dcaMothAxis{100, 0, 0.2, "DCA [cm]"};
108+
const AxisSpec dcaMothAxis{100, 0, 0.03, "DCA [cm]"};
80109
const AxisSpec dcaDaugAxis{200, 0, 20, "DCA [cm]"};
81110
const AxisSpec radiusAxis{100, -1, 40, "Decay radius [cm]"};
82111

@@ -85,8 +114,8 @@ struct sigmaminustask {
85114
const AxisSpec radiusResolutionAxis{100, -0.5, 0.5, "(r_{rec} - r_{gen}) / r_{gen}"};
86115

87116
const AxisSpec boolAxis{2, -0.5, 1.5, "Boolean value"};
88-
const AxisSpec filtersAxis{10, -0.5, 9.5, "Filter index"};
89-
const AxisSpec fakeITSAxis{9, -2.5, 6.5, "Fake ITS cluster layer"};
117+
const AxisSpec filtersAxis{12, -0.5, 11.5, "Filter index"};
118+
const AxisSpec fakeITSAxis{8, -1.5, 6.5, "Fake ITS cluster layer"};
90119

91120
// Event selection
92121
rEventSelection.add("hVertexZRec", "hVertexZRec", {HistType::kTH1F, {vertexZAxis}});
@@ -117,8 +146,8 @@ struct sigmaminustask {
117146
}
118147

119148
if (doprocessFindable) {
120-
std::vector<std::string> filterLabels = {"Initial", "ITS/TPC present", "Moth ITS", "Moth p_{T}", "Daug ITS+TPC", "#eta", "#Delta#phi", "Radius", "Collision", "Daug TOF"};
121-
149+
std::vector<std::string> filterLabels = {"Initial", "ITS/TPC present", "ITS/TPC quality", "Moth p_{T}", "min #eta", "max #Delta#phi", "max #Delta Z", "max DCAmoth", "min DCAdaug", "min Radius", "sel8 coll", "Daug TOF"};
150+
122151
// Add findable Sigma histograms
123152
rFindable.add("hfakeITSfindable", "hfakeITSfindable", {HistType::kTH1F, {fakeITSAxis}});
124153
rFindable.add("hFilterIndex", "hFilterIndex", {HistType::kTH1F, {filtersAxis}});
@@ -146,7 +175,28 @@ struct sigmaminustask {
146175
rFindable.add("h2PtDaugFilter_plus_pikink", "h2PtDaugFilter_plus_pikink", {HistType::kTH2F, {filtersAxis, ptUnsignedAxis}});
147176
rFindable.add("h2PtDaugFilter_minus_pikink", "h2PtDaugFilter_minus_pikink", {HistType::kTH2F, {filtersAxis, ptUnsignedAxis}});
148177

178+
rFindable.add("h2DCAMothPt_protonkink", "h2DCAMothPt_protonkink", {HistType::kTH2F, {ptAxis, dcaMothAxis}});
179+
rFindable.add("h2DCADaugPt_protonkink", "h2DCADaugPt_protonkink", {HistType::kTH2F, {ptAxis, dcaDaugAxis}});
180+
rFindable.add("h2DCAMothPt_pikink", "h2DCAMothPt_pikink", {HistType::kTH2F, {ptAxis, dcaMothAxis}});
181+
rFindable.add("h2DCADaugPt_pikink", "h2DCADaugPt_pikink", {HistType::kTH2F, {ptAxis, dcaDaugAxis}});
182+
}
183+
}
184+
185+
void initCCDB(aod::BCs::iterator const& bc)
186+
{
187+
if (mRunNumber == bc.runNumber()) {
188+
return;
189+
}
190+
mRunNumber = bc.runNumber();
191+
LOG(info) << "Initializing CCDB for run " << mRunNumber;
192+
o2::parameters::GRPMagField* grpmag = ccdb->getForRun<o2::parameters::GRPMagField>(grpmagPath, mRunNumber);
193+
o2::base::Propagator::initFieldFromGRP(grpmag);
194+
mBz = grpmag->getNominalL3Field();
195+
if (!matLUT) {
196+
matLUT = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(lutPath));
149197
}
198+
o2::base::Propagator::Instance()->setMatLUT(matLUT);
199+
LOG(info) << "Task initialized for run " << mRunNumber << " with magnetic field " << mBz << " kZG";
150200
}
151201

152202
float alphaAP(const std::array<float, 3>& momMother, const std::array<float, 3>& momKink)
@@ -346,7 +396,6 @@ struct sigmaminustask {
346396
}
347397
}
348398
}
349-
350399
PROCESS_SWITCH(sigmaminustask, processMC, "MC processing", false);
351400

352401
void fillFindableHistograms(int filterIndex, float mcRadius, float recRadius, float ptMoth, float ptDaug, bool isSigmaMinus, bool isPiDaughter)
@@ -375,7 +424,7 @@ struct sigmaminustask {
375424
}
376425

377426
void processFindable(aod::KinkCands const& kinkCands, aod::McTrackLabels const& trackLabelsMC,
378-
TracksFull const& tracks, aod::McParticles const&, CollisionsFullMC const&)
427+
TracksFull const& tracks, aod::McParticles const&, CollisionsFullMC const&, aod::BCs const&)
379428
{
380429
// A - generated findable track pairs map: mcMother.globalIndex() -> (motherTrack.globalIndex(), daughterTrack.globalIndex())
381430
std::unordered_map<int64_t, std::pair<int64_t, int64_t>> allCandsIndices;
@@ -446,32 +495,28 @@ struct sigmaminustask {
446495
if (trackIndices.second == -1 || trackIndices.first == -1) {
447496
continue;
448497
}
498+
449499
// Retrieve mother and daughter tracks and mcParticles
450500
auto motherTrack = tracks.rawIteratorAt(trackIndices.first);
451501
auto daughterTrack = tracks.rawIteratorAt(trackIndices.second);
452502
auto mcLabMoth = trackLabelsMC.rawIteratorAt(motherTrack.globalIndex());
453503
auto mcLabDaug = trackLabelsMC.rawIteratorAt(daughterTrack.globalIndex());
454-
if (!mcLabMoth.has_mcParticle() || !mcLabDaug.has_mcParticle()) {
455-
continue;
456-
}
457504
auto mcMother = mcLabMoth.mcParticle_as<aod::McParticles>();
458505
auto mcDaughter = mcLabDaug.mcParticle_as<aod::McParticles>();
459506

460-
// Compute mass and radii
507+
// Compute useful quantities for histograms
461508
bool isSigmaMinus = (std::abs(mcMother.pdgCode()) == 3112);
462509
bool isPiDaughter = (std::abs(mcDaughter.pdgCode()) == 211);
463-
464-
//float mcMass = std::sqrt(mcMother.e() * mcMother.e() - mcMother.p() * mcMother.p());
465-
//int sigmaSign = mcMother.pdgCode() > 0 ? 1 : -1;
510+
int sigmaSign = mcMother.pdgCode() > 0 ? 1 : -1;
511+
float recPtDaughter = daughterTrack.pt();
512+
float recPtMother = motherTrack.pt();
466513
float mcRadius = std::sqrt((mcMother.vx() - mcDaughter.vx()) * (mcMother.vx() - mcDaughter.vx()) + (mcMother.vy() - mcDaughter.vy()) * (mcMother.vy() - mcDaughter.vy()));
467514
float recRadius = -1.0;
468515
if (findableToKinkCand.find(mcMother.globalIndex()) != findableToKinkCand.end()) {
469516
auto kinkCand = kinkCands.rawIteratorAt(findableToKinkCand[mcMother.globalIndex()]);
470517
recRadius = std::sqrt(kinkCand.xDecVtx() * kinkCand.xDecVtx() + kinkCand.yDecVtx() * kinkCand.yDecVtx());
471518
}
472-
float recPtDaughter = daughterTrack.pt();
473-
float recPtMother = motherTrack.pt();
474-
519+
475520
// Check for detector mismatches in ITS mother tracks
476521
auto mask_value = mcLabMoth.mcMask();
477522
int mismatchITS_index = -1;
@@ -487,76 +532,115 @@ struct sigmaminustask {
487532
int filterIndex = 0;
488533
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
489534

490-
// 1 - tracks with right ITS, TPC, TOF signals
535+
// 1 - tracks with right ITS, TPC, TOF signals
491536
if (motherTrack.has_collision() && motherTrack.hasITS() && !motherTrack.hasTPC() && !motherTrack.hasTOF() &&
492537
daughterTrack.hasITS() && daughterTrack.hasTPC()) {
493538
filterIndex += 1;
494539
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
495540
rFindable.fill(HIST("hfakeITSfindable"), mismatchITS_index);
496-
497541
} else {
498542
continue;
499543
}
500544

501-
// 2, 3 - mother track ITS properties
502-
if (motherTrack.itsNCls() < 6 &&
503-
motherTrack.itsNClsInnerBarrel() == 3 && motherTrack.itsChi2NCl() < 36) {
545+
// 2 - moth+daug track quality cuts
546+
bool motherGoodITS = motherTrack.hasITS() && motherTrack.itsNCls() < 6 && motherTrack.itsNClsInnerBarrel() == 3 && motherTrack.itsChi2NCl() < 36;
547+
bool daughterGoodITSTPC = daughterTrack.hasITS() && daughterTrack.hasTPC() && daughterTrack.itsNClsInnerBarrel() == 0 &&
548+
daughterTrack.itsNCls() < 4 && daughterTrack.tpcNClsCrossedRows() > 0.8 * daughterTrack.tpcNClsFindable() && daughterTrack.tpcNClsFound() > nTPCClusMinDaugKB;
549+
if (motherGoodITS && daughterGoodITSTPC) {
504550
filterIndex += 1;
505551
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
506552
} else {
507553
continue;
508554
}
509555

510-
if (motherTrack.pt() > KBminPtMoth) {
556+
// 3 - mother track min pT
557+
if (motherTrack.pt() > minPtMothKB) {
511558
filterIndex += 1;
512559
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
513560
} else {
514561
continue;
515562
}
516563

517-
// 4 - daughter track ITS+TPC properties
518-
if (daughterTrack.itsNClsInnerBarrel() == 0 && daughterTrack.itsNCls() < 4 &&
519-
daughterTrack.tpcNClsCrossedRows() > 0.8 * daughterTrack.tpcNClsFindable() && daughterTrack.tpcNClsFound() > KBnTPCClusMinDaug) {
564+
// 4 - geometric cuts: eta
565+
if (std::abs(motherTrack.eta()) < etaMaxKB && std::abs(daughterTrack.eta()) < etaMaxKB) {
520566
filterIndex += 1;
521567
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
522568
} else {
523569
continue;
524570
}
525571

526-
// 5 - geometric cuts: eta
527-
if (std::abs(motherTrack.eta()) < KBetaMax && std::abs(daughterTrack.eta()) < KBetaMax) {
572+
// 5 - geometric cuts: phi difference
573+
if (std::abs(motherTrack.phi() - daughterTrack.phi()) * radToDeg < maxPhiDiffKB) {
528574
filterIndex += 1;
529575
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
530576
} else {
531577
continue;
532578
}
533579

534-
// 6 - geometric cuts: phi difference
535-
if (std::abs(motherTrack.phi() - daughterTrack.phi()) * radToDeg < KBmaxPhiDiff) {
580+
// DCA calculation: initialization CCDB
581+
auto collision = motherTrack.template collision_as<CollisionsFullMC>();
582+
auto bc = collision.template bc_as<aod::BCs>();
583+
initCCDB(bc);
584+
const o2::math_utils::Point3D<float> collVtx{collision.posX(), collision.posY(), collision.posZ()};
585+
o2::track::TrackParCov trackParCovMoth = getTrackParCov(motherTrack);
586+
o2::track::TrackParCov trackParCovDaug = getTrackParCov(daughterTrack);
587+
588+
// get DCA to PV for mother and daughter tracks
589+
std::array<float, 2> dcaInfoMoth;
590+
o2::base::Propagator::Instance()->propagateToDCA(collVtx, trackParCovMoth, mBz, 2.f, static_cast<o2::base::Propagator::MatCorrType>(cfgMaterialCorrection.value), &dcaInfoMoth);
591+
std::array<float, 2> dcaInfoDaug;
592+
o2::base::Propagator::Instance()->propagateToDCA(collVtx, trackParCovDaug, mBz, 2.f, static_cast<o2::base::Propagator::MatCorrType>(cfgMaterialCorrection.value), &dcaInfoDaug);
593+
float dcaXYMother = std::abs(dcaInfoMoth[0]);
594+
float dcaXYDaughter = std::abs(dcaInfoDaug[0]);
595+
if (isPiDaughter) {
596+
rFindable.fill(HIST("h2DCAMothPt_pikink"), sigmaSign * recPtMother, dcaXYMother);
597+
rFindable.fill(HIST("h2DCADaugPt_pikink"), sigmaSign * recPtDaughter, dcaXYDaughter);
598+
} else {
599+
rFindable.fill(HIST("h2DCAMothPt_protonkink"), sigmaSign * recPtMother, dcaXYMother);
600+
rFindable.fill(HIST("h2DCADaugPt_protonkink"), sigmaSign * recPtDaughter, dcaXYDaughter);
601+
}
602+
603+
// 6 - max Z difference
604+
if (std::abs(trackParCovMoth.getZ() - trackParCovDaug.getZ()) < maxZDiffKB) {
605+
filterIndex += 1;
606+
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
607+
} else {
608+
continue;
609+
}
610+
611+
// 7 - DCA mother
612+
if (dcaXYMother < maxDcaMothPvKB) {
536613
filterIndex += 1;
537614
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
538615
} else {
539616
continue;
540617
}
541-
542-
// 7 - radius cut
543-
if (recRadius > KBradiusCut) {
618+
619+
// 8 - DCA daughter
620+
if (dcaXYDaughter > minDcaDaugPvKB) {
544621
filterIndex += 1;
545622
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
546623
} else {
547624
continue;
548625
}
549626

550-
// 8 - collision selection
551-
auto collision = motherTrack.template collision_as<CollisionsFullMC>();
627+
// 9 - radius cut
628+
if (recRadius > radiusCutKB) {
629+
filterIndex += 1;
630+
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
631+
} else {
632+
continue;
633+
}
634+
635+
// 10 - collision selection
552636
if (!(std::abs(collision.posZ()) > cutzvertex || !collision.sel8())) {
553637
filterIndex += 1;
554638
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
555639
} else {
556640
continue;
557641
}
558642

559-
// 9 - TOF daughter presence
643+
// 11 - TOF daughter presence
560644
if (daughterTrack.hasTOF()) {
561645
filterIndex += 1;
562646
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, isSigmaMinus, isPiDaughter);
@@ -572,10 +656,3 @@ WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
572656
return WorkflowSpec{
573657
adaptAnalysisTask<sigmaminustask>(cfgc)};
574658
}
575-
576-
// TO DO:
577-
// 2) Histogram of fake its tracks of mothers among findable not found candidates
578-
// 2.1) -1 index for not fake, 0,1,2,3 etc. for fake ITS tracks, with index as layer of fake cluster
579-
// 3) Add DCA mother and daughter to PV using track propagation from hyperhelium or hypertriton tasks
580-
// 3.1) Do it for each findable, add cuts on DCA to the filterIndex histos to understand what's the most effective cut
581-
// 4) Open PR

0 commit comments

Comments
 (0)