53 std::vector<edm::InputTag> badPixelFEDChannelCollectionLabels_ = iConfig.
getParameter<
edm::ParameterSet>(
"SiPixelStatusProducerParameters").getParameter<std::vector<edm::InputTag> >(
"badPixelFEDChannelCollections");
54 for (
auto &
t : badPixelFEDChannelCollectionLabels_)
55 theBadPixelFEDChannelsTokens_.push_back(consumes<PixelFEDChannelCollection>(
t));
58 fPixelClusterLabel_ = iConfig.
getParameter<
edm::ParameterSet>(
"SiPixelStatusProducerParameters").getUntrackedParameter<edm::InputTag>(
"pixelClusterLabel");
59 fSiPixelClusterToken_ = consumes<edmNew::DetSetVector<SiPixelCluster>>(fPixelClusterLabel_);
65 beginLumi_ = endLumi_ = -1;
66 endLumi_ = endRun_ = -1;
68 produces<SiPixelDetectorStatus, edm::Transition::EndLuminosityBlock>(
"siPixelStatus");
80 <<
"beginlumi setup "<<endl;
82 if ( countLumi_ == 0 && resetNLumi_ > 0 ) {
85 beginRun_ = lumiSeg.
run();
91 if(siPixelFedCablingMapWatcher_.check(iSetup)||trackerDIGIGeoWatcher_.check(iSetup)||trackerTopoWatcher_.check(iSetup)){
95 fCablingMap_ = fCablingMap.product();
98 fFedIds = fCablingMap_->det2fedMap();
105 for (TrackerGeometry::DetContainer::const_iterator it = fTG->dets().begin(); it != fTG->dets().end(); it++){
108 if (pgdu ==
nullptr)
continue;
109 DetId detId = (*it)->geographicalId();
110 int detid = detId.
rawId();
119 int nrocs = nROCrows*nROCcolumns;
121 fDet.addModule(detid, nrocs);
123 fSensors[detid] = std::make_pair(rowsperroc,colsperroc);
124 fSensorLayout[detid] = std::make_pair(nROCrows,nROCcolumns);
126 std::map<int, int> rocIdMap;
127 for(
int irow = 0; irow<nROCrows; irow++){
129 for(
int icol = 0; icol<nROCcolumns; icol++){
131 int dummyOfflineRow = (rowsperroc/2-1) + irow*rowsperroc;
132 int dummeOfflineColumn = (colsperroc/2-1) + icol*colsperroc;
134 int key = indexROC(irow,icol,nROCcolumns);
136 int roc(-1), rocR(-1), rocC(-1);
137 onlineRocColRow(detId, dummyOfflineRow, dummeOfflineColumn, roc, rocR, rocC);
145 fRocIds[detid] = rocIdMap;
161 <<
"start cluster analyzer "<<endl;
168 if(!iEvent.
getByToken(fSiPixelClusterToken_, hClusterColl)){
169 edm::LogWarning(
"SiPixelStatusProducer") <<
" edmNew::DetSetVector<SiPixelCluster> "<<fPixelClusterLabel_<<
" does not exist!"<<endl;
173 iEvent.
getByToken(fSiPixelClusterToken_, hClusterColl);
177 for (
const auto&
clusters: *hClusterColl) {
179 int detid = clusters.detId();
180 int rowsperroc = fSensors[detid].first;
181 int colsperroc = fSensors[detid].second;
183 int nROCcolumns = fSensorLayout[detid].second;
186 std::map<int,int> fRocIds_detid;
187 if(fRocIds.find(detid)!=fRocIds.end()){
188 fRocIds_detid = fRocIds[detid];
191 const vector<SiPixelCluster::Pixel>& pixvector = clu.pixels();
192 for (
unsigned int i = 0;
i < pixvector.size(); ++
i) {
194 int mr0 = pixvector[
i].x;
195 int mc0 = pixvector[
i].y;
197 int irow = mr0/rowsperroc;
198 int icol = mc0/colsperroc;
200 int key = indexROC(irow,icol,nROCcolumns);
201 if(fRocIds_detid.find(key)!=fRocIds_detid.end()){
202 roc = fRocIds_detid[
key];
205 fDet.fillDIGI(detid, roc);
215 edm::LogWarning(
"SiPixelStatusProducer") <<
" edmNew::DetSetVector<SiPixelCluster> "<<fPixelClusterLabel_<<
" is NOT Valid!"<<endl;
226 if (!iEvent.
getByToken(tk, pixelFEDChannelCollectionHandle)) {
227 edm::LogWarning(
"SiPixelStatusProducer") <<
" PixelFEDChannelCollection with index "<<tk.index()<<
" does NOT exist!"<<std::endl;
230 iEvent.
getByToken(tk, pixelFEDChannelCollectionHandle);
232 if(!pixelFEDChannelCollectionHandle.
isValid()) {
233 edm::LogWarning(
"SiPixelStatusProducer") <<
" PixelFEDChannelCollection with index "<<tk.index()<<
" is NOT valid!"<<endl;
237 std::map<int, std::vector<PixelFEDChannel> > tmpFEDerror25;
238 for (
const auto& disabledChannels: *pixelFEDChannelCollectionHandle) {
240 for(
const auto& ch: disabledChannels) {
242 DetId detId = disabledChannels.detId();
243 int detid = detId.
rawId();
247 FEDerror25_[detid].push_back(ch);
249 else tmpFEDerror25[detid].push_back(ch);
257 if(!tmpFEDerror25.empty() && !FEDerror25_.empty()){
259 std::map<int, std::vector<PixelFEDChannel> >::iterator itFEDerror25;
260 for (itFEDerror25 = FEDerror25_.begin(); itFEDerror25 != FEDerror25_.end(); itFEDerror25++) {
262 int detid = itFEDerror25->first;
263 if(tmpFEDerror25.find(detid)!=tmpFEDerror25.end()){
265 std::vector<PixelFEDChannel> chs = itFEDerror25->second;
266 std::vector<PixelFEDChannel> chs_tmp = tmpFEDerror25[detid];
268 std::vector<PixelFEDChannel> chs_common;
269 for(
unsigned int ich = 0; ich<chs.size(); ich++){
273 for(
unsigned int ich_tmp = 0; ich_tmp<chs_tmp.size(); ich_tmp++){
277 chs_common.push_back(ch);
break;
283 if(chs_common.empty()) FEDerror25_.erase(itFEDerror25);
285 else { FEDerror25_[detid].clear();
286 FEDerror25_[detid] = chs_common;
290 FEDerror25_.erase(itFEDerror25);
315 <<
"endlumi producer "<<endl;
318 endRun_ = lumiSeg.
run();
321 if ( resetNLumi_ == -1 )
return;
322 if ( countLumi_ < resetNLumi_ )
return;
325 if(!FEDerror25_.empty()){
326 std::map<int, std::vector<PixelFEDChannel> >::iterator itFEDerror25;
327 for (itFEDerror25 = FEDerror25_.begin(); itFEDerror25 != FEDerror25_.end(); itFEDerror25++) {
328 int detid = itFEDerror25->first;
329 std::vector<PixelFEDChannel> chs = itFEDerror25->second;
330 for(
unsigned int ich = 0; ich<chs.size(); ich++){
331 fDet.fillFEDerror25(detid,chs[ich]);
336 fDet.setRunRange(beginRun_,endRun_);
337 fDet.setLSRange(beginLumi_,endLumi_);
338 fDet.setNevents(ftotalevents);
341 auto result = std::make_unique<SiPixelDetectorStatus>();
347 <<
"new lumi-based data stored for run "<<beginRun_<<
" lumi from "<<beginLumi_<<
" to "<<endLumi_<<std::endl;
350 fDet.resetDetectorStatus();
364 detector.
rawId = detId.
rawId(); detector.
row = offlineRow; detector.
col = offlineCol;
394 return int(icol+irow*nROCcolumns);
411 psd0.
add<std::vector<edm::InputTag>>(
"badPixelFEDChannelCollections", {
416 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