Skip to content

Commit 5b4d355

Browse files
hfribertHenrik Fribert
andauthored
[PWGCF] Feature: Derived-to-derived for kinks and pt recalc (#15063)
Co-authored-by: Henrik Fribert <ge35huh@nidoqueen.ktas.ph.tum.de>
1 parent d1baafd commit 5b4d355

File tree

2 files changed

+153
-5
lines changed

2 files changed

+153
-5
lines changed

PWGCF/Femto/Core/kinkBuilder.h

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,19 @@ class KinkSelection : public BaseSelection<float, o2::aod::femtodatatypes::KinkM
307307
void computeKinkMotherKinematics(const T& kinkCand)
308308
{
309309
std::array<float, 3> momMother = {kinkCand.pxMoth(), kinkCand.pyMoth(), kinkCand.pzMoth()};
310-
mKinkMotherPt = RecoDecay::pt(momMother);
310+
std::array<float, 3> momDaughter = {kinkCand.pxDaug(), kinkCand.pyDaug(), kinkCand.pzDaug()};
311+
311312
mKinkMotherEta = RecoDecay::eta(momMother);
312313
mKinkMotherPhi = RecoDecay::phi(momMother);
314+
315+
// Recalculate pT using kinematic constraints
316+
float ptRecalc = utils::calcPtnew(momMother[0], momMother[1], momMother[2],
317+
momDaughter[0], momDaughter[1], momDaughter[2]);
318+
if (ptRecalc > 0.f) {
319+
mKinkMotherPt = ptRecalc;
320+
} else {
321+
mKinkMotherPt = -1.f;
322+
}
313323
}
314324

315325
template <typename T>
@@ -401,7 +411,7 @@ class KinkBuilder
401411
{
402412
if constexpr (modes::isEqual(kinkType, modes::Kink::kSigma)) {
403413
LOG(info) << "Initialize femto Sigma builder...";
404-
mProduceSigmas = utils::enableTable("FSigmas_001", table.produceSigmas.value, initContext);
414+
mProduceSigmas = utils::enableTable("FSigmas_002", table.produceSigmas.value, initContext);
405415
mProduceSigmaMasks = utils::enableTable("FSigmaMasks_001", table.produceSigmaMasks.value, initContext);
406416
mProduceSigmaExtras = utils::enableTable("FSigmaExtras_001", table.produceSigmaExtras.value, initContext);
407417
}
@@ -510,11 +520,12 @@ class KinkBuilder
510520
template <typename T1, typename T2, typename T3>
511521
void fillSigma(T1& collisionProducts, T2& kinkProducts, T3 const& kink, int64_t daughterIndex)
512522
{
523+
// Mass is calculated from original momentum components stored in kink table
513524
float mass = kink.mSigmaMinus();
514525

515526
if (mProduceSigmas) {
516527
kinkProducts.producedSigmas(collisionProducts.producedCollision.lastIndex(),
517-
kink.mothSign() * mKinkSelection.getKinkMotherPt(),
528+
kink.mothSign() * mKinkSelection.getKinkMotherPt(), // Recalculated pT
518529
mKinkSelection.getKinkMotherEta(),
519530
mKinkSelection.getKinkMotherPhi(),
520531
mass,
@@ -538,11 +549,12 @@ class KinkBuilder
538549
template <typename T1, typename T2, typename T3>
539550
void fillSigmaPlus(T1& collisionProducts, T2& kinkProducts, T3 const& kink, int64_t daughterIndex)
540551
{
552+
// Mass is calculated from original momentum components stored in kink table
541553
float mass = kink.mSigmaPlus();
542554

543555
if (mProduceSigmaPlus) {
544556
kinkProducts.producedSigmaPlus(collisionProducts.producedCollision.lastIndex(),
545-
kink.mothSign() * mKinkSelection.getKinkMotherPt(),
557+
kink.mothSign() * mKinkSelection.getKinkMotherPt(), // Recalculated pT
546558
mKinkSelection.getKinkMotherEta(),
547559
mKinkSelection.getKinkMotherPhi(),
548560
mass,
@@ -576,6 +588,103 @@ class KinkBuilder
576588
bool mProduceSigmaPlusExtras = false;
577589
};
578590

591+
struct ConfKinkTablesDerivedToDerived : o2::framework::ConfigurableGroup {
592+
std::string prefix = std::string("KinkTables");
593+
o2::framework::Configurable<int> limitSigma{"limitSigma", 1, "At least this many sigmas need to be in the collision"};
594+
o2::framework::Configurable<int> limitSigmaPlus{"limitSigmaPlus", 0, "At least this many sigma pluses need to be in the collision"};
595+
};
596+
597+
struct KinkBuilderDerivedToDerivedProducts : o2::framework::ProducesGroup {
598+
o2::framework::Produces<o2::aod::StoredFSigmas_002> producedSigmas;
599+
o2::framework::Produces<o2::aod::StoredFSigmaMasks_001> producedSigmaMasks;
600+
o2::framework::Produces<o2::aod::StoredFSigmaPlus_001> producedSigmaPluses;
601+
o2::framework::Produces<o2::aod::StoredFSigmaPlusMasks_001> producedSigmaPlusMasks;
602+
};
603+
604+
class KinkBuilderDerivedToDerived
605+
{
606+
public:
607+
KinkBuilderDerivedToDerived() = default;
608+
~KinkBuilderDerivedToDerived() = default;
609+
610+
template <typename T>
611+
void init(T& config)
612+
{
613+
mLimitSigma = config.limitSigma.value;
614+
mLimitSigmaPlus = config.limitSigmaPlus.value;
615+
616+
if (mLimitSigma == 0 && mLimitSigmaPlus == 0) {
617+
LOG(fatal) << "Both sigma limit and sigmaplus limit are 0. Breaking...";
618+
}
619+
}
620+
621+
template <typename T1, typename T2, typename T3, typename T4>
622+
bool collisionHasTooFewSigma(T1 const& col, T2 const& /*sigmaTable*/, T3& partitionSigma, T4& cache)
623+
{
624+
auto sigmaSlice = partitionSigma->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
625+
if (sigmaSlice.size() >= mLimitSigma) {
626+
return false;
627+
}
628+
return true;
629+
}
630+
631+
template <typename T1, typename T2, typename T3, typename T4>
632+
bool collisionHasTooFewSigmaPlus(T1 const& col, T2 const& /*sigmaPlusTable*/, T3& partitionSigmaPlus, T4& cache)
633+
{
634+
auto sigmaPlusSlice = partitionSigmaPlus->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
635+
if (sigmaPlusSlice.size() >= mLimitSigmaPlus) {
636+
return false;
637+
}
638+
return true;
639+
}
640+
641+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
642+
void processSigma(T1 const& col, T2 const& /*sigmaTable*/, T3 const& oldTrackTable, T4& partitionSigma, T5& trackBuilder, T6& cache, T7& newSigmaTable, T8& newTrackTable, T9& newCollisionTable)
643+
{
644+
auto sigmaSlice = partitionSigma->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
645+
646+
for (auto const& sigma : sigmaSlice) {
647+
648+
auto chaDaughter = oldTrackTable.rawIteratorAt(sigma.chaDauId() - oldTrackTable.offset());
649+
650+
int chaDaughterIndex = trackBuilder.getDaughterIndex(chaDaughter, newTrackTable, newCollisionTable);
651+
652+
newSigmaTable.producedSigmas(newCollisionTable.producedCollision.lastIndex(),
653+
sigma.signedPt(),
654+
sigma.eta(),
655+
sigma.phi(),
656+
sigma.mass(),
657+
chaDaughterIndex);
658+
newSigmaTable.producedSigmaMasks(sigma.mask());
659+
}
660+
}
661+
662+
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
663+
void processSigmaPlus(T1 const& col, T2 const& /*sigmaPlusTable*/, T3 const& oldTrackTable, T4& partitionSigmaPlus, T5& trackBuilder, T6& cache, T7& newSigmaPlusTable, T8& newTrackTable, T9& newCollisionTable)
664+
{
665+
auto sigmaPlusSlice = partitionSigmaPlus->sliceByCached(o2::aod::femtobase::stored::fColId, col.globalIndex(), cache);
666+
667+
for (auto const& sigmaPlus : sigmaPlusSlice) {
668+
669+
auto chaDaughter = oldTrackTable.rawIteratorAt(sigmaPlus.chaDauId() - oldTrackTable.offset());
670+
671+
int chaDaughterIndex = trackBuilder.getDaughterIndex(chaDaughter, newTrackTable, newCollisionTable);
672+
673+
newSigmaPlusTable.producedSigmaPluses(newCollisionTable.producedCollision.lastIndex(),
674+
sigmaPlus.signedPt(),
675+
sigmaPlus.eta(),
676+
sigmaPlus.phi(),
677+
sigmaPlus.mass(),
678+
chaDaughterIndex);
679+
newSigmaPlusTable.producedSigmaPlusMasks(sigmaPlus.mask());
680+
}
681+
}
682+
683+
private:
684+
int mLimitSigma = 0;
685+
int mLimitSigmaPlus = 0;
686+
};
687+
579688
} // namespace kinkbuilder
580689
} // namespace o2::analysis::femto
581690
#endif // PWGCF_FEMTO_CORE_KINKBUILDER_H_

PWGCF/Femto/TableProducer/femtoProducerDerivedToDerived.cxx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/// \author Anton Riedel, TU München, anton.riedel@tum.de
1515

1616
#include "PWGCF/Femto/Core/collisionBuilder.h"
17+
#include "PWGCF/Femto/Core/kinkBuilder.h"
1718
#include "PWGCF/Femto/Core/partitions.h"
1819
#include "PWGCF/Femto/Core/trackBuilder.h"
1920
#include "PWGCF/Femto/Core/v0Builder.h"
@@ -41,6 +42,8 @@ struct FemtoProducerDerivedToDerived {
4142
using Tracks = o2::soa::Join<o2::aod::FTracks, o2::aod::FTrackMasks>;
4243
using Lambdas = o2::soa::Join<o2::aod::FLambdas, o2::aod::FLambdaMasks>;
4344
using K0shorts = o2::soa::Join<o2::aod::FK0shorts, o2::aod::FK0shortMasks>;
45+
using Sigma = o2::soa::Join<o2::aod::FSigmas, o2::aod::FSigmaMasks>;
46+
using SigmaPlus = o2::soa::Join<o2::aod::FSigmaPlus, o2::aod::FSigmaPlusMasks>;
4447

4548
o2::framework::SliceCache cache;
4649

@@ -74,12 +77,26 @@ struct FemtoProducerDerivedToDerived {
7477
o2::framework::Partition<K0shorts> k0shortPartition = MAKE_K0SHORT_PARTITION(k0shortSelection1);
7578
o2::framework::Preslice<K0shorts> perColK0shorts = o2::aod::femtobase::stored::fColId;
7679

80+
// kink builder
81+
kinkbuilder::KinkBuilderDerivedToDerived kinkBuilder;
82+
kinkbuilder::KinkBuilderDerivedToDerivedProducts kinkBuilderProducts;
83+
kinkbuilder::ConfKinkTablesDerivedToDerived confKinkBuilder;
84+
85+
kinkbuilder::ConfSigmaSelection1 sigmaSelection1;
86+
o2::framework::Partition<Sigma> sigmaPartition = MAKE_SIGMA_PARTITION(sigmaSelection1);
87+
o2::framework::Preslice<Sigma> perColSigma = o2::aod::femtobase::stored::fColId;
88+
89+
kinkbuilder::ConfSigmaPlusSelection1 sigmaPlusSelection1;
90+
o2::framework::Partition<SigmaPlus> sigmaPlusPartition = MAKE_SIGMAPLUS_PARTITION(sigmaPlusSelection1);
91+
o2::framework::Preslice<SigmaPlus> perColSigmaPlus = o2::aod::femtobase::stored::fColId;
92+
7793
void init(o2::framework::InitContext& /*context*/)
7894
{
7995
trackBuilder.init(confTrackBuilder);
8096
v0Builder.init(confV0Builder);
97+
kinkBuilder.init(confKinkBuilder);
8198

82-
if ((doprocessTracks + doprocessTracksLambdas + doprocessTracksK0shorts) > 1) {
99+
if ((doprocessTracks + doprocessTracksLambdas + doprocessTracksK0shorts + doprocessTracksSigma + doprocessTracksSigmaPlus) > 1) {
83100
LOG(fatal) << "Only one proccess function can be activated";
84101
}
85102
}
@@ -116,6 +133,28 @@ struct FemtoProducerDerivedToDerived {
116133
v0Builder.processK0shorts(col, k0shorts, tracks, k0shortPartition, trackBuilder, cache, v0BuilderProducts, trackBuilderProducts, collisionBuilderProducts);
117134
}
118135
PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksK0shorts, "Process k0short and tracks", false);
136+
137+
void processTracksSigma(FilteredCollision const& col, Tracks const& tracks, Sigma const& sigma)
138+
{
139+
if (trackBuilder.collisionHasTooFewTracks(col, tracks, trackPartition1, trackPartition2, cache) || kinkBuilder.collisionHasTooFewSigma(col, sigma, sigmaPartition, cache)) {
140+
return;
141+
}
142+
collisionBuilder.processCollision(col, collisionBuilderProducts);
143+
trackBuilder.processTracks(col, tracks, trackPartition1, trackPartition2, cache, trackBuilderProducts, collisionBuilderProducts);
144+
kinkBuilder.processSigma(col, sigma, tracks, sigmaPartition, trackBuilder, cache, kinkBuilderProducts, trackBuilderProducts, collisionBuilderProducts);
145+
}
146+
PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksSigma, "Process sigma and tracks", false);
147+
148+
void processTracksSigmaPlus(FilteredCollision const& col, Tracks const& tracks, SigmaPlus const& sigmaplus)
149+
{
150+
if (trackBuilder.collisionHasTooFewTracks(col, tracks, trackPartition1, trackPartition2, cache) || kinkBuilder.collisionHasTooFewSigmaPlus(col, sigmaplus, sigmaPlusPartition, cache)) {
151+
return;
152+
}
153+
collisionBuilder.processCollision(col, collisionBuilderProducts);
154+
trackBuilder.processTracks(col, tracks, trackPartition1, trackPartition2, cache, trackBuilderProducts, collisionBuilderProducts);
155+
kinkBuilder.processSigmaPlus(col, sigmaplus, tracks, sigmaPlusPartition, trackBuilder, cache, kinkBuilderProducts, trackBuilderProducts, collisionBuilderProducts);
156+
}
157+
PROCESS_SWITCH(FemtoProducerDerivedToDerived, processTracksSigmaPlus, "Process sigmaPlus and tracks", false);
119158
};
120159

121160
o2::framework::WorkflowSpec defineDataProcessing(o2::framework::ConfigContext const& cfgc)

0 commit comments

Comments
 (0)