Skip to content

Commit

Permalink
Merge pull request #42330 from aloeliger/bxVectorbxCheck_13_1
Browse files Browse the repository at this point in the history
[13_1_X] Add BX boundary checks for BXVector push_back
  • Loading branch information
cmsbuild authored Jul 23, 2023
2 parents ef77fef + d73c248 commit 91d6622
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions DataFormats/L1Trigger/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<use name="DataFormats/L1TrackTrigger"/>
<use name="DataFormats/HcalDetId"/>
<use name="FWCore/Concurrency"/>
<use name="FWCore/MessageLogger"/>
<use name="hls"/>
<export>
<lib name="1"/>
Expand Down
16 changes: 12 additions & 4 deletions DataFormats/L1Trigger/interface/BXVector.icc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <iostream>
using namespace std;

#include "FWCore/MessageLogger/interface/MessageLogger.h"

template <class T>
BXVector<T>::BXVector(unsigned size, // number of objects per BX
int bxFirst, // first BX stored
Expand Down Expand Up @@ -131,11 +133,17 @@ unsigned BXVector<T>::size(int bx) const {
// add element with given BX index
template <class T>
void BXVector<T>::push_back(int bx, T object) {
data_.insert(data_.begin() + itrs_[indexFromBX(bx)] + size(bx), object);
for (unsigned k = 0; k < itrs_.size(); k++) {
if (k > indexFromBX(bx)) {
itrs_[k]++;
if (bx >= bxFirst_ && bx <= bxLast_) {
data_.insert(data_.begin() + itrs_[indexFromBX(bx)] + size(bx), object);
for (unsigned k = 0; k < itrs_.size(); k++) {
if (k > indexFromBX(bx)) {
itrs_[k]++;
}
}
} else {
edm::LogWarning("BXVectorBXViolation")
<< "Something attempted to push to a BXVector BX that does not exist. The data will be ignored. bx: " << bx
<< " bxFirst: " << bxFirst_ << " bxLast: " << bxLast_;
}
}

Expand Down

0 comments on commit 91d6622

Please sign in to comment.