diff --git a/PWGJE/TableProducer/jetEventWeightMCD.cxx b/PWGJE/TableProducer/jetEventWeightMCD.cxx index 0709a362d7f..0fb8d8161e6 100644 --- a/PWGJE/TableProducer/jetEventWeightMCD.cxx +++ b/PWGJE/TableProducer/jetEventWeightMCD.cxx @@ -40,14 +40,22 @@ struct JetEventWeightMCDTask { void processMCDetectorLevelEventWeight(MCDetectorLevelJetTable const& jet, soa::Join const&, aod::JetMcCollisions const&) { auto collision = jet.template collision_as>(); - mcDetectorLevelWeightsTable(jet.globalIndex(), collision.mcCollision().weight()); + if (collision.has_mcCollision()) { + mcDetectorLevelWeightsTable(jet.globalIndex(), collision.mcCollision().weight()); + } else { + mcDetectorLevelWeightsTable(jet.globalIndex(), 0.0); + } } PROCESS_SWITCH(JetEventWeightMCDTask, processMCDetectorLevelEventWeight, "Fill event weight tables for detector level MC jets", false); void processMCDetectorLevelEventWiseSubtractedEventWeight(MCDetectorLevelEventWiseSubtractedJetTable const& jet, soa::Join const&, aod::JetMcCollisions const&) { auto collision = jet.template collision_as>(); - mcDetectorLevelEventWiseSubtractedWeightsTable(jet.globalIndex(), collision.mcCollision().weight()); + if (collision.has_mcCollision()) { + mcDetectorLevelEventWiseSubtractedWeightsTable(jet.globalIndex(), collision.mcCollision().weight()); + } else { + mcDetectorLevelEventWiseSubtractedWeightsTable(jet.globalIndex(), 0.0); + } } PROCESS_SWITCH(JetEventWeightMCDTask, processMCDetectorLevelEventWiseSubtractedEventWeight, "Fill event weight tables for detector level MC jets", false); };