Skip to content

Commit

Permalink
Including per ROC histograms for Pixel Cluster Counting luminosity
Browse files Browse the repository at this point in the history
  • Loading branch information
perrotta committed May 27, 2024
1 parent 32dc277 commit 64e31f9
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
31 changes: 23 additions & 8 deletions Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCEventProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ________________________________________________________________**/

// C++ standard
#include <string>

// CMS
#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
#include "DataFormats/DetId/interface/DetId.h"
Expand All @@ -28,6 +29,7 @@ ________________________________________________________________**/
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "TMath.h"

//The class
class AlcaPCCEventProducer : public edm::stream::EDProducer<> {
public:
Expand All @@ -45,6 +47,10 @@ class AlcaPCCEventProducer : public edm::stream::EDProducer<> {
int countEvt_; //counter
int countLumi_; //counter

const int rowsperroc = 52;
const int colsperroc = 80;
const int nROCcolumns = 8;

std::unique_ptr<reco::PixelClusterCountsInEvent> thePCCob;
};

Expand Down Expand Up @@ -79,14 +85,23 @@ void AlcaPCCEventProducer::produce(edm::Event& iEvent, const edm::EventSetup& iS
}
DetId detId = mod.id();

//--The following will be used when we make a theshold for the clusters.
//--Keeping this for features that may be implemented later.
// -- clusters on this det
//edmNew::DetSet<SiPixelCluster>::const_iterator di;
//int nClusterCount=0;
//for (di = mod.begin(); di != mod.end(); ++di) {
// nClusterCount++;
//}
// Iterate over Clusters in module to fill per ROC histogram
for (auto const& cluster : mod) {
for (int i = 0; i < cluster.size(); ++i) {
const auto pix = cluster.pixel(i);
// TODO: add roc threshold to config if(di.adc > fRocThreshold_) {
if (pix.adc > 0) {
int irow = pix.x / rowsperroc; /* constant column direction is along x-axis */
int icol = pix.y / colsperroc; /* constant row direction is along y-axis */
/* generate the folling roc index that is going to map with ROC id as
8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 */
int key = icol + irow * nROCcolumns;
thePCCob->incrementRoc(((detId << 7) + key), 1);
}
}
}

int nCluster = mod.size();
thePCCob->increment(detId(), nCluster);
thePCCob->setbxID(bx);
Expand Down
27 changes: 27 additions & 0 deletions DataFormats/Luminosity/interface/PixelClusterCounts.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,73 @@ namespace reco {
m_counts.at(LumiConstants::numBX * modIndex + bxID - 1) += count;
}

void incrementRoc(int rD, unsigned int bxID, int count) {
size_t rocIndex = std::distance(m_RocID.begin(), std::find(m_RocID.begin(), m_RocID.end(), rD));
if (rocIndex == m_RocID.size()) {
m_RocID.push_back(rD);
m_countsRoc.resize(m_countsRoc.size() + LumiConstants::numBX, 0);
}
m_countsRoc.at(LumiConstants::numBX * rocIndex + bxID - 1) += count;
}

void eventCounter(unsigned int bxID) { m_events.at(bxID - 1)++; }

void add(reco::PixelClusterCountsInEvent const& pccInEvent) {
std::vector<int> const& countsInEvent = pccInEvent.counts();
std::vector<int> const& rocCountsInEvent = pccInEvent.countsRoc();
std::vector<int> const& modIDInEvent = pccInEvent.modID();
std::vector<int> const& rocIDInEvent = pccInEvent.rocID();
int bxIDInEvent = pccInEvent.bxID();
for (unsigned int i = 0; i < modIDInEvent.size(); i++) {
increment(modIDInEvent[i], bxIDInEvent, countsInEvent.at(i));
}
for (unsigned int i = 0; i < rocIDInEvent.size(); i++) {
incrementRoc(rocIDInEvent[i], bxIDInEvent, rocCountsInEvent.at(i));
}
}

void merge(reco::PixelClusterCounts const& pcc) {
std::vector<int> const& counts = pcc.readCounts();
std::vector<int> const& countsRoc = pcc.readRocCounts();
std::vector<int> const& modIDs = pcc.readModID();
std::vector<int> const& rocIDs = pcc.readRocID();
std::vector<int> const& events = pcc.readEvents();
for (unsigned int i = 0; i < modIDs.size(); i++) {
for (unsigned int bxID = 0; bxID < LumiConstants::numBX; ++bxID) {
increment(modIDs[i], bxID + 1, counts.at(i * LumiConstants::numBX + bxID));
}
}
for (unsigned int i = 0; i < rocIDs.size(); i++) {
for (unsigned int bxID = 0; bxID < LumiConstants::numBX; ++bxID) {
incrementRoc(rocIDs[i], bxID + 1, countsRoc.at(i * LumiConstants::numBX + bxID));
}
}
for (unsigned int i = 0; i < LumiConstants::numBX; ++i) {
m_events[i] += events[i];
}
}

void reset() {
m_counts.clear();
m_countsRoc.clear();
m_ModID.clear();
m_RocID.clear();
m_events.clear();
m_events.resize(LumiConstants::numBX, 0);
}

std::vector<int> const& readCounts() const { return (m_counts); }
std::vector<int> const& readRocCounts() const { return (m_countsRoc); }
std::vector<int> const& readEvents() const { return (m_events); }
std::vector<int> const& readModID() const { return (m_ModID); }
std::vector<int> const& readRocID() const { return (m_RocID); }

private:
std::vector<int> m_counts;
std::vector<int> m_countsRoc;
std::vector<int> m_events;
std::vector<int> m_ModID;
std::vector<int> m_RocID;
};

} // namespace reco
Expand Down
15 changes: 15 additions & 0 deletions DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,32 @@ namespace reco {
m_counts[modIndex] += count;
}

void incrementRoc(int rD, int count) {
size_t rocIndex = std::distance(m_RocID.begin(), std::find(m_RocID.begin(), m_RocID.end(), rD));
if (rocIndex == m_RocID.size()) {
m_RocID.push_back(rD);
m_countsRoc.push_back(0);
}
m_countsRoc[rocIndex] += count;
}

void setbxID(unsigned int inputbxID) { m_bxID = inputbxID; }

std::vector<int> const& counts() const { return (m_counts); }

std::vector<int> const& countsRoc() const { return (m_countsRoc); }

std::vector<int> const& modID() const { return (m_ModID); }

std::vector<int> const& rocID() const { return (m_RocID); }

unsigned int const& bxID() const { return m_bxID; }

private:
std::vector<int> m_counts;
std::vector<int> m_countsRoc;
std::vector<int> m_ModID;
std::vector<int> m_RocID;
unsigned int m_bxID;
};

Expand Down
6 changes: 4 additions & 2 deletions DataFormats/Luminosity/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
</class>
<class name="std::vector<LumiSummary::L1>"/>
<class name="std::vector<LumiSummary::HLT>"/>
<class name="reco::PixelClusterCounts" ClassVersion="3">
<class name="reco::PixelClusterCounts" ClassVersion="4">
<version ClassVersion="4" checksum="63275688"/>
<version ClassVersion="3" checksum="1474294271"/>
</class>
<class name="edm::Wrapper<reco::PixelClusterCounts>"/>
<class name="reco::PixelClusterCountsInEvent" ClassVersion="3">
<class name="reco::PixelClusterCountsInEvent" ClassVersion="4">
<version ClassVersion="4" checksum="3986679997"/>
<version ClassVersion="3" checksum="3776858548"/>
</class>
<class name="edm::Wrapper<reco::PixelClusterCountsInEvent>"/>
Expand Down

0 comments on commit 64e31f9

Please sign in to comment.