2727#include < Framework/AnalysisTask.h>
2828#include < Framework/Configurable.h>
2929#include < Framework/InitContext.h>
30+ #include < Framework/O2DatabasePDGPlugin.h>
3031#include < Framework/runDataProcessing.h>
3132
3233#include < Rtypes.h>
@@ -106,11 +107,11 @@ struct SlimTablesProducer {
106107 Configurable<float > vertexZCut{" vertexZCut" , 10 .0f , " Accepted z-vertex range" };
107108 Configurable<std::string> eventSelections{" eventSelections" , " sel8" , " Event selection" };
108109 Configurable<std::string> trackSelections{" trackSelections" , " globalTracks" , " set track selections; other option: uniformTracks" };
109- Configurable<int > minTPCNClsCrossedRows{" minTPCNClsCrossedRows" , 80 , " min TPC crossed rows" };
110110 Configurable<bool > skipMBGapEvents{" skipMBGapEvents" , false , " flag to choose to reject min. bias gap events; jet-level rejection can also be applied at the jet finder level for jets only, here rejection is applied for collision and track process functions for the first time, and on jets in case it was set to false at the jet finder level" };
111111 Configurable<bool > applyRCTSelections{" applyRCTSelections" , true , " decide to apply RCT selections" };
112112
113113 std::vector<int > eventSelectionBits;
114+ Service<o2::framework::O2DatabasePDG> pdgDatabase;
114115 int trackSelection = -1 ;
115116 bool doSumw2 = false ;
116117
@@ -181,32 +182,30 @@ struct SlimTablesProducer {
181182 }
182183 PROCESS_SWITCH (SlimTablesProducer, processData, " process collisions and tracks for data" , false );
183184
184- void processMC (soa::Filtered<aod::JetCollisionsMCD> const & collisions ,
185- aod::JetMcCollisions const &, // join the weight
185+ void processMC (soa::Filtered<aod::JetMcCollisions>::iterator const & mccollision ,
186+ soa::SmallGroups< aod::JetCollisionsMCD> const & collisions , // join the weight
186187 soa::Filtered<aod::JetTracksMCD> const & tracks,
187188 soa::Filtered<aod::JetParticles> const & particles)
188189 {
190+ float eventWeightMC = mccollision.weight ();
191+ if (collisions.size () != 1 ) { // skip the mccollision if it has mre than 1 associated rec collision
192+ return ;
193+ }
194+ histos.fill (HIST (" h_mcCollMCP_counts_weight" ), 0.5 , eventWeightMC);
195+ if (std::abs (mccollision.posZ ()) > vertexZCut)
196+ histos.fill (HIST (" h_mcCollMCP_counts_weight" ), 1.5 , eventWeightMC);
197+ if (!jetderiveddatautilities::selectMcCollision (mccollision, skipMBGapEvents, applyRCTSelections)) {
198+ return ;
199+ }
200+ histos.fill (HIST (" h_mcCollMCP_counts_weight" ), 2.5 , eventWeightMC);
189201 for (auto const & collision : collisions) {
190202 float eventWeight = collision.weight ();
191203 if (!collision.has_mcCollision ()) {
192204 continue ;
193205 }
194- auto mcColl = collision.mcCollision (); // corresponding MC coll
195- histos.fill (HIST (" h_mcCollMCD_counts_weight" ), 0.5 , eventWeight);
196- histos.fill (HIST (" h_mcCollMCP_counts_weight" ), 0.5 , eventWeight);
197206 if (!jetderiveddatautilities::selectCollision (collision, eventSelectionBits, skipMBGapEvents, applyRCTSelections)) {
198207 continue ;
199208 }
200- if (!jetderiveddatautilities::selectMcCollision (mcColl, skipMBGapEvents, applyRCTSelections)) {
201- continue ;
202- }
203- histos.fill (HIST (" h_mcCollMCD_counts_weight" ), 1.5 , eventWeight);
204- histos.fill (HIST (" h_mcCollMCP_counts_weight" ), 1.5 , eventWeight);
205- if (std::abs (mcColl.posZ ()) > vertexZCut)
206- continue ;
207- histos.fill (HIST (" h_mcCollMCP_counts_weight" ), 2.5 , eventWeight);
208-
209- float eventMCWeight = mcColl.weight ();
210209 slimCollisions (collision.posZ (), collision.collisionTime (), eventWeight);
211210 auto slimCollIndex = slimCollisions.lastIndex ();
212211 auto slicedTracks = tracks.sliceBy (perCollisionTracks, collision.globalIndex ()); // tracks associated to the rec collision
@@ -218,12 +217,15 @@ struct SlimTablesProducer {
218217 float energy = std::sqrt (p * p + mass * mass);
219218 slimTracks (slimCollIndex, track.px (), track.py (), track.pz (), energy);
220219 }
221- slimMcCollisions (mcColl .posZ (), eventMCWeight );
220+ slimMcCollisions (mccollision .posZ (), eventWeightMC );
222221 auto slimMcCollIndex = slimMcCollisions.lastIndex ();
223- auto slicedParticles = particles.sliceBy (perMcCollisionParticles, mcColl.globalIndex ()); // particles associated to the mc collision
224- for (const auto & particle : slicedParticles) {
222+ for (const auto & particle : particles) {
225223 if (!particle.isPhysicalPrimary ())
226224 continue ;
225+ auto pdgParticle = pdgDatabase->GetParticle (particle.pdgCode ());
226+ auto pdgCharge = pdgParticle ? std::abs (pdgParticle->Charge ()) : -1.0 ;
227+ if (pdgCharge < 3.0 ) // keep charged particles, exclude neutrals
228+ continue ;
227229 slimParticles (slimMcCollIndex, particle.px (), particle.py (), particle.pz (), particle.energy ());
228230 }
229231 }
0 commit comments