Skip to content

Commit 7b06eaf

Browse files
authored
[PWGCF] Implement collision tagger in femto framework (#18607)
1 parent 51576a7 commit 7b06eaf

17 files changed

Lines changed: 2658 additions & 62 deletions

‎PWGCF/Femto/Core/collisionTagger.h‎

Lines changed: 1016 additions & 0 deletions
Large diffs are not rendered by default.

‎PWGCF/Femto/DataModel/FemtoTables.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,18 @@ DECLARE_SOA_TABLE_STAGED_VERSIONED(FColMasks_001, "FCOLMASK", 1, //! collision m
143143
using FColMasks = FColMasks_001;
144144
using StoredFColMasks = StoredFColMasks_001;
145145

146+
// table for collision tags: one bit per (wagon, pair type) combination the collision tagger was
147+
// self-configured to check, set if the collision has what it takes to form at least one pair of
148+
// that type (both particle-1-role and particle-2-role candidates present, or, for a same-species
149+
// pair, at least 2 distinct candidates passing the one shared selection). Used to pre-filter the
150+
// mixed-event pool instead of discovering empty collisions only after slicing. Which bit means
151+
// what is assigned at self-configuration time and logged by the tagger; see
152+
// PWGCF/Femto/TableProducer/femtoProducerCollisionTagger.cxx.
153+
DECLARE_SOA_TABLE_STAGED_VERSIONED(FColTags_001, "FCOLTAG", 1, //! collision tags
154+
femtocollisions::CollisionTag);
155+
using FColTags = FColTags_001;
156+
using StoredFColTags = StoredFColTags_001;
157+
146158
DECLARE_SOA_TABLE_STAGED_VERSIONED(FColSphericities_001, "FCOLSPHERICITY", 1, //! sphericity
147159
femtocollisions::Sphericity);
148160
using FColSphericities = FColSphericities_001;

‎PWGCF/Femto/TableProducer/CMakeLists.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ o2physics_add_dpl_workflow(femto-producer
1414
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils O2Physics::PWGEMPhotonMesonCore
1515
COMPONENT_NAME Analysis)
1616

17+
o2physics_add_dpl_workflow(femto-producer-collision-tagger
18+
SOURCES ./femtoProducerCollisionTagger.cxx
19+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
20+
COMPONENT_NAME Analysis)
21+
1722
o2physics_add_dpl_workflow(femto-producer-derived-to-derived
1823
SOURCES ./femtoProducerDerivedToDerived.cxx
1924
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore

‎PWGCF/Femto/TableProducer/femtoProducerCollisionTagger.cxx‎

Lines changed: 704 additions & 0 deletions
Large diffs are not rendered by default.

‎PWGCF/Femto/Tasks/femtoPairD0D0.cxx‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "PWGCF/Femto/Core/closePairRejection.h"
1919
#include "PWGCF/Femto/Core/collisionBuilder.h"
2020
#include "PWGCF/Femto/Core/collisionHistManager.h"
21+
#include "PWGCF/Femto/Core/collisionTagger.h"
2122
#include "PWGCF/Femto/Core/modes.h"
2223
#include "PWGCF/Femto/Core/pairBuilder.h"
2324
#include "PWGCF/Femto/Core/pairCleaner.h"
@@ -32,11 +33,13 @@
3233
#include <Framework/AnalysisTask.h>
3334
#include <Framework/BinningPolicy.h>
3435
#include <Framework/Configurable.h>
36+
#include <Framework/DeviceSpec.h>
3537
#include <Framework/Expressions.h>
3638
#include <Framework/HistogramRegistry.h>
3739
#include <Framework/HistogramSpec.h>
3840
#include <Framework/InitContext.h>
3941
#include <Framework/OutputObjHeader.h>
42+
#include <Framework/RunningWorkflowInfo.h>
4043
#include <Framework/runDataProcessing.h>
4144

4245
#include <map>
@@ -68,13 +71,20 @@ struct FemtoPairD0D0 {
6871

6972
using FemtoMcParticlesWithLabel = o2::soa::Join<o2::aod::FMcParticles, o2::aod::FMcMotherLabels>;
7073

74+
// opt-in: carries FColTags, only needed by processMixedEventWithTagging.
75+
using FemtoCollisionsWithTags = o2::soa::Join<FemtoCollisions, o2::aod::FColTags>;
76+
using FilteredFemtoCollisionsWithTags = o2::soa::Filtered<FemtoCollisionsWithTags>;
77+
7178
o2::framework::SliceCache cache;
7279

7380
// setup collisions
7481
collisionbuilder::ConfCollisionSelection collisionSelection;
7582
o2::framework::expressions::Filter collisionFilter = MAKE_COLLISION_FILTER(collisionSelection);
7683
colhistmanager::ConfCollisionBinning confCollisionBinning;
7784

85+
// opt-in, only needed by processMixedEventWithTagging below.
86+
collisiontagger::ConfTagging<collisiontagger::role::D0D0Pair> confTaggingD0D0;
87+
7888
// setup for daughters
7989
// separate binning per d0 slot, so that both hypotheses can be binned independently
8090
trackhistmanager::ConfD01PosDauBinning confD01PosDauBinning;
@@ -141,9 +151,9 @@ struct FemtoPairD0D0 {
141151
closepairrejection::ConfCprD0DaugherD0DaughterPos confCprPos;
142152
closepairrejection::ConfCprD0DaugherD0DaughterNeg confCprNeg;
143153

144-
void init(o2::framework::InitContext&)
154+
void init(o2::framework::InitContext& context)
145155
{
146-
bool processData = doprocessSameEvent || doprocessMixedEvent;
156+
bool processData = doprocessSameEvent || doprocessMixedEvent || doprocessMixedEventWithTagging;
147157
bool processMc = doprocessSameEventMc || doprocessMixedEventMc;
148158

149159
if (processData && processMc) {
@@ -153,6 +163,19 @@ struct FemtoPairD0D0 {
153163
LOG(fatal) << "Neither data nor mc processing is enabled. Breaking...";
154164
}
155165

166+
if (doprocessMixedEventWithTagging) {
167+
auto const& workflows = context.services().get<o2::framework::RunningWorkflowInfo const>();
168+
auto const& ownDevice = context.services().get<o2::framework::DeviceSpec const>();
169+
auto roles = collisiontagger::discoverTaggedRoles(workflows);
170+
int bit = collisiontagger::findOwnBit(roles, ownDevice.name, confTaggingD0D0.Role);
171+
if (bit < 0) {
172+
LOG(fatal) << "processMixedEventWithTagging is enabled, but no femto-collision-tagger device "
173+
<< "(with processD0D0 enabled) tagging this device (" << ownDevice.name << ") was found in this workflow.";
174+
}
175+
confTaggingD0D0.internalTagMask.value = static_cast<datatypes::CollisionTagType>(1) << bit;
176+
LOG(info) << "Collision tagger bit for " << ownDevice.name << " (D0D0): " << bit;
177+
}
178+
156179
// setup columnpolicy for binning
157180
// default values are used during instantiation, so we need to explicity update them here
158181
mixBinsVtxMult = {{confMixing.vtxBins.value, confMixing.multBins.value}};
@@ -208,6 +231,16 @@ struct FemtoPairD0D0 {
208231
}
209232
PROCESS_SWITCH(FemtoPairD0D0, processSameEventMc, "Enable processing same event processing for d0-d0 with mc information", false);
210233

234+
// Opt-in counterpart of processMixedEvent() below -- same "Partition declared and bound inside
235+
// process()" idiom as femtoPairTrackTrack.cxx's processMixedEventWithTagging.
236+
void processMixedEventWithTagging(FilteredFemtoCollisionsWithTags const& cols, FemtoTracks const& tracks, FemtoD0s const& /*d0s*/)
237+
{
238+
o2::framework::Partition<FilteredFemtoCollisionsWithTags> taggedCollisions = ncheckbit(o2::aod::femtocollisions::collisionTag, confTaggingD0D0.internalTagMask);
239+
taggedCollisions.bindTable(cols);
240+
pairD0D0Builder.processMixedEvent<modes::Mode::kMe_Reco>(taggedCollisions, tracks, d0Partition1, d0Partition2, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent);
241+
}
242+
PROCESS_SWITCH(FemtoPairD0D0, processMixedEventWithTagging, "Enable processing mixed event processing for d0-d0, pre-filtered using the collision tagger", false);
243+
211244
void processMixedEvent(FilteredFemtoCollisions const& cols, FemtoTracks const& tracks, FemtoD0s const& /*d0s*/)
212245
{
213246
pairD0D0Builder.processMixedEvent<modes::Mode::kMe_Reco>(cols, tracks, d0Partition1, d0Partition2, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent);

‎PWGCF/Femto/Tasks/femtoPairTrackCascade.cxx‎

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "PWGCF/Femto/Core/closePairRejection.h"
1919
#include "PWGCF/Femto/Core/collisionBuilder.h"
2020
#include "PWGCF/Femto/Core/collisionHistManager.h"
21+
#include "PWGCF/Femto/Core/collisionTagger.h"
2122
#include "PWGCF/Femto/Core/modes.h"
2223
#include "PWGCF/Femto/Core/pairBuilder.h"
2324
#include "PWGCF/Femto/Core/pairCleaner.h"
@@ -33,11 +34,13 @@
3334
#include <Framework/AnalysisTask.h>
3435
#include <Framework/BinningPolicy.h>
3536
#include <Framework/Configurable.h>
37+
#include <Framework/DeviceSpec.h>
3638
#include <Framework/Expressions.h>
3739
#include <Framework/HistogramRegistry.h>
3840
#include <Framework/HistogramSpec.h>
3941
#include <Framework/InitContext.h>
4042
#include <Framework/OutputObjHeader.h>
43+
#include <Framework/RunningWorkflowInfo.h>
4144
#include <Framework/runDataProcessing.h>
4245

4346
#include <map>
@@ -56,6 +59,10 @@ struct FemtoPairTrackCascade {
5659
using FilteredFemtoCollisionsWithLabel = o2::soa::Filtered<FemtoCollisionsWithLabel>;
5760
using FilteredFemtoCollisionWithLabel = FilteredFemtoCollisionsWithLabel::iterator;
5861

62+
// opt-in FColTags , only needed by processXiMixedEventWithTagging/processOmegaMixedEventWithTagging
63+
using FemtoCollisionsWithTags = o2::soa::Join<FemtoCollisions, o2::aod::FColTags>;
64+
using FilteredFemtoCollisionsWithTags = o2::soa::Filtered<FemtoCollisionsWithTags>;
65+
5966
using FemtoTracks = o2::soa::Join<o2::aod::FTracks, o2::aod::FTrackMasks>;
6067
using FemtoXis = o2::soa::Join<o2::aod::FXis, o2::aod::FXiMasks>;
6168
using FemtoOmegas = o2::soa::Join<o2::aod::FOmegas, o2::aod::FOmegaMasks>;
@@ -78,6 +85,11 @@ struct FemtoPairTrackCascade {
7885
o2::framework::expressions::Filter collisionFilter = MAKE_COLLISION_FILTER(collisionSelection);
7986
colhistmanager::ConfCollisionBinning confCollisionBinning;
8087

88+
// opt-in, only needed by processXiMixedEventWithTagging/processOmegaMixedEventWithTagging --
89+
// two separate instances since Xi and Omega are tagged independently (see init()).
90+
collisiontagger::ConfTagging<collisiontagger::role::TrackXiPair> confTaggingXi;
91+
collisiontagger::ConfTagging<collisiontagger::role::TrackOmegaPair> confTaggingOmega;
92+
8193
// setup tracks
8294
trackbuilder::ConfTrackSelection1 confTrackSelection;
8395
trackhistmanager::ConfTrackBinning1 confTrackBinning;
@@ -185,18 +197,43 @@ struct FemtoPairTrackCascade {
185197
closepairrejection::ConfCprTrackCascadeBachelor confCprBachelor;
186198
closepairrejection::ConfCprTrackV0Daughter confCprV0Daughter;
187199

188-
void init(o2::framework::InitContext&)
200+
void init(o2::framework::InitContext& context)
189201
{
190-
bool processData = doprocessXiSameEvent || doprocessXiMixedEvent || doprocessOmegaSameEvent || doprocessOmegaMixedEvent;
202+
bool processData = doprocessXiSameEvent || doprocessXiMixedEvent || doprocessOmegaSameEvent || doprocessOmegaMixedEvent || doprocessXiMixedEventWithTagging || doprocessOmegaMixedEventWithTagging;
191203
bool processFitVars = doprocessXiSameEventWithFitVars || doprocessXiMixedEventWithFitVars || doprocessOmegaSameEventWithFitVars || doprocessOmegaMixedEventWithFitVars;
192204
bool processMc = doprocessXiSameEventMc || doprocessXiMixedEventMc || doprocessOmegaSameEventMc || doprocessOmegaMixedEventMc;
193205

194206
if (static_cast<int>(processData) + static_cast<int>(processFitVars) + static_cast<int>(processMc) > 1) {
195207
LOG(fatal) << "More than one of data, FitVars or mc processing is activated. Breaking...";
196208
}
197209

198-
bool processXi = doprocessXiSameEvent || doprocessXiSameEventWithFitVars || doprocessXiSameEventMc || doprocessXiMixedEvent || doprocessXiMixedEventWithFitVars || doprocessXiMixedEventMc;
199-
bool processOmega = doprocessOmegaSameEvent || doprocessOmegaSameEventWithFitVars || doprocessOmegaSameEventMc || doprocessOmegaMixedEvent || doprocessOmegaMixedEventWithFitVars || doprocessOmegaMixedEventMc;
210+
bool processXi = doprocessXiSameEvent || doprocessXiSameEventWithFitVars || doprocessXiSameEventMc || doprocessXiMixedEvent || doprocessXiMixedEventWithFitVars || doprocessXiMixedEventMc || doprocessXiMixedEventWithTagging;
211+
bool processOmega = doprocessOmegaSameEvent || doprocessOmegaSameEventWithFitVars || doprocessOmegaSameEventMc || doprocessOmegaMixedEvent || doprocessOmegaMixedEventWithFitVars || doprocessOmegaMixedEventMc || doprocessOmegaMixedEventWithTagging;
212+
213+
// Each species discovers its own tag bit independently (see Core/collisionTagger.h).
214+
if (doprocessXiMixedEventWithTagging || doprocessOmegaMixedEventWithTagging) {
215+
auto const& workflows = context.services().get<o2::framework::RunningWorkflowInfo const>();
216+
auto const& ownDevice = context.services().get<o2::framework::DeviceSpec const>();
217+
auto roles = collisiontagger::discoverTaggedRoles(workflows);
218+
if (doprocessXiMixedEventWithTagging) {
219+
int bit = collisiontagger::findOwnBit(roles, ownDevice.name, confTaggingXi.Role);
220+
if (bit < 0) {
221+
LOG(fatal) << "processXiMixedEventWithTagging is enabled, but no femto-collision-tagger device "
222+
<< "(with processTrackCascade enabled) tagging this device (" << ownDevice.name << ") was found in this workflow.";
223+
}
224+
confTaggingXi.internalTagMask.value = static_cast<datatypes::CollisionTagType>(1) << bit;
225+
LOG(info) << "Collision tagger bit for " << ownDevice.name << " (Xi): " << bit;
226+
}
227+
if (doprocessOmegaMixedEventWithTagging) {
228+
int bit = collisiontagger::findOwnBit(roles, ownDevice.name, confTaggingOmega.Role);
229+
if (bit < 0) {
230+
LOG(fatal) << "processOmegaMixedEventWithTagging is enabled, but no femto-collision-tagger device "
231+
<< "(with processTrackCascade enabled) tagging this device (" << ownDevice.name << ") was found in this workflow.";
232+
}
233+
confTaggingOmega.internalTagMask.value = static_cast<datatypes::CollisionTagType>(1) << bit;
234+
LOG(info) << "Collision tagger bit for " << ownDevice.name << " (Omega): " << bit;
235+
}
236+
}
200237

201238
if (processXi && processOmega) {
202239
LOG(fatal) << "Both xi-track and omega-track processing is enabled. Breaking...";
@@ -280,6 +317,17 @@ struct FemtoPairTrackCascade {
280317
}
281318
PROCESS_SWITCH(FemtoPairTrackCascade, processXiSameEventMc, "Enable processing same event processing for tracks and xis with mc information", false);
282319

320+
// Opt-in counterpart of processXiMixedEvent() below -- same "Partition declared and bound
321+
// inside process()" idiom as femtoPairTrackTrack.cxx's processMixedEventWithTagging. Requires
322+
// a femto-collision-tagger device (processTrackCascade enabled) in the same workflow -- see init().
323+
void processXiMixedEventWithTagging(FilteredFemtoCollisionsWithTags const& cols, FemtoTracks const& tracks, FemtoXis const& /*xis*/)
324+
{
325+
o2::framework::Partition<FilteredFemtoCollisionsWithTags> taggedCollisions = ncheckbit(o2::aod::femtocollisions::collisionTag, confTaggingXi.internalTagMask);
326+
taggedCollisions.bindTable(cols);
327+
pairTrackXiBuilder.processMixedEvent<modes::Mode::kMe_Reco>(taggedCollisions, tracks, trackPartition, xiPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent);
328+
}
329+
PROCESS_SWITCH(FemtoPairTrackCascade, processXiMixedEventWithTagging, "Enable processing mixed event processing for tracks and xis, pre-filtered using the collision tagger", false);
330+
283331
void processXiMixedEvent(FilteredFemtoCollisions const& cols, FemtoTracks const& tracks, FemtoXis const& /*xis*/)
284332
{
285333
pairTrackXiBuilder.processMixedEvent<modes::Mode::kMe_Reco>(cols, tracks, trackPartition, xiPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent);
@@ -316,6 +364,15 @@ struct FemtoPairTrackCascade {
316364
}
317365
PROCESS_SWITCH(FemtoPairTrackCascade, processOmegaSameEventMc, "Enable processing same event processing for tracks and omegas with mc information", false);
318366

367+
// Opt-in counterpart of processOmegaMixedEvent() below -- same idiom as processXiMixedEventWithTagging above.
368+
void processOmegaMixedEventWithTagging(FilteredFemtoCollisionsWithTags const& cols, FemtoTracks const& tracks, FemtoOmegas const& /*omegas*/)
369+
{
370+
o2::framework::Partition<FilteredFemtoCollisionsWithTags> taggedCollisions = ncheckbit(o2::aod::femtocollisions::collisionTag, confTaggingOmega.internalTagMask);
371+
taggedCollisions.bindTable(cols);
372+
pairTrackOmegaBuilder.processMixedEvent<modes::Mode::kMe_Reco>(taggedCollisions, tracks, trackPartition, omegaPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent);
373+
}
374+
PROCESS_SWITCH(FemtoPairTrackCascade, processOmegaMixedEventWithTagging, "Enable processing mixed event processing for tracks and omegas, pre-filtered using the collision tagger", false);
375+
319376
void processOmegaMixedEvent(FilteredFemtoCollisions const& cols, FemtoTracks const& tracks, FemtoOmegas const& /*omegas*/)
320377
{
321378
pairTrackOmegaBuilder.processMixedEvent<modes::Mode::kMe_Reco>(cols, tracks, trackPartition, omegaPartition, cache, mixBinsVtxMult, mixBinsVtxCent, mixBinsVtxMultCent);

0 commit comments

Comments
 (0)