Skip to content

Commit

Permalink
Merge/cmssw 14 1 x qcore producer backup (#6)
Browse files Browse the repository at this point in the history
* code check

* address floor comment
  • Loading branch information
sihyunjeon authored Dec 18, 2024
1 parent cfa1103 commit 6118c11
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions DataFormats/Phase2TrackerDigi/src/Phase2ITChip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ std::vector<Phase2ITQCore> Phase2ITChip::rem_duplicates(std::vector<Phase2ITQCor
//Returns a list of the qcores with hits arranged by increasing column and then row numbers
std::vector<Phase2ITQCore> Phase2ITChip::organize_QCores(std::vector<Phase2ITQCore> qcores) {
std::vector<Phase2ITQCore> organized_list = {};
while (qcores.size() > 0) {
while (!qcores.empty()) {
int min = 0;

for (size_t i = 1; i < qcores.size(); i++) {
Expand All @@ -87,7 +87,7 @@ std::vector<Phase2ITQCore> link_QCores(std::vector<Phase2ITQCore> qcores) {
}

//.size() is unsigned. If size is zero size()-1 is a huge number hence this needs to be protected
if (qcores.size() > 0) {
if (!qcores.empty()) {
for (size_t i = 0; i < qcores.size() - 1; i++) {
if (qcores[i].get_col() != qcores[i + 1].get_col()) {
qcores[i].setIsLast(true);
Expand All @@ -103,6 +103,7 @@ std::vector<Phase2ITQCore> link_QCores(std::vector<Phase2ITQCore> qcores) {
std::vector<Phase2ITQCore> Phase2ITChip::get_organized_QCores() {
std::vector<Phase2ITQCore> qcores = {};

qcores.reserve(hitList_.size());
for (const auto& hit : hitList_) {
qcores.push_back(get_QCore_from_hit(hit));
}
Expand All @@ -114,7 +115,7 @@ std::vector<Phase2ITQCore> Phase2ITChip::get_organized_QCores() {
std::vector<bool> Phase2ITChip::get_chip_code() {
std::vector<bool> code = {};

if (hitList_.size() > 0) {
if (!hitList_.empty()) {
std::vector<Phase2ITQCore> qcores = get_organized_QCores();
bool is_new_col = true;

Expand Down
6 changes: 4 additions & 2 deletions DataFormats/Phase2TrackerDigi/src/Phase2ITQCore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::vector<bool> Phase2ITQCore::toRocCoordinates(std::vector<bool>& hitmap) {
std::vector<bool> ROC_hitmap(16, false);

for (size_t i = 0; i < hitmap.size(); i++) {
int row = std::floor(i / 4);
int row = i / 4;
int col = i % 4;
int new_row;
int new_col;
Expand All @@ -34,7 +34,7 @@ std::vector<bool> Phase2ITQCore::toRocCoordinates(std::vector<bool>& hitmap) {
new_row = row / 2;
new_col = 2 * col;
} else {
new_row = std::floor(row / 2);
new_row = row / 2;
new_col = 2 * col + 1;
}

Expand All @@ -49,6 +49,7 @@ std::vector<bool> Phase2ITQCore::toRocCoordinates(std::vector<bool>& hitmap) {
std::vector<bool> Phase2ITQCore::getHitmap() {
std::vector<bool> hitmap = {};

hitmap.reserve(hits_.size());
for (auto hit : hits_) {
hitmap.push_back(hit > 0);
}
Expand All @@ -59,6 +60,7 @@ std::vector<bool> Phase2ITQCore::getHitmap() {
std::vector<int> Phase2ITQCore::getADCs() {
std::vector<int> adcmap = {};

adcmap.reserve(adcs_.size());
for (auto adc : adcs_) {
adcmap.push_back(adc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Phase2ITQCoreProducer : public edm::stream::EDProducer<> {
~Phase2ITQCoreProducer() override = default;

private:
virtual void produce(edm::Event&, const edm::EventSetup&);
void produce(edm::Event&, const edm::EventSetup&) override;

const edm::InputTag src_;
const edm::EDGetTokenT<edm::DetSetVector<PixelDigi>> pixelDigi_token_;
Expand Down

0 comments on commit 6118c11

Please sign in to comment.