CMS 3D CMS Logo

SiPixelMonitorVertexSoA.cc
Go to the documentation of this file.
1 // -*- C++ -*-
3 // Package: SiPixelMonitorVertexSoA
4 // Class: SiPixelMonitorVertexSoA
5 //
8 //
9 // Author: Suvankar Roy Chowdhury
10 //
20 // DQM Histograming
26 
28 public:
29  using IndToEdm = std::vector<uint16_t>;
31  ~SiPixelMonitorVertexSoA() override = default;
32  void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;
33  void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
34  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
35 
36 private:
48 };
49 
50 //
51 // constructors
52 //
53 
55  tokenSoAVertex_ = consumes(iConfig.getParameter<edm::InputTag>("pixelVertexSrc"));
56  tokenBeamSpot_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotSrc"));
57  topFolderName_ = iConfig.getParameter<std::string>("topFolderName");
58 }
59 
60 //
61 // -- Analyze
62 //
64  const auto& vsoaHandle = iEvent.getHandle(tokenSoAVertex_);
65  if (!vsoaHandle.isValid()) {
66  edm::LogWarning("SiPixelMonitorVertexSoA") << "No Vertex SoA found \n returning!" << std::endl;
67  return;
68  }
69 
70  auto const& vsoa = *vsoaHandle;
71  int nVertices = vsoa.view().nvFinal();
72  auto bsHandle = iEvent.getHandle(tokenBeamSpot_);
73  float x0 = 0., y0 = 0., z0 = 0., dxdz = 0., dydz = 0.;
74  if (!bsHandle.isValid()) {
75  edm::LogWarning("SiPixelMonitorVertexSoA") << "No beamspot found. returning vertexes with (0,0,Z) ";
76  } else {
77  const reco::BeamSpot& bs = *bsHandle;
78  x0 = bs.x0();
79  y0 = bs.y0();
80  z0 = bs.z0();
81  dxdz = bs.dxdz();
82  dydz = bs.dydz();
83  }
84 
85  for (int iv = 0; iv < nVertices; iv++) {
86  auto si = vsoa.view()[iv].sortInd();
87  auto z = vsoa.view()[si].zv();
88  auto x = x0 + dxdz * z;
89  auto y = y0 + dydz * z;
90 
91  z += z0;
92  hx->Fill(x);
93  hy->Fill(y);
94  hz->Fill(z);
95  auto ndof = vsoa.view()[si].ndof();
96  hchi2->Fill(vsoa.view()[si].chi2());
97  hchi2oNdof->Fill(vsoa.view()[si].chi2() / ndof);
98  hptv2->Fill(vsoa.view()[si].ptv2());
99  hntrks->Fill(ndof + 1);
100  }
102 }
103 
104 //
105 // -- Book Histograms
106 //
108  edm::Run const& iRun,
109  edm::EventSetup const& iSetup) {
110  //std::string top_folder = ""//
111  ibooker.cd();
113  hnVertex = ibooker.book1D("nVertex", ";# of Vertices;#entries", 101, -0.5, 100.5);
114  hx = ibooker.book1D("vx", ";Vertex x;#entries", 10, -5., 5.);
115  hy = ibooker.book1D("vy", ";Vertex y;#entries", 10, -5., 5.);
116  hz = ibooker.book1D("vz", ";Vertex z;#entries", 30, -30., 30);
117  hchi2 = ibooker.book1D("chi2", ";Vertex chi-squared;#entries", 40, 0., 20.);
118  hchi2oNdof = ibooker.book1D("chi2oNdof", ";Vertex chi-squared/Ndof;#entries", 40, 0., 20.);
119  hptv2 = ibooker.book1D("ptsq", ";Vertex #sum (p_{T})^{2};#entries", 200, 0., 200.);
120  hntrks = ibooker.book1D("ntrk", ";#tracks associated;#entries", 100, -0.5, 99.5);
121 }
122 
124  // monitorpixelVertexSoA
126  desc.add<edm::InputTag>("pixelVertexSrc", edm::InputTag("pixelVerticesSoA"));
127  desc.add<edm::InputTag>("beamSpotSrc", edm::InputTag("offlineBeamSpot"));
128  desc.add<std::string>("topFolderName", "SiPixelHeterogeneous/PixelVertexSoA");
129  descriptions.addWithDefaultLabel(desc);
130 }
131 
float dydz
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
int32_t *__restrict__ iv
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::vector< uint16_t > IndToEdm
float dxdz
SiPixelMonitorVertexSoA(const edm::ParameterSet &)
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::BeamSpot > tokenBeamSpot_
edm::EDGetTokenT< ZVertexSoAHost > tokenSoAVertex_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~SiPixelMonitorVertexSoA() override=default
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) override
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
Definition: Run.h:45
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)