diff --git a/CalibTracker/SiPixelQuality/BuildFile.xml b/CalibTracker/SiPixelQuality/BuildFile.xml
index ef7127c85b9ba..9b76a483be2b3 100644
--- a/CalibTracker/SiPixelQuality/BuildFile.xml
+++ b/CalibTracker/SiPixelQuality/BuildFile.xml
@@ -1,11 +1,23 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
diff --git a/CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h b/CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h
index 9d4ae424f0a4d..1ad897dd86816 100644
--- a/CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h
+++ b/CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h
@@ -13,85 +13,77 @@ class SiPixelDetectorStatus {
SiPixelDetectorStatus();
~SiPixelDetectorStatus();
+ // reset
+ void resetDetectorStatus();
+ // combine detector status
+ void updateDetectorStatus(SiPixelDetectorStatus newData);
+
// file I/O
void readFromFile(std::string filename);
- void dumpToFile(std::string filename);
+ void dumpToFile(std::ofstream& outFile);
+
+ /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
// add SiPixelModuleStatus for detID, specifying nrocs
void addModule(int detid, int nrocs);
// add a SiPixelModuleStatus obj for detID
void addModule(int detid, SiPixelModuleStatus a);
+ // get a Module
+ bool findModule(int detid);
+ SiPixelModuleStatus* getModule(int detid);
// fill hit in double idc in ROC roc into module detid
void fillDIGI(int detid, int roc);
// fill FEDerror25 info
void fillFEDerror25(int detid, PixelFEDChannel ch);
+ // detector status : std:map - collection of module status
+ std::map getDetectorStatus() { return fModules_; }
+ // list of ROCs with FEDerror25
std::map> getFEDerror25Rocs();
+ // total number of DIGIs
+ unsigned long int digiOccDET() { return fDetHits_; }
+ // total processed events
+ void setNevents(unsigned long int N) { ftotalevents_ = N; }
+ unsigned long int getNevents() { return ftotalevents_; }
+ // number of modules in detector
+ int nmodules();
// determine detector average nhits and RMS
double perRocDigiOcc();
double perRocDigiOccVar();
- unsigned long int digiOccDET() { return fDetHits; }
-
- // number of modules in detector
- int nmodules();
-
- // get a Module
- bool findModule(int detid);
- SiPixelModuleStatus* getModule(int detid);
-
- // provide for iterating over the entire detector
- std::map::iterator begin();
- std::map::iterator next();
- std::map::iterator end();
-
// set the time stamps
void setRunRange(int run0, int run1) {
- fRun0 = run0;
- fRun1 = run1;
+ fRun0_ = run0;
+ fRun1_ = run1;
}
- std::pair getRunRange() { return std::make_pair(fRun0, fRun1); }
+ std::pair getRunRange() { return std::make_pair(fRun0_, fRun1_); }
+ //////////////////////////////////////////////////////////////////////////////////
void setLSRange(int ls0, int ls1) {
- fLS0 = ls0;
- fLS1 = ls1;
- }
- std::pair getLSRange() { return std::make_pair(fLS0, fLS1); }
-
- // total processed events
- void setNevents(unsigned long int N) { fNevents = N; }
- unsigned long int getNevents() { return fNevents; }
-
- void resetDetectorStatus() {
- fModules.clear();
- fDetHits = 0;
- fNevents = 0;
- fRun0 = 99999999;
- fRun1 = 0;
- fLS0 = 99999999;
- fLS1 = 0;
+ fLS0_ = ls0;
+ fLS1_ = ls1;
}
+ std::pair getLSRange() { return std::make_pair(fLS0_, fLS1_); }
- // combine detector status
- void updateDetectorStatus(SiPixelDetectorStatus newData);
-
- // detector status
- std::map getDetectorStatus() { return fModules; }
+ // provide for iterating over the entire detector
+ std::map::iterator begin();
+ std::map::iterator next();
+ std::map::iterator end();
private:
- std::map fModules;
+ std::map fModules_;
// first and last lumisection seen in this instance
- int fLS0, fLS1;
- // first and last run seen in this instance (should be the same number!)
- int fRun0, fRun1;
+ int fLS0_, fLS1_;
+ // first and last run (should be the same number! as currently only perform Single Run Harvestor)
+ int fRun0_, fRun1_;
// number of events processed
- unsigned long int fNevents;
+ unsigned long int ftotalevents_;
// total hits in detector
- unsigned long int fDetHits;
+ unsigned long int fDetHits_;
};
#endif
diff --git a/CalibTracker/SiPixelQuality/interface/SiPixelModuleStatus.h b/CalibTracker/SiPixelQuality/interface/SiPixelModuleStatus.h
index 66c45177e8d0d..86a05498ea49e 100644
--- a/CalibTracker/SiPixelQuality/interface/SiPixelModuleStatus.h
+++ b/CalibTracker/SiPixelQuality/interface/SiPixelModuleStatus.h
@@ -9,21 +9,25 @@
// ----------------------------------------------------------------------
class SiPixelModuleStatus {
public:
- SiPixelModuleStatus(int det = 0, int nrocs = 16);
+ SiPixelModuleStatus(int det = 0, int nrocs = 16); // default for Phase-1
~SiPixelModuleStatus();
- /// fill with online coordinates
+ /// fill digi
void fillDIGI(int iroc);
-
- /// fill with online coordinates (nhit > 1)
- void updateDIGI(int iroc, unsigned int nhit);
-
/// fill FEDerror25
void fillFEDerror25(PixelFEDChannel ch);
+ /// update digi (nhit > 1)
+ void updateDIGI(int iroc, unsigned int nhit);
+ /// update FEDerror25
+ void updateFEDerror25(int iroc, bool FEDerror25);
+
/// return ROC status (= hits on ROC iroc)
unsigned int digiOccROC(int iroc);
+ /// return ROC FEDerror25
+ bool fedError25(int iroc);
+
/// return module status (= hits on module)
unsigned int digiOccMOD();
@@ -33,6 +37,7 @@ class SiPixelModuleStatus {
/// accessors and setters
int detid();
int nrocs();
+ void setDetId(int detid);
void setNrocs(int iroc);
/// calculate (averaged over this module's ROCs) mean hit number and its sigma
@@ -44,8 +49,8 @@ class SiPixelModuleStatus {
void updateModuleStatus(SiPixelModuleStatus newData);
private:
- int fDetid, fNrocs;
- std::vector fRocs;
+ int fDetid_, fNrocs_;
+ std::vector fRocs_;
};
#endif
diff --git a/CalibTracker/SiPixelQuality/interface/SiPixelRocStatus.h b/CalibTracker/SiPixelQuality/interface/SiPixelRocStatus.h
index 9433d130da585..d06c8baa9c07d 100644
--- a/CalibTracker/SiPixelQuality/interface/SiPixelRocStatus.h
+++ b/CalibTracker/SiPixelQuality/interface/SiPixelRocStatus.h
@@ -6,18 +6,20 @@ class SiPixelRocStatus {
public:
SiPixelRocStatus();
~SiPixelRocStatus();
+
void fillDIGI();
- void updateDIGI(unsigned int hits);
void fillFEDerror25();
- // stuckTBM
- bool isFEDerror25() { return isFEDerror25_; }
+ void updateDIGI(unsigned int hits);
+ void updateFEDerror25(bool fedError25);
// occpancy
unsigned int digiOccROC();
+ // FEDerror25 for stuckTBM
+ bool isFEDerror25();
private:
- unsigned int fDC;
+ unsigned int fDC_;
bool isFEDerror25_;
};
diff --git a/CalibTracker/SiPixelQuality/interface/SiPixelTopoFinder.h b/CalibTracker/SiPixelQuality/interface/SiPixelTopoFinder.h
new file mode 100644
index 0000000000000..260be71772f3b
--- /dev/null
+++ b/CalibTracker/SiPixelQuality/interface/SiPixelTopoFinder.h
@@ -0,0 +1,72 @@
+#ifndef SiPixelTopoFinder_H
+#define SiPixelTopoFinder_H
+// -*- C++ -*-
+//
+// Class: SiPixelTopoFinder
+//
+#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
+#include "DataFormats/DetId/interface/DetId.h"
+#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
+#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
+#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
+#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
+#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
+#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
+
+class SiPixelTopoFinder {
+public:
+ SiPixelTopoFinder();
+ ~SiPixelTopoFinder();
+
+ void init(const TrackerGeometry* trackerGeometry,
+ const TrackerTopology* trackerTopology,
+ const SiPixelFedCablingMap* siPixelFedCablingMap);
+
+ std::vector getDetIds() const { return fDetIds_; }
+
+ std::map> getSensors() const { return fSensors_; }
+
+ std::map> getSensorLayout() const { return fSensorLayout_; }
+
+ std::unordered_map getFedIds() const { return fFedIds_; }
+
+ std::map> getRocIds() const { return fRocIds_; }
+
+private:
+ // initialize with nullptr
+ int phase_ = -1;
+
+ const TrackerTopology* tkTopo_ = nullptr;
+ const TrackerGeometry* tkGeom_ = nullptr;
+ const SiPixelFedCablingMap* cablingMap_ = nullptr;
+
+ // List of DetIds
+ std::vector fDetIds_;
+ // ROC size (number of row, number of columns for each det id)
+ std::map> fSensors_;
+ // the roc layout on a module
+ std::map> fSensorLayout_;
+ // fedId as a function of detId
+ std::unordered_map fFedIds_;
+ // map the index ROC to rocId
+ std::map> fRocIds_;
+
+ // conversion between online(local, per-ROC) row/column and offline(global, per-Module) row/column
+ void onlineRocColRow(const DetId& detId,
+ const SiPixelFedCablingMap* cablingMap,
+ int fedId,
+ int offlineRow,
+ int offlineCol,
+ int& roc,
+ int& row,
+ int& col);
+
+ int indexROC(int irow, int icol, int nROCcolumns);
+
+ // some helper function for pixel naming
+ int quadrant(const DetId& detid);
+ int side(const DetId& detid);
+ int half(const DetId& detid);
+};
+
+#endif
diff --git a/CalibTracker/SiPixelQuality/plugins/BuildFile.xml b/CalibTracker/SiPixelQuality/plugins/BuildFile.xml
index 370caef69d1ee..f46c3c837e19a 100644
--- a/CalibTracker/SiPixelQuality/plugins/BuildFile.xml
+++ b/CalibTracker/SiPixelQuality/plugins/BuildFile.xml
@@ -1,20 +1,44 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.cc b/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.cc
index 068d413e1ff59..aafbe44ee1750 100644
--- a/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.cc
+++ b/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.cc
@@ -1,9 +1,3 @@
-/**_________________________________________________________________
- class: SiPixelStatusProducer.cc
- package: CalibTracker/SiPixelQuality
-
- ________________________________________________________________**/
-
// C++ standard
#include
// ROOT
@@ -11,12 +5,7 @@
// CMSSW FW
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/MakerMacros.h"
-#include "FWCore/Framework/interface/ConsumesCollector.h"
-#include "FWCore/Framework/interface/ESWatcher.h"
-#include "FWCore/Framework/interface/EventSetup.h"
-#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
-#include "FWCore/Utilities/interface/Transition.h"
// CMSSW DataFormats
#include "DataFormats/Common/interface/ConditionsInEdm.h"
#include "DataFormats/Common/interface/DetSetVector.h"
@@ -34,226 +23,174 @@
#include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h"
#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
-// EDProducer related dataformat
-#include "DQM/SiPixelPhase1Common/interface/SiPixelCoordinates.h"
-#include "CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h"
-// header file
-#include "CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h"
-using namespace std;
+// Header file
+#include "CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h"
-//--------------------------------------------------------------------------------------------------
-SiPixelStatusProducer::SiPixelStatusProducer(const edm::ParameterSet& iConfig)
- : trackerGeometryToken_(
- esConsumes()),
- trackerTopologyToken_(esConsumes()),
- siPixelFedCablingMapToken_(
- esConsumes()) {
- // get parameter
-
- // badPixelFEDChannelCollections
- std::vector badPixelFEDChannelCollectionLabels_ =
+SiPixelStatusProducer::SiPixelStatusProducer(const edm::ParameterSet& iConfig, SiPixelTopoCache const*) {
+ /* badPixelFEDChannelCollections */
+ std::vector badPixelFEDChannelCollectionLabels =
iConfig.getParameter("SiPixelStatusProducerParameters")
.getParameter>("badPixelFEDChannelCollections");
- for (auto& t : badPixelFEDChannelCollectionLabels_)
+ for (auto& t : badPixelFEDChannelCollectionLabels)
theBadPixelFEDChannelsTokens_.push_back(consumes(t));
- // badPixelFEDChannelCollections = cms.VInputTag(cms.InputTag('siPixelDigis'))
+ /* pixel clusters */
fPixelClusterLabel_ = iConfig.getParameter("SiPixelStatusProducerParameters")
.getUntrackedParameter("pixelClusterLabel");
fSiPixelClusterToken_ = consumes>(fPixelClusterLabel_);
- resetNLumi_ = iConfig.getParameter("SiPixelStatusProducerParameters")
- .getUntrackedParameter("resetEveryNLumi", 1);
-
- ftotalevents = 0;
- countLumi_ = 0;
- beginLumi_ = endLumi_ = -1;
- endLumi_ = endRun_ = -1;
+ //debug_ = iConfig.getUntrackedParameter("debug");
+ /* register products */
produces("siPixelStatus");
}
-//--------------------------------------------------------------------------------------------------
SiPixelStatusProducer::~SiPixelStatusProducer() {}
//--------------------------------------------------------------------------------------------------
-void SiPixelStatusProducer::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) {
- edm::LogInfo("SiPixelStatusProducer") << "beginlumi setup " << endl;
-
- if (countLumi_ == 0 && resetNLumi_ > 0) {
- beginLumi_ = lumiSeg.luminosityBlock();
- beginRun_ = lumiSeg.run();
- ftotalevents = 0;
- }
-
- // The es watcher is acutally not needed if run parallel jobs for each lumi section
- if (siPixelFedCablingMapWatcher_.check(iSetup) || trackerDIGIGeoWatcher_.check(iSetup) ||
- trackerTopoWatcher_.check(iSetup)) {
- trackerGeometry_ = &iSetup.getData(trackerGeometryToken_);
- const TrackerTopology* trackerTopology = &iSetup.getData(trackerTopologyToken_);
- fCablingMap_ = &iSetup.getData(siPixelFedCablingMapToken_);
-
- coord_.init(trackerTopology, trackerGeometry_, fCablingMap_);
-
- fFedIds = fCablingMap_->det2fedMap();
-
- } // if conditionWatcher_.check(iSetup)
-
- // init the SiPixelDetectorStatus fDet and sensor size fSensors in the begining (when countLumi is zero)
- if (countLumi_ == 0) {
- for (TrackerGeometry::DetContainer::const_iterator it = trackerGeometry_->dets().begin();
- it != trackerGeometry_->dets().end();
- it++) {
- const PixelGeomDetUnit* pgdu = dynamic_cast((*it));
- if (pgdu == nullptr)
- continue;
- DetId detId = (*it)->geographicalId();
- int detid = detId.rawId();
-
- // don't want to use magic number row 80 column 52
- const PixelTopology* topo = static_cast(&pgdu->specificTopology());
- int rowsperroc = topo->rowsperroc();
- int colsperroc = topo->colsperroc();
-
- int nROCrows = pgdu->specificTopology().nrows() / rowsperroc;
- int nROCcolumns = pgdu->specificTopology().ncolumns() / colsperroc;
- int nrocs = nROCrows * nROCcolumns;
-
- fDet.addModule(detid, nrocs);
-
- fSensors[detid] = std::make_pair(rowsperroc, colsperroc);
- fSensorLayout[detid] = std::make_pair(nROCrows, nROCcolumns);
-
- std::map rocIdMap;
- for (int irow = 0; irow < nROCrows; irow++) {
- for (int icol = 0; icol < nROCcolumns; icol++) {
- int dummyOfflineRow = (rowsperroc / 2 - 1) + irow * rowsperroc;
- int dummeOfflineColumn = (colsperroc / 2 - 1) + icol * colsperroc;
- // encode irow, icol
- int key = indexROC(irow, icol, nROCcolumns);
- int roc(-1), rocR(-1), rocC(-1);
- onlineRocColRow(detId, dummyOfflineRow, dummeOfflineColumn, roc, rocR, rocC);
+void SiPixelStatusProducer::beginRun(edm::Run const&, edm::EventSetup const&) {
+ /*Is it good to pass the objects stored in runCache to set class private members values *
+ or just call runCahche every time in the calss function?*/
+
+ edm::LogInfo("SiPixelStatusProducer") << "beginRun: update the std::map for pixel geo/topo " << std::endl;
+ /* update the std::map for pixel geo/topo */
+ /* vector of all detIds */
+ fDetIds_ = runCache()->getDetIds(); //getDetIds();
+ /* ROC size (number of row, number of columns for each det id) */
+ fSensors_ = runCache()->getSensors();
+ /* the roc layout on a module */
+ fSensorLayout_ = runCache()->getSensorLayout();
+ /* fedId as a function of detId */
+ fFedIds_ = runCache()->getFedIds();
+ /* map the index ROC to rocId */
+ fRocIds_ = runCache()->getRocIds();
+}
- int value = roc;
- rocIdMap[key] = value;
- }
- }
+void SiPixelStatusProducer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
+ edm::LogInfo("SiPixelStatusProducer") << "beginlumi instance" << std::endl;
- fRocIds[detid] = rocIdMap;
- }
+ /* initialize fDet_ with a set of modules(detIds) and clean the fFEDerror25_ */
+ fDet_ = SiPixelDetectorStatus();
+ for (unsigned int itDetId = 0; itDetId < fDetIds_.size(); ++itDetId) {
+ int detid = fDetIds_[itDetId];
+ int nrocs = fSensorLayout_[detid].first * fSensorLayout_[detid].second;
- } // init when countLumi = 0
+ fDet_.addModule(detid, nrocs);
+ }
- FEDerror25_.clear();
- countLumi_++;
+ fFEDerror25_.clear();
+ ftotalevents_ = 0;
}
-//--------------------------------------------------------------------------------------------------
-void SiPixelStatusProducer::accumulate(edm::Event const& iEvent, const edm::EventSetup&) {
- ftotalevents++;
+void SiPixelStatusProducer::accumulate(edm::Event const& iEvent, edm::EventSetup const&) {
+ edm::LogInfo("SiPixelStatusProducer") << "start cluster analyzer " << std::endl;
- edm::LogInfo("SiPixelStatusProducer") << "start cluster analyzer " << endl;
+ /* count number of events for the current module instance in the luminosityBlock */
+ ftotalevents_++;
- // ----------------------------------------------------------------------
- // -- Pixel cluster analysis
- // ----------------------------------------------------------------------
+ /* ----------------------------------------------------------------------
+ -- Pixel cluster analysis
+ ----------------------------------------------------------------------*/
edm::Handle> hClusterColl;
if (!iEvent.getByToken(fSiPixelClusterToken_, hClusterColl)) {
edm::LogWarning("SiPixelStatusProducer")
- << " edmNew::DetSetVector " << fPixelClusterLabel_ << " does not exist!" << endl;
+ << " edmNew::DetSetVector " << fPixelClusterLabel_ << " does not exist!" << std::endl;
return;
}
iEvent.getByToken(fSiPixelClusterToken_, hClusterColl);
if (hClusterColl.isValid()) {
- for (const auto& clusters : *hClusterColl) { //loop over different clusters in a clusters vector (module)
- for (const auto& clu : clusters) { // loop over cluster in a given detId (module)
+ for (const auto& clusters : *hClusterColl) { /*loop over different clusters in a clusters vector (module)*/
+ for (const auto& clu : clusters) { /*loop over cluster in a given detId (module)*/
int detid = clusters.detId();
- int rowsperroc = fSensors[detid].first;
- int colsperroc = fSensors[detid].second;
+ int rowsperroc = fSensors_[detid].first;
+ int colsperroc = fSensors_[detid].second;
- int nROCcolumns = fSensorLayout[detid].second;
+ //int nROCrows = fSensorLayout_[detid].first;
+ int nROCcolumns = fSensorLayout_[detid].second;
int roc(-1);
- std::map fRocIds_detid;
- if (fRocIds.find(detid) != fRocIds.end()) {
- fRocIds_detid = fRocIds[detid];
+ std::map rocIds_detid;
+ if (fRocIds_.find(detid) != fRocIds_.end()) {
+ rocIds_detid = fRocIds_[detid];
}
- const vector& pixvector = clu.pixels();
+ /* A module is made with a few ROCs
+ Need to convert global row/column (on a module) to local row/column (on a ROC) */
+ const std::vector& pixvector = clu.pixels();
for (unsigned int i = 0; i < pixvector.size(); ++i) {
- int mr0 = pixvector[i].x; // constant column direction is along x-axis,
- int mc0 = pixvector[i].y; // constant row direction is along y-axis
+ int mr0 = pixvector[i].x; /* constant column direction is along x-axis */
+ int mc0 = pixvector[i].y; /* constant row direction is along y-axis */
int irow = mr0 / rowsperroc;
int icol = mc0 / colsperroc;
int key = indexROC(irow, icol, nROCcolumns);
- if (fRocIds_detid.find(key) != fRocIds_detid.end()) {
- roc = fRocIds_detid[key];
+ if (rocIds_detid.find(key) != rocIds_detid.end()) {
+ roc = rocIds_detid[key];
}
- fDet.fillDIGI(detid, roc);
+ fDet_.fillDIGI(detid, roc);
- } // loop over pixels in a given cluster
+ } /* loop over pixels in a cluster */
- } // loop over cluster in a given detId (module)
+ } /* loop over cluster in a detId (module) */
- } // loop over detId-grouped clusters in cluster detId-grouped clusters-vector
+ } /* loop over detId-grouped clusters in cluster detId-grouped clusters-vector* */
- } // hClusterColl.isValid()
+ } /* hClusterColl.isValid() */
else {
edm::LogWarning("SiPixelStatusProducer")
- << " edmNew::DetSetVector " << fPixelClusterLabel_ << " is NOT Valid!" << endl;
+ << " edmNew::DetSetVector " << fPixelClusterLabel_ << " is NOT Valid!" << std::endl;
}
- //////////////////////////////////////////////////////////////////////
- // FEDerror25 per-ROC per-event
+ /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
+
+ /* FEDerror25 per-ROC per-event */
edm::Handle pixelFEDChannelCollectionHandle;
- // look over different resouces of takens
+ /* look over different resouces of tokens */
for (const edm::EDGetTokenT& tk : theBadPixelFEDChannelsTokens_) {
- // collection has to exist
if (!iEvent.getByToken(tk, pixelFEDChannelCollectionHandle)) {
edm::LogWarning("SiPixelStatusProducer")
<< " PixelFEDChannelCollection with index " << tk.index() << " does NOT exist!" << std::endl;
continue;
}
+
iEvent.getByToken(tk, pixelFEDChannelCollectionHandle);
- // collection has to be valid
if (!pixelFEDChannelCollectionHandle.isValid()) {
edm::LogWarning("SiPixelStatusProducer")
- << " PixelFEDChannelCollection with index " << tk.index() << " is NOT valid!" << endl;
+ << " PixelFEDChannelCollection with index " << tk.index() << " is NOT valid!" << std::endl;
continue;
}
- // FEDerror channels for the current events
+
+ /* FEDerror channels for the current events */
std::map> tmpFEDerror25;
for (const auto& disabledChannels : *pixelFEDChannelCollectionHandle) {
- //loop over different PixelFED in a PixelFED vector (module)
+ /* loop over different PixelFED in a PixelFED vector (module) */
for (const auto& ch : disabledChannels) {
DetId detId = disabledChannels.detId();
int detid = detId.rawId();
- if (ftotalevents == 1) {
- // FEDerror25 channels for the first event in the lumi section
- FEDerror25_[detid].push_back(ch);
+ if (ftotalevents_ == 1) {
+ /* FEDerror25 channels for the "first" event in the lumi section (first for the current instance of the module) */
+ fFEDerror25_[detid].push_back(ch);
} else
tmpFEDerror25[detid].push_back(ch);
- } // loop over different PixelFED in a PixelFED vector (different channel for a given module)
-
- } // loop over different (different DetId) PixelFED vectors in PixelFEDChannelCollection
+ } /* loop over different PixelFED in a PixelFED vector (different channel for a module) */
- // Compare the current FEDerror list with the first event's FEDerror list
- // and save the common channels
- if (!tmpFEDerror25.empty() && !FEDerror25_.empty()) { // non-empty FEDerror lists
+ } /* loop over different (different DetId) PixelFED vectors in PixelFEDChannelCollection */
+ /* Compare the current FEDerror list with the first event's FEDerror list
+ * and save the common channels */
+ if (!tmpFEDerror25.empty() && !fFEDerror25_.empty()) {
std::map>::iterator itFEDerror25;
- for (itFEDerror25 = FEDerror25_.begin(); itFEDerror25 != FEDerror25_.end(); itFEDerror25++) {
+ for (itFEDerror25 = fFEDerror25_.begin(); itFEDerror25 != fFEDerror25_.end(); itFEDerror25++) {
int detid = itFEDerror25->first;
if (tmpFEDerror25.find(detid) != tmpFEDerror25.end()) {
std::vector chs = itFEDerror25->second;
@@ -262,147 +199,79 @@ void SiPixelStatusProducer::accumulate(edm::Event const& iEvent, const edm::Even
std::vector chs_common;
for (unsigned int ich = 0; ich < chs.size(); ich++) {
PixelFEDChannel ch = chs[ich];
- // look over the current FEDerror25 channels, save the common FED channels
+ /* loop over the current FEDerror25 channels, save the common FED channels */
for (unsigned int ich_tmp = 0; ich_tmp < chs_tmp.size(); ich_tmp++) {
PixelFEDChannel ch_tmp = chs_tmp[ich_tmp];
- if ((ch.fed == ch_tmp.fed) && (ch.link == ch_tmp.link)) { // the same FED channel
+ if ((ch.fed == ch_tmp.fed) && (ch.link == ch_tmp.link)) { /* the same FED channel */
chs_common.push_back(ch);
break;
}
}
}
- // remove the full module from FEDerror25 list if no common channels are left
+ /* remove the full module from FEDerror25 list if no common channels are left */
if (chs_common.empty())
- FEDerror25_.erase(itFEDerror25);
- // otherwise replace with the common channels
+ fFEDerror25_.erase(itFEDerror25);
+ /* otherwise replace with the common channels */
else {
- FEDerror25_[detid].clear();
- FEDerror25_[detid] = chs_common;
+ fFEDerror25_[detid].clear();
+ fFEDerror25_[detid] = chs_common;
}
- } else { // remove the full module from FEDerror25 list if the module doesn't appear in the current event's FEDerror25 list
- FEDerror25_.erase(itFEDerror25);
+ } else { /* remove the full module from FEDerror25 list if the module doesn't appear in the current event's FEDerror25 list */
+ fFEDerror25_.erase(itFEDerror25);
}
- } // loop over modules that have FEDerror25 in the first event in the lumi section
+ } /* loop over modules that have FEDerror25 in the first event in the lumi section */
- } // non-empty FEDerror lists
+ } /* non-empty FEDerror lists */
- } // look over different resouces of takens
+ } /* look over different resouces of takens */
- // no per-event collection put into iEvent
- // If use produce() function and no collection is put into iEvent, produce() will not run in unScheduled mode
- // Now since CMSSW_10_1_X, the accumulate() function will run whatsoever in the unScheduled mode
- // But accumulate() is NOT available and will NOT be available for releases before CMSSW_10_1_X
+ /* Caveat
+ no per-event collection put into iEvent
+ If use produce() function and no collection is put into iEvent, produce() will not run in unScheduled mode
+ Now since CMSSW_10_1_X, the accumulate() function will run whatsoever in the unScheduled mode
+ Accumulate() is NOT available for releases BEFORE CMSSW_10_1_X */
}
-//--------------------------------------------------------------------------------------------------
-void SiPixelStatusProducer::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup&) {}
+void SiPixelStatusProducer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {
+ /* set total number of events through ftotalevents_ */
+ fDet_.setNevents(ftotalevents_);
-//--------------------------------------------------------------------------------------------------
-void SiPixelStatusProducer::endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup&) {
- edm::LogInfo("SiPixelStatusProducer") << "endlumi producer " << endl;
-
- endLumi_ = lumiSeg.luminosityBlock();
- endRun_ = lumiSeg.run();
-
- // check if countLumi_ is large enough to read out/save data and reset for the next round
- if (resetNLumi_ == -1)
- return;
- if (countLumi_ < resetNLumi_)
- return;
-
- // set the FEDerror25 flag to be true for ROCs send out FEDerror25 for all events in the lumi section
- if (!FEDerror25_.empty()) {
- std::map>::iterator itFEDerror25;
- for (itFEDerror25 = FEDerror25_.begin(); itFEDerror25 != FEDerror25_.end(); itFEDerror25++) {
- int detid = itFEDerror25->first;
- std::vector chs = itFEDerror25->second;
- for (unsigned int ich = 0; ich < chs.size(); ich++) {
- fDet.fillFEDerror25(detid, chs[ich]);
- }
- }
- }
-
- fDet.setRunRange(beginRun_, endRun_);
- fDet.setLSRange(beginLumi_, endLumi_);
- fDet.setNevents(ftotalevents);
-
- // save result
- auto result = std::make_unique();
- *result = fDet;
-
- // only save for the lumi sections with NON-ZERO events
- lumiSeg.put(std::move(result), std::string("siPixelStatus"));
- edm::LogInfo("SiPixelStatusProducer") << "new lumi-based data stored for run " << beginRun_ << " lumi from "
- << beginLumi_ << " to " << endLumi_ << std::endl;
+ if (ftotalevents_ > 0) {
+ /* Add FEDerror25 information into SiPixelDetectorStatus fDet_ for FED channels stored in fFEDerror25_ */
+ if (!fFEDerror25_.empty()) { // non-empty FEDerror25
+ std::map>::iterator itFEDerror25;
+ for (itFEDerror25 = fFEDerror25_.begin(); itFEDerror25 != fFEDerror25_.end();
+ itFEDerror25++) { // loop over detIds
+ int detid = itFEDerror25->first;
+ std::vector chs = itFEDerror25->second;
+ for (unsigned int ich = 0; ich < chs.size(); ich++) {
+ fDet_.fillFEDerror25(detid, chs[ich]);
+ }
+ } // loop over detIds
+ } // if non-empty FEDerror25
- // reset detector status and lumi-counter
- fDet.resetDetectorStatus();
- countLumi_ = 0;
- ftotalevents = 0;
- FEDerror25_.clear();
+ } // only for non-zero events
}
-//--------------------------------------------------------------------------------------------------
-void SiPixelStatusProducer::onlineRocColRow(
- const DetId& detId, int offlineRow, int offlineCol, int& roc, int& row, int& col) {
- int fedId = fFedIds[detId.rawId()];
-
- // from detector to cabling
- sipixelobjects::ElectronicIndex cabling;
- sipixelobjects::DetectorIndex detector; //{detId.rawId(), offlineRow, offlineCol};
- detector.rawId = detId.rawId();
- detector.row = offlineRow;
- detector.col = offlineCol;
-
- SiPixelFrameConverter converter(fCablingMap_, fedId);
- converter.toCabling(cabling, detector);
-
- // then one can construct local pixel
- sipixelobjects::LocalPixel::DcolPxid loc;
- loc.dcol = cabling.dcol;
- loc.pxid = cabling.pxid;
- // and get local(online) row/column
- sipixelobjects::LocalPixel locpixel(loc);
- col = locpixel.rocCol();
- row = locpixel.rocRow();
- //sipixelobjects::CablingPathToDetUnit path = {(unsigned int) fedId, (unsigned int)cabling.link, (unsigned int)cabling.roc};
- //const sipixelobjects::PixelROC *theRoc = fCablingMap_->findItem(path);
- const sipixelobjects::PixelROC* theRoc = converter.toRoc(cabling.link, cabling.roc);
- roc = theRoc->idInDetUnit();
-
- // has to be BPIX; has to be minus side; has to be half module
- // for phase-I, there is no half module
- if (detId.subdetId() == PixelSubdetector::PixelBarrel && coord_.side(detId) == 1 && coord_.half(detId)) {
- roc += 8;
- }
+void SiPixelStatusProducer::endLuminosityBlockSummary(
+ edm::LuminosityBlock const& iLumi,
+ edm::EventSetup const&,
+ std::vector* siPixelDetectorStatusVtr) const {
+ /*add the Stream's partial information to the full information*/
+
+ /* only save for the lumi sections with NON-ZERO events */
+ if (ftotalevents_ > 0)
+ siPixelDetectorStatusVtr->push_back(fDet_);
}
-//--------------------------------------------------------------------------------------------------
+/* helper function */
int SiPixelStatusProducer::indexROC(int irow, int icol, int nROCcolumns) {
return int(icol + irow * nROCcolumns);
- // 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
-}
-
-//--------------------------------------------------------------------------------------------------
-//edmPythonConfigToCppValidation CalibTracker/SiPixelQuality/python/SiPixelStatusProducer_cfi.py
-void SiPixelStatusProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
- // siPixelStatusProducer
- edm::ParameterSetDescription desc;
- {
- edm::ParameterSetDescription psd0;
- psd0.addUntracked("resetEveryNLumi", 1);
- psd0.addUntracked("pixelClusterLabel", edm::InputTag("siPixelClusters", "", "RECO"));
- psd0.add>("badPixelFEDChannelCollections",
- {
- edm::InputTag("siPixelDigis"),
- });
- desc.add("SiPixelStatusProducerParameters", psd0);
- }
- descriptions.add("siPixelStatusProducer", desc);
+ /* 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 */
}
DEFINE_FWK_MODULE(SiPixelStatusProducer);
diff --git a/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h b/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h
index 80f111fea22b4..cb8b3b492e478 100644
--- a/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h
+++ b/CalibTracker/SiPixelQuality/plugins/SiPixelStatusProducer.h
@@ -2,22 +2,37 @@
#define CalibTracker_SiPixelQuality_SiPixelStatusProducer_h
/**_________________________________________________________________
- class: SiPixelStatusProducer.h
- package: CalibTracker/SiPixelQuality
-
-________________________________________________________________**/
+ * class: SiPixelStatusProducer.h
+ * package: CalibTracker/SiPixelQuality
+ * reference : https://twiki.cern.ch/twiki/bin/view/CMSPublic/FWMultithreadedFrameworkStreamModuleInterface
+ *________________________________________________________________**/
// C++ standard
+#include
+#include
+#include
+#include
+
#include
-// CMS FW
+// // CMS FW
#include "FWCore/Framework/interface/Frameworkfwd.h"
-#include "FWCore/Framework/interface/one/EDProducer.h"
+#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
+#include "FWCore/Framework/interface/ESWatcher.h"
+#include "FWCore/Framework/interface/ConsumesCollector.h"
+#include "FWCore/Framework/interface/EventSetup.h"
+#include "FWCore/Framework/interface/LuminosityBlock.h"
+#include "FWCore/Utilities/interface/Transition.h"
+#include "FWCore/Utilities/interface/ESGetToken.h"
+// Concurrency
+#include "FWCore/Utilities/interface/ReusableObjectHolder.h"
+#include "FWCore/Concurrency/interface/SerialTaskQueue.h"
+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
-// Pixel data format
+// // Pixel data format
#include "CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h"
#include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
@@ -25,79 +40,228 @@ ________________________________________________________________**/
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h"
// Tracker Geo
-#include "DQM/SiPixelPhase1Common/interface/SiPixelCoordinates.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
+// SiPixelTopoFinder
+#include "CalibTracker/SiPixelQuality/interface/SiPixelTopoFinder.h"
+// SiPixelDetectorStatus
+#include "CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h"
-class SiPixelStatusProducer
- : public edm::one::EDProducer {
+/* Cache to pertain SiPixelTopoFinder */
+class SiPixelTopoCache {
public:
- explicit SiPixelStatusProducer(const edm::ParameterSet&);
- ~SiPixelStatusProducer() override;
+ SiPixelTopoCache(edm::ParameterSet const& iPSet){};
+
+ std::shared_ptr getSiPixelTopoFinder(edm::EventSetup const& iSetup) const {
+ std::shared_ptr returnValue;
- static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
+ m_queue.pushAndWait([&]() {
+ if (!this->siPixelFedCablingMapWatcher_.check(iSetup) && !this->trackerDIGIGeoWatcher_.check(iSetup) &&
+ !this->trackerTopoWatcher_.check(iSetup)) {
+ /*the condition hasn't changed so we can just use our old value*/
+ returnValue = m_mostRecentSiPixelTopoFinder_;
+ } else {
+ edm::ESHandle tkGeoHandle;
+ iSetup.get().get(tkGeoHandle);
+ const TrackerGeometry* trackerGeometry = tkGeoHandle.product();
+
+ edm::ESHandle tkTopoHandle;
+ iSetup.get().get(tkTopoHandle);
+ const TrackerTopology* trackerTopology = tkTopoHandle.product();
+
+ edm::ESHandle cMapHandle;
+ iSetup.get().get(cMapHandle);
+ const SiPixelFedCablingMap* cablingMap = cMapHandle.product();
+
+ /*the condition has changed so we need to update*/
+ //const TrackerGeometry* trackerGeometry = &iSetup.getData(trackerGeometryToken);
+ //const TrackerTopology* trackerTopology = &iSetup.getData(trackerTopologyToken);
+ //const SiPixelFedCablingMap* cablingMap = &iSetup.getData(siPixelFedCablingMapToken);
+
+ returnValue = m_holder.makeOrGet([]() { return new SiPixelTopoFinder(); });
+ returnValue->init(trackerGeometry, trackerTopology, cablingMap);
+
+ m_mostRecentSiPixelTopoFinder_ = returnValue;
+ }
+ }); //m_queue
+
+ return returnValue;
+ }
private:
- void beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup&) final;
- void endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup&) final;
- void endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup&) final;
- void accumulate(edm::Event const&, const edm::EventSetup&) final;
+ mutable edm::ReusableObjectHolder m_holder;
+ mutable edm::SerialTaskQueue m_queue;
- virtual void onlineRocColRow(const DetId& detId, int offlineRow, int offlineCol, int& roc, int& row, int& col) final;
+ /* Condition watchers */
+ /* CablingMaps */
+ mutable edm::ESWatcher siPixelFedCablingMapWatcher_;
+ /* TrackerDIGIGeo */
+ mutable edm::ESWatcher trackerDIGIGeoWatcher_;
+ /* TrackerTopology */
+ mutable edm::ESWatcher trackerTopoWatcher_;
- virtual int indexROC(int irow, int icol, int nROCcolumns) final;
+ /* SiPixelTopoFinder */
+ mutable std::shared_ptr m_mostRecentSiPixelTopoFinder_;
+};
- // time granularity control
- unsigned long int ftotalevents;
- int resetNLumi_;
- int countLumi_; //counter
+/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
- int beginLumi_;
- int endLumi_;
- int beginRun_;
- int endRun_;
+class SiPixelStatusProducer :
+
+ public edm::stream::EDProducer,
+ edm::RunCache,
+ edm::LuminosityBlockSummaryCache>,
+ edm::EndLuminosityBlockProducer,
+ edm::Accumulator> {
+public:
+ SiPixelStatusProducer(edm::ParameterSet const& iPSet, SiPixelTopoCache const*);
+ ~SiPixelStatusProducer() override;
- // condition watchers
- // CablingMaps
- edm::ESWatcher siPixelFedCablingMapWatcher_;
- const SiPixelFedCablingMap* fCablingMap_ = nullptr;
+ /* module description */
+ static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
+ edm::ParameterSetDescription desc;
+ {
+ edm::ParameterSetDescription psd0;
+ psd0.addUntracked("pixelClusterLabel", edm::InputTag("siPixelClusters", "", "RECO"));
+ psd0.add>("badPixelFEDChannelCollections",
+ {
+ edm::InputTag("siPixelDigis"),
+ });
+ desc.add("SiPixelStatusProducerParameters", psd0);
+ }
+ descriptions.add("siPixelStatusProducer", desc);
+ }
- // TrackerDIGIGeo
- edm::ESWatcher trackerDIGIGeoWatcher_;
- const TrackerGeometry* trackerGeometry_ = nullptr;
+ /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
- // TrackerTopology
- edm::ESWatcher trackerTopoWatcher_;
+ /* For each instance of the module*/
+ void beginRun(edm::Run const&, edm::EventSetup const&) final;
- edm::ESGetToken trackerGeometryToken_;
- edm::ESGetToken trackerTopologyToken_;
- edm::ESGetToken siPixelFedCablingMapToken_;
+ void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) final;
+ void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) final;
+
+ void accumulate(edm::Event const& iEvent, edm::EventSetup const& iSetup) final;
+
+ void endLuminosityBlockSummary(edm::LuminosityBlock const& iLumi,
+ edm::EventSetup const&,
+ std::vector* siPixelDetectorStatusVtr) const final; //override;
+
+ /* For global or runCache */
- // SiPixel offline<->online conversion
- // -- map (for each detid) of the map from offline col/row to the online roc/col/row
- SiPixelCoordinates coord_;
+ static std::unique_ptr initializeGlobalCache(edm::ParameterSet const& iPSet) {
+ edm::LogInfo("SiPixelStatusProducer") << "Init global Cache " << std::endl;
+ return std::make_unique(iPSet);
+ }
- // ROC size (number of row, number of columns for each det id)
- std::map> fSensors;
- // the roc layout on a module
- std::map> fSensorLayout;
- // fedId as a function of detId
- std::unordered_map fFedIds;
- // map the index ROC to rocId
- std::map> fRocIds;
+ static std::shared_ptr globalBeginRun(edm::Run const& iRun,
+ edm::EventSetup const& iSetup,
+ GlobalCache const* iCache) {
+ edm::LogInfo("SiPixelStatusProducer") << "Global beginRun " << std::endl;
+ return iCache->getSiPixelTopoFinder(iSetup);
+ }
+
+ static void globalEndRun(edm::Run const& iRun, edm::EventSetup const&, RunContext const* iContext) {
+ /* Do nothing */
+ }
+
+ static void globalEndJob(SiPixelTopoCache const*) { /* Do nothing */
+ }
+
+ static std::shared_ptr> globalBeginLuminosityBlockSummary(
+ edm::LuminosityBlock const&, edm::EventSetup const&, LuminosityBlockContext const*) {
+ return std::make_shared>();
+ }
+
+ static void globalEndLuminosityBlockSummary(edm::LuminosityBlock const&,
+ edm::EventSetup const&,
+ LuminosityBlockContext const* iContext,
+ std::vector*) {
+ /* Do nothing */
+ }
+
+ static void globalEndLuminosityBlockProduce(edm::LuminosityBlock& iLumi,
+ edm::EventSetup const&,
+ LuminosityBlockContext const* iContext,
+ std::vector const* siPixelDetectorStatusVtr) {
+ edm::LogInfo("SiPixelStatusProducer") << "Global endlumi producer " << std::endl;
+
+ // only save result for non-zero event lumi block
+ if (!siPixelDetectorStatusVtr->empty()) {
+ int lumi = iLumi.luminosityBlock();
+ int run = iLumi.run();
+
+ SiPixelDetectorStatus siPixelDetectorStatus = SiPixelDetectorStatus();
+ for (unsigned int instance = 0; instance < siPixelDetectorStatusVtr->size(); instance++) {
+ siPixelDetectorStatus.updateDetectorStatus((*siPixelDetectorStatusVtr)[instance]);
+ }
+
+ siPixelDetectorStatus.setRunRange(run, run);
+ siPixelDetectorStatus.setLSRange(lumi, lumi);
+
+ if (debug_) {
+ std::string outTxt = Form("SiPixelDetectorStatus_Run%d_Lumi%d.txt", run, lumi);
+ std::ofstream outFile;
+ outFile.open(outTxt.c_str(), std::ios::app);
+ siPixelDetectorStatus.dumpToFile(outFile);
+ outFile.close();
+ }
+
+ /* save result */
+ auto result = std::make_unique();
+ *result = siPixelDetectorStatus;
+
+ iLumi.put(std::move(result), std::string("siPixelStatus"));
+ edm::LogInfo("SiPixelStatusProducer")
+ << " lumi-based data stored for run " << run << " lumi " << lumi << std::endl;
+ }
+ }
+
+private:
+ virtual int indexROC(int irow, int icol, int nROCcolumns) final;
+
+ /* ParameterSet */
+ static const bool debug_ = false;
- // Producer inputs / controls
edm::InputTag fPixelClusterLabel_;
edm::EDGetTokenT> fSiPixelClusterToken_;
std::vector> theBadPixelFEDChannelsTokens_;
- // Channels always have FEDerror25 for the full lumi section
- std::map> FEDerror25_;
+ /*
+ edm::ESGetToken trackerGeometryToken_;
+ edm::ESGetToken trackerTopologyToken_;
+ edm::ESGetToken siPixelFedCablingMapToken_;
+ */
+
+ /*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
+ /* private data member, one instance per stream */
+
+ /* per-Run data (The pixel topo cannot be changed during a Run) */
+ /* vector of all detIds */
+ std::vector fDetIds_;
+ /* ROC size (number of row, number of columns for each det id) */
+ std::map> fSensors_;
+ /* the roc layout on a module */
+ std::map> fSensorLayout_;
+ /* fedId as a function of detId */
+ std::unordered_map fFedIds_;
+ /* map the index ROC to rocId */
+ std::map> fRocIds_;
+
+ /* per-LuminosityBlock data */
+ unsigned long int ftotalevents_;
+
+ int beginLumi_;
+ int endLumi_;
+ int beginRun_;
+ int endRun_;
+
+ /* Channels always have FEDerror25 for all events in the lumisection */
+ std::map> fFEDerror25_;
// Producer production (output collection)
- SiPixelDetectorStatus fDet;
+ SiPixelDetectorStatus fDet_;
};
#endif
diff --git a/CalibTracker/SiPixelQuality/python/ALCARECOSiPixelCalZeroBias_cff.py b/CalibTracker/SiPixelQuality/python/ALCARECOSiPixelCalZeroBias_cff.py
index 235f117a3a9fd..0f5276d2ea048 100644
--- a/CalibTracker/SiPixelQuality/python/ALCARECOSiPixelCalZeroBias_cff.py
+++ b/CalibTracker/SiPixelQuality/python/ALCARECOSiPixelCalZeroBias_cff.py
@@ -23,8 +23,6 @@
# SiPixelStatus producer
from CalibTracker.SiPixelQuality.SiPixelStatusProducer_cfi import *
-# fit as function of lumi sections
-siPixelStatusProducer.SiPixelStatusProducerParameters.resetEveryNLumi = 1
# Sequence #
seqALCARECOSiPixelCalZeroBias = cms.Sequence(ALCARECOSiPixelCalZeroBiasHLT*ALCARECOSiPixelCalZeroBiasDCSFilter*siPixelStatusProducer)
diff --git a/CalibTracker/SiPixelQuality/python/SiPixelStatusProducer_cfi.py b/CalibTracker/SiPixelQuality/python/SiPixelStatusProducer_cfi.py
index e9f339cdb94f7..c7b2560dd5908 100644
--- a/CalibTracker/SiPixelQuality/python/SiPixelStatusProducer_cfi.py
+++ b/CalibTracker/SiPixelQuality/python/SiPixelStatusProducer_cfi.py
@@ -4,7 +4,6 @@
SiPixelStatusProducerParameters = cms.PSet(
badPixelFEDChannelCollections = cms.VInputTag(cms.InputTag('siPixelDigis')),
pixelClusterLabel = cms.untracked.InputTag("siPixelClusters::RECO"),
- resetEveryNLumi = cms.untracked.int32( 1 )
)
)
diff --git a/CalibTracker/SiPixelQuality/src/SiPixelDetectorStatus.cc b/CalibTracker/SiPixelQuality/src/SiPixelDetectorStatus.cc
index a422367c1bdd7..f0dad49f92b34 100644
--- a/CalibTracker/SiPixelQuality/src/SiPixelDetectorStatus.cc
+++ b/CalibTracker/SiPixelQuality/src/SiPixelDetectorStatus.cc
@@ -11,9 +11,9 @@
#include "CalibTracker/SiPixelQuality/interface/SiPixelDetectorStatus.h"
// ----------------------------------------------------------------------
-SiPixelDetectorStatus::SiPixelDetectorStatus() : fLS0(99999999), fLS1(0), fRun0(99999999), fRun1(0) {
- fDetHits = 0;
- fNevents = 0;
+SiPixelDetectorStatus::SiPixelDetectorStatus() : fLS0_(99999999), fLS1_(0), fRun0_(99999999), fRun1_(0) {
+ fDetHits_ = 0;
+ ftotalevents_ = 0;
}
// ----------------------------------------------------------------------
@@ -43,15 +43,15 @@ void SiPixelDetectorStatus::readFromFile(std::string filename) {
}
if (sline.find("# SiPixelDetectorStatus for LS") != std::string::npos) {
- std::sscanf(sline.c_str(), "# SiPixelDetectorStatus for LS %d .. %d", &fLS0, &fLS1);
+ std::sscanf(sline.c_str(), "# SiPixelDetectorStatus for LS %d .. %d", &fLS0_, &fLS1_);
continue;
}
if (sline.find("# SiPixelDetectorStatus for run") != std::string::npos) {
- std::sscanf(sline.c_str(), "# SiPixelDetectorStatus for run %d .. %d", &fRun0, &fRun1);
+ std::sscanf(sline.c_str(), "# SiPixelDetectorStatus for run %d .. %d", &fRun0_, &fRun1_);
continue;
}
if (sline.find("# SiPixelDetectorStatus total hits = ") != std::string::npos) {
- std::sscanf(sline.c_str(), "# SiPixelDetectorStatus total hits = %ld", &fDetHits);
+ std::sscanf(sline.c_str(), "# SiPixelDetectorStatus total hits = %ld", &fDetHits_);
continue;
}
@@ -60,19 +60,20 @@ void SiPixelDetectorStatus::readFromFile(std::string filename) {
nroc = roc;
if (detid != oldDetId) {
if (pMod) {
- pMod->setNrocs(nroc + 1);
+ pMod->setNrocs(nroc + 1); // roc ranges from 0, "+1" to get number of rocs per module
}
oldDetId = detid;
if (getModule(detid) == nullptr) {
- addModule(detid, nroc + 1);
+ addModule(detid, nroc + 1); // roc ranges from 0, "+1" to get number of rocs per module
}
pMod = getModule(detid);
nroc = 0;
}
- if (pMod) {
- fDetHits += hits;
+ // for existing module, update its content
+ if (pMod != nullptr) {
+ fDetHits_ += hits;
pMod->updateModuleDIGI(roc, hits);
}
}
@@ -81,51 +82,50 @@ void SiPixelDetectorStatus::readFromFile(std::string filename) {
}
// ----------------------------------------------------------------------
-void SiPixelDetectorStatus::dumpToFile(std::string filename) {
- std::ofstream OD(filename.c_str());
+void SiPixelDetectorStatus::dumpToFile(std::ofstream& OD) {
OD << "# SiPixelDetectorStatus START" << std::endl;
- OD << "# SiPixelDetectorStatus for LS " << fLS0 << " .. " << fLS1 << std::endl;
- OD << "# SiPixelDetectorStatus for run " << fRun0 << " .. " << fRun1 << std::endl;
- OD << "# SiPixelDetectorStatus total hits = " << fDetHits << std::endl;
+ OD << "# SiPixelDetectorStatus for LS " << fLS0_ << " .. " << fLS1_ << std::endl;
+ OD << "# SiPixelDetectorStatus for run " << fRun0_ << " .. " << fRun1_ << std::endl;
+ OD << "# SiPixelDetectorStatus total hits = " << fDetHits_ << std::endl;
for (std::map::iterator it = SiPixelDetectorStatus::begin();
it != SiPixelDetectorStatus::end();
++it) {
for (int iroc = 0; iroc < it->second.nrocs(); ++iroc) {
- for (int idc = 0; idc < 26; ++idc) {
- OD << Form("%10d %2d %3d", it->first, iroc, int(it->second.getRoc(iroc)->digiOccROC())) << std::endl;
- }
+ OD << Form("%10d %2d %3d", it->first, iroc, int(it->second.getRoc(iroc)->digiOccROC())) << std::endl;
}
}
OD << "# SiPixelDetectorStatus END" << std::endl;
- OD.close();
}
// ----------------------------------------------------------------------
void SiPixelDetectorStatus::addModule(int detid, int nrocs) {
- SiPixelModuleStatus a(detid, nrocs);
- fModules.insert(std::make_pair(detid, a));
+ // only need to add NEW modules
+ if (fModules_.find(detid) == fModules_.end()) {
+ SiPixelModuleStatus a(detid, nrocs);
+ fModules_.insert(std::make_pair(detid, a));
+ }
}
// ----------------------------------------------------------------------
-void SiPixelDetectorStatus::addModule(int detid, SiPixelModuleStatus a) { fModules.insert(std::make_pair(detid, a)); }
+void SiPixelDetectorStatus::addModule(int detid, SiPixelModuleStatus a) { fModules_.insert(std::make_pair(detid, a)); }
// ----------------------------------------------------------------------
void SiPixelDetectorStatus::fillDIGI(int detid, int roc) {
- ++fDetHits;
- fModules[detid].fillDIGI(roc);
+ ++fDetHits_;
+ fModules_[detid].fillDIGI(roc);
}
// ----------------------------------------------------------------------
void SiPixelDetectorStatus::fillFEDerror25(int detid, PixelFEDChannel ch) {
- if (fModules.find(detid) != fModules.end()) {
- fModules[detid].fillFEDerror25(ch);
+ if (fModules_.find(detid) != fModules_.end()) {
+ fModules_[detid].fillFEDerror25(ch);
}
}
// FEDerror25 effected ROCs in for each module
std::map> SiPixelDetectorStatus::getFEDerror25Rocs() {
- std::map> badRocLists_;
+ std::map> badRocLists;
for (std::map::iterator itMod = SiPixelDetectorStatus::begin();
itMod != SiPixelDetectorStatus::end();
@@ -139,37 +139,32 @@ std::map> SiPixelDetectorStatus::getFEDerror25Rocs() {
if (roc->isFEDerror25()) {
list.push_back(iroc);
}
- badRocLists_[detid] = list;
+ badRocLists[detid] = list;
}
}
- return badRocLists_;
+ return badRocLists;
}
// ----------------------------------------------------------------------
-std::map::iterator SiPixelDetectorStatus::begin() { return fModules.begin(); }
-
-// ----------------------------------------------------------------------
-//map::iterator SiPixelDetectorStatus::next() {
-// return fNext++;
-//}
+std::map::iterator SiPixelDetectorStatus::begin() { return fModules_.begin(); }
// ----------------------------------------------------------------------
-std::map::iterator SiPixelDetectorStatus::end() { return fModules.end(); }
+std::map::iterator SiPixelDetectorStatus::end() { return fModules_.end(); }
// ----------------------------------------------------------------------
-int SiPixelDetectorStatus::nmodules() { return static_cast(fModules.size()); }
+int SiPixelDetectorStatus::nmodules() { return static_cast(fModules_.size()); }
// ----------------------------------------------------------------------
SiPixelModuleStatus* SiPixelDetectorStatus::getModule(int detid) {
- if (fModules.find(detid) == fModules.end()) {
+ if (fModules_.find(detid) == fModules_.end()) {
return nullptr;
}
- return &(fModules[detid]);
+ return &(fModules_[detid]);
}
bool SiPixelDetectorStatus::findModule(int detid) {
- if (fModules.find(detid) == fModules.end())
+ if (fModules_.find(detid) == fModules_.end())
return false;
else
return true;
@@ -206,18 +201,31 @@ double SiPixelDetectorStatus::perRocDigiOccVar() {
return TMath::Sqrt(fDetSigma);
}
+/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
+
// combine status from different data (coming from different run/lumi)
void SiPixelDetectorStatus::updateDetectorStatus(SiPixelDetectorStatus newData) {
// loop over new data status
for (std::map::iterator it = newData.begin(); it != newData.end(); ++it) {
int detid = it->first;
- if (fModules.find(detid) != fModules.end()) { // if the detid is in the module lists
- fModules[detid].updateModuleStatus(*(newData.getModule(detid)));
- } else {
- fModules.insert(std::make_pair(detid, *(newData.getModule(detid))));
+
+ if (fModules_.find(detid) != fModules_.end()) { // if the detid is in the module lists
+ fModules_[detid].updateModuleStatus(*(newData.getModule(detid)));
+ } else { // if new module, add(insert) the module data
+ fModules_.insert(std::make_pair(detid, *(newData.getModule(detid))));
}
}
- fDetHits = fDetHits + newData.digiOccDET();
- fNevents = fNevents + newData.getNevents();
+ fDetHits_ = fDetHits_ + newData.digiOccDET();
+ ftotalevents_ = ftotalevents_ + newData.getNevents();
+}
+
+void SiPixelDetectorStatus::resetDetectorStatus() {
+ fModules_.clear();
+ fDetHits_ = 0;
+ ftotalevents_ = 0;
+ fRun0_ = 99999999;
+ fRun1_ = 0;
+ fLS0_ = 99999999;
+ fLS1_ = 0;
}
diff --git a/CalibTracker/SiPixelQuality/src/SiPixelModuleStatus.cc b/CalibTracker/SiPixelQuality/src/SiPixelModuleStatus.cc
index dd6a7513432d8..be64108c3c3e4 100644
--- a/CalibTracker/SiPixelQuality/src/SiPixelModuleStatus.cc
+++ b/CalibTracker/SiPixelQuality/src/SiPixelModuleStatus.cc
@@ -9,10 +9,10 @@
#include "CalibTracker/SiPixelQuality/interface/SiPixelModuleStatus.h"
// ----------------------------------------------------------------------
-SiPixelModuleStatus::SiPixelModuleStatus(int detId, int nrocs) : fDetid(detId), fNrocs(nrocs) {
- for (int i = 0; i < fNrocs; ++i) {
+SiPixelModuleStatus::SiPixelModuleStatus(int detId, int nrocs) : fDetid_(detId), fNrocs_(nrocs) {
+ for (int i = 0; i < fNrocs_; ++i) {
SiPixelRocStatus a;
- fRocs.push_back(a);
+ fRocs_.push_back(a);
}
};
@@ -21,94 +21,99 @@ SiPixelModuleStatus::~SiPixelModuleStatus(){};
// ----------------------------------------------------------------------
void SiPixelModuleStatus::fillDIGI(int iroc) {
- if (iroc < fNrocs)
- fRocs[iroc].fillDIGI();
+ if (iroc < fNrocs_)
+ fRocs_[iroc].fillDIGI();
}
-
-// ----------------------------------------------------------------------
-void SiPixelModuleStatus::updateDIGI(int iroc, unsigned int nhit) {
- if (iroc < fNrocs)
- fRocs[iroc].updateDIGI(nhit);
-}
-
// ----------------------------------------------------------------------
void SiPixelModuleStatus::fillFEDerror25(PixelFEDChannel ch) {
int roc_first = int(ch.roc_first);
int roc_last = int(ch.roc_last);
- for (int iroc = 0; iroc < fNrocs; iroc++) {
+ for (int iroc = 0; iroc < fNrocs_; iroc++) {
if (iroc >= roc_first && iroc <= roc_last) {
- fRocs[iroc].fillFEDerror25();
+ fRocs_[iroc].fillFEDerror25();
}
}
}
+// ----------------------------------------------------------------------
+int SiPixelModuleStatus::detid() { return fDetid_; }
+// ----------------------------------------------------------------------
+int SiPixelModuleStatus::nrocs() { return fNrocs_; }
+// ----------------------------------------------------------------------
+void SiPixelModuleStatus::setDetId(int detid) { fDetid_ = detid; }
+// ----------------------------------------------------------------------
+void SiPixelModuleStatus::setNrocs(int nRoc) { fNrocs_ = nRoc; }
// ----------------------------------------------------------------------
-unsigned int SiPixelModuleStatus::digiOccROC(int iroc) { return (iroc < fNrocs ? fRocs[iroc].digiOccROC() : -1); }
+void SiPixelModuleStatus::updateDIGI(int iroc, unsigned int nhit) {
+ if (iroc < fNrocs_)
+ fRocs_[iroc].updateDIGI(nhit);
+}
+// ----------------------------------------------------------------------
+void SiPixelModuleStatus::updateFEDerror25(int iroc, bool fedError25) {
+ if (iroc < fNrocs_)
+ fRocs_[iroc].updateFEDerror25(fedError25);
+}
+// ----------------------------------------------------------------------
+unsigned int SiPixelModuleStatus::digiOccROC(int iroc) { return (iroc < fNrocs_ ? fRocs_[iroc].digiOccROC() : 0); }
+// ----------------------------------------------------------------------
+bool SiPixelModuleStatus::fedError25(int iroc) { return (iroc < fNrocs_ ? fRocs_[iroc].isFEDerror25() : false); }
// ----------------------------------------------------------------------
unsigned int SiPixelModuleStatus::digiOccMOD() {
unsigned int count(0);
- for (int iroc = 0; iroc < fNrocs; ++iroc) {
+ for (int iroc = 0; iroc < fNrocs_; ++iroc) {
count += digiOccROC(iroc);
}
return count;
}
-// ----------------------------------------------------------------------
-int SiPixelModuleStatus::detid() { return fDetid; }
-
-// ----------------------------------------------------------------------
-int SiPixelModuleStatus::nrocs() { return fNrocs; }
-
-// ----------------------------------------------------------------------
-void SiPixelModuleStatus::setNrocs(int iroc) { fNrocs = iroc; }
-
// ----------------------------------------------------------------------
double SiPixelModuleStatus::perRocDigiOcc() {
unsigned int ave(0);
- for (int iroc = 0; iroc < fNrocs; ++iroc) {
+ for (int iroc = 0; iroc < fNrocs_; ++iroc) {
unsigned int inc = digiOccROC(iroc);
ave += inc;
}
- return (1.0 * ave) / fNrocs;
+ return (1.0 * ave) / fNrocs_;
}
double SiPixelModuleStatus::perRocDigiOccVar() {
double fModAverage = SiPixelModuleStatus::perRocDigiOcc();
double sig = 1.0;
- for (int iroc = 0; iroc < fNrocs; ++iroc) {
+ for (int iroc = 0; iroc < fNrocs_; ++iroc) {
unsigned int inc = digiOccROC(iroc);
sig += (fModAverage - inc) * (fModAverage - inc);
}
- double fModSigma = sig / (fNrocs - 1);
+ double fModSigma = sig / (fNrocs_ - 1);
return TMath::Sqrt(fModSigma);
}
// ----------------------------------------------------------------------
-// Be careful : return the address not the value of ROC status
-SiPixelRocStatus* SiPixelModuleStatus::getRoc(int i) { return &fRocs[i]; }
+// Return the address not the value of ROC status
+SiPixelRocStatus* SiPixelModuleStatus::getRoc(int iroc) { return (iroc < fNrocs_ ? &fRocs_[iroc] : nullptr); }
// ----------------------------------------------------------------------
-void SiPixelModuleStatus::updateModuleDIGI(int iroc, unsigned int nhits) { fRocs[iroc].updateDIGI(nhits); }
-
+void SiPixelModuleStatus::updateModuleDIGI(int iroc, unsigned int nhits) {
+ if (iroc < fNrocs_)
+ fRocs_[iroc].updateDIGI(nhits);
+}
+// ----------------------------------------------------------------------
void SiPixelModuleStatus::updateModuleStatus(SiPixelModuleStatus newData) {
bool isSameModule = true;
- if (fDetid != newData.detid() || fNrocs != newData.nrocs()) {
+ if (fDetid_ != newData.detid() || fNrocs_ != newData.nrocs()) {
isSameModule = false;
}
if (isSameModule) {
- for (int iroc = 0; iroc < fNrocs; ++iroc) {
+ for (int iroc = 0; iroc < fNrocs_; ++iroc) { // loop over rocs
//update occupancy
- fRocs[iroc].updateDIGI(newData.digiOccROC(iroc));
+ fRocs_[iroc].updateDIGI(newData.digiOccROC(iroc));
//update FEDerror25
- SiPixelRocStatus* rocStatus = newData.getRoc(iroc);
- if (rocStatus->isFEDerror25()) {
- fRocs[iroc].fillFEDerror25();
- }
- }
+ fRocs_[iroc].updateFEDerror25(newData.fedError25(iroc));
+
+ } // loop over rocs
} // if same module
}
diff --git a/CalibTracker/SiPixelQuality/src/SiPixelRocStatus.cc b/CalibTracker/SiPixelQuality/src/SiPixelRocStatus.cc
index 4da2c8af4b897..e2a00349e3bfb 100644
--- a/CalibTracker/SiPixelQuality/src/SiPixelRocStatus.cc
+++ b/CalibTracker/SiPixelQuality/src/SiPixelRocStatus.cc
@@ -9,7 +9,7 @@ using namespace std;
// ----------------------------------------------------------------------
SiPixelRocStatus::SiPixelRocStatus() {
- fDC = 0;
+ fDC_ = 0;
isFEDerror25_ = false;
}
@@ -17,13 +17,17 @@ SiPixelRocStatus::SiPixelRocStatus() {
SiPixelRocStatus::~SiPixelRocStatus() {}
// ----------------------------------------------------------------------
-void SiPixelRocStatus::fillDIGI() { fDC++; }
-
+void SiPixelRocStatus::fillDIGI() { fDC_++; }
// ----------------------------------------------------------------------
-void SiPixelRocStatus::updateDIGI(unsigned int hits) { fDC += hits; }
+void SiPixelRocStatus::fillFEDerror25() { isFEDerror25_ = true; }
// ----------------------------------------------------------------------
-void SiPixelRocStatus::fillFEDerror25() { isFEDerror25_ = true; }
+void SiPixelRocStatus::updateDIGI(unsigned int hits) { fDC_ += hits; }
+// ----------------------------------------------------------------------
+/*AND logic to update FEDerror25*/
+void SiPixelRocStatus::updateFEDerror25(bool fedError25) { isFEDerror25_ = isFEDerror25_ && fedError25; }
// ----------------------------------------------------------------------
-unsigned int SiPixelRocStatus::digiOccROC() { return fDC; }
+unsigned int SiPixelRocStatus::digiOccROC() { return fDC_; }
+// ----------------------------------------------------------------------
+bool SiPixelRocStatus::isFEDerror25() { return isFEDerror25_; }
diff --git a/CalibTracker/SiPixelQuality/src/SiPixelTopoFinder.cc b/CalibTracker/SiPixelQuality/src/SiPixelTopoFinder.cc
new file mode 100644
index 0000000000000..8c01192c91068
--- /dev/null
+++ b/CalibTracker/SiPixelQuality/src/SiPixelTopoFinder.cc
@@ -0,0 +1,149 @@
+
+#include "CalibTracker/SiPixelQuality/interface/SiPixelTopoFinder.h"
+
+#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
+#include "Geometry/CommonTopologies/interface/PixelTopology.h"
+#include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
+#include "DataFormats/TrackerCommon/interface/PixelEndcapName.h"
+#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
+#include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h"
+
+SiPixelTopoFinder::SiPixelTopoFinder() {}
+
+SiPixelTopoFinder::~SiPixelTopoFinder() {}
+
+void SiPixelTopoFinder::init(const TrackerGeometry* trackerGeometry,
+ const TrackerTopology* trackerTopology,
+ const SiPixelFedCablingMap* siPixelFedCablingMap) {
+ phase_ = -1;
+
+ tkGeom_ = trackerGeometry;
+ tkTopo_ = trackerTopology;
+ cablingMap_ = siPixelFedCablingMap;
+ // from cabling map to FedIds
+ fFedIds_ = cablingMap_->det2fedMap();
+
+ // clear data
+ fDetIds_.clear();
+ fSensors_.clear();
+ fSensorLayout_.clear();
+ fRocIds_.clear();
+
+ // loop over tracker geometry
+ for (TrackerGeometry::DetContainer::const_iterator it = tkGeom_->dets().begin(); it != tkGeom_->dets().end();
+ it++) { // tracker geo
+
+ const PixelGeomDetUnit* pgdu = dynamic_cast((*it));
+ if (pgdu == nullptr)
+ continue;
+ // get detId for a module
+ DetId detId = (*it)->geographicalId();
+ int detid = detId.rawId();
+ fDetIds_.push_back(detid);
+
+ // don't want to use magic number row 80 column 52 for Phase-1
+ const PixelTopology* topo = static_cast(&pgdu->specificTopology());
+ int rowsperroc = topo->rowsperroc();
+ int colsperroc = topo->colsperroc();
+
+ int nROCrows = pgdu->specificTopology().nrows() / rowsperroc;
+ int nROCcolumns = pgdu->specificTopology().ncolumns() / colsperroc;
+
+ fSensors_[detid] = std::make_pair(rowsperroc, colsperroc);
+ fSensorLayout_[detid] = std::make_pair(nROCrows, nROCcolumns);
+
+ std::map rocIdMap;
+ for (int irow = 0; irow < nROCrows; irow++) { // row
+ for (int icol = 0; icol < nROCcolumns; icol++) { // column
+ int dummyOfflineRow = (rowsperroc / 2 - 1) + irow * rowsperroc;
+ int dummeOfflineColumn = (colsperroc / 2 - 1) + icol * colsperroc;
+ int fedId = fFedIds_[detId.rawId()];
+
+ int roc(-1), rocR(-1), rocC(-1);
+ SiPixelTopoFinder::onlineRocColRow(
+ detId, cablingMap_, fedId, dummyOfflineRow, dummeOfflineColumn, roc, rocR, rocC);
+
+ // encode irow, icol
+ int key = SiPixelTopoFinder::indexROC(irow, icol, nROCcolumns);
+ int value = roc;
+ rocIdMap[key] = value;
+ } // column
+ } // row
+
+ fRocIds_[detid] = rocIdMap;
+
+ } // tracker geo
+}
+
+void SiPixelTopoFinder::onlineRocColRow(const DetId& detId,
+ const SiPixelFedCablingMap* cablingMap,
+ int fedId,
+ int offlineRow,
+ int offlineCol,
+ int& roc,
+ int& row,
+ int& col) {
+ // from detector to cabling
+ sipixelobjects::ElectronicIndex cabling;
+ sipixelobjects::DetectorIndex detector; //{detId.rawId(), offlineRow, offlineCol};
+ detector.rawId = detId.rawId();
+ detector.row = offlineRow;
+ detector.col = offlineCol;
+
+ SiPixelFrameConverter converter(cablingMap, fedId);
+ converter.toCabling(cabling, detector);
+
+ // then one can construct local pixel
+ sipixelobjects::LocalPixel::DcolPxid loc;
+ loc.dcol = cabling.dcol;
+ loc.pxid = cabling.pxid;
+ // and get local(online) row/column
+ sipixelobjects::LocalPixel locpixel(loc);
+ col = locpixel.rocCol();
+ row = locpixel.rocRow();
+ //sipixelobjects::CablingPathToDetUnit path = {(unsigned int) fedId, (unsigned int)cabling.link, (unsigned int)cabling.roc};
+ //const sipixelobjects::PixelROC *theRoc = fCablingMap_->findItem(path);
+ const sipixelobjects::PixelROC* theRoc = converter.toRoc(cabling.link, cabling.roc);
+ roc = theRoc->idInDetUnit();
+
+ // has to be BPIX; has to be minus side; has to be half module
+ // for phase-I, there is no half module
+ if (detId.subdetId() == PixelSubdetector::PixelBarrel && SiPixelTopoFinder::side(detId) == 1 &&
+ SiPixelTopoFinder::half(detId)) {
+ roc += 8;
+ }
+}
+
+int SiPixelTopoFinder::indexROC(int irow, int icol, int nROCcolumns) {
+ return int(icol + irow * nROCcolumns);
+
+ /*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 */
+}
+
+// The following three functions copied from DQM/SiPixelPhase1Common/src/SiPixelCoordinates.cc
+int SiPixelTopoFinder::quadrant(const DetId& detid) {
+ if (detid.subdetId() == PixelSubdetector::PixelBarrel)
+ return PixelBarrelName(detid, tkTopo_, phase_).shell();
+ else if (detid.subdetId() == PixelSubdetector::PixelEndcap)
+ return PixelEndcapName(detid, tkTopo_, phase_).halfCylinder();
+ else
+ return -9999;
+}
+
+int SiPixelTopoFinder::side(const DetId& detid) {
+ if (detid.subdetId() == PixelSubdetector::PixelBarrel)
+ return 1 + (SiPixelTopoFinder::quadrant(detid) > 2);
+ else if (detid.subdetId() == PixelSubdetector::PixelEndcap)
+ return tkTopo_->pxfSide(detid);
+ else
+ return -9999;
+}
+
+int SiPixelTopoFinder::half(const DetId& detid) {
+ if (detid.subdetId() == PixelSubdetector::PixelBarrel)
+ return PixelBarrelName(detid, tkTopo_, phase_).isHalfModule();
+ else
+ return -9999;
+}
diff --git a/CalibTracker/SiPixelQuality/src/classes_def.xml b/CalibTracker/SiPixelQuality/src/classes_def.xml
index ce92229721d54..4f0f31e84d2b9 100644
--- a/CalibTracker/SiPixelQuality/src/classes_def.xml
+++ b/CalibTracker/SiPixelQuality/src/classes_def.xml
@@ -1,15 +1,15 @@
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/CalibTracker/SiPixelQuality/test/step3_SiPixelCalZeroBias_RAW2DIGI_RECO_ALCA.py b/CalibTracker/SiPixelQuality/test/step3_SiPixelCalZeroBias_RAW2DIGI_RECO_ALCA.py
index b582940534be1..18cf020237283 100644
--- a/CalibTracker/SiPixelQuality/test/step3_SiPixelCalZeroBias_RAW2DIGI_RECO_ALCA.py
+++ b/CalibTracker/SiPixelQuality/test/step3_SiPixelCalZeroBias_RAW2DIGI_RECO_ALCA.py
@@ -6,7 +6,7 @@
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Run2_2017_cff import Run2_2017
-process = cms.Process('ALCAHARVEST',Run2_2017)
+process = cms.Process('RECO',Run2_2017)
# import of standard configurations
process.load('Configuration.StandardSequences.Services_cff')
@@ -495,13 +495,14 @@
#Setup FWK for multithreaded
process.options.numberOfThreads=cms.untracked.uint32(8)
-process.options.numberOfStreams=cms.untracked.uint32(0)
-process.options.numberOfConcurrentLuminosityBlocks=cms.untracked.uint32(1)
+process.options.numberOfStreams=cms.untracked.uint32(4)
+process.options.numberOfConcurrentLuminosityBlocks=cms.untracked.uint32(2)
# Customisation from command line
process.MessageLogger.cerr.FwkReport.reportEvery = 1000
+
#Have logErrorHarvester wait for the same EDProducers to finish as those providing data for the OutputModule
from FWCore.Modules.logErrorHarvester_cff import customiseLogErrorHarvesterUsingOutputCommands
process = customiseLogErrorHarvesterUsingOutputCommands(process)