@@ -266,6 +266,7 @@ struct DeuteronInTriggeredEvents {
266266 Produces<o2::aod::NucleiTable> nucleiTable; // For data
267267 Produces<o2::aod::NucleiTableMCExtension> nucleiTableMCExtension; // For MC analysis
268268 Produces<o2::aod::GenEventMCSel> genEventMCSel; // For MC reco events
269+ Produces<o2::aod::NucleiTableMC> nucleiTableMC; // For MC analysis as data
269270 Service<o2::ccdb::BasicCCDBManager> ccdb;
270271 Service<o2::framework::O2DatabasePDG> pdgDB; // For INELgt0 gen MC selection
271272 Zorro zorro; // Definition of Zorro: helpful for skimmed data
@@ -1111,6 +1112,77 @@ struct DeuteronInTriggeredEvents {
11111112 }
11121113 }
11131114 PROCESS_SWITCH (DeuteronInTriggeredEvents, processMC, " MC analysis" , false );
1115+
1116+ void processMCasData (soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels> const & collisions, aod::McCollisions const & mcCollisions, soa::Join<TrackCandidates, aod::McTrackLabels> const & tracks, aod::McParticles const & particlesMC, aod::BCsWithTimestamps const &)
1117+ {
1118+ nuclei::candidates.clear ();
1119+ std::vector<bool > goodCollisions (mcCollisions.size (), false );
1120+
1121+ for (const auto & collision : collisions) {
1122+ if (!eventSelectionWithHisto (collision)) {
1123+ continue ;
1124+ }
1125+
1126+ // Avoid unwanted memory leaks
1127+ if (!collision.has_mcCollision ())
1128+ continue ;
1129+
1130+ int mcId = collision.mcCollisionId ();
1131+ if (mcId < 0 || mcId >= static_cast <int >(mcCollisions.size ()))
1132+ continue ;
1133+
1134+ goodCollisions[collision.mcCollisionId ()] = true ;
1135+ const auto & slicedTracks = tracks.sliceBy (tracksPerCollisions, collision.globalIndex ());
1136+ fillDataInfo (collision, slicedTracks);
1137+ }
1138+
1139+ std::vector<bool > isReconstructed (particlesMC.size (), false );
1140+ for (size_t i{0 }; i < nuclei::candidates.size (); ++i) {
1141+ auto & c = nuclei::candidates[i];
1142+ if (c.fillTree ) {
1143+ auto label = tracks.iteratorAt (c.globalIndex );
1144+
1145+ if (label.mcParticleId () < -1 || label.mcParticleId () >= particlesMC.size ()) {
1146+ continue ;
1147+ }
1148+
1149+ auto particle = particlesMC.iteratorAt (label.mcParticleId ());
1150+
1151+ int motherPdgCode = 0 ;
1152+ float motherDecRadius = -1 ;
1153+ isReconstructed[particle.globalIndex ()] = true ;
1154+
1155+ if (particle.isPhysicalPrimary ()) {
1156+ c.flags |= kIsPhysicalPrimary ;
1157+ if (particle.has_mothers ()) {
1158+ for (const auto & motherparticle : particle.mothers_as <aod::McParticles>()) {
1159+ if (std::find (nuclei::hfMothCodes.begin (), nuclei::hfMothCodes.end (), std::abs (motherparticle.pdgCode ())) != nuclei::hfMothCodes.end ()) {
1160+ c.flags |= kIsSecondaryFromWeakDecay ;
1161+ motherPdgCode = motherparticle.pdgCode ();
1162+ motherDecRadius = std::hypot (particle.vx () - motherparticle.vx (), particle.vy () - motherparticle.vy ());
1163+ break ;
1164+ }
1165+ }
1166+ }
1167+ } else if (particle.getProcess () == TMCProcess::kPDecay ) {
1168+ c.flags |= kIsSecondaryFromWeakDecay ;
1169+ for (const auto & motherparticle : particle.mothers_as <aod::McParticles>()) {
1170+ motherPdgCode = motherparticle.pdgCode ();
1171+ motherDecRadius = std::hypot (particle.vx () - motherparticle.vx (), particle.vy () - motherparticle.vy ());
1172+ }
1173+ } else {
1174+ c.flags |= kIsSecondaryFromMaterial ;
1175+ }
1176+
1177+ isReconstructed[particle.globalIndex ()] = true ;
1178+ float absoDecL = computeAbsoDecL (particle);
1179+
1180+ nucleiTableMC (c.pt , c.eta , c.phi , c.tpcInnerParam , c.beta , c.zVertex , c.nContrib , c.dcaXY , c.dcaZ , c.tpcSignal , c.itsChi2 , c.tpcChi2 , c.tofChi2 , c.flags , c.tpcFindableCls , c.tpcCrossedRows , c.itsClsMap , c.tpcNCls , c.tpcNClsShared , c.clusterSizesITS , goodCollisions[particle.mcCollisionId ()], particle.pt (), particle.eta (), particle.phi (), particle.pdgCode (), motherPdgCode, motherDecRadius, absoDecL);
1181+ }
1182+ }
1183+ }
1184+
1185+ PROCESS_SWITCH (DeuteronInTriggeredEvents, processMCasData, " MC as data analysis" , false );
11141186};
11151187
11161188WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
0 commit comments