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