diff --git a/analyzers/dataframe/MCParticle.cc b/analyzers/dataframe/MCParticle.cc index f2acd5c625..adf88d713a 100644 --- a/analyzers/dataframe/MCParticle.cc +++ b/analyzers/dataframe/MCParticle.cc @@ -432,7 +432,7 @@ ROOT::VecOps::RVec MCParticle::get_parentid(ROOT::VecOps::RVec mcind, // returns one MCParticle selected by its index in the particle block edm4hep::MCParticleData MCParticle::sel_byIndex( int idx, ROOT::VecOps::RVec in) { edm4hep::MCParticleData dummy; - if ( idx < in.size() ) { + if ( idx >= 0 && idx < in.size() ) { return in.at(idx) ; } else { @@ -454,6 +454,8 @@ std::vector MCParticle::get_list_of_stable_particles_from_decay( int i, ROO // returns a vector with the indices (in the Particle block) of the stable daughters of the particle i, // from the complete decay chain. + if ( i < 0 || i >= in.size() ) return res; + int db = in.at(i).daughters_begin ; int de = in.at(i).daughters_end; @@ -486,6 +488,8 @@ std::vector MCParticle::get_list_of_particles_from_decay(int i, ROOT::VecOp // returns a vector with the indices (in the Particle block) of the daughters of the particle i + if ( i < 0 || i >= in.size() ) return res; + int db = in.at(i).daughters_begin ; int de = in.at(i).daughters_end; if ( db == de ) return res; // particle is stable