diff --git a/DQMOffline/RecoB/plugins/BuildFile.xml b/DQMOffline/RecoB/plugins/BuildFile.xml index 96c7675095bda..525978a757b7b 100644 --- a/DQMOffline/RecoB/plugins/BuildFile.xml +++ b/DQMOffline/RecoB/plugins/BuildFile.xml @@ -14,7 +14,7 @@ - + diff --git a/DQMOffline/RecoB/plugins/PrimaryVertexMonitor.cc b/DQMOffline/RecoB/plugins/PrimaryVertexMonitor.cc index ab75f579409d5..aef80a57a6676 100644 --- a/DQMOffline/RecoB/plugins/PrimaryVertexMonitor.cc +++ b/DQMOffline/RecoB/plugins/PrimaryVertexMonitor.cc @@ -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 using namespace reco; using namespace edm; PrimaryVertexMonitor::PrimaryVertexMonitor(const edm::ParameterSet& pSet) - : conf_(pSet), + : vertexInputTag_(pSet.getParameter("vertexLabel")), + beamSpotInputTag_(pSet.getParameter("beamSpotLabel")), + vertexToken_(consumes(vertexInputTag_)), + scoreToken_(consumes(vertexInputTag_)), + beamspotToken_(consumes(beamSpotInputTag_)), + conf_(pSet), TopFolderName_(pSet.getParameter("TopFolderName")), AlignmentLabel_(pSet.getParameter("AlignmentLabel")), ndof_(pSet.getParameter("ndof")), @@ -40,13 +46,7 @@ PrimaryVertexMonitor::PrimaryVertexMonitor(const edm::ParameterSet& pSet) eta_pt1(nullptr), phi_pt10(nullptr), eta_pt10(nullptr), - dxy2(nullptr) { - vertexInputTag_ = pSet.getParameter("vertexLabel"); - beamSpotInputTag_ = pSet.getParameter("beamSpotLabel"); - vertexToken_ = consumes(vertexInputTag_); - scoreToken_ = consumes(vertexInputTag_); - beamspotToken_ = consumes(beamSpotInputTag_); -} + dxy2(nullptr) {} // -- BeginRun //---------------------------------------------------------------------------------// @@ -216,15 +216,17 @@ void PrimaryVertexMonitor::IPMonitoring::bookIPMonitor(DQMStore::IBooker& iBooke double VarMin = config.getParameter(fmt::format("D{}Min", varname_)); double VarMax = config.getParameter(fmt::format("D{}Max", varname_)); - int PhiBin = config.getParameter("PhiBin"); + PhiBin_ = config.getParameter("PhiBin"); + PhiMin_ = config.getParameter("PhiMin"); + PhiMax_ = config.getParameter("PhiMax"); int PhiBin2D = config.getParameter("PhiBin2D"); - double PhiMin = config.getParameter("PhiMin"); - double PhiMax = config.getParameter("PhiMax"); - int EtaBin = config.getParameter("EtaBin"); + EtaBin_ = config.getParameter("EtaBin"); + EtaMin_ = config.getParameter("EtaMin"); + EtaMax_ = config.getParameter("EtaMax"); int EtaBin2D = config.getParameter("EtaBin2D"); - double EtaMin = config.getParameter("EtaMin"); - double EtaMax = config.getParameter("EtaMax"); + + // 1D variables IP_ = iBooker.book1D(fmt::format("d{}_pt{}", varname_, pTcut_), fmt::format("PV tracks (p_{{T}} > {} GeV) d_{{{}}} (#mum)", pTcut_, varname_), @@ -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, @@ -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, @@ -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., @@ -278,9 +289,9 @@ 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., @@ -288,15 +299,17 @@ void PrimaryVertexMonitor::IPMonitoring::bookIPMonitor(DQMStore::IBooker& iBooke 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, @@ -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., @@ -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); @@ -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); @@ -558,5 +583,36 @@ void PrimaryVertexMonitor::vertexPlots(const Vertex& v, const BeamSpot& beamSpot } } +void PrimaryVertexMonitor::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.add("TopFolderName", "OfflinePV"); + desc.add("AlignmentLabel", "Alignment"); + desc.add("ndof", 4); + desc.add("useHPforAlignmentPlots", true); + desc.add("vertexLabel", edm::InputTag("offlinePrimaryVertices")); + desc.add("beamSpotLabel", edm::InputTag("offlineBeamSpot")); + desc.add("PUMax", 80.0); + desc.add("Xpos", 0.1); + desc.add("Ypos", 0.0); + desc.add("TkSizeBin", 100); + desc.add("TkSizeMin", -0.5); + desc.add("TkSizeMax", 499.5); + desc.add("DxyBin", 100); + desc.add("DxyMin", -5000.0); + desc.add("DxyMax", 5000.0); + desc.add("DzBin", 100); + desc.add("DzMin", -2000.0); + desc.add("DzMax", 2000.0); + desc.add("PhiBin", 32); + desc.add("PhiMin", -M_PI); + desc.add("PhiMax", M_PI); + desc.add("EtaBin", 26); + desc.add("EtaMin", 2.5); + desc.add("EtaMax", -2.5); + desc.add("PhiBin2D", 12); + desc.add("EtaBin2D", 8); + descriptions.addWithDefaultLabel(desc); +} + //define this as a plug-in DEFINE_FWK_MODULE(PrimaryVertexMonitor); diff --git a/DQMOffline/RecoB/plugins/PrimaryVertexMonitor.h b/DQMOffline/RecoB/plugins/PrimaryVertexMonitor.h index 395b4485d92fe..9000adfb14025 100644 --- a/DQMOffline/RecoB/plugins/PrimaryVertexMonitor.h +++ b/DQMOffline/RecoB/plugins/PrimaryVertexMonitor.h @@ -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 * @@ -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 vertexToken_; - edm::EDGetTokenT beamspotToken_; - using VertexScore = edm::ValueMap; - edm::EDGetTokenT scoreToken_; - - edm::InputTag vertexInputTag_, beamSpotInputTag_; + // event data - edm::ParameterSet conf_; + const edm::InputTag vertexInputTag_; + const edm::InputTag beamSpotInputTag_; + const edm::EDGetTokenT vertexToken_; + using VertexScore = edm::ValueMap; + const edm::EDGetTokenT scoreToken_; + const edm::EDGetTokenT 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;