Skip to content

Commit

Permalink
Merge pull request #42459 from mmusich/addUnbalanceForZPointingAngle
Browse files Browse the repository at this point in the history
Tracker Alignment monitoring: add unbalance histograms for pointing angle in Z events
  • Loading branch information
cmsbuild authored Aug 6, 2023
2 parents 4a44c58 + 015d956 commit 4a98a53
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 6 deletions.
23 changes: 23 additions & 0 deletions DQMOffline/Alignment/interface/DiMuonVertexMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <string>

// user includes
#include "DQMOffline/Alignment/interface/DiLeptonPlotHelpers.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "FWCore/Framework/interface/Event.h"
Expand Down Expand Up @@ -76,9 +77,31 @@ class DiMuonVertexMonitor : public DQMEDAnalyzer {
MonitorElement *hCosPhi3D_;
MonitorElement *hCosPhiInv_;
MonitorElement *hCosPhiInv3D_;
MonitorElement *hCosPhiUnbalance_;
MonitorElement *hCosPhi3DUnbalance_;
MonitorElement *hInvMass_;
MonitorElement *hCutFlow_;

// 2D histograms of pointing angle vs variable
edm::ParameterSet CosPhi3DConfiguration_;
DiLepPlotHelp::PlotsVsKinematics CosPhi3DPlots_ = DiLepPlotHelp::PlotsVsKinematics(DiLepPlotHelp::MM);

// 2D histograms of 3D PV-SV distance vs variable
edm::ParameterSet SVDistConfiguration_;
DiLepPlotHelp::PlotsVsKinematics SVDistPlots_ = DiLepPlotHelp::PlotsVsKinematics(DiLepPlotHelp::MM);

// 2D histograms of 3D PV-SV distance significance vs variable
edm::ParameterSet SVDistSigConfiguration_;
DiLepPlotHelp::PlotsVsKinematics SVDistSigPlots_ = DiLepPlotHelp::PlotsVsKinematics(DiLepPlotHelp::MM);

// 2D histograms of PV-SV transverse distance vs variable
edm::ParameterSet SVDist3DConfiguration_;
DiLepPlotHelp::PlotsVsKinematics SVDist3DPlots_ = DiLepPlotHelp::PlotsVsKinematics(DiLepPlotHelp::MM);

// 2D histograms of PV-SV transverse distance significance vs variable
edm::ParameterSet SVDist3DSigConfiguration_;
DiLepPlotHelp::PlotsVsKinematics SVDist3DSigPlots_ = DiLepPlotHelp::PlotsVsKinematics(DiLepPlotHelp::MM);

// impact parameters information
MonitorElement *hdxy_;
MonitorElement *hdz_;
Expand Down
14 changes: 12 additions & 2 deletions DQMOffline/Alignment/python/ALCARECOTkAlDQM_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@
decayMotherName = "J/#psi",
vertices = 'offlinePrimaryVertices',
FolderName = "AlCaReco/"+__selectionName,
maxSVdist = 50
maxSVdist = 50,
CosPhi3DConfig = dict(maxDeltaEta = 1.3),
SVDistConfig = dict(maxDeltaEta = 1.3),
SVDistSigConfig = dict(maxDeltaEta = 1.3),
SVDist3DConfig = dict(maxDeltaEta = 1.3),
SVDist3DSigConfig = dict(maxDeltaEta = 1.3)
)

ALCARECOTkAlJpsiMassBiasDQM = DQMOffline.Alignment.DiMuonMassBiasMonitor_cfi.DiMuonMassBiasMonitor.clone(
Expand Down Expand Up @@ -234,7 +239,12 @@
decayMotherName = "#Upsilon",
vertices = 'offlinePrimaryVertices',
FolderName = "AlCaReco/"+__selectionName,
maxSVdist = 50
maxSVdist = 50,
CosPhi3DConfig = dict(maxDeltaEta = 1.6),
SVDistConfig = dict(maxDeltaEta = 1.6),
SVDistSigConfig = dict(maxDeltaEta = 1.6),
SVDist3DConfig = dict(maxDeltaEta = 1.6),
SVDist3DSigConfig = dict(maxDeltaEta = 1.6)
)

ALCARECOTkAlUpsilonMassBiasDQM = DQMOffline.Alignment.DiMuonMassBiasMonitor_cfi.DiMuonMassBiasMonitor.clone(
Expand Down
52 changes: 51 additions & 1 deletion DQMOffline/Alignment/python/DiMuonVertexMonitor_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,54 @@
decayMotherName = cms.string('Z'),
vertices = cms.InputTag('offlinePrimaryVertices'),
FolderName = cms.string('DiMuonVertexMonitor'),
maxSVdist = cms.double(50))
maxSVdist = cms.double(50),
CosPhi3DConfig = cms.PSet(
name = cms.string('CosPhi3D'),
title = cms.string('cos(#phi_{3D})'),
yUnits = cms.string(''),
NxBins = cms.int32(24),
NyBins = cms.int32(50),
ymin = cms.double(-1),
ymax = cms.double(1),
maxDeltaEta = cms.double(3.7)
),
SVDistConfig = cms.PSet(
name = cms.string('SVDist'),
title = cms.string('PV-SV distance'),
yUnits = cms.string('[#mum]'),
NxBins = cms.int32(24),
NyBins = cms.int32(100),
ymin = cms.double(0),
ymax = cms.double(300),
maxDeltaEta = cms.double(3.7)
),
SVDistSigConfig = cms.PSet(
name = cms.string('SVDistSig'),
title = cms.string('PV-SV distance significance'),
yUnits = cms.string('[#mum]'),
NxBins = cms.int32(24),
NyBins = cms.int32(100),
ymin = cms.double(0),
ymax = cms.double(5),
maxDeltaEta = cms.double(3.7)
),
SVDist3DConfig = cms.PSet(
name = cms.string('SVDist3D'),
title = cms.string('PV-SV 3D distance'),
yUnits = cms.string('[#mum]'),
NxBins = cms.int32(24),
NyBins = cms.int32(100),
ymin = cms.double(0),
ymax = cms.double(300),
maxDeltaEta = cms.double(3.7)
),
SVDist3DSigConfig = cms.PSet(
name = cms.string('SVDist3DSig'),
title = cms.string('PV-SV 3D distance significance'),
yUnits = cms.string('[#mum]'),
NxBins = cms.int32(24),
NyBins = cms.int32(100),
ymin = cms.double(0),
ymax = cms.double(5),
maxDeltaEta = cms.double(3.7)
))
117 changes: 114 additions & 3 deletions DQMOffline/Alignment/src/DiMuonVertexMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ DiMuonVertexMonitor::DiMuonVertexMonitor(const edm::ParameterSet& iConfig)
motherName_(iConfig.getParameter<std::string>("decayMotherName")),
MEFolderName_(iConfig.getParameter<std::string>("FolderName")),
useClosestVertex_(iConfig.getParameter<bool>("useClosestVertex")),
maxSVdist_(iConfig.getParameter<double>("maxSVdist")) {
maxSVdist_(iConfig.getParameter<double>("maxSVdist")),
CosPhi3DConfiguration_(iConfig.getParameter<edm::ParameterSet>("CosPhi3DConfig")),
SVDistConfiguration_(iConfig.getParameter<edm::ParameterSet>("SVDistConfig")),
SVDistSigConfiguration_(iConfig.getParameter<edm::ParameterSet>("SVDistSigConfig")),
SVDist3DConfiguration_(iConfig.getParameter<edm::ParameterSet>("SVDist3DConfig")),
SVDist3DSigConfiguration_(iConfig.getParameter<edm::ParameterSet>("SVDist3DSigConfig")) {
if (motherName_.find('Z') != std::string::npos) {
massLimits_ = std::make_pair(50., 120);
} else if (motherName_.find("J/#psi") != std::string::npos) {
Expand Down Expand Up @@ -91,6 +96,8 @@ void DiMuonVertexMonitor::bookHistograms(DQMStore::IBooker& iBooker, edm::Run co
hCosPhi3D_ = iBooker.book1D("CosPhi3D", fmt::sprintf("%s;cos(#phi_{3D});%s", histTit, ps), 50, -1., 1.);
hCosPhiInv_ = iBooker.book1D("CosPhiInv", fmt::sprintf("%s;inverted cos(#phi_{xy});%s", histTit, ps), 50, -1., 1.);
hCosPhiInv3D_ = iBooker.book1D("CosPhiInv3D", fmt::sprintf("%s;inverted cos(#phi_{3D});%s", histTit, ps), 50, -1., 1.);
hCosPhiUnbalance_ = iBooker.book1D("CosPhiUnbalance", fmt::sprintf("%s;cos(#phi_{xy}) unbalance;#Delta%s", histTit, ps), 50, -1.,1.);
hCosPhi3DUnbalance_ = iBooker.book1D("CosPhi3DUnbalance", fmt::sprintf("%s;cos(#phi_{3D}) unbalance;#Delta%s", histTit, ps), 50, -1., 1.);

hdxy_ = iBooker.book1D("dxy", fmt::sprintf("%s;muon track d_{xy}(PV) [#mum];muon tracks", histTit), 150, -300, 300);
hdz_ = iBooker.book1D("dz", fmt::sprintf("%s;muon track d_{z}(PV) [#mum];muon tracks", histTit), 150, -300, 300);
Expand All @@ -101,6 +108,26 @@ void DiMuonVertexMonitor::bookHistograms(DQMStore::IBooker& iBooker, edm::Run co
hIP2dsig_ = iBooker.book1D("IP2Dsig", fmt::sprintf("%s;muon track IP_{2D} significance;muon tracks", histTit), 100, 0., 5.);
hIP3dsig_ = iBooker.book1D("IP3Dsig", fmt::sprintf("%s;muon track IP_{3D} significance;muon tracks", histTit), 100, 0., 5.);
// clang-format on

// now book the cosphi3D plots vs kinematics
iBooker.setCurrentFolder(MEFolderName_ + "/DiMuonVertexMonitor/CosPhi3DPlots");
CosPhi3DPlots_.bookFromPSet(iBooker, CosPhi3DConfiguration_);

// now book the PV-SV distance plots vs kinematics
iBooker.setCurrentFolder(MEFolderName_ + "/DiMuonVertexMonitor/SVDistPlots");
SVDistPlots_.bookFromPSet(iBooker, SVDistConfiguration_);

// now book the PV-SV distance significance plots vs kinematics
iBooker.setCurrentFolder(MEFolderName_ + "/DiMuonVertexMonitor/SVDistSigPlots");
SVDistSigPlots_.bookFromPSet(iBooker, SVDistSigConfiguration_);

// now book the PV-SV 3D distance plots vs kinematics
iBooker.setCurrentFolder(MEFolderName_ + "/DiMuonVertexMonitor/SVDist3DPlots");
SVDist3DPlots_.bookFromPSet(iBooker, SVDist3DConfiguration_);

// now book the PV-SV 3D distance significance plots vs kinematics
iBooker.setCurrentFolder(MEFolderName_ + "/DiMuonVertexMonitor/SVDist3DSigPlots");
SVDist3DSigPlots_.bookFromPSet(iBooker, SVDist3DSigConfiguration_);
}

void DiMuonVertexMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
Expand Down Expand Up @@ -173,9 +200,10 @@ void DiMuonVertexMonitor::analyze(const edm::Event& iEvent, const edm::EventSetu

reco::Vertex theMainVtx;
if (!useClosestVertex_ || theClosestVertex == nullptr) {
theMainVtx = *theClosestVertex;
} else {
// if the closest vertex is not available, or explicitly not chosen
theMainVtx = vertexHandle.product()->front();
} else {
theMainVtx = *theClosestVertex;
}

const math::XYZPoint theMainVtxPos(theMainVtx.position().x(), theMainVtx.position().y(), theMainVtx.position().z());
Expand Down Expand Up @@ -237,6 +265,14 @@ void DiMuonVertexMonitor::analyze(const edm::Event& iEvent, const edm::EventSetu
hSVDist3DErr_->Fill(dist3D_err * cmToum);
hSVDist3DSig_->Fill(distance3D / dist3D_err);

// creat the pair of TLorentVectors used to make the plos
std::pair<TLorentzVector, TLorentzVector> tktk_p4 = std::make_pair(p4_tplus, p4_tminus);

SVDistPlots_.fillPlots(distance * cmToum, tktk_p4);
SVDistSigPlots_.fillPlots(distance / dist_err, tktk_p4);
SVDist3DPlots_.fillPlots(distance3D * cmToum, tktk_p4);
SVDist3DSigPlots_.fillPlots(distance3D / dist3D_err, tktk_p4);

// cut on the PV - SV distance
if (distance * cmToum < maxSVdist_) {
double cosphi = (ZpT.x() * deltaVtx.x() + ZpT.y() * deltaVtx.y()) /
Expand All @@ -252,6 +288,15 @@ void DiMuonVertexMonitor::analyze(const edm::Event& iEvent, const edm::EventSetu
// inverted
hCosPhiInv_->Fill(-cosphi);
hCosPhiInv3D_->Fill(-cosphi3D);

// unbalance
hCosPhiUnbalance_->Fill(cosphi, 1.);
hCosPhiUnbalance_->Fill(-cosphi, -1.);
hCosPhi3DUnbalance_->Fill(cosphi3D, 1.);
hCosPhi3DUnbalance_->Fill(-cosphi3D, -1.);

// fill the cos(phi3D) plots
CosPhi3DPlots_.fillPlots(cosphi3D, tktk_p4);
}
} else {
edm::LogWarning("DiMuonVertexMonitor") << "hardest primary vertex in the event is not valid!";
Expand Down Expand Up @@ -295,6 +340,72 @@ void DiMuonVertexMonitor::fillDescriptions(edm::ConfigurationDescriptions& descr
desc.add<std::string>("decayMotherName", "Z");
desc.add<bool>("useClosestVertex", true);
desc.add<double>("maxSVdist", 50.);

{
edm::ParameterSetDescription psCosPhi3D;
psCosPhi3D.add<std::string>("name", "CosPhi3D");
psCosPhi3D.add<std::string>("title", "cos(#phi_{3D})");
psCosPhi3D.add<std::string>("yUnits", "");
psCosPhi3D.add<int>("NxBins", 24);
psCosPhi3D.add<int>("NyBins", 50);
psCosPhi3D.add<double>("ymin", -1.);
psCosPhi3D.add<double>("ymax", 1.);
psCosPhi3D.add<double>("maxDeltaEta", 3.7);
desc.add<edm::ParameterSetDescription>("CosPhi3DConfig", psCosPhi3D);
}

{
edm::ParameterSetDescription psSVDist;
psSVDist.add<std::string>("name", "SVDist");
psSVDist.add<std::string>("title", "PV-SV distance");
psSVDist.add<std::string>("yUnits", "[#mum]");
psSVDist.add<int>("NxBins", 24);
psSVDist.add<int>("NyBins", 100);
psSVDist.add<double>("ymin", 0.);
psSVDist.add<double>("ymax", 300.);
psSVDist.add<double>("maxDeltaEta", 3.7);
desc.add<edm::ParameterSetDescription>("SVDistConfig", psSVDist);
}

{
edm::ParameterSetDescription psSVDistSig;
psSVDistSig.add<std::string>("name", "SVDistSig");
psSVDistSig.add<std::string>("title", "PV-SV distance significance");
psSVDistSig.add<std::string>("yUnits", "[#mum]");
psSVDistSig.add<int>("NxBins", 24);
psSVDistSig.add<int>("NyBins", 100);
psSVDistSig.add<double>("ymin", 0.);
psSVDistSig.add<double>("ymax", 5.);
psSVDistSig.add<double>("maxDeltaEta", 3.7);
desc.add<edm::ParameterSetDescription>("SVDistSigConfig", psSVDistSig);
}

{
edm::ParameterSetDescription psSVDist3D;
psSVDist3D.add<std::string>("name", "SVDist3D");
psSVDist3D.add<std::string>("title", "PV-SV 3D distance");
psSVDist3D.add<std::string>("yUnits", "[#mum]");
psSVDist3D.add<int>("NxBins", 24);
psSVDist3D.add<int>("NyBins", 100);
psSVDist3D.add<double>("ymin", 0.);
psSVDist3D.add<double>("ymax", 300.);
psSVDist3D.add<double>("maxDeltaEta", 3.7);
desc.add<edm::ParameterSetDescription>("SVDist3DConfig", psSVDist3D);
}

{
edm::ParameterSetDescription psSVDist3DSig;
psSVDist3DSig.add<std::string>("name", "SVDist3DSig");
psSVDist3DSig.add<std::string>("title", "PV-SV 3D distance significance");
psSVDist3DSig.add<std::string>("yUnits", "[#mum]");
psSVDist3DSig.add<int>("NxBins", 24);
psSVDist3DSig.add<int>("NyBins", 100);
psSVDist3DSig.add<double>("ymin", 0.);
psSVDist3DSig.add<double>("ymax", 5.);
psSVDist3DSig.add<double>("maxDeltaEta", 3.7);
desc.add<edm::ParameterSetDescription>("SVDist3DSigConfig", psSVDist3DSig);
}

descriptions.addWithDefaultLabel(desc);
}

Expand Down

0 comments on commit 4a98a53

Please sign in to comment.