@@ -32,7 +32,9 @@ struct ConfParticleCleaner : o2::framework::ConfigurableGroup {
3232 o2::framework::Configurable<bool > activate{" activate" , false , " Activate particle cleaner" };
3333 o2::framework::Configurable<std::vector<int >> requiredPdgCodes{" requiredPdgCodes" , {}, " Only consider particles with this exact pdg code (including the sign!)" };
3434 o2::framework::Configurable<std::vector<int >> rejectedPdgCodes{" rejectedPdgCodes" , {}, " Reject particles with this exact pdg code (including the sign!)" };
35- o2::framework::Configurable<bool > rejectedParticleWithoutMcInformation{" rejectedParticleWithoutMcInformation" , true , " If true, all particles which have no associated MC information, are rejected by default" };
35+ o2::framework::Configurable<bool > rejectParticleWithoutMcParticle{" rejectParticleWithoutMcParticle" , false , " If true, particles which have no associated MC information, are rejected" };
36+ o2::framework::Configurable<bool > rejectParticleWithoutMcMother{" rejectParticleWithoutMcMother" , false , " If true, particles which have no associated mother are rejected" };
37+ o2::framework::Configurable<bool > rejectParticleWithoutMcPartonicMother{" rejectParticleWithoutMcPartonicMother" , false , " If true, all particles which have no associated partonic mother" };
3638 o2::framework::Configurable<std::vector<int >> requiredMotherPdgCodes{" requiredMotherPdgCodes" , {}, " Only consider particles whose mothers have one of the supplied pdg codes (inclduing the sign!)" };
3739 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!)" };
3840 o2::framework::Configurable<std::vector<int >> requiredPartonicMotherPdgCodes{" requiredPartonicMotherPdgCodes" , {}, " Only consider particles whose partonic mothers have one of the supplied pdg codes (inclduing the sign!)" };
@@ -87,122 +89,141 @@ class ParticleCleaner
8789 {
8890 mActivate = confMpc.activate .value ;
8991
90- mRejectParticleWithoutMcInformation = confMpc.rejectedParticleWithoutMcInformation .value ;
92+ mRejectParticleWithoutMcParticle = confMpc.rejectParticleWithoutMcParticle .value ;
93+ mRejectParticleWithoutMcMother = confMpc.rejectParticleWithoutMcMother .value ;
94+ mRejectParticleWithoutMcPartonicMother = confMpc.rejectParticleWithoutMcPartonicMother .value ;
9195
9296 mRequiredPdgCodes = confMpc.requiredPdgCodes .value ;
9397 mRejectedPdgCodes = confMpc.rejectedPdgCodes .value ;
9498
9599 mRequiredMotherPdgCodes = confMpc.requiredMotherPdgCodes .value ;
96- mRejectMotherPdgCodes = confMpc.rejectMotherPdgCodes .value ;
100+ mRejectedMotherPdgCodes = confMpc.rejectMotherPdgCodes .value ;
97101
98102 mRequiredPartonicMotherPdgCodes = confMpc.requiredPartonicMotherPdgCodes .value ;
99- mRejectPartonicMotherPdgCodes = confMpc.rejectPartonicMotherPdgCodes .value ;
103+ mRejectedPartonicMotherPdgCodes = confMpc.rejectPartonicMotherPdgCodes .value ;
100104 }
101105
102106 template <typename T1, typename T2, typename T3, typename T4>
103- bool isClean (T1 const & particle, T2 const & /* mcParticles*/ , T3 const & /* mcMothers*/ , T4 const & /* mcPartonicMothers*/ )
107+ bool isClean (T1 const & particle,
108+ T2 const & /* mcParticles*/ ,
109+ T3 const & /* mcMothers*/ ,
110+ T4 const & /* mcPartonicMothers*/ )
104111 {
105- // check whether we apply cuts at all
106112 if (!mActivate ) {
107113 return true ;
108114 }
109- // check if we even have an associated mc particle
115+
116+ bool hasRequiredPdgCode = true ;
117+ bool hasRejectedPdgCode = false ;
118+
119+ bool hasMotherWithRequiredPdgCode = true ;
120+ bool hasMotherWithRejectedPdgCode = false ;
121+
122+ bool hasPartonicMotherWithRequiredPdgCode = true ;
123+ bool hasPartonicMotherWithRejectedPdgCode = false ;
124+
125+ // MC particle
110126 if (!particle.has_fMcParticle ()) {
111- if (mRejectParticleWithoutMcInformation ) {
127+ if (mRejectParticleWithoutMcParticle || ! mRequiredPdgCodes . empty () ) {
112128 return false ;
113- } else {
114- return true ;
115129 }
116- }
117- // perfrom cuts based on mc information of the particle itself
118- auto mcParticle = particle.template fMcParticle_as <T2>();
119-
120- // if list is empty, set it to true and skip the looop
121- bool hasRequiredPdgCode = true ;
122- if (!mRequiredPdgCodes .empty ()) {
123- hasRequiredPdgCode = false ;
124- for (int const & pdgCode : mRequiredPdgCodes ) {
125- if (pdgCode == mcParticle.pdgCode ()) {
126- hasRequiredPdgCode = true ;
127- break ;
130+ } else {
131+ auto mcParticle = particle.template fMcParticle_as <T2>();
132+
133+ if (!mRequiredPdgCodes .empty ()) {
134+ hasRequiredPdgCode = false ;
135+ for (int const & pdgCode : mRequiredPdgCodes ) {
136+ if (pdgCode == mcParticle.pdgCode ()) {
137+ hasRequiredPdgCode = true ;
138+ break ;
139+ }
128140 }
129141 }
130- }
131142
132- bool hasRejectedPdgCode = false ;
133- if (! mRejectedPdgCodes . empty () ) {
134- for ( int const & pdgCode : mRejectedPdgCodes ) {
135- if (pdgCode == mcParticle. pdgCode ()) {
136- hasRejectedPdgCode = true ;
137- break ;
143+ if (! mRejectedPdgCodes . empty ()) {
144+ for ( int const & pdgCode : mRejectedPdgCodes ) {
145+ if ( pdgCode == mcParticle. pdgCode () ) {
146+ hasRejectedPdgCode = true ;
147+ break ;
148+ }
138149 }
139150 }
140151 }
141152
142- // perfrom cuts based on mc information of the mothers
143- auto mother = particle.template fMcMother_as <T3>();
144-
145- // if list is empty, set it to true and skip the looop
146- bool hasMotherWithRequiredPdgCode = true ;
147- if (!mRequiredMotherPdgCodes .empty ()) {
148- hasMotherWithRequiredPdgCode = false ;
149- for (int const & pdgCode : mRequiredMotherPdgCodes ) {
150- if (pdgCode == mother.pdgCode ()) {
151- hasMotherWithRequiredPdgCode = true ;
152- break ;
153+ // MC mother
154+ if (!particle.has_fMcMother ()) {
155+ if (mRejectParticleWithoutMcMother || !mRequiredMotherPdgCodes .empty ()) {
156+ return false ;
157+ }
158+ } else {
159+ auto mother = particle.template fMcMother_as <T3>();
160+
161+ if (!mRequiredMotherPdgCodes .empty ()) {
162+ hasMotherWithRequiredPdgCode = false ;
163+ for (int const & pdgCode : mRequiredMotherPdgCodes ) {
164+ if (pdgCode == mother.pdgCode ()) {
165+ hasMotherWithRequiredPdgCode = true ;
166+ break ;
167+ }
153168 }
154169 }
155- }
156170
157- bool hasMotherWithRejectedPdgCode = false ;
158- if (! mRejectMotherPdgCodes . empty () ) {
159- for ( int const & pdgCode : mRejectMotherPdgCodes ) {
160- if (pdgCode == mother. pdgCode ()) {
161- hasMotherWithRejectedPdgCode = true ;
162- break ;
171+ if (! mRejectedMotherPdgCodes . empty ()) {
172+ for ( int const & pdgCode : mRejectedMotherPdgCodes ) {
173+ if ( pdgCode == mother. pdgCode () ) {
174+ hasMotherWithRejectedPdgCode = true ;
175+ break ;
176+ }
163177 }
164178 }
165179 }
166180
167- // perfrom cuts based on mc information of the partonic mothers
168- auto partonicMother = particle.template fMcPartMoth_as <T4>();
169-
170- // if list is empty, set it to true and skip the looop
171- bool hasPartonicMotherWithRequiredPdgCode = true ;
172- if (!mRequiredPartonicMotherPdgCodes .empty ()) {
173- hasPartonicMotherWithRequiredPdgCode = false ;
174- for (int const & pdgCode : mRequiredPartonicMotherPdgCodes ) {
175- if (pdgCode == partonicMother.pdgCode ()) {
176- hasPartonicMotherWithRequiredPdgCode = true ;
177- break ;
181+ // MC partonic mother
182+ if (!particle.has_fMcPartMoth ()) {
183+ if (mRejectParticleWithoutMcPartonicMother ||
184+ !mRequiredPartonicMotherPdgCodes .empty ()) {
185+ return false ;
186+ }
187+ } else {
188+ auto partonicMother = particle.template fMcPartMoth_as <T4>();
189+
190+ if (!mRequiredPartonicMotherPdgCodes .empty ()) {
191+ hasPartonicMotherWithRequiredPdgCode = false ;
192+ for (int const & pdgCode : mRequiredPartonicMotherPdgCodes ) {
193+ if (pdgCode == partonicMother.pdgCode ()) {
194+ hasPartonicMotherWithRequiredPdgCode = true ;
195+ break ;
196+ }
178197 }
179198 }
180- }
181199
182- bool hasPartonicMotherWithRejectedPdgCode = false ;
183- if (! mRejectPartonicMotherPdgCodes . empty () ) {
184- for ( int const & pdgCode : mRejectPartonicMotherPdgCodes ) {
185- if (pdgCode == partonicMother. pdgCode ()) {
186- hasPartonicMotherWithRejectedPdgCode = true ;
187- break ;
200+ if (! mRejectedPartonicMotherPdgCodes . empty ()) {
201+ for ( int const & pdgCode : mRejectedPartonicMotherPdgCodes ) {
202+ if ( pdgCode == partonicMother. pdgCode () ) {
203+ hasPartonicMotherWithRejectedPdgCode = true ;
204+ break ;
205+ }
188206 }
189207 }
190208 }
191209
192210 return hasRequiredPdgCode && !hasRejectedPdgCode &&
193211 hasMotherWithRequiredPdgCode && !hasMotherWithRejectedPdgCode &&
194- hasPartonicMotherWithRequiredPdgCode && !hasPartonicMotherWithRejectedPdgCode;
212+ hasPartonicMotherWithRequiredPdgCode &&
213+ !hasPartonicMotherWithRejectedPdgCode;
195214 }
196215
197216 private:
198217 bool mActivate = false ;
199- bool mRejectParticleWithoutMcInformation = true ;
218+ bool mRejectParticleWithoutMcParticle = true ;
219+ bool mRejectParticleWithoutMcMother = true ;
220+ bool mRejectParticleWithoutMcPartonicMother = true ;
200221 std::vector<int > mRequiredPdgCodes = {};
201222 std::vector<int > mRejectedPdgCodes = {};
202223 std::vector<int > mRequiredMotherPdgCodes {};
203- std::vector<int > mRejectMotherPdgCodes {};
224+ std::vector<int > mRejectedMotherPdgCodes {};
204225 std::vector<int > mRequiredPartonicMotherPdgCodes {};
205- std::vector<int > mRejectPartonicMotherPdgCodes {};
226+ std::vector<int > mRejectedPartonicMotherPdgCodes {};
206227};
207228
208229} // namespace particlecleaner
0 commit comments