Skip to content

Commit

Permalink
Merge pull request #38642 from mmusich/updatePrimaryVertexMonitorForR…
Browse files Browse the repository at this point in the history
…un3_12_4_X

[12.4.X] update `PrimaryVertexMonitor` for Run-3 data-taking
  • Loading branch information
cmsbuild committed Jul 8, 2022
2 parents 90d3c09 + a87fb79 commit 4c2ef01
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
47 changes: 29 additions & 18 deletions DQMOffline/RecoB/plugins/PrimaryVertexMonitor.cc
Expand Up @@ -39,6 +39,10 @@ PrimaryVertexMonitor::PrimaryVertexMonitor(const edm::ParameterSet& pSet)
dz(nullptr),
dxyErr(nullptr),
dzErr(nullptr),
phi_pt1(nullptr),
eta_pt1(nullptr),
phi_pt10(nullptr),
eta_pt10(nullptr),
dxyVsPhi_pt1(nullptr),
dzVsPhi_pt1(nullptr),
dxyVsEta_pt1(nullptr),
Expand All @@ -51,8 +55,6 @@ PrimaryVertexMonitor::PrimaryVertexMonitor(const edm::ParameterSet& pSet)
dzVsEta_pt10(nullptr),
dxyVsEtaVsPhi_pt10(nullptr),
dzVsEtaVsPhi_pt10(nullptr) {
// dqmStore_ = edm::Service<DQMStore>().operator->();

vertexInputTag_ = pSet.getParameter<InputTag>("vertexLabel");
beamSpotInputTag_ = pSet.getParameter<InputTag>("beamSpotLabel");
vertexToken_ = consumes<reco::VertexCollection>(vertexInputTag_);
Expand Down Expand Up @@ -208,6 +210,13 @@ void PrimaryVertexMonitor::bookHistograms(DQMStore::IBooker& iBooker, edm::Run c
dz = iBooker.book1D("dz", "PV tracks (p_{T} > 1 GeV) d_{z} (#mum)", DzBin, DzMin, DzMax);
dzErr = iBooker.book1D("dzErr", "PV tracks (p_{T} > 1 GeV) d_{z} error(#mum)", 100, 0., 10000.);

phi_pt1 = iBooker.book1D("phi_pt1", "PV tracks (p_{T} > 1 GeV) #phi; PV tracks #phi;#tracks", PhiBin, PhiMin, PhiMax);
eta_pt1 = iBooker.book1D("eta_pt1", "PV tracks (p_{T} > 1 GeV) #eta; PV tracks #eta;#tracks", EtaBin, EtaMin, EtaMax);
phi_pt10 =
iBooker.book1D("phi_pt10", "PV tracks (p_{T} > 10 GeV) #phi; PV tracks #phi;#tracks", PhiBin, PhiMin, PhiMax);
eta_pt10 =
iBooker.book1D("eta_pt10", "PV tracks (p_{T} > 10 GeV) #phi; PV tracks #eta;#tracks", EtaBin, EtaMin, EtaMax);

dxyVsPhi_pt1 = iBooker.bookProfile("dxyVsPhi_pt1",
"PV tracks (p_{T} > 1 GeV) d_{xy} (#mum) VS track #phi",
PhiBin,
Expand Down Expand Up @@ -369,8 +378,6 @@ void PrimaryVertexMonitor::bookHistograms(DQMStore::IBooker& iBooker, edm::Run c
dzVsEtaVsPhi_pt10->setAxisTitle("PV track (p_{T} > 10 GeV) d_{z} (#mum)", 3);
}

PrimaryVertexMonitor::~PrimaryVertexMonitor() {}

void PrimaryVertexMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
Handle<reco::VertexCollection> recVtxs;
iEvent.getByToken(vertexToken_, recVtxs);
Expand Down Expand Up @@ -445,8 +452,8 @@ void PrimaryVertexMonitor::analyze(const edm::Event& iEvent, const edm::EventSet
bsSigmaZ->Fill(beamSpot.sigmaZ());
bsDxdz->Fill(beamSpot.dxdz());
bsDydz->Fill(beamSpot.dydz());
bsBeamWidthX->Fill(beamSpot.BeamWidthX() * 10000);
bsBeamWidthY->Fill(beamSpot.BeamWidthY() * 10000);
bsBeamWidthX->Fill(beamSpot.BeamWidthX() * cmToUm);
bsBeamWidthY->Fill(beamSpot.BeamWidthY() * cmToUm);
// bsType->Fill(beamSpot.type());
}

Expand All @@ -465,7 +472,6 @@ void PrimaryVertexMonitor::pvTracksPlots(const Vertex& v) {

size_t nTracks = 0;
float sumPT = 0.;
const int cmToUm = 10000;

for (reco::Vertex::trackRef_iterator t = v.tracks_begin(); t != v.tracks_end(); t++) {
bool isHighPurity = (**t).quality(reco::TrackBase::highPurity);
Expand All @@ -484,8 +490,8 @@ void PrimaryVertexMonitor::pvTracksPlots(const Vertex& v) {
float w = v.trackWeight(*t);
float chi2NDF = (**t).normalizedChi2();
float chi2Prob = TMath::Prob((**t).chi2(), (int)(**t).ndof());
float Dxy = (**t).dxy(myVertex) * cmToUm; // is it needed ?
float Dz = (**t).dz(myVertex) * cmToUm; // is it needed ?
float Dxy = (**t).dxy(myVertex) * cmToUm;
float Dz = (**t).dz(myVertex) * cmToUm;
float DxyErr = (**t).dxyError() * cmToUm;
float DzErr = (**t).dzError() * cmToUm;

Expand All @@ -500,6 +506,8 @@ void PrimaryVertexMonitor::pvTracksPlots(const Vertex& v) {
dz->Fill(Dz);
dxyErr->Fill(DxyErr);
dzErr->Fill(DzErr);
phi_pt1->Fill(phi);
eta_pt1->Fill(eta);

dxyVsPhi_pt1->Fill(phi, Dxy);
dzVsPhi_pt1->Fill(phi, Dz);
Expand All @@ -510,6 +518,9 @@ void PrimaryVertexMonitor::pvTracksPlots(const Vertex& v) {

if (pt < 10.)
continue;

phi_pt10->Fill(phi);
eta_pt10->Fill(eta);
dxyVsPhi_pt10->Fill(phi, Dxy);
dzVsPhi_pt10->Fill(phi, Dz);
dxyVsEta_pt10->Fill(eta, Dxy);
Expand Down Expand Up @@ -549,15 +560,15 @@ void PrimaryVertexMonitor::vertexPlots(const Vertex& v, const BeamSpot& beamSpot

float xb = beamSpot.x0() + beamSpot.dxdz() * (v.position().z() - beamSpot.z0());
float yb = beamSpot.y0() + beamSpot.dydz() * (v.position().z() - beamSpot.z0());
xDiff[i]->Fill((v.position().x() - xb) * 10000);
yDiff[i]->Fill((v.position().y() - yb) * 10000);

xerr[i]->Fill(v.xError() * 10000);
yerr[i]->Fill(v.yError() * 10000);
zerr[i]->Fill(v.zError() * 10000);
xerrVsTrks[i]->Fill(weight, v.xError() * 10000);
yerrVsTrks[i]->Fill(weight, v.yError() * 10000);
zerrVsTrks[i]->Fill(weight, v.zError() * 10000);
xDiff[i]->Fill((v.position().x() - xb) * cmToUm);
yDiff[i]->Fill((v.position().y() - yb) * cmToUm);

xerr[i]->Fill(v.xError() * cmToUm);
yerr[i]->Fill(v.yError() * cmToUm);
zerr[i]->Fill(v.zError() * cmToUm);
xerrVsTrks[i]->Fill(weight, v.xError() * cmToUm);
yerrVsTrks[i]->Fill(weight, v.yError() * cmToUm);
zerrVsTrks[i]->Fill(weight, v.zError() * cmToUm);

nans[i]->Fill(1., edm::isNotFinite(v.position().x()) * 1.);
nans[i]->Fill(2., edm::isNotFinite(v.position().y()) * 1.);
Expand Down
6 changes: 5 additions & 1 deletion DQMOffline/RecoB/plugins/PrimaryVertexMonitor.h
Expand Up @@ -27,7 +27,7 @@ class PrimaryVertexMonitor : public DQMEDAnalyzer {
public:
explicit PrimaryVertexMonitor(const edm::ParameterSet &pSet);

~PrimaryVertexMonitor() override;
~PrimaryVertexMonitor() override = default;

void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
void analyze(const edm::Event &, const edm::EventSetup &) override;
Expand All @@ -53,6 +53,8 @@ class PrimaryVertexMonitor : public DQMEDAnalyzer {
bool useHPfoAlignmentPlots_;
bool errorPrinted_;

static constexpr int cmToUm = 10000;

// the histos
MonitorElement *nbvtx, *nbgvtx, *nbtksinvtx[2], *trksWeight[2], *score[2];
MonitorElement *tt[2];
Expand All @@ -65,6 +67,8 @@ class PrimaryVertexMonitor : public DQMEDAnalyzer {

MonitorElement *sumpt, *ntracks, *weight, *chi2ndf, *chi2prob;
MonitorElement *dxy, *dxy2, *dz, *dxyErr, *dzErr;
MonitorElement *phi_pt1, *eta_pt1;
MonitorElement *phi_pt10, *eta_pt10;
MonitorElement *dxyVsPhi_pt1, *dzVsPhi_pt1;
MonitorElement *dxyVsEta_pt1, *dzVsEta_pt1;
MonitorElement *dxyVsEtaVsPhi_pt1, *dzVsEtaVsPhi_pt1;
Expand Down
5 changes: 3 additions & 2 deletions DQMOffline/RecoB/python/PrimaryVertexMonitor_cff.py
@@ -1,6 +1,5 @@
import FWCore.ParameterSet.Config as cms


from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
pvMonitor = DQMEDAnalyzer('PrimaryVertexMonitor',
TopFolderName = cms.string("OfflinePV"),
Expand Down Expand Up @@ -32,7 +31,9 @@

# same as above, should be in sync with cut used in Vertex finder...
from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel
from Configuration.Eras.Modifier_run3_common_cff import run3_common
from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
phase1Pixel.toModify(pvMonitor, EtaBin=31, EtaMin=-3.0, EtaMax=3.0)
phase1Pixel.toModify(pvMonitor, EtaBin=28, EtaMin=-2.7, EtaMax=2.7)
run3_common.toModify(pvMonitor, Xpos = 0.15, Ypos=-0.15) #recentering since initial Run3 beamspot is at (0.17,-0.18) cm
phase2_tracker.toModify(pvMonitor, EtaBin=41, EtaBin2D=9, EtaMin=-4.0, EtaMax=4.0)

0 comments on commit 4c2ef01

Please sign in to comment.