Skip to content

Commit 6c47c04

Browse files
lauraserLaura Serksnyte
andauthored
[PWGCF] Updated derived-to-derived producer to include the bitmask check (#11792)
Co-authored-by: Laura Serksnyte <laura.serksnyte@cern.ch>
1 parent 5367291 commit 6c47c04

File tree

1 file changed

+116
-70
lines changed

1 file changed

+116
-70
lines changed

PWGCF/FemtoDream/TableProducer/femtoDreamProducerTaskForSpecificAnalysis.cxx

Lines changed: 116 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,32 @@
1313
/// \brief Tasks that reads the track tables and creates track triplets; only three identical particles can be used
1414
/// \author Laura Serksnyte, TU München, laura.serksnyte@tum.de
1515

16-
#include <vector>
17-
#include <string>
16+
#include "PWGCF/DataModel/FemtoDerived.h"
17+
#include "PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h"
18+
#include "PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h"
19+
#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h"
20+
#include "PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h"
21+
#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h"
22+
#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h"
23+
24+
#include "Framework/ASoAHelpers.h"
1825
#include "Framework/AnalysisTask.h"
19-
#include "Framework/runDataProcessing.h"
2026
#include "Framework/HistogramRegistry.h"
21-
#include "Framework/ASoAHelpers.h"
27+
#include "Framework/O2DatabasePDGPlugin.h"
2228
#include "Framework/RunningWorkflowInfo.h"
2329
#include "Framework/StepTHn.h"
24-
#include "Framework/O2DatabasePDGPlugin.h"
25-
#include "TDatabasePDG.h"
30+
#include "Framework/runDataProcessing.h"
2631

27-
#include "PWGCF/DataModel/FemtoDerived.h"
28-
#include "PWGCF/FemtoDream/Core/femtoDreamParticleHisto.h"
29-
#include "PWGCF/FemtoDream/Core/femtoDreamEventHisto.h"
30-
#include "PWGCF/FemtoDream/Core/femtoDreamPairCleaner.h"
31-
#include "PWGCF/FemtoDream/Core/femtoDreamContainerThreeBody.h"
32-
#include "PWGCF/FemtoDream/Core/femtoDreamDetaDphiStar.h"
33-
#include "PWGCF/FemtoDream/Core/femtoDreamUtils.h"
32+
#include <string>
33+
#include <vector>
3434

3535
using namespace o2;
3636
using namespace o2::analysis::femtoDream;
3737
using namespace o2::framework;
3838
using namespace o2::framework::expressions;
3939
using namespace o2::soa;
4040

41-
struct femtoDreamProducerTaskForSpecificAnalysis {
41+
struct FemtoDreamProducerTaskForSpecificAnalysis {
4242

4343
SliceCache cache;
4444

@@ -49,33 +49,45 @@ struct femtoDreamProducerTaskForSpecificAnalysis {
4949
float mMassOne = -999, mMassTwo = -999, mMassThree = -999;
5050
int collisions = 0;
5151

52-
Configurable<int> ConfNumberOfTracks{"ConfNumberOfTracks", 3, "Number of tracks"};
53-
Configurable<int> ConfNumberOfV0{"ConfNumberOfV0", 0, "Number of V0"};
54-
Configurable<int> ConfNumberOfCascades{"ConfNumberOfCascades", 0, "Number of Cascades"};
52+
// Require bitmask selection for candidates
53+
Configurable<bool> confRequireBitmask{"confRequireBitmask", false, "Require bitmask selection for candidates"};
54+
55+
// Number of candidates required
56+
Configurable<int> confNumberOfTracks{"confNumberOfTracks", 3, "Number of tracks"};
57+
Configurable<int> confNumberOfV0{"confNumberOfV0", 0, "Number of V0"};
58+
Configurable<int> confNumberOfCascades{"confNumberOfCascades", 0, "Number of Cascades"};
5559

5660
/// Track selection
57-
Configurable<float> ConfPIDthrMom{"ConfPIDthrMom", 1.f, "Momentum threshold from which TPC and TOF are required for PID"};
58-
Configurable<o2::aod::femtodreamparticle::cutContainerType> ConfTPCPIDBit{"ConfTPCPIDBit", 16, "PID TPC bit from cutCulator "};
59-
Configurable<o2::aod::femtodreamparticle::cutContainerType> ConfTPCTOFPIDBit{"ConfTPCTOFPIDBit", 8, "PID TPCTOF bit from cutCulator"};
61+
Configurable<float> confPIDthrMom{"confPIDthrMom", 1.f, "Momentum threshold from which TPC and TOF are required for PID"};
62+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confTPCPIDBit{"confTPCPIDBit", 16, "PID TPC bit from cutCulator "};
63+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confTPCTOFPIDBit{"confTPCTOFPIDBit", 8, "PID TPCTOF bit from cutCulator"};
64+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confCutPart{"confCutPart", 0, "Track - Selection bit from cutCulator for part"};
65+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confCutPartAntiPart{"confCutPartAntiPart", 0, "Track - Selection bit from cutCulator for antipart"};
6066

6167
/// Partition for selected particles
62-
Partition<aod::FDParticles> SelectedParts = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) &&
63-
ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= ConfPIDthrMom, ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCPIDBit), ncheckbit(aod::femtodreamparticle::pidcut, ConfTPCTOFPIDBit));
68+
Partition<aod::FDParticles> selectedParts = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kTrack)) &&
69+
ifnode(aod::femtodreamparticle::pt * (nexp(aod::femtodreamparticle::eta) + nexp(-1.f * aod::femtodreamparticle::eta)) / 2.f <= confPIDthrMom, ncheckbit(aod::femtodreamparticle::pidcut, confTPCPIDBit), ncheckbit(aod::femtodreamparticle::pidcut, confTPCTOFPIDBit));
6470

6571
/// V0 selection
66-
Configurable<float> Conf_minInvMass_V0{"Conf_minInvMass_V0", 1.08, "Minimum invariant mass of V0 (particle)"};
67-
Configurable<float> Conf_maxInvMass_V0{"Conf_maxInvMass_V0", 1.15, "Maximum invariant mass of V0 (particle)"};
68-
Configurable<float> Conf_minInvMassAnti_V0{"Conf_minInvMassAnti_V0", 1.08, "Minimum invariant mass of V0 (antiparticle)"};
69-
Configurable<float> Conf_maxInvMassAnti_V0{"Conf_maxInvMassAnti_V0", 1.15, "Maximum invariant mass of V0 (antiparticle)"};
72+
Configurable<float> confMinInvMassV0{"confMinInvMassV0", 1.08, "Minimum invariant mass of V0 (particle)"};
73+
Configurable<float> confMaxInvMassV0{"confMaxInvMassV0", 1.15, "Maximum invariant mass of V0 (particle)"};
74+
Configurable<float> confMinInvMassAntiV0{"confMinInvMassAntiV0", 1.08, "Minimum invariant mass of V0 (antiparticle)"};
75+
Configurable<float> confMaxInvMassAntiV0{"confMaxInvMassAntiV0", 1.15, "Maximum invariant mass of V0 (antiparticle)"};
76+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confCutV0SameForAntipart{"confCutV0SameForAntipart", 0, "V0 - Selection bit from cutCulator for part/antipart"};
77+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confChildPosCutV0{"confChildPosCutV0", 149, "Selection bit for positive child of V0"};
78+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confChildPosTPCBitV0{"confChildPosTPCBitV0", 2, "PID TPC bit for positive child of V0"};
79+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confChildNegCutV0{"confChildNegCutV0", 149, "Selection bit for negative child of V0"};
80+
Configurable<o2::aod::femtodreamparticle::cutContainerType> confChildNegTPCBitV0{"confChildNegTPCBitV0", 2, "PID TPC bit for negative child of V0"};
81+
7082
/// Cascade selection
71-
Configurable<float> Conf_minInvMass_Cascade{"Conf_minInvMass_Cascade", 1.2, "Minimum invariant mass of Cascade (particle)"};
72-
Configurable<float> Conf_maxInvMass_Cascade{"Conf_maxInvMass_Cascade", 1.5, "Maximum invariant mass of Cascade (particle)"};
83+
Configurable<float> confMinInvMassCascade{"confMinInvMassCascade", 1.2, "Minimum invariant mass of Cascade (particle)"};
84+
Configurable<float> confMaxInvMassCascade{"confMaxInvMassCascade", 1.5, "Maximum invariant mass of Cascade (particle)"};
7385

7486
// Partition for selected particles
75-
Partition<aod::FDParticles> SelectedV0s = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0));
76-
Partition<aod::FDParticles> SelectedCascades = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kCascade));
87+
Partition<aod::FDParticles> selectedV0s = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kV0));
88+
Partition<aod::FDParticles> selectedCascades = (aod::femtodreamparticle::partType == uint8_t(aod::femtodreamparticle::ParticleType::kCascade));
7789

78-
HistogramRegistry EventRegistry{"EventRegistry", {}, OutputObjHandlingPolicy::AnalysisObject};
90+
HistogramRegistry eventRegistry{"eventRegistry", {}, OutputObjHandlingPolicy::AnalysisObject};
7991

8092
static constexpr uint32_t kSignPlusMask = 1 << 1;
8193

@@ -94,9 +106,13 @@ struct femtoDreamProducerTaskForSpecificAnalysis {
94106

95107
void init(InitContext&)
96108
{
97-
EventRegistry.add("hStatistiscs", ";bin;Entries", kTH1F, {{3, 0, 3}});
98-
// get bit for the collision mask
109+
eventRegistry.add("hStatistiscs", ";bin;Entries", kTH1F, {{3, 0, 3}});
110+
// Never run V0s and Cascades together as this will DOUBLE the track number and induce self correlations
111+
if ((doprocessCollisionsWithNTracksAndNCascades && doprocessCollisionsWithNTracksAndNV0)) {
112+
LOG(fatal) << "Never run V0s and Cascades together as this will DOUBLE the track number and induce self correlations!";
113+
}
99114
}
115+
100116
/// This function stores accepted collisions in derived data
101117
/// @tparam PartitionType
102118
/// @tparam PartType
@@ -105,36 +121,66 @@ struct femtoDreamProducerTaskForSpecificAnalysis {
105121
/// @param groupSelectedV0s partition for the second particle passed by the process function
106122
/// @param parts femtoDreamParticles table
107123
template <bool isMC, typename PartitionType, typename PartType>
108-
void createSpecifiedDerivedData(o2::aod::FDCollision& col, PartitionType groupSelectedTracks, PartitionType groupSelectedV0s, PartType parts)
124+
void createSpecifiedDerivedData(const o2::aod::FDCollision& col, PartitionType groupSelectedTracks, PartitionType groupSelectedV0s, PartType parts)
109125
{
110126
/// check tracks
111127
int tracksCount = 0;
112128
int antitracksCount = 0;
113-
for (auto& part : groupSelectedTracks) {
129+
for (const auto& part : groupSelectedTracks) {
114130
if (part.cut() & 1) {
115-
antitracksCount++;
131+
if (!confRequireBitmask || ncheckbit(part.cut(), confCutPartAntiPart)) {
132+
antitracksCount++;
133+
}
116134
} else {
117-
tracksCount++;
135+
if (!confRequireBitmask || ncheckbit(part.cut(), confCutPart)) {
136+
tracksCount++;
137+
}
118138
}
119139
}
120140

121141
/// check V0s
122-
int V0Count = 0;
142+
int v0Count = 0;
123143
int antiV0Count = 0;
124-
for (auto& V0 : groupSelectedV0s) {
125-
if ((V0.mLambda() > Conf_minInvMass_V0) && (V0.mLambda() < Conf_maxInvMass_V0)) {
126-
V0Count++;
127-
} else if ((V0.mAntiLambda() > Conf_minInvMassAnti_V0) && (V0.mAntiLambda() < Conf_maxInvMassAnti_V0)) {
128-
antiV0Count++;
144+
for (const auto& V0 : groupSelectedV0s) {
145+
if ((V0.mLambda() > confMinInvMassV0) && (V0.mLambda() < confMaxInvMassV0)) {
146+
if (confRequireBitmask) {
147+
if (ncheckbit(V0.cut(), confCutV0SameForAntipart)) {
148+
const auto& posChild = parts.iteratorAt(V0.index() - 2);
149+
const auto& negChild = parts.iteratorAt(V0.index() - 1);
150+
if (((posChild.cut() & confChildPosCutV0) == confChildPosCutV0 &&
151+
(posChild.pidcut() & confChildPosTPCBitV0) == confChildPosTPCBitV0 &&
152+
(negChild.cut() & confChildNegCutV0) == confChildNegCutV0 &&
153+
(negChild.pidcut() & confChildNegTPCBitV0) == confChildNegTPCBitV0)) {
154+
v0Count++;
155+
}
156+
}
157+
} else {
158+
v0Count++;
159+
}
160+
} else if ((V0.mAntiLambda() > confMinInvMassAntiV0) && (V0.mAntiLambda() < confMaxInvMassAntiV0)) {
161+
if (confRequireBitmask) {
162+
if (ncheckbit(V0.cut(), confCutV0SameForAntipart)) {
163+
const auto& posChild = parts.iteratorAt(V0.index() - 2);
164+
const auto& negChild = parts.iteratorAt(V0.index() - 1);
165+
if (((posChild.cut() & confChildPosCutV0) == confChildPosCutV0 &&
166+
(posChild.pidcut() & confChildNegTPCBitV0) == confChildNegTPCBitV0 && // exchanged values because checking antiparticle daughters and pid of particles exchange
167+
(negChild.cut() & confChildNegCutV0) == confChildNegCutV0 &&
168+
(negChild.pidcut() & confChildPosTPCBitV0) == confChildPosTPCBitV0)) { // exchanged values because checking antiparticle daughters and pid of particles exchange
169+
antiV0Count++;
170+
}
171+
}
172+
} else {
173+
antiV0Count++;
174+
}
129175
}
130176
}
131177

132178
std::vector<int> tmpIDtrack;
133179

134-
if ((V0Count >= ConfNumberOfV0 && tracksCount >= ConfNumberOfTracks) || (antiV0Count >= ConfNumberOfV0 && antitracksCount >= ConfNumberOfTracks)) {
135-
EventRegistry.fill(HIST("hStatistiscs"), 1);
180+
if ((v0Count >= confNumberOfV0 && tracksCount >= confNumberOfTracks) || (antiV0Count >= confNumberOfV0 && antitracksCount >= confNumberOfTracks)) {
181+
eventRegistry.fill(HIST("hStatistiscs"), 1);
136182
outputCollision(col.posZ(), col.multV0M(), col.multNtr(), col.sphericity(), col.magField());
137-
for (auto& femtoParticle : parts) {
183+
for (const auto& femtoParticle : parts) {
138184
if (aod::femtodreamparticle::ParticleType::kTrack == femtoParticle.partType()) {
139185
std::vector<int> childIDs = {0, 0};
140186
outputParts(outputCollision.lastIndex(),
@@ -190,23 +236,23 @@ struct femtoDreamProducerTaskForSpecificAnalysis {
190236
}
191237
}
192238
} else {
193-
EventRegistry.fill(HIST("hStatistiscs"), 2);
239+
eventRegistry.fill(HIST("hStatistiscs"), 2);
194240
}
195241
}
196242

197243
/// process function to create derived data with only collisions containing n tracks
198244
/// \param col subscribe to the collision table (Data)
199245
/// \param parts subscribe to the femtoDreamParticleTable
200-
void processCollisionsWithNTracksAndNV0(o2::aod::FDCollision& col,
201-
o2::aod::FDParticles& parts)
246+
void processCollisionsWithNTracksAndNV0(const o2::aod::FDCollision& col,
247+
const o2::aod::FDParticles& parts)
202248
{
203-
EventRegistry.fill(HIST("hStatistiscs"), 0);
204-
auto thegroupSelectedParts = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache);
205-
auto thegroupSelectedV0s = SelectedV0s->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache);
249+
eventRegistry.fill(HIST("hStatistiscs"), 0);
250+
auto thegroupSelectedParts = selectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache);
251+
auto thegroupSelectedV0s = selectedV0s->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache);
206252

207253
createSpecifiedDerivedData<false>(col, thegroupSelectedParts, thegroupSelectedV0s, parts);
208254
}
209-
PROCESS_SWITCH(femtoDreamProducerTaskForSpecificAnalysis, processCollisionsWithNTracksAndNV0, "Enable producing data with ppp collisions for data", true);
255+
PROCESS_SWITCH(FemtoDreamProducerTaskForSpecificAnalysis, processCollisionsWithNTracksAndNV0, "Enable producing data with ppp collisions for data", true);
210256

211257
/// This function stores accepted collisions in derived data
212258
/// @tparam PartitionType
@@ -216,13 +262,13 @@ struct femtoDreamProducerTaskForSpecificAnalysis {
216262
/// @param groupSelectedV0s partition for the second particle passed by the process function
217263
/// @param parts femtoDreamParticles table
218264
template <bool isMC, typename PartitionType, typename PartType>
219-
void createSpecifiedDerivedData_TrkCascade(o2::aod::FDCollision& col, PartitionType groupSelectedTracks, PartitionType groupSelectedCascades, PartType parts)
265+
void createSpecifiedDerivedDataTrkCascade(const o2::aod::FDCollision& col, PartitionType groupSelectedTracks, PartitionType groupSelectedCascades, PartType parts)
220266
{
221267

222268
/// check tracks
223269
int tracksCount = 0;
224270
int antitracksCount = 0;
225-
for (auto& part : groupSelectedTracks) {
271+
for (const auto& part : groupSelectedTracks) {
226272
if (part.cut() & 1) {
227273
antitracksCount++;
228274
} else {
@@ -231,23 +277,23 @@ struct femtoDreamProducerTaskForSpecificAnalysis {
231277
}
232278

233279
/// check Cascades
234-
int CascadeCount = 0;
280+
int ascadeCount = 0;
235281
int antiCascadeCount = 0;
236-
for (auto& casc : groupSelectedCascades) {
282+
for (const auto& casc : groupSelectedCascades) {
237283
if ((casc.cut() & kSignPlusMask) == kSignPlusMask) {
238-
CascadeCount++;
284+
ascadeCount++;
239285
} else {
240286
antiCascadeCount++;
241287
}
242288
}
243289

244290
std::vector<int> tmpIDtrack;
245291

246-
if ((CascadeCount >= ConfNumberOfCascades && tracksCount >= ConfNumberOfTracks) || (antiCascadeCount >= ConfNumberOfCascades && antitracksCount >= ConfNumberOfTracks)) {
247-
EventRegistry.fill(HIST("hStatistiscs"), 1);
292+
if ((ascadeCount >= confNumberOfCascades && tracksCount >= confNumberOfTracks) || (antiCascadeCount >= confNumberOfCascades && antitracksCount >= confNumberOfTracks)) {
293+
eventRegistry.fill(HIST("hStatistiscs"), 1);
248294
outputCollision(col.posZ(), col.multV0M(), col.multNtr(), col.sphericity(), col.magField());
249295

250-
for (auto& femtoParticle : parts) {
296+
for (const auto& femtoParticle : parts) {
251297
if (aod::femtodreamparticle::ParticleType::kTrack == femtoParticle.partType()) {
252298
std::vector<int> childIDs = {0, 0};
253299
outputParts(outputCollision.lastIndex(),
@@ -323,29 +369,29 @@ struct femtoDreamProducerTaskForSpecificAnalysis {
323369
}
324370
}
325371
} else {
326-
EventRegistry.fill(HIST("hStatistiscs"), 2);
372+
eventRegistry.fill(HIST("hStatistiscs"), 2);
327373
}
328374
}
329375

330376
/// process function to create derived data with only collisions containing n tracks
331377
/// \param col subscribe to the collision table (Data)
332378
/// \param parts subscribe to the femtoDreamParticleTable
333-
void processCollisionsWithNTracksAndNCascades(o2::aod::FDCollision& col,
334-
o2::aod::FDParticles& parts)
379+
void processCollisionsWithNTracksAndNCascades(const o2::aod::FDCollision& col,
380+
const o2::aod::FDParticles& parts)
335381
{
336-
EventRegistry.fill(HIST("hStatistiscs"), 0);
337-
auto thegroupSelectedParts = SelectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache);
338-
auto thegroupSelectedCascades = SelectedCascades->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache);
382+
eventRegistry.fill(HIST("hStatistiscs"), 0);
383+
auto thegroupSelectedParts = selectedParts->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache);
384+
auto thegroupSelectedCascades = selectedCascades->sliceByCached(aod::femtodreamparticle::fdCollisionId, col.globalIndex(), cache);
339385

340-
createSpecifiedDerivedData_TrkCascade<false>(col, thegroupSelectedParts, thegroupSelectedCascades, parts);
386+
createSpecifiedDerivedDataTrkCascade<false>(col, thegroupSelectedParts, thegroupSelectedCascades, parts);
341387
}
342-
PROCESS_SWITCH(femtoDreamProducerTaskForSpecificAnalysis, processCollisionsWithNTracksAndNCascades, "Enable producing data with tracks and Cascades collisions for data", true);
388+
PROCESS_SWITCH(FemtoDreamProducerTaskForSpecificAnalysis, processCollisionsWithNTracksAndNCascades, "Enable producing data with tracks and Cascades collisions for data", true);
343389
};
344390

345391
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
346392
{
347393
WorkflowSpec workflow{
348-
adaptAnalysisTask<femtoDreamProducerTaskForSpecificAnalysis>(cfgc),
394+
adaptAnalysisTask<FemtoDreamProducerTaskForSpecificAnalysis>(cfgc),
349395
};
350396
return workflow;
351397
}

0 commit comments

Comments
 (0)