Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:23

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiPixelPhase1DeadFEDChannels
0004 // Class:      SiPixelPhase1DeadFEDChannels
0005 //
0006 
0007 // Original Author: F.Fiori
0008 
0009 // C++ stuff
0010 #include <iostream>
0011 
0012 // CMSSW stuff
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0017 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0018 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0019 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCabling.h"
0020 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
0021 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
0022 
0023 // DQM Stuff
0024 #include "DQMServices/Core/interface/DQMStore.h"
0025 
0026 // Input data stuff
0027 #include "DataFormats/Common/interface/DetSetVector.h"
0028 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
0029 #include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h"
0030 
0031 // PixelDQM Framework
0032 #include "DQM/SiPixelPhase1Common/interface/SiPixelPhase1Base.h"
0033 
0034 namespace {
0035 
0036   class SiPixelPhase1DeadFEDChannels final : public SiPixelPhase1Base {
0037     // List of quantities to be plotted.
0038     enum {
0039       DEADCHAN,
0040       DEADCHANROC
0041 
0042     };
0043 
0044   public:
0045     explicit SiPixelPhase1DeadFEDChannels(const edm::ParameterSet& conf);
0046     void analyze(const edm::Event&, const edm::EventSetup&) override;
0047 
0048   private:
0049     edm::EDGetTokenT<PixelFEDChannelCollection> pixelFEDChannelCollectionToken_;
0050     edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeomToken_;
0051     edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> cablingMapToken_;
0052 
0053     bool firstEvent_;
0054     const TrackerGeometry* trackerGeometry_ = nullptr;
0055     const SiPixelFedCabling* cablingMap = nullptr;
0056   };
0057 
0058   SiPixelPhase1DeadFEDChannels::SiPixelPhase1DeadFEDChannels(const edm::ParameterSet& iConfig)
0059       : SiPixelPhase1Base(iConfig) {
0060     pixelFEDChannelCollectionToken_ = consumes<PixelFEDChannelCollection>(edm::InputTag("siPixelDigis"));
0061     trackerGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
0062     cablingMapToken_ = esConsumes<SiPixelFedCablingMap, SiPixelFedCablingMapRcd>();
0063     firstEvent_ = true;
0064   };
0065 
0066   void SiPixelPhase1DeadFEDChannels::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0067     if (!checktrigger(iEvent, iSetup, DCS))
0068       return;
0069 
0070     if (firstEvent_) {
0071       edm::ESHandle<TrackerGeometry> tmpTkGeometry = iSetup.getHandle(trackerGeomToken_);
0072       trackerGeometry_ = &(*tmpTkGeometry);
0073 
0074       edm::ESHandle<SiPixelFedCablingMap> pixelCabling = iSetup.getHandle(cablingMapToken_);
0075       cablingMap = pixelCabling.product();
0076 
0077       firstEvent_ = false;
0078     }
0079 
0080     edm::Handle<edmNew::DetSetVector<PixelFEDChannel> > input;
0081 
0082     iEvent.getByToken(pixelFEDChannelCollectionToken_, input);
0083     if (!input.isValid())
0084       return;
0085 
0086     for (const auto& disabledOnDetId : *input) {
0087       for (const auto& ch : disabledOnDetId) {
0088         sipixelobjects::CablingPathToDetUnit path = {ch.fed, ch.link, 0};
0089 
0090         for (path.roc = 1; path.roc <= (ch.roc_last - ch.roc_first) + 1; path.roc++) {
0091           const sipixelobjects::PixelROC* roc = cablingMap->findItem(path);
0092           assert(roc != nullptr);
0093           assert(roc->rawId() == disabledOnDetId.detId());
0094 
0095           const PixelGeomDetUnit* theGeomDet =
0096               dynamic_cast<const PixelGeomDetUnit*>(trackerGeometry_->idToDet(roc->rawId()));
0097           PixelTopology const* topology = &(theGeomDet->specificTopology());
0098           sipixelobjects::LocalPixel::RocRowCol local = {topology->rowsperroc() / 2,
0099                                                          topology->colsperroc() / 2};  //center of ROC
0100           sipixelobjects::GlobalPixel global = roc->toGlobal(sipixelobjects::LocalPixel(local));
0101           histo[DEADCHANROC].fill(disabledOnDetId.detId(), &iEvent, global.col, global.row);
0102         }
0103 
0104         histo[DEADCHAN].fill(disabledOnDetId.detId(), &iEvent);  // global count
0105       }
0106     }
0107 
0108     histo[DEADCHAN].executePerEventHarvesting(&iEvent);
0109   }
0110 }  //namespace
0111 
0112 DEFINE_FWK_MODULE(SiPixelPhase1DeadFEDChannels);