diff --git a/Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCEventProducer.cc b/Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCEventProducer.cc index e644b38ae45f7..908f612b5d92b 100644 --- a/Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCEventProducer.cc +++ b/Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCEventProducer.cc @@ -9,6 +9,7 @@ ________________________________________________________________**/ // C++ standard #include + // CMS #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h" #include "DataFormats/DetId/interface/DetId.h" @@ -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: @@ -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 thePCCob; }; @@ -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::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); diff --git a/DataFormats/Luminosity/interface/PixelClusterCounts.h b/DataFormats/Luminosity/interface/PixelClusterCounts.h index 5581a1e36135f..1b4b190092030 100644 --- a/DataFormats/Luminosity/interface/PixelClusterCounts.h +++ b/DataFormats/Luminosity/interface/PixelClusterCounts.h @@ -31,26 +31,47 @@ 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 const& countsInEvent = pccInEvent.counts(); + std::vector const& rocCountsInEvent = pccInEvent.countsRoc(); std::vector const& modIDInEvent = pccInEvent.modID(); + std::vector 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 const& counts = pcc.readCounts(); + std::vector const& countsRoc = pcc.readRocCounts(); std::vector const& modIDs = pcc.readModID(); + std::vector const& rocIDs = pcc.readRocID(); std::vector 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]; } @@ -58,19 +79,25 @@ namespace reco { 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 const& readCounts() const { return (m_counts); } + std::vector const& readRocCounts() const { return (m_countsRoc); } std::vector const& readEvents() const { return (m_events); } std::vector const& readModID() const { return (m_ModID); } + std::vector const& readRocID() const { return (m_RocID); } private: std::vector m_counts; + std::vector m_countsRoc; std::vector m_events; std::vector m_ModID; + std::vector m_RocID; }; } // namespace reco diff --git a/DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h b/DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h index e5ffa4886796f..94227393ea11a 100644 --- a/DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h +++ b/DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h @@ -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 const& counts() const { return (m_counts); } + std::vector const& countsRoc() const { return (m_countsRoc); } + std::vector const& modID() const { return (m_ModID); } + std::vector const& rocID() const { return (m_RocID); } + unsigned int const& bxID() const { return m_bxID; } private: std::vector m_counts; + std::vector m_countsRoc; std::vector m_ModID; + std::vector m_RocID; unsigned int m_bxID; }; diff --git a/DataFormats/Luminosity/src/classes_def.xml b/DataFormats/Luminosity/src/classes_def.xml index 47e92b0d46c8d..52c6c5668725f 100644 --- a/DataFormats/Luminosity/src/classes_def.xml +++ b/DataFormats/Luminosity/src/classes_def.xml @@ -46,11 +46,13 @@ - + + - + +