52 std::vector<edm::InputTag> badPixelFEDChannelCollectionLabels_ =
54 .getParameter<std::vector<edm::InputTag>>(
"badPixelFEDChannelCollections");
55 for (
auto&
t : badPixelFEDChannelCollectionLabels_)
56 theBadPixelFEDChannelsTokens_.push_back(consumes<PixelFEDChannelCollection>(
t));
60 .getUntrackedParameter<edm::InputTag>(
"pixelClusterLabel");
61 fSiPixelClusterToken_ = consumes<edmNew::DetSetVector<SiPixelCluster>>(fPixelClusterLabel_);
63 .getUntrackedParameter<int>(
"resetEveryNLumi", 1);
68 beginLumi_ = endLumi_ = -1;
69 endLumi_ = endRun_ = -1;
71 produces<SiPixelDetectorStatus, edm::Transition::EndLuminosityBlock>(
"siPixelStatus");
79 edm::LogInfo(
"SiPixelStatusProducer") <<
"beginlumi setup " << endl;
81 if (countLumi_ == 0 && resetNLumi_ > 0) {
83 beginRun_ = lumiSeg.
run();
88 if (siPixelFedCablingMapWatcher_.check(iSetup) || trackerDIGIGeoWatcher_.check(iSetup) ||
89 trackerTopoWatcher_.check(iSetup)) {
92 fCablingMap_ = fCablingMap.product();
95 fFedIds = fCablingMap_->det2fedMap();
100 if (countLumi_ == 0) {
101 for (TrackerGeometry::DetContainer::const_iterator it = fTG->dets().begin(); it != fTG->dets().end(); it++) {
105 DetId detId = (*it)->geographicalId();
106 int detid = detId.
rawId();
115 int nrocs = nROCrows * nROCcolumns;
117 fDet.addModule(detid, nrocs);
119 fSensors[detid] = std::make_pair(rowsperroc, colsperroc);
120 fSensorLayout[detid] = std::make_pair(nROCrows, nROCcolumns);
122 std::map<int, int> rocIdMap;
123 for (
int irow = 0; irow < nROCrows; irow++) {
124 for (
int icol = 0; icol < nROCcolumns; icol++) {
125 int dummyOfflineRow = (rowsperroc / 2 - 1) + irow * rowsperroc;
126 int dummeOfflineColumn = (colsperroc / 2 - 1) + icol * colsperroc;
128 int key = indexROC(irow, icol, nROCcolumns);
130 int roc(-1), rocR(-1), rocC(-1);
131 onlineRocColRow(detId, dummyOfflineRow, dummeOfflineColumn,
roc, rocR, rocC);
138 fRocIds[detid] = rocIdMap;
151 edm::LogInfo(
"SiPixelStatusProducer") <<
"start cluster analyzer " << endl;
158 if (!iEvent.
getByToken(fSiPixelClusterToken_, hClusterColl)) {
160 <<
" edmNew::DetSetVector<SiPixelCluster> " << fPixelClusterLabel_ <<
" does not exist!" << endl;
164 iEvent.
getByToken(fSiPixelClusterToken_, hClusterColl);
167 for (
const auto&
clusters : *hClusterColl) {
169 int detid = clusters.detId();
170 int rowsperroc = fSensors[detid].first;
171 int colsperroc = fSensors[detid].second;
173 int nROCcolumns = fSensorLayout[detid].second;
176 std::map<int, int> fRocIds_detid;
177 if (fRocIds.find(detid) != fRocIds.end()) {
178 fRocIds_detid = fRocIds[detid];
181 const vector<SiPixelCluster::Pixel>& pixvector = clu.pixels();
182 for (
unsigned int i = 0;
i < pixvector.size(); ++
i) {
183 int mr0 = pixvector[
i].x;
184 int mc0 = pixvector[
i].y;
186 int irow = mr0 / rowsperroc;
187 int icol = mc0 / colsperroc;
189 int key = indexROC(irow, icol, nROCcolumns);
190 if (fRocIds_detid.find(key) != fRocIds_detid.end()) {
191 roc = fRocIds_detid[
key];
194 fDet.fillDIGI(detid, roc);
205 <<
" edmNew::DetSetVector<SiPixelCluster> " << fPixelClusterLabel_ <<
" is NOT Valid!" << endl;
215 if (!iEvent.
getByToken(tk, pixelFEDChannelCollectionHandle)) {
217 <<
" PixelFEDChannelCollection with index " << tk.index() <<
" does NOT exist!" << std::endl;
220 iEvent.
getByToken(tk, pixelFEDChannelCollectionHandle);
222 if (!pixelFEDChannelCollectionHandle.
isValid()) {
224 <<
" PixelFEDChannelCollection with index " << tk.index() <<
" is NOT valid!" << endl;
228 std::map<int, std::vector<PixelFEDChannel>> tmpFEDerror25;
229 for (
const auto& disabledChannels : *pixelFEDChannelCollectionHandle) {
231 for (
const auto& ch : disabledChannels) {
232 DetId detId = disabledChannels.detId();
233 int detid = detId.
rawId();
235 if (ftotalevents == 1) {
237 FEDerror25_[detid].push_back(ch);
239 tmpFEDerror25[detid].push_back(ch);
247 if (!tmpFEDerror25.empty() && !FEDerror25_.empty()) {
249 std::map<int, std::vector<PixelFEDChannel>>::iterator itFEDerror25;
250 for (itFEDerror25 = FEDerror25_.begin(); itFEDerror25 != FEDerror25_.end(); itFEDerror25++) {
251 int detid = itFEDerror25->first;
252 if (tmpFEDerror25.find(detid) != tmpFEDerror25.end()) {
253 std::vector<PixelFEDChannel> chs = itFEDerror25->second;
254 std::vector<PixelFEDChannel> chs_tmp = tmpFEDerror25[detid];
256 std::vector<PixelFEDChannel> chs_common;
257 for (
unsigned int ich = 0; ich < chs.size(); ich++) {
260 for (
unsigned int ich_tmp = 0; ich_tmp < chs_tmp.size(); ich_tmp++) {
263 chs_common.push_back(ch);
269 if (chs_common.empty())
270 FEDerror25_.erase(itFEDerror25);
273 FEDerror25_[detid].clear();
274 FEDerror25_[detid] = chs_common;
277 FEDerror25_.erase(itFEDerror25);
297 edm::LogInfo(
"SiPixelStatusProducer") <<
"endlumi producer " << endl;
300 endRun_ = lumiSeg.
run();
303 if (resetNLumi_ == -1)
305 if (countLumi_ < resetNLumi_)
309 if (!FEDerror25_.empty()) {
310 std::map<int, std::vector<PixelFEDChannel>>::iterator itFEDerror25;
311 for (itFEDerror25 = FEDerror25_.begin(); itFEDerror25 != FEDerror25_.end(); itFEDerror25++) {
312 int detid = itFEDerror25->first;
313 std::vector<PixelFEDChannel> chs = itFEDerror25->second;
314 for (
unsigned int ich = 0; ich < chs.size(); ich++) {
315 fDet.fillFEDerror25(detid, chs[ich]);
320 fDet.setRunRange(beginRun_, endRun_);
321 fDet.setLSRange(beginLumi_, endLumi_);
322 fDet.setNevents(ftotalevents);
325 auto result = std::make_unique<SiPixelDetectorStatus>();
330 edm::LogInfo(
"SiPixelStatusProducer") <<
"new lumi-based data stored for run " << beginRun_ <<
" lumi from " 331 << beginLumi_ <<
" to " << endLumi_ << std::endl;
334 fDet.resetDetectorStatus();
342 const DetId& detId,
int offlineRow,
int offlineCol,
int&
roc,
int& row,
int&
col) {
349 detector.
row = offlineRow;
350 detector.
col = offlineCol;
377 return int(icol + irow * nROCcolumns);
393 psd0.
add<std::vector<edm::InputTag>>(
"badPixelFEDChannelCollections",
399 descriptions.
add(
"siPixelStatusProducer", desc);
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual int nrows() const =0
virtual int rowsperroc() const =0
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr uint32_t rawId() const
get the raw id
void accumulate(edm::Event const &, const edm::EventSetup &iSetup) final
SiPixelStatusProducer(const edm::ParameterSet &)
identify pixel inside single ROC
~SiPixelStatusProducer() override
LuminosityBlockNumber_t luminosityBlock() const
#define DEFINE_FWK_MODULE(type)
virtual int colsperroc() const =0
void put(std::unique_ptr< PROD > product)
Put a new product.
virtual void onlineRocColRow(const DetId &detId, int offlineRow, int offlineCol, int &roc, int &row, int &col) final
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double collumn and pixel ID in double collumn representation
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, const edm::EventSetup &iSetup) final
virtual int ncolumns() const =0
sipixelobjects::PixelROC const * toRoc(int link, int roc) const
virtual int indexROC(int irow, int icol, int nROCcolumns) final
void endLuminosityBlockProduce(edm::LuminosityBlock &lumiSeg, const edm::EventSetup &iSetup) final
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, const edm::EventSetup &iSetup) final