Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.1.X] Miscellaneous PrimaryVertexMonitor updates #46109

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DQMOffline/RecoB/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<use name="FWCore/Utilities"/>
<use name="JetMETCorrections/JetCorrector"/>
<use name="SimDataFormats/GeneratorProducts"/>
<library file="BTagPerformanceAnalyzerOnData.cc PrimaryVertexMonitor.cc BTagPerformanceHarvester.cc MiniAODTaggerAnalyzer.cc MiniAODTaggerHarvester.cc MiniAODSVAnalyzer.cc" name="DQMOfflineRecoBPlugins">
<library file="*.cc" name="DQMOfflineRecoBPlugins">
<flags EDM_PLUGIN="1"/>
</library>

134 changes: 95 additions & 39 deletions DQMOffline/RecoB/plugins/PrimaryVertexMonitor.cc
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
// user includes
#include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
#include "DQMOffline/RecoB/plugins/PrimaryVertexMonitor.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/isFinite.h"

#include "CommonTools/Statistics/interface/ChiSquaredProbability.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/isFinite.h"

// ROOT includes
#include "TMath.h"

// system includes
#include <fmt/format.h>

using namespace reco;
using namespace edm;

PrimaryVertexMonitor::PrimaryVertexMonitor(const edm::ParameterSet& pSet)
: conf_(pSet),
: vertexInputTag_(pSet.getParameter<InputTag>("vertexLabel")),
beamSpotInputTag_(pSet.getParameter<InputTag>("beamSpotLabel")),
vertexToken_(consumes<reco::VertexCollection>(vertexInputTag_)),
scoreToken_(consumes<VertexScore>(vertexInputTag_)),
beamspotToken_(consumes<reco::BeamSpot>(beamSpotInputTag_)),
conf_(pSet),
TopFolderName_(pSet.getParameter<std::string>("TopFolderName")),
AlignmentLabel_(pSet.getParameter<std::string>("AlignmentLabel")),
ndof_(pSet.getParameter<int>("ndof")),
Expand All @@ -40,13 +46,7 @@ PrimaryVertexMonitor::PrimaryVertexMonitor(const edm::ParameterSet& pSet)
eta_pt1(nullptr),
phi_pt10(nullptr),
eta_pt10(nullptr),
dxy2(nullptr) {
vertexInputTag_ = pSet.getParameter<InputTag>("vertexLabel");
beamSpotInputTag_ = pSet.getParameter<InputTag>("beamSpotLabel");
vertexToken_ = consumes<reco::VertexCollection>(vertexInputTag_);
scoreToken_ = consumes<VertexScore>(vertexInputTag_);
beamspotToken_ = consumes<reco::BeamSpot>(beamSpotInputTag_);
}
dxy2(nullptr) {}

// -- BeginRun
//---------------------------------------------------------------------------------//
Expand Down Expand Up @@ -216,15 +216,17 @@ void PrimaryVertexMonitor::IPMonitoring::bookIPMonitor(DQMStore::IBooker& iBooke
double VarMin = config.getParameter<double>(fmt::format("D{}Min", varname_));
double VarMax = config.getParameter<double>(fmt::format("D{}Max", varname_));

int PhiBin = config.getParameter<int>("PhiBin");
PhiBin_ = config.getParameter<int>("PhiBin");
PhiMin_ = config.getParameter<double>("PhiMin");
PhiMax_ = config.getParameter<double>("PhiMax");
int PhiBin2D = config.getParameter<int>("PhiBin2D");
double PhiMin = config.getParameter<double>("PhiMin");
double PhiMax = config.getParameter<double>("PhiMax");

int EtaBin = config.getParameter<int>("EtaBin");
EtaBin_ = config.getParameter<int>("EtaBin");
EtaMin_ = config.getParameter<double>("EtaMin");
EtaMax_ = config.getParameter<double>("EtaMax");
int EtaBin2D = config.getParameter<int>("EtaBin2D");
double EtaMin = config.getParameter<double>("EtaMin");
double EtaMax = config.getParameter<double>("EtaMax");

// 1D variables

IP_ = iBooker.book1D(fmt::format("d{}_pt{}", varname_, pTcut_),
fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} (#mum)", pTcut_, varname_),
Expand All @@ -238,11 +240,20 @@ void PrimaryVertexMonitor::IPMonitoring::bookIPMonitor(DQMStore::IBooker& iBooke
0.,
(varname_.find("xy") != std::string::npos) ? 2000. : 10000.);

IPPull_ = iBooker.book1D(
fmt::format("d{}Pull_pt{}", varname_, pTcut_),
fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}}/#sigma_{{d_{{{}}}}}", pTcut_, varname_, varname_),
100,
-5.,
5.);

// profiles

IPVsPhi_ = iBooker.bookProfile(fmt::format("d{}VsPhi_pt{}", varname_, pTcut_),
fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} VS track #phi", pTcut_, varname_),
PhiBin,
PhiMin,
PhiMax,
PhiBin_,
PhiMin_,
PhiMax_,
VarBin,
VarMin,
VarMax,
Expand All @@ -252,9 +263,9 @@ void PrimaryVertexMonitor::IPMonitoring::bookIPMonitor(DQMStore::IBooker& iBooke

IPVsEta_ = iBooker.bookProfile(fmt::format("d{}VsEta_pt{}", varname_, pTcut_),
fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} VS track #eta", pTcut_, varname_),
EtaBin,
EtaMin,
EtaMax,
EtaBin_,
EtaMin_,
EtaMax_,
VarBin,
VarMin,
VarMax,
Expand All @@ -265,9 +276,9 @@ void PrimaryVertexMonitor::IPMonitoring::bookIPMonitor(DQMStore::IBooker& iBooke
IPErrVsPhi_ =
iBooker.bookProfile(fmt::format("d{}ErrVsPhi_pt{}", varname_, pTcut_),
fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} error VS track #phi", pTcut_, varname_),
PhiBin,
PhiMin,
PhiMax,
PhiBin_,
PhiMin_,
PhiMax_,
VarBin,
0.,
(varname_.find("xy") != std::string::npos) ? 100. : 200.,
Expand All @@ -278,25 +289,27 @@ void PrimaryVertexMonitor::IPMonitoring::bookIPMonitor(DQMStore::IBooker& iBooke
IPErrVsEta_ =
iBooker.bookProfile(fmt::format("d{}ErrVsEta_pt{}", varname_, pTcut_),
fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} error VS track #eta", pTcut_, varname_),
EtaBin,
EtaMin,
EtaMax,
EtaBin_,
EtaMin_,
EtaMax_,
VarBin,
0.,
(varname_.find("xy") != std::string::npos) ? 100. : 200.,
"");
IPErrVsEta_->setAxisTitle("PV track (p_{T} > 1 GeV) #eta", 1);
IPErrVsEta_->setAxisTitle(fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} error (#mum)", pTcut_, varname_), 2);

// 2D profiles

IPVsEtaVsPhi_ = iBooker.bookProfile2D(
fmt::format("d{}VsEtaVsPhi_pt{}", varname_, pTcut_),
fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} VS track #eta VS track #phi", pTcut_, varname_),
EtaBin2D,
EtaMin,
EtaMax,
EtaMin_,
EtaMax_,
PhiBin2D,
PhiMin,
PhiMax,
PhiMin_,
PhiMax_,
VarBin,
VarMin,
VarMax,
Expand All @@ -309,11 +322,11 @@ void PrimaryVertexMonitor::IPMonitoring::bookIPMonitor(DQMStore::IBooker& iBooke
fmt::format("d{}ErrVsEtaVsPhi_pt{}", varname_, pTcut_),
fmt::format("PV tracks (p_{{T}} > {}) d_{{{}}} error VS track #eta VS track #phi", pTcut_, varname_),
EtaBin2D,
EtaMin,
EtaMax,
EtaMin_,
EtaMax_,
PhiBin2D,
PhiMin,
PhiMax,
PhiMin_,
PhiMax_,
VarBin,
0.,
(varname_.find("xy") != std::string::npos) ? 100. : 200.,
Expand Down Expand Up @@ -452,22 +465,28 @@ void PrimaryVertexMonitor::pvTracksPlots(const Vertex& v) {
chi2prob->Fill(chi2Prob);
dxy2->Fill(Dxy);

// dxy pT>1

dxy_pt1.IP_->Fill(Dxy);
dxy_pt1.IPVsPhi_->Fill(phi, Dxy);
dxy_pt1.IPVsEta_->Fill(eta, Dxy);
dxy_pt1.IPVsEtaVsPhi_->Fill(eta, phi, Dxy);

dxy_pt1.IPErr_->Fill(DxyErr);
dxy_pt1.IPPull_->Fill(Dxy / DxyErr);
dxy_pt1.IPErrVsPhi_->Fill(phi, DxyErr);
dxy_pt1.IPErrVsEta_->Fill(eta, DxyErr);
dxy_pt1.IPErrVsEtaVsPhi_->Fill(eta, phi, DxyErr);

// dz pT>1

dz_pt1.IP_->Fill(Dz);
dz_pt1.IPVsPhi_->Fill(phi, Dz);
dz_pt1.IPVsEta_->Fill(eta, Dz);
dz_pt1.IPVsEtaVsPhi_->Fill(eta, phi, Dz);

dz_pt1.IPErr_->Fill(DzErr);
dz_pt1.IPPull_->Fill(Dz / DzErr);
dz_pt1.IPErrVsPhi_->Fill(phi, DzErr);
dz_pt1.IPErrVsEta_->Fill(eta, DzErr);
dz_pt1.IPErrVsEtaVsPhi_->Fill(eta, phi, DzErr);
Expand All @@ -478,22 +497,28 @@ void PrimaryVertexMonitor::pvTracksPlots(const Vertex& v) {
phi_pt10->Fill(phi);
eta_pt10->Fill(eta);

// dxy pT>10

dxy_pt10.IP_->Fill(Dxy);
dxy_pt10.IPVsPhi_->Fill(phi, Dxy);
dxy_pt10.IPVsEta_->Fill(eta, Dxy);
dxy_pt10.IPVsEtaVsPhi_->Fill(eta, phi, Dxy);

dxy_pt10.IPErr_->Fill(DxyErr);
dxy_pt10.IPPull_->Fill(Dxy / DxyErr);
dxy_pt10.IPErrVsPhi_->Fill(phi, DxyErr);
dxy_pt10.IPErrVsEta_->Fill(eta, DxyErr);
dxy_pt10.IPErrVsEtaVsPhi_->Fill(eta, phi, DxyErr);

// dxz pT>10

dz_pt10.IP_->Fill(Dz);
dz_pt10.IPVsPhi_->Fill(phi, Dz);
dz_pt10.IPVsEta_->Fill(eta, Dz);
dz_pt10.IPVsEtaVsPhi_->Fill(eta, phi, Dz);

dz_pt10.IPErr_->Fill(DzErr);
dz_pt10.IPPull_->Fill(Dz / DzErr);
dz_pt10.IPErrVsPhi_->Fill(phi, DzErr);
dz_pt10.IPErrVsEta_->Fill(eta, DzErr);
dz_pt10.IPErrVsEtaVsPhi_->Fill(eta, phi, DzErr);
Expand Down Expand Up @@ -558,5 +583,36 @@ void PrimaryVertexMonitor::vertexPlots(const Vertex& v, const BeamSpot& beamSpot
}
}

void PrimaryVertexMonitor::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("TopFolderName", "OfflinePV");
desc.add<std::string>("AlignmentLabel", "Alignment");
desc.add<int>("ndof", 4);
desc.add<bool>("useHPforAlignmentPlots", true);
desc.add<InputTag>("vertexLabel", edm::InputTag("offlinePrimaryVertices"));
desc.add<InputTag>("beamSpotLabel", edm::InputTag("offlineBeamSpot"));
desc.add<double>("PUMax", 80.0);
desc.add<double>("Xpos", 0.1);
desc.add<double>("Ypos", 0.0);
desc.add<int>("TkSizeBin", 100);
desc.add<double>("TkSizeMin", -0.5);
desc.add<double>("TkSizeMax", 499.5);
desc.add<int>("DxyBin", 100);
desc.add<double>("DxyMin", -5000.0);
desc.add<double>("DxyMax", 5000.0);
desc.add<int>("DzBin", 100);
desc.add<double>("DzMin", -2000.0);
desc.add<double>("DzMax", 2000.0);
desc.add<int>("PhiBin", 32);
desc.add<double>("PhiMin", -M_PI);
desc.add<double>("PhiMax", M_PI);
desc.add<int>("EtaBin", 26);
desc.add<double>("EtaMin", 2.5);
desc.add<double>("EtaMax", -2.5);
desc.add<int>("PhiBin2D", 12);
desc.add<int>("EtaBin2D", 8);
descriptions.addWithDefaultLabel(desc);
}

//define this as a plug-in
DEFINE_FWK_MODULE(PrimaryVertexMonitor);
60 changes: 32 additions & 28 deletions DQMOffline/RecoB/plugins/PrimaryVertexMonitor.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
#ifndef PrimaryVertexMonitor_H
#define PrimaryVertexMonitor_H

#include "FWCore/Utilities/interface/EDGetToken.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/Common/interface/Association.h"
#ifndef DQMOffline_RecoB_PrimaryVertexMonitor_H
#define DQMOffline_RecoB_PrimaryVertexMonitor_H

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/Common/interface/Association.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"

/** \class PrimaryVertexMonitor
*
Expand All @@ -26,42 +23,49 @@
class PrimaryVertexMonitor : public DQMEDAnalyzer {
public:
explicit PrimaryVertexMonitor(const edm::ParameterSet &pSet);

~PrimaryVertexMonitor() override = default;

static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
void analyze(const edm::Event &, const edm::EventSetup &) override;

struct IPMonitoring {
std::string varname_;
float pTcut_;
dqm::reco::MonitorElement *IP_, *IPErr_;
dqm::reco::MonitorElement *IP_, *IPErr_, *IPPull_;
dqm::reco::MonitorElement *IPVsPhi_, *IPVsEta_;
dqm::reco::MonitorElement *IPErrVsPhi_, *IPErrVsEta_;
dqm::reco::MonitorElement *IPVsEtaVsPhi_, *IPErrVsEtaVsPhi_;

void bookIPMonitor(DQMStore::IBooker &, const edm::ParameterSet &);

private:
int PhiBin_, EtaBin_;
double PhiMin_, PhiMax_, EtaMin_, EtaMax_;
};

private:
void pvTracksPlots(const reco::Vertex &v);
void vertexPlots(const reco::Vertex &v, const reco::BeamSpot &beamSpot, int i);

edm::EDGetTokenT<reco::VertexCollection> vertexToken_;
edm::EDGetTokenT<reco::BeamSpot> beamspotToken_;
using VertexScore = edm::ValueMap<float>;
edm::EDGetTokenT<VertexScore> scoreToken_;

edm::InputTag vertexInputTag_, beamSpotInputTag_;
// event data

edm::ParameterSet conf_;
const edm::InputTag vertexInputTag_;
const edm::InputTag beamSpotInputTag_;
const edm::EDGetTokenT<reco::VertexCollection> vertexToken_;
using VertexScore = edm::ValueMap<float>;
const edm::EDGetTokenT<VertexScore> scoreToken_;
const edm::EDGetTokenT<reco::BeamSpot> beamspotToken_;

std::string dqmLabel;
// configuration

std::string TopFolderName_;
std::string AlignmentLabel_;
int ndof_;
bool useHPfoAlignmentPlots_;
const edm::ParameterSet conf_;
const std::string dqmLabel;
const std::string TopFolderName_;
const std::string AlignmentLabel_;
const int ndof_;
const bool useHPfoAlignmentPlots_;
bool errorPrinted_;

static constexpr int cmToUm = 10000;
Expand Down