Skip to content

Commit

Permalink
protect against other_tracks.size() < fake_multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
bainbrid committed Oct 5, 2018
1 parent 47976f6 commit b81504e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/TrackerElectronsFeatures.cc
Original file line number Diff line number Diff line change
@@ -728,8 +728,9 @@ TrackerElectronsFeatures::analyze(const Event& iEvent, const EventSetup& iSetup)
// fill the backgrounds (prescaled according to 'fakesMultiplier' configurable)
// fill other electron quantities
std::vector<int> indices;
int nfakes = 0;
while ( other_tracks.size() > 0 && nfakes < fake_multiplier_ ) {
unsigned int nfakes = 0;
while ( nfakes < other_tracks.size() && nfakes < fake_multiplier_ ) {

int index = int( gRandom->Rndm() * other_tracks.size() );
if ( std::find( indices.begin(), indices.end(), index ) != indices.end() ) { continue; }
indices.push_back(index);

0 comments on commit b81504e

Please sign in to comment.