Skip to content

Commit c4c3694

Browse files
authored
Refactor V0 selection logic and configuration parameters
1 parent 400e948 commit c4c3694

1 file changed

Lines changed: 83 additions & 69 deletions

File tree

PWGHF/HFC/TableProducer/correlatorXicHadrons.cxx

Lines changed: 83 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ struct HfCorrelatorXicHadronsSelection {
128128
Configurable<float> ptCandMin{"ptCandMin", 1., "min. cand. pT"};
129129

130130
struct : ConfigurableGroup {
131-
Configurable<float> cfgV0radiusMin{"cfgV0radiusMin", 1.2, "minimum decay radius"};
132-
Configurable<float> cfgDCAPosToPVMin{"cfgDCAPosToPVMin", 0.05, "minimum DCA to PV for positive track"};
133-
Configurable<float> cfgDCANegToPVMin{"cfgDCANegToPVMin", 0.2, "minimum DCA to PV for negative track"};
134-
Configurable<float> cfgV0CosPA{"cfgV0CosPA", 0.995, "minimum v0 cosine"};
135-
Configurable<float> cfgDCAV0Dau{"cfgDCAV0Dau", 1.0, "maximum DCA between daughters"};
136-
Configurable<float> cfgV0PtMin{"cfgV0PtMin", 0, "minimum pT for lambda"};
137-
Configurable<float> cfgV0LifeTime{"cfgV0LifeTime", 30., "maximum lambda lifetime"};
138131
Configurable<float> cfgPV{"cfgPV", 10., "maximum z-vertex"};
139132
Configurable<int> cfgMaxOccupancy{"cfgMaxOccupancy", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"};
140133
Configurable<int> cfgMinOccupancy{"cfgMinOccupancy", 0, "maximum occupancy of tracks in neighbouring collisions in a given time range"};
@@ -221,37 +214,6 @@ struct HfCorrelatorXicHadronsSelection {
221214
candSel(isCandFound);
222215
}
223216

224-
template <typename TCollision, typename V0>
225-
bool selectionV0(TCollision const& collision, V0 const& candidate)
226-
{
227-
if (candidate.v0radius() < cfgV0.cfgV0radiusMin) {
228-
return false;
229-
}
230-
if (std::abs(candidate.dcapostopv()) < cfgV0.cfgDCAPosToPVMin) {
231-
return false;
232-
}
233-
if (std::abs(candidate.dcanegtopv()) < cfgV0.cfgDCANegToPVMin) {
234-
return false;
235-
}
236-
if (candidate.v0cosPA() < cfgV0.cfgV0CosPA) {
237-
return false;
238-
}
239-
if (std::abs(candidate.dcaV0daughters()) > cfgV0.cfgDCAV0Dau) {
240-
return false;
241-
}
242-
if (candidate.pt() < cfgV0.cfgV0PtMin) {
243-
return false;
244-
}
245-
if (std::abs(candidate.yLambda()) > yCandMax) {
246-
return false;
247-
}
248-
if (candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda > cfgV0.cfgV0LifeTime) {
249-
return false;
250-
}
251-
252-
return true;
253-
}
254-
255217
template <typename TCollision>
256218
bool eventSelV0(TCollision const& col)
257219
{
@@ -292,12 +254,7 @@ struct HfCorrelatorXicHadronsSelection {
292254
candSel(isCandFound);
293255
return;
294256
}
295-
for (const auto& v0 : V0s) {
296-
if (selectionV0(collision, v0)) {
297-
isCandFound = true;
298-
break;
299-
}
300-
}
257+
isCandFound = true;
301258
candSel(isCandFound);
302259
}
303260
PROCESS_SWITCH(HfCorrelatorXicHadronsSelection, processV0Selection, "Process V0 Collision Selection for Data", false);
@@ -404,17 +361,27 @@ struct HfCorrelatorXicHadrons {
404361
} cfgXicCand;
405362

406363
struct : ConfigurableGroup {
407-
Configurable<float> cfgDaughPrPtMax{"cfgDaughPrPtMax", 5.f, "max. pT daughter proton"};
408-
Configurable<float> cfgDaughPrPtMin{"cfgDaughPrPtMin", 0.3f, "min. pT daughter proton"};
409-
Configurable<float> cfgDaughPiPtMax{"cfgDaughPiPtMax", 10.f, "max. pT daughter pion"};
410-
Configurable<float> cfgDaughPiPtMin{"cfgDaughPiPtMin", 0.3f, "min. pT daughter pion"};
411-
Configurable<float> cfgDaughPIDCutsTPCPr{"cfgDaughPIDCutsTPCPr", 2.5f, "max. TPC nSigma proton"};
412-
Configurable<float> cfgDaughPIDCutsTPCPi{"cfgDaughPIDCutsTPCPi", 2.5f, "max. TPC nSigma pion"};
413-
Configurable<float> cfgDaughPIDCutsTOFPi{"cfgDaughPIDCutsTOFPi", 2.5f, "max. TOF nSigma pion"};
414-
Configurable<float> cfgDaughPIDCutsTOFPr{"cfgDaughPIDCutsTOFPr", 2.5f, "max. TOF nSigma pion"};
415-
Configurable<float> cfgHypMassWindow{"cfgHypMassWindow", 0.1f, "single lambda mass selection"};
364+
Configurable<float> cfgDaughPrPtMax{"cfgDaughPrPtMax", 5., "max. pT Daughter Proton"};
365+
Configurable<float> cfgDaughPrPtMin{"cfgDaughPrPtMin", 0.3, "min. pT Daughter Proton"};
366+
Configurable<float> cfgDaughPiPtMax{"cfgDaughPiPtMax", 10., "max. pT Daughter Pion"};
367+
Configurable<float> cfgDaughPiPtMin{"cfgDaughPiPtMin", 0.3, "min. pT Daughter Pion"};
368+
Configurable<float> cfgDaughPIDCutsTPCPr{"cfgDaughPIDCutsTPCPr", 2.5, "max. TPCnSigma Proton"};
369+
Configurable<float> cfgDaughPIDCutsTPCPi{"cfgDaughPIDCutsTPCPi", 2.5, "max. TPCnSigma Pion"};
370+
Configurable<float> cfgDaughPIDCutsTOFPi{"cfgDaughPIDCutsTOFPi", 2.5, "max. TOFnSigma Pion"};
371+
Configurable<float> cfgDaughPIDCutsTOFPr{"cfgDaughPIDCutsTOFPr", 2.5, "max. TOFnSigma Pion"};
372+
Configurable<float> cfgHypMassWindow{"cfgHypMassWindow", 0.1, "single lambda mass selection"};
416373
Configurable<bool> cfgIsCorrCollMatchV0{"cfgIsCorrCollMatchV0", true, "check if daughter and mother collision are same"};
417374
Configurable<bool> cfgCalDataDrivenEffPr{"cfgCalDataDrivenEffPr", false, "calculate data driven efficiency of proton using Lambda"};
375+
Configurable<float> cfgV0radiusMin{"cfgV0radiusMin", 1.2, "minimum decay radius"};
376+
Configurable<float> cfgDCAPosToPVMin{"cfgDCAPosToPVMin", 0.05, "minimum DCA to PV for positive track"};
377+
Configurable<float> cfgDCANegToPVMin{"cfgDCANegToPVMin", 0.2, "minimum DCA to PV for negative track"};
378+
Configurable<float> cfgV0CosPA{"cfgV0CosPA", 0.995, "minimum v0 cosine"};
379+
Configurable<float> cfgDCAV0Dau{"cfgDCAV0Dau", 1.0, "maximum DCA between daughters"};
380+
Configurable<float> cfgV0PtMin{"cfgV0PtMin", 0, "minimum pT for lambda"};
381+
Configurable<float> cfgV0LifeTime{"cfgV0LifeTime", 30., "maximum lambda lifetime"};
382+
Configurable<int> cfgMaxOccupancy{"cfgMaxOccupancy", 999999, "maximum occupancy of tracks in neighbouring collisions in a given time range"};
383+
Configurable<int> cfgMinOccupancy{"cfgMinOccupancy", 0, "maximum occupancy of tracks in neighbouring collisions in a given time range"};
384+
Configurable<float> cfgPV{"cfgPV", 10., "maximum z-vertex"};
418385
Configurable<bool> calEffV0{"calEffV0", false, "calculate lambda0 efficiency"};
419386
} cfgV0;
420387

@@ -632,6 +599,37 @@ struct HfCorrelatorXicHadrons {
632599
}
633600
}
634601

602+
template <typename TCollision, typename V0>
603+
bool selectionV0(TCollision const& collision, V0 const& candidate)
604+
{
605+
if (candidate.v0radius() < cfgV0.cfgV0radiusMin) {
606+
return false;
607+
}
608+
if (std::abs(candidate.dcapostopv()) < cfgV0.cfgDCAPosToPVMin) {
609+
return false;
610+
}
611+
if (std::abs(candidate.dcanegtopv()) < cfgV0.cfgDCANegToPVMin) {
612+
return false;
613+
}
614+
if (candidate.v0cosPA() < cfgV0.cfgV0CosPA) {
615+
return false;
616+
}
617+
if (std::abs(candidate.dcaV0daughters()) > cfgV0.cfgDCAV0Dau) {
618+
return false;
619+
}
620+
if (candidate.pt() < cfgV0.cfgV0PtMin) {
621+
return false;
622+
}
623+
if (std::abs(candidate.yLambda()) > cfgXicCand.yCandMax) {
624+
return false;
625+
}
626+
if (candidate.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda > cfgV0.cfgV0LifeTime) {
627+
return false;
628+
}
629+
630+
return true;
631+
}
632+
635633
template <typename Tracktype, typename V0Type>
636634
bool isSelectedV0Daughter(Tracktype const& track, V0Type v0, int pid)
637635
{
@@ -698,21 +696,25 @@ struct HfCorrelatorXicHadrons {
698696
// ========================================
699697
// Efficiency calculation block
700698
// ========================================
701-
template <bool IsMc, typename V0, typename TrackType>
702-
void fillEffV0(V0 const& v0s,
699+
template <bool IsMc, typename CollType, typename V0, typename TrackType, typename PartType>
700+
void fillEffV0(CollType const& col,
701+
V0 const& v0s,
703702
TrackType const&,
704-
aod::McParticles const& mcParticles)
703+
PartType const& mcParticles)
705704
{
705+
int countV0 = 1;
706706
// Data-driven efficiency calculation for protons using Lambda
707707
for (const auto& v0 : v0s) {
708+
bool passV0Sel = selectionV0(col, v0);
709+
708710
auto const& trackV0Pos = v0.template posTrack_as<TrackType>();
709711
auto const& trackV0Neg = v0.template negTrack_as<TrackType>();
710712
if (cfgV0.cfgIsCorrCollMatchV0 && ((v0.collisionId() != trackV0Pos.collisionId()) || (v0.collisionId() != trackV0Neg.collisionId()))) {
711713
continue;
712714
}
713715

714716
// Process Lambda (proton + pion)
715-
if (std::abs(o2::constants::physics::MassLambda - v0.mLambda()) < cfgV0.cfgHypMassWindow) {
717+
if (passV0Sel && std::abs(o2::constants::physics::MassLambda - v0.mLambda()) < cfgV0.cfgHypMassWindow) {
716718
entryHadron(v0.mLambda(), trackV0Pos.eta(), trackV0Pos.pt() * trackV0Pos.sign(), 0, 0, v0.pt());
717719
entryTrkPID(trackV0Pos.tpcNSigmaPr(), trackV0Pos.tpcNSigmaKa(), trackV0Pos.tpcNSigmaPi(), trackV0Pos.tofNSigmaPr(), trackV0Pos.tofNSigmaKa(), trackV0Pos.tofNSigmaPi());
718720

@@ -736,7 +738,7 @@ struct HfCorrelatorXicHadrons {
736738
}
737739
}
738740

739-
if (std::abs(o2::constants::physics::MassLambda - v0.mAntiLambda()) < cfgV0.cfgHypMassWindow) {
741+
if (passV0Sel && std::abs(o2::constants::physics::MassLambda - v0.mAntiLambda()) < cfgV0.cfgHypMassWindow) {
740742
entryHadron(v0.mAntiLambda(), trackV0Neg.eta(), trackV0Neg.pt() * trackV0Neg.sign(), 0, 0, v0.pt());
741743
entryTrkPID(trackV0Neg.tpcNSigmaPr(), trackV0Neg.tpcNSigmaKa(), trackV0Neg.tpcNSigmaPi(), trackV0Neg.tofNSigmaPr(), trackV0Neg.tofNSigmaKa(), trackV0Neg.tofNSigmaPi());
742744

@@ -769,7 +771,8 @@ struct HfCorrelatorXicHadrons {
769771
auto const& partV0Pos = trackV0Pos.mcParticle();
770772
auto const& partV0Neg = trackV0Neg.mcParticle();
771773

772-
if (v0Mc.pdgCode() == kLambda0) {
774+
if (passV0Sel && v0Mc.pdgCode() == kLambda0) {
775+
if (isSelectedV0Daughter(trackV0Pos, v0, kProton) && isSelectedV0Daughter(trackV0Neg, v0, kPiMinus)) {
773776
registry.fill(HIST("hV0LambdaMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
774777
registry.fill(HIST("hV0LambdaReflMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
775778
if (cfgV0.calEffV0 && v0Mc.isPhysicalPrimary() && v0Mc.producedByGenerator()) {
@@ -782,7 +785,9 @@ struct HfCorrelatorXicHadrons {
782785
registry.fill(HIST("hV0LambdaReflPiKRejMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
783786
}
784787
}
785-
if (v0Mc.pdgCode() == kLambda0Bar) {
788+
}
789+
if (passV0Sel && v0Mc.pdgCode() == kLambda0Bar) {
790+
if (isSelectedV0Daughter(trackV0Neg, v0, kProtonBar) && isSelectedV0Daughter(trackV0Pos, v0, kPiPlus)) {
786791
registry.fill(HIST("hV0LambdaMcRec"), v0.mAntiLambda(), v0.pt(), partV0Neg.pt());
787792
registry.fill(HIST("hV0LambdaReflMcRec"), v0.mLambda(), v0.pt(), partV0Pos.pt());
788793

@@ -796,12 +801,10 @@ struct HfCorrelatorXicHadrons {
796801
}
797802
}
798803
}
799-
}
800-
801-
if constexpr (IsMc) {
802-
if (cfgV0.calEffV0) {
804+
if (cfgV0.calEffV0 && countV0 == 1) {
805+
auto genPart = mcParticles.sliceBy(perTrueCollision, v0Mc.mcCollisionId());
803806

804-
for (const auto& particle : mcParticles) {
807+
for (const auto& particle : genPart) {
805808

806809
if (std::abs(particle.pdgCode()) != kLambda0) {
807810
continue;
@@ -814,13 +817,14 @@ struct HfCorrelatorXicHadrons {
814817
continue;
815818
}
816819

817-
auto daughterParts = particle.daughters_as<aod::McParticles>();
820+
auto daughterParts = particle.template daughters_as<aod::McParticles>();
818821
const int8_t nDaughtersV0 = 2;
819822

820823
if (daughterParts.size() != nDaughtersV0) {
821824
continue;
822825
}
823826

827+
int8_t countPassedDaughter = 0;
824828
for (const auto& currentDaughter : daughterParts) {
825829

826830
if (std::abs(currentDaughter.eta()) > cfgXicCand.etaTrackMax) {
@@ -841,10 +845,17 @@ struct HfCorrelatorXicHadrons {
841845
} else {
842846
continue;
843847
}
848+
countPassedDaughter++;
849+
}
850+
if (countPassedDaughter == nDaughtersV0) {
851+
registry.fill(HIST("hV0PtPrimLambdaMcGen"), particle.pt());
844852
}
845-
registry.fill(HIST("hV0PtPrimLambdaMcGen"), particle.pt());
846853
}
847854
}
855+
countV0++;
856+
857+
}
858+
848859
}
849860
}
850861

@@ -996,6 +1007,9 @@ struct HfCorrelatorXicHadrons {
9961007

9971008
// Correlate Xic with all Lambda V0 in the same event
9981009
for (const auto& v0 : v0s) {
1010+
if (!selectionV0(collision, v0)){
1011+
continue;
1012+
}
9991013
auto const& trackV0Pos = v0.template posTrack_as<TrackType>();
10001014
auto const& trackV0Neg = v0.template negTrack_as<TrackType>();
10011015

@@ -1696,12 +1710,12 @@ struct HfCorrelatorXicHadrons {
16961710
PROCESS_SWITCH(HfCorrelatorXicHadrons, processMcRecXic0V0, "Mc process for v0 lambda with Xic0", false);
16971711

16981712
/// MC Reco processing: Xic0 with V0 Lambda
1699-
void processV0McRec(SelCollisions::iterator const&,
1713+
void processV0McRec(SelCollisions::iterator const& collision,
17001714
TracksWithMc const& tracks,
17011715
soa::Join<aod::V0Datas, aod::McV0Labels> const& v0s,
17021716
aod::McParticles const& mcParticles)
17031717
{
1704-
fillEffV0<true>(v0s, tracks, mcParticles);
1718+
fillEffV0<true>(collision, v0s, tracks, mcParticles);
17051719
}
17061720
PROCESS_SWITCH(HfCorrelatorXicHadrons, processV0McRec, "Mc process for v0 lambda", false);
17071721

0 commit comments

Comments
 (0)