Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including per ROC histograms for Pixel Cluster Counting luminosity #44996

Merged
merged 17 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 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,25 @@ 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);
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;

// TODO: add roc threshold to config if(di.adc > fRocThreshold_) {
if (pix.adc > 0) {
thePCCob->incrementRoc(((detId << 7) + key), 1);
}
duff-ae marked this conversation as resolved.
Show resolved Hide resolved
}
}

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
8 changes: 4 additions & 4 deletions DataFormats/Luminosity/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
</class>
<class name="std::vector<LumiSummary::L1>"/>
<class name="std::vector<LumiSummary::HLT>"/>
<class name="reco::PixelClusterCounts" ClassVersion="3">
<version ClassVersion="3" checksum="1474294271"/>
duff-ae marked this conversation as resolved.
Show resolved Hide resolved
<class name="reco::PixelClusterCounts" ClassVersion="4">
<version ClassVersion="4" checksum="63275688"/>
</class>
<class name="edm::Wrapper<reco::PixelClusterCounts>"/>
<class name="reco::PixelClusterCountsInEvent" ClassVersion="3">
duff-ae marked this conversation as resolved.
Show resolved Hide resolved
<version ClassVersion="3" checksum="3776858548"/>
<class name="reco::PixelClusterCountsInEvent" ClassVersion="4">
<version ClassVersion="4" checksum="3986679997"/>
</class>
<class name="edm::Wrapper<reco::PixelClusterCountsInEvent>"/>
</lcgdict>