CMS 3D CMS Logo

SiPixelMonitorRecHitsSoA.cc
Go to the documentation of this file.
1 // -*- C++ -*-
3 // Package: SiPixelMonitorRecHitsSoA
4 // Class: SiPixelMonitorRecHitsSoA
5 //
8 //
9 // Author: Suvankar Roy Chowdhury, Alessandro Rossi
10 //
18 // DQM Histograming
24 // Geometry
31 
32 template <typename T>
34 public:
37 
39  ~SiPixelMonitorRecHitsSoA() override = default;
40  void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
41  void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;
42  void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
43  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
44 
45 private:
50  const TrackerGeometry* tkGeom_ = nullptr;
51  const TrackerTopology* tTopo_ = nullptr;
60  MonitorElement* hBposZPL[4]; // max 4 barrel hits
69  MonitorElement* hFposXYD[2][12]; // max 12 endcap disks
73 };
74 
75 //
76 // constructors
77 //
78 
79 template <typename T>
82  topoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()),
83  tokenSoAHitsCPU_(consumes(iConfig.getParameter<edm::InputTag>("pixelHitsSrc"))),
84  topFolderName_(iConfig.getParameter<std::string>("TopFolderName")) {}
85 //
86 // Begin Run
87 //
88 template <typename T>
90  tkGeom_ = &iSetup.getData(geomToken_);
91  tTopo_ = &iSetup.getData(topoToken_);
92 }
93 
94 //
95 // -- Analyze
96 //
97 template <typename T>
99  const auto& rhsoaHandle = iEvent.getHandle(tokenSoAHitsCPU_);
100  if (!rhsoaHandle.isValid()) {
101  edm::LogWarning("SiPixelMonitorRecHitsSoA") << "No RecHits SoA found \n returning!" << std::endl;
102  return;
103  }
104  auto const& rhsoa = *rhsoaHandle;
105  auto const& soa2d = rhsoa.const_view();
106 
107  uint32_t nHits_ = soa2d.nHits();
108  hnHits->Fill(nHits_);
109  auto detIds = tkGeom_->detUnitIds();
110  for (uint32_t i = 0; i < nHits_; i++) {
111  DetId id = detIds[soa2d[i].detectorIndex()];
112  float xG = soa2d[i].xGlobal();
113  float yG = soa2d[i].yGlobal();
114  float zG = soa2d[i].zGlobal();
115  float rG = soa2d[i].rGlobal();
116  float fphi = short2phi(soa2d[i].iphi());
117  uint32_t charge = soa2d[i].chargeAndStatus().charge;
118  int16_t sizeX = std::ceil(float(std::abs(soa2d[i].clusterSizeX()) / 8.));
119  int16_t sizeY = std::ceil(float(std::abs(soa2d[i].clusterSizeY()) / 8.));
120  hBFposZP->Fill(zG, fphi);
121  int16_t ysign = yG >= 0 ? 1 : -1;
122  hBFposZR->Fill(zG, rG * ysign);
123  switch (id.subdetId()) {
125  hBposXY->Fill(xG, yG);
126  hBposZP->Fill(zG, fphi);
127  hBcharge->Fill(charge);
128  hBsizex->Fill(sizeX);
129  hBsizey->Fill(sizeY);
130  hBposZPL[tTopo_->pxbLayer(id) - 1]->Fill(zG, fphi);
131  hBchargeL[tTopo_->pxbLayer(id) - 1]->Fill(charge);
132  hBsizexL[tTopo_->pxbLayer(id) - 1]->Fill(sizeX);
133  hBsizeyL[tTopo_->pxbLayer(id) - 1]->Fill(sizeY);
134  break;
136  hFposXY->Fill(xG, yG);
137  hFposZP->Fill(zG, fphi);
138  hFcharge->Fill(charge);
139  hFsizex->Fill(sizeX);
140  hFsizey->Fill(sizeY);
141  hFposXYD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(xG, yG);
142  hFchargeD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(charge);
143  hFsizexD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeX);
144  hFsizeyD[tTopo_->pxfSide(id) - 1][tTopo_->pxfDisk(id) - 1]->Fill(sizeY);
145  break;
146  }
147  }
148 }
149 
150 //
151 // -- Book Histograms
152 //
153 template <typename T>
155  edm::Run const& iRun,
156  edm::EventSetup const& iSetup) {
157  iBook.cd();
158  iBook.setCurrentFolder(topFolderName_);
159 
160  // clang-format off
161  //Global
162  hnHits = iBook.book1D("nHits", "RecHits per event;RecHits;#events", 200, 0, 5000);
163  hBFposZP = iBook.book2D("recHitsGlobalPosZP", "RecHits position Global;Z;#phi", 1000, -60, 60, 200,-3.2,3.2);
164  hBFposZR = iBook.book2D("recHitsGlobalPosZR", "RecHits position Global;Z;R", 1000, -60, 60, 200,-20,20);
165  //Barrel
166  hBposXY = iBook.book2D("recHitsBarrelPosXY", "RecHits position Barrel;X;Y", 200, -20, 20, 200,-20,20);
167  hBposZP = iBook.book2D("recHitsBarrelPosZP", "RecHits position Barrel;Z;#phi", 300, -30, 30, 200,-3.2,3.2);
168  hBcharge = iBook.book1D("recHitsBarrelCharge", "RecHits Charge Barrel;Charge;#events", 250, 0, 100000);
169  hBsizex = iBook.book1D("recHitsBarrelSizex", "RecHits SizeX Barrel;SizeX;#events", 50, 0, 50);
170  hBsizey = iBook.book1D("recHitsBarrelSizey", "RecHits SizeY Barrel;SizeY;#events", 50, 0, 50);
171  //Barrel Layer
172  for(unsigned int il=0;il<tkGeom_->numberOfLayers(PixelSubdetector::PixelBarrel);il++){
173  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);
174  hBchargeL[il] = iBook.book1D(Form("recHitsBLay%dCharge",il+1), Form("RecHits Charge Barrel Layer%d;Charge;#events",il+1), 250, 0, 100000);
175  hBsizexL[il] = iBook.book1D(Form("recHitsBLay%dSizex",il+1), Form("RecHits SizeX Barrel Layer%d;SizeX;#events",il+1), 50, 0, 50);
176  hBsizeyL[il] = iBook.book1D(Form("recHitsBLay%dSizey",il+1), Form("RecHits SizeY Barrel Layer%d;SizeY;#events",il+1), 50, 0, 50);
177  }
178  //Endcaps
179  hFposXY = iBook.book2D("recHitsEndcapsPosXY", "RecHits position Endcaps;X;Y", 200, -20, 20, 200,-20, 20);
180  hFposZP = iBook.book2D("recHitsEndcapsPosZP", "RecHits position Endcaps;Z;#phi", 600, -60, 60, 200,-3.2,3.2);
181  hFcharge = iBook.book1D("recHitsEndcapsCharge", "RecHits Charge Endcaps;Charge;#events", 250, 0, 100000);
182  hFsizex = iBook.book1D("recHitsEndcapsSizex", "RecHits SizeX Endcaps;SizeX;#events", 50, 0, 50);
183  hFsizey = iBook.book1D("recHitsEndcapsSizey", "RecHits SizeY Endcaps;SizeY;#events", 50, 0, 50);
184  //Endcaps Disk
185  for(int is=0;is<2;is++){
186  int sign=is==0? -1:1;
187  for(unsigned int id=0;id<tkGeom_->numberOfLayers(PixelSubdetector::PixelEndcap);id++){
188  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);
189  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);
190  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);
191  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);
192  }
193  }
194 }
195 
196 template<typename T>
198  // monitorpixelRecHitsSoA
200  desc.add<edm::InputTag>("pixelHitsSrc", edm::InputTag("siPixelRecHitsPreSplittingSoA"));
201  desc.add<std::string>("TopFolderName", "SiPixelHeterogeneous/PixelRecHitsSoA");
202  descriptions.addWithDefaultLabel(desc);
203 }
204 
207 
constexpr int32_t ceil(float num)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
MonitorElement * hFposXYD[2][12]
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
MonitorElement * hFsizeyD[2][12]
MonitorElement * hFchargeD[2][12]
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
TrackingRecHitSoAView< T > HitSoA
~SiPixelMonitorRecHitsSoA() override=default
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * hFsizexD[2][12]
int iEvent
Definition: GenABIO.cc:224
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Definition: DetId.h:17
const TrackerTopology * tTopo_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
constexpr float short2phi(short x)
Definition: approx_atan2.h:285
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) override
HLT enums.
const edm::EDGetTokenT< HitsOnHost > tokenSoAHitsCPU_
typename TrackingRecHitSoA< TrackerTraits >::template TrackingRecHitSoALayout<>::View TrackingRecHitSoAView
SiPixelMonitorRecHitsSoA(const edm::ParameterSet &)
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
const TrackerGeometry * tkGeom_
Definition: Run.h:45