Skip to content

Commit ede3d7d

Browse files
authored
Tracked cascade labeler process added (AliceO2Group#2430)
* Tracked cascade labeler added * default for tracked cascade labels should be FALSE * fix bug fixes bug in which the wrong (non-tracked) label table was populated inside tracked cascade labeler process. --------- Co-authored-by: David Dobrigkeit Chinellato <david.dobrigkeit.chinellato.cern.ch>
1 parent bad38c4 commit ede3d7d

1 file changed

Lines changed: 55 additions & 1 deletion

File tree

PWGLF/TableProducer/cascadelabelbuilder.cxx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ using LabeledTracks = soa::Join<aod::Tracks, aod::McTrackLabels>;
4646
//*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*
4747
struct cascadeLabelBuilder {
4848
Produces<aod::McCascLabels> casclabels; // MC labels for cascades
49+
Produces<aod::McTraCascLabels> tracasclabels; // MC labels for cascades
4950
void init(InitContext const&) {}
5051

5152
//*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*
5253
// build cascade labels
53-
void process(aod::Collision const& collision, aod::CascDataExt const& casctable, aod::V0sLinked const&, aod::V0Datas const& v0table, aod::McTrackLabels const&, aod::McParticles const&)
54+
void processCascades(aod::CascDatas const& casctable, aod::V0sLinked const&, aod::V0Datas const& v0table, aod::McTrackLabels const&, aod::McParticles const&)
5455
{
5556
for (auto& casc : casctable) {
5657
// Loop over those that actually have the corresponding V0 associated to them
@@ -98,6 +99,59 @@ struct cascadeLabelBuilder {
9899
lLabel);
99100
} // end casctable loop
100101
}
102+
PROCESS_SWITCH(cascadeLabelBuilder, processCascades, "Produce regular cascade label tables", true);
103+
104+
//*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*
105+
// build tracked cascade labels
106+
void processTrackedCascades(aod::TraCascDatas const& casctable, aod::V0sLinked const&, aod::V0Datas const& v0table, aod::McTrackLabels const&, aod::McParticles const&)
107+
{
108+
for (auto& casc : casctable) {
109+
// Loop over those that actually have the corresponding V0 associated to them
110+
auto v0 = casc.v0_as<o2::aod::V0sLinked>();
111+
if (!(v0.has_v0Data())) {
112+
tracasclabels(-1);
113+
continue; // skip those cascades for which V0 doesn't exist
114+
}
115+
auto v0data = v0.v0Data(); // de-reference index to correct v0data in case it exists
116+
int lLabel = -1;
117+
118+
// Acquire all three daughter tracks, please
119+
auto lBachTrack = casc.bachelor_as<aod::McTrackLabels>();
120+
auto lNegTrack = v0data.negTrack_as<aod::McTrackLabels>();
121+
auto lPosTrack = v0data.posTrack_as<aod::McTrackLabels>();
122+
123+
// Association check
124+
// There might be smarter ways of doing this in the future
125+
if (lNegTrack.has_mcParticle() && lPosTrack.has_mcParticle() && lBachTrack.has_mcParticle()) {
126+
auto lMCBachTrack = lBachTrack.mcParticle_as<aod::McParticles>();
127+
auto lMCNegTrack = lNegTrack.mcParticle_as<aod::McParticles>();
128+
auto lMCPosTrack = lPosTrack.mcParticle_as<aod::McParticles>();
129+
130+
// Step 1: check if the mother is the same, go up a level
131+
if (lMCNegTrack.has_mothers() && lMCPosTrack.has_mothers()) {
132+
for (auto& lNegMother : lMCNegTrack.mothers_as<aod::McParticles>()) {
133+
for (auto& lPosMother : lMCPosTrack.mothers_as<aod::McParticles>()) {
134+
if (lNegMother == lPosMother) {
135+
// if we got to this level, it means the mother particle exists and is the same
136+
// now we have to go one level up and compare to the bachelor mother too
137+
for (auto& lV0Mother : lNegMother.mothers_as<aod::McParticles>()) {
138+
for (auto& lBachMother : lMCBachTrack.mothers_as<aod::McParticles>()) {
139+
if (lV0Mother == lBachMother) {
140+
lLabel = lV0Mother.globalIndex();
141+
}
142+
}
143+
} // end conditional V0-bach pair
144+
} // end neg = pos mother conditional
145+
}
146+
} // end loop neg/pos mothers
147+
} // end conditional of mothers existing
148+
} // end association check
149+
// Construct label table (note: this will be joinable with CascDatas)
150+
tracasclabels(
151+
lLabel);
152+
} // end casctable loop
153+
}
154+
PROCESS_SWITCH(cascadeLabelBuilder, processTrackedCascades, "Produce tracked cascade label tables", false);
101155
};
102156

103157
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)

0 commit comments

Comments
 (0)