Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-14 02:50:05

0001 // -*- C++ -*-
0002 ///bookLayer
0003 // Package:    SiPixelPhase1MonitorRecHitsSoA
0004 // Class:      SiPixelPhase1MonitorRecHitsSoA
0005 //
0006 /**\class SiPixelPhase1MonitorRecHitsSoA SiPixelPhase1MonitorRecHitsSoA.cc 
0007 */
0008 //
0009 // Author: Suvankar Roy Chowdhury, Alessandro Rossi
0010 //
0011 #include "DataFormats/Math/interface/approx_atan2.h"
0012 #include "DataFormats/Common/interface/Handle.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/Frameworkfwd.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 // DQM Histograming
0019 #include "DQMServices/Core/interface/MonitorElement.h"
0020 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0021 #include "DQMServices/Core/interface/DQMStore.h"
0022 #include "CUDADataFormats/TrackingRecHit/interface/TrackingRecHit2DHeterogeneous.h"
0023 // Geometry
0024 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0025 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0026 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0027 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0028 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0029 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0030 
0031 class SiPixelPhase1MonitorRecHitsSoA : public DQMEDAnalyzer {
0032 public:
0033   explicit SiPixelPhase1MonitorRecHitsSoA(const edm::ParameterSet&);
0034   ~SiPixelPhase1MonitorRecHitsSoA() override = default;
0035   void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
0036   void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;
0037   void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0038   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0039 
0040 private:
0041   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
0042   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
0043   const edm::EDGetTokenT<TrackingRecHit2DCPU> tokenSoAHitsCPU_;
0044   const std::string topFolderName_;
0045   const TrackerGeometry* tkGeom_ = nullptr;
0046   const TrackerTopology* tTopo_ = nullptr;
0047   MonitorElement* hnHits;
0048   MonitorElement* hBFposZP;
0049   MonitorElement* hBFposZR;
0050   MonitorElement* hBposXY;
0051   MonitorElement* hBposZP;
0052   MonitorElement* hBcharge;
0053   MonitorElement* hBsizex;
0054   MonitorElement* hBsizey;
0055   MonitorElement* hBposZPL[4];
0056   MonitorElement* hBchargeL[4];
0057   MonitorElement* hBsizexL[4];
0058   MonitorElement* hBsizeyL[4];
0059   MonitorElement* hFposXY;
0060   MonitorElement* hFposZP;
0061   MonitorElement* hFcharge;
0062   MonitorElement* hFsizex;
0063   MonitorElement* hFsizey;
0064   MonitorElement* hFposXYD[2][3];
0065   MonitorElement* hFchargeD[2][3];
0066   MonitorElement* hFsizexD[2][3];
0067   MonitorElement* hFsizeyD[2][3];
0068 };
0069 
0070 //
0071 // constructors
0072 //
0073 
0074 SiPixelPhase1MonitorRecHitsSoA::SiPixelPhase1MonitorRecHitsSoA(const edm::ParameterSet& iConfig)
0075     : geomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()),
0076       topoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()),
0077       tokenSoAHitsCPU_(consumes<TrackingRecHit2DCPU>(iConfig.getParameter<edm::InputTag>("pixelHitsSrc"))),
0078       topFolderName_(iConfig.getParameter<std::string>("TopFolderName")) {}
0079 //
0080 // Begin Run
0081 //
0082 void SiPixelPhase1MonitorRecHitsSoA::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
0083   tkGeom_ = &iSetup.getData(geomToken_);
0084   tTopo_ = &iSetup.getData(topoToken_);
0085 }
0086 
0087 //
0088 // -- Analyze
0089 //
0090 void SiPixelPhase1MonitorRecHitsSoA::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0091   const auto& rhsoaHandle = iEvent.getHandle(tokenSoAHitsCPU_);
0092   if (!rhsoaHandle.isValid()) {
0093     edm::LogWarning("SiPixelPhase1MonitorRecHitsSoA") << "No RecHits SoA found \n returning!" << std::endl;
0094     return;
0095   }
0096   auto const& rhsoa = *rhsoaHandle;
0097   const TrackingRecHit2DSOAView* soa2d = rhsoa.view();
0098 
0099   uint32_t nHits_ = soa2d->nHits();
0100   hnHits->Fill(nHits_);
0101   auto detIds = tkGeom_->detUnitIds();
0102   for (uint32_t i = 0; i < nHits_; i++) {
0103     DetId id = detIds[soa2d->detectorIndex(i)];
0104     float xG = soa2d->xGlobal(i);
0105     float yG = soa2d->yGlobal(i);
0106     float zG = soa2d->zGlobal(i);
0107     float rG = soa2d->rGlobal(i);
0108     float fphi = short2phi(soa2d->iphi(i));
0109     uint32_t charge = soa2d->charge(i);
0110     int16_t sizeX = std::ceil(float(std::abs(soa2d->clusterSizeX(i)) / 8.));
0111     int16_t sizeY = std::ceil(float(std::abs(soa2d->clusterSizeY(i)) / 8.));
0112     hBFposZP->Fill(zG, fphi);
0113     int16_t ysign = yG >= 0 ? 1 : -1;
0114     hBFposZR->Fill(zG, rG * ysign);
0115     switch (id.subdetId()) {
0116       case PixelSubdetector::PixelBarrel:
0117         hBposXY->Fill(xG, yG);
0118         hBposZP->Fill(zG, fphi);
0119         hBcharge->Fill(charge);
0120         hBsizex->Fill(sizeX);
0121         hBsizey->Fill(sizeY);
0122         hBposZPL[tTopo_->pxbLayer(id) - 1]->Fill(zG, fphi);
0123         hBchargeL[tTopo_->pxbLayer(id) - 1]->Fill(charge);
0124         hBsizexL[tTopo_->pxbLayer(id) - 1]->Fill(sizeX);
0125         hBsizeyL[tTopo_->pxbLayer(id) - 1]->Fill(sizeY);
0126         break;
0127       case PixelSubdetector::PixelEndcap:
0128         hFposXY->Fill(xG, yG);
0129         hFposZP->Fill(zG, fphi);
0130         hFcharge->Fill(charge);
0131         hFsizex->Fill(sizeX);
0132         hFsizey->Fill(sizeY);
0133         hFposXYD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(xG, yG);
0134         hFchargeD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(charge);
0135         hFsizexD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeX);
0136         hFsizeyD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeY);
0137         break;
0138     }
0139   }
0140 }
0141 
0142 //
0143 // -- Book Histograms
0144 //
0145 void SiPixelPhase1MonitorRecHitsSoA::bookHistograms(DQMStore::IBooker& iBook,
0146                                                     edm::Run const& iRun,
0147                                                     edm::EventSetup const& iSetup) {
0148   iBook.cd();
0149   iBook.setCurrentFolder(topFolderName_);
0150 
0151   // clang-format off
0152   //Global
0153   hnHits = iBook.book1D("nHits", "RecHits per event;RecHits;#events", 200, 0, 5000);
0154   hBFposZP = iBook.book2D("recHitsGlobalPosZP", "RecHits position Global;Z;#phi", 1000, -60, 60, 200,-3.2,3.2);
0155   hBFposZR = iBook.book2D("recHitsGlobalPosZR", "RecHits position Global;Z;R", 1000, -60, 60, 200,-20,20);
0156   //Barrel
0157   hBposXY = iBook.book2D("recHitsBarrelPosXY", "RecHits position Barrel;X;Y", 200, -20, 20, 200,-20,20);
0158   hBposZP = iBook.book2D("recHitsBarrelPosZP", "RecHits position Barrel;Z;#phi", 300, -30, 30, 200,-3.2,3.2);
0159   hBcharge = iBook.book1D("recHitsBarrelCharge", "RecHits Charge Barrel;Charge;#events", 250, 0, 100000);
0160   hBsizex = iBook.book1D("recHitsBarrelSizex", "RecHits SizeX Barrel;SizeX;#events", 50, 0, 50);
0161   hBsizey = iBook.book1D("recHitsBarrelSizey", "RecHits SizeY Barrel;SizeY;#events", 50, 0, 50);
0162   //Barrel Layer
0163   for(unsigned int il=0;il<tkGeom_->numberOfLayers(PixelSubdetector::PixelBarrel);il++){
0164     hBposZPL[il] = iBook.book2D(Form("recHitsBLay%dPosZP",il+1), Form("RecHits position Barrel Layer%d;Z;#phi",il+1), 300, -30, 30, 200,-3.2,3.2);
0165     hBchargeL[il] = iBook.book1D(Form("recHitsBLay%dCharge",il+1), Form("RecHits Charge Barrel Layer%d;Charge;#events",il+1), 250, 0, 100000);
0166     hBsizexL[il] = iBook.book1D(Form("recHitsBLay%dSizex",il+1), Form("RecHits SizeX Barrel Layer%d;SizeX;#events",il+1), 50, 0, 50);
0167     hBsizeyL[il] = iBook.book1D(Form("recHitsBLay%dSizey",il+1), Form("RecHits SizeY Barrel Layer%d;SizeY;#events",il+1), 50, 0, 50);
0168   }
0169   //Endcaps
0170   hFposXY = iBook.book2D("recHitsEndcapsPosXY", "RecHits position Endcaps;X;Y", 200, -20, 20, 200,-20, 20);
0171   hFposZP = iBook.book2D("recHitsEndcapsPosZP", "RecHits position Endcaps;Z;#phi", 600, -60, 60, 200,-3.2,3.2);
0172   hFcharge = iBook.book1D("recHitsEndcapsCharge", "RecHits Charge Endcaps;Charge;#events", 250, 0, 100000);
0173   hFsizex = iBook.book1D("recHitsEndcapsSizex", "RecHits SizeX Endcaps;SizeX;#events", 50, 0, 50);
0174   hFsizey = iBook.book1D("recHitsEndcapsSizey", "RecHits SizeY Endcaps;SizeY;#events", 50, 0, 50);
0175   //Endcaps Disk
0176   for(int is=0;is<2;is++){
0177     int sign=is==0? -1:1;
0178     for(unsigned int id=0;id<tkGeom_->numberOfLayers(PixelSubdetector::PixelEndcap);id++){
0179       hFposXYD[is][id] = iBook.book2D(Form("recHitsFDisk%+dPosXY",id*sign+sign), Form("RecHits position Endcaps Disk%+d;X;Y",id*sign+sign), 200, -20, 20, 200,-20,20);
0180       hFchargeD[is][id] = iBook.book1D(Form("recHitsFDisk%+dCharge",id*sign+sign), Form("RecHits Charge Endcaps Disk%+d;Charge;#events",id*sign+sign), 250, 0, 100000);
0181       hFsizexD[is][id] = iBook.book1D(Form("recHitsFDisk%+dSizex",id*sign+sign), Form("RecHits SizeX Endcaps Disk%+d;SizeX;#events",id*sign+sign), 50, 0, 50);
0182       hFsizeyD[is][id] = iBook.book1D(Form("recHitsFDisk%+dSizey",id*sign+sign), Form("RecHits SizeY Endcaps Disk%+d;SizeY;#events",id*sign+sign), 50, 0, 50);
0183     }
0184   }
0185 }
0186 
0187 void SiPixelPhase1MonitorRecHitsSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0188   // monitorpixelRecHitsSoA
0189   edm::ParameterSetDescription desc;
0190   desc.add<edm::InputTag>("pixelHitsSrc", edm::InputTag("siPixelRecHitsPreSplittingSoA"));
0191   desc.add<std::string>("TopFolderName", "SiPixelHeterogeneous/PixelRecHitsSoA");
0192   descriptions.addWithDefaultLabel(desc);
0193 }
0194 DEFINE_FWK_MODULE(SiPixelPhase1MonitorRecHitsSoA);