Skip to content

Commit 374f605

Browse files
committed
Feat: add class to cut on mc information
1 parent 0b11a23 commit 374f605

File tree

4 files changed

+141
-1
lines changed

4 files changed

+141
-1
lines changed

PWGCF/Femto/Core/closePairRejection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class CloseTrackRejection
222222
count++;
223223
}
224224
}
225-
// for small momemeta the calculation of phistar might fail, if the particle did not reach a certain radius
225+
// for small momemeta the calculation of phistar might fail, if the particle did not reach one or more of the outer radii
226226
if (count > 0) {
227227
mAverageDphistar = std::accumulate(mDphistar.begin(), mDphistar.end(), 0.f) / count; // only average values if phistar could be computed
228228
} else {

PWGCF/Femto/Core/closeTripletRejection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ template <const char* prefixTrack1Track2,
4747
class CloseTripletRejectionTrackTrackTrack
4848
{
4949
public:
50+
CloseTripletRejectionTrackTrackTrack() = default;
51+
~CloseTripletRejectionTrackTrackTrack() = default;
52+
5053
template <typename T>
5154
void init(o2::framework::HistogramRegistry* registry,
5255
std::map<closepairrejection::CprHist, std::vector<o2::framework::AxisSpec>> const& specs,
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Copyright 2019-2022 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file tripletCleaner.h
13+
/// \brief triplet cleaner class
14+
/// \author anton.riedel@tum.de, TU München, anton.riedel@tum.de
15+
16+
#ifndef PWGCF_FEMTO_CORE_MCPARTICLECLEANER_H_
17+
#define PWGCF_FEMTO_CORE_MCPARTICLECLEANER_H_
18+
19+
#include "Framework/Configurable.h"
20+
21+
#include <vector>
22+
23+
namespace o2::analysis::femto
24+
{
25+
namespace mcparticlecleaner
26+
{
27+
28+
template <const char* Prefix>
29+
struct ConfMcParticleCleaner : o2::framework::ConfigurableGroup {
30+
std::string prefix = std::string(Prefix);
31+
o2::framework::Configurable<bool> cutOnMcTruth{"cutOnMcTruth", false, "Perform cuts based on MC truth information. If false, all following options are ignored"};
32+
o2::framework::Configurable<int> pdgCode{"pdgCode", 221, "Only consider particles with this exact pdg code (including the sign!)"};
33+
o2::framework::Configurable<bool> rejectedParticleWithoutMcInformation{"rejectedParticleWithoutMcInformation", true, "If true, all particles which have no associated MC information, are rejected by default"};
34+
o2::framework::Configurable<std::vector<int>> requiredMotherPdgCodes{"requiredMotherPdgCodes", {}, "Only consider particles whose mothers have one of the supplied pdg codes (inclduing the sign!)"};
35+
o2::framework::Configurable<std::vector<int>> rejectMotherPdgCodes{"rejectMotherPdgCodes", {}, "Only consider particles whose mothers do not have one of the supplied pdg codes (inclduing the sign!)"};
36+
o2::framework::Configurable<std::vector<int>> requiredPartonicMotherPdgCodes{"requiredPartonicMotherPdgCodes", {}, "Only consider particles whose partonic mothers have one of the supplied pdg codes (inclduing the sign!)"};
37+
o2::framework::Configurable<std::vector<int>> rejectPartonicMotherPdgCodes{"rejectPartonicMotherPdgCodes", {}, "Only consider particles whose mothers do not have one of the supplied pdg codes (inclduing the sign!)"};
38+
};
39+
40+
class McParticleCleaner
41+
{
42+
public:
43+
McParticleCleaner() = default;
44+
~McParticleCleaner() = default;
45+
46+
template <typename T>
47+
void init(T const& confMpc)
48+
{
49+
mCutOnMcTruth = confMpc.cutOnMcTruth.value;
50+
mRejectParticleWithoutMcInformation = confMpc.rejectedParticleWithoutMcInformation.value;
51+
mPdgCode = confMpc.pdgCode.value;
52+
mRequiredMotherPdgCodes = confMpc.requiredMotherPdgCodes.value;
53+
mRejectMotherPdgCodes = confMpc.rejectMotherPdgCodes.value;
54+
mRequiredPartonicMotherPdgCodes = confMpc.requiredPartonicMotherPdgCodes.value;
55+
mRejectPartonicMotherPdgCodes = confMpc.rejectPartonicMotherPdgCodes.value;
56+
}
57+
58+
template <typename T1, typename T2, typename T3, typename T4>
59+
bool checkCuts(T1 const& particle, T2 const& /*mcParticles*/, T3 const& /*mcMothers*/, T4 const& /*mcPartonicMothers*/)
60+
{
61+
// check whether we apply cuts at all
62+
if (!mCutOnMcTruth) {
63+
return true;
64+
}
65+
// check if we even have an associated mc particle
66+
if (!particle.has_fMcParticle()) {
67+
if (mRejectParticleWithoutMcInformation) {
68+
return false;
69+
} else {
70+
return true;
71+
}
72+
}
73+
// perfrom cuts based on mc information of the particle itself
74+
auto mcParticle = particle.template fMcParticle_as<T2>();
75+
if (mPdgCode != mcParticle.pdgCode()) {
76+
return false;
77+
}
78+
79+
// perfrom cuts based on mc information of the mothers
80+
auto mother = particle.template fMcMother_as<T3>();
81+
82+
// if list is empty, set it to true and skip the looop
83+
bool hasMotherWithRequiredPdgCode = mRequiredMotherPdgCodes.empty();
84+
for (int pdgCode : mRequiredMotherPdgCodes) {
85+
if (pdgCode == mother.pdgCode()) {
86+
hasMotherWithRequiredPdgCode = true;
87+
break;
88+
}
89+
}
90+
91+
bool hasMotherWithRejectedPdgCode = true;
92+
for (int pdgCode : mRejectMotherPdgCodes) {
93+
if (pdgCode == mother.pdgCode()) {
94+
hasMotherWithRejectedPdgCode = false;
95+
break;
96+
}
97+
}
98+
99+
// perfrom cuts based on mc information of the partonic mothers
100+
auto partonicMother = particle.template fMcPartMoth_as<T4>();
101+
102+
// if list is empty, set it to true and skip the looop
103+
bool hasPartonicMotherWithRequiredPdgCode = mRequiredPartonicMotherPdgCodes.empty();
104+
for (int pdgCode : mRequiredPartonicMotherPdgCodes) {
105+
if (pdgCode == partonicMother.pdgCode()) {
106+
hasPartonicMotherWithRequiredPdgCode = true;
107+
break;
108+
}
109+
}
110+
111+
bool hasPartonicMotherWithRejectedPdgCode = true;
112+
for (int pdgCode : mRejectPartonicMotherPdgCodes) {
113+
if (pdgCode == partonicMother.pdgCode()) {
114+
hasPartonicMotherWithRejectedPdgCode = false;
115+
break;
116+
}
117+
}
118+
119+
return hasMotherWithRequiredPdgCode && !hasMotherWithRejectedPdgCode &&
120+
hasPartonicMotherWithRequiredPdgCode && !hasPartonicMotherWithRejectedPdgCode;
121+
}
122+
123+
private:
124+
bool mCutOnMcTruth = false;
125+
bool mRejectParticleWithoutMcInformation = true;
126+
int mPdgCode = 0;
127+
std::vector<int> mRequiredMotherPdgCodes{};
128+
std::vector<int> mRejectMotherPdgCodes{};
129+
std::vector<int> mRequiredPartonicMotherPdgCodes{};
130+
std::vector<int> mRejectPartonicMotherPdgCodes{};
131+
};
132+
133+
} // namespace mcparticlecleaner
134+
} // namespace o2::analysis::femto
135+
136+
#endif // PWGCF_FEMTO_CORE_MCPARTICLECLEANER_H_

PWGCF/Femto/Core/tripletCleaner.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class TrackTrackTrackTripletCleaner : public paircleaner::BasePairCleaner
2727
{
2828
public:
2929
TrackTrackTrackTripletCleaner() = default;
30+
~TrackTrackTrackTripletCleaner() = default;
3031

3132
template <typename T1, typename T2, typename T3, typename T4>
3233
bool isCleanTriplet(T1 const& track1, T2 const& track2, T3 const& track3, T4 const& /*trackTable*/) const

0 commit comments

Comments
 (0)