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

[13.2.X] Added efficiencies of matched and unmatched tracks (between HLT and offline) vs LS, vs online lumi and vs PU #42593

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
21 changes: 19 additions & 2 deletions DQM/TrackingMonitorSource/interface/TrackToTrackComparisonHists.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/Scalers/interface/LumiScalers.h"
#include "DataFormats/OnlineMetaData/interface/OnlineLuminosityRecord.h"
#include "DQMServices/Core/interface/MonitorElement.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
Expand Down Expand Up @@ -41,6 +43,7 @@ class TrackToTrackComparisonHists : public DQMEDAnalyzer {
MonitorElement *h_tracks, *h_pt, *h_eta, *h_phi, *h_dxy, *h_dz, *h_dxyWRTpv, *h_dzWRTpv, *h_charge, *h_hits;
MonitorElement *h_dRmin, *h_dRmin_l;
MonitorElement* h_pt_vs_eta;
MonitorElement *h_onlinelumi, *h_PU, *h_ls;
};

struct matchingME {
Expand Down Expand Up @@ -69,8 +72,14 @@ class TrackToTrackComparisonHists : public DQMEDAnalyzer {
void book_generic_tracks_histos(DQMStore::IBooker& ibooker, generalME& mes, TString label, std::string& dir);
void book_matching_tracks_histos(DQMStore::IBooker& ibooker, matchingME& mes, TString label, std::string& dir);

void fill_generic_tracks_histos(
generalME& mes, reco::Track* trk, reco::BeamSpot* bs, reco::Vertex* pv, bool requirePlateau = true);
void fill_generic_tracks_histos(generalME& mes,
reco::Track* trk,
reco::BeamSpot* bs,
reco::Vertex* pv,
unsigned int ls,
double onlinelumi,
double PU,
bool requirePlateau = true);
void fill_matching_tracks_histos(
matchingME& mes, reco::Track* mon, reco::Track* ref, reco::BeamSpot* bs, reco::Vertex* pv);

Expand All @@ -86,6 +95,8 @@ class TrackToTrackComparisonHists : public DQMEDAnalyzer {
edm::EDGetTokenT<reco::BeamSpot> referenceBSToken_;
edm::EDGetTokenT<reco::VertexCollection> monitoredPVToken_;
edm::EDGetTokenT<reco::VertexCollection> referencePVToken_;
edm::EDGetTokenT<LumiScalersCollection> lumiScalersToken_;
edm::EDGetTokenT<OnlineLuminosityRecord> onlineMetaDataDigisToken_;

private:
// edm::ParameterSet conf_;
Expand Down Expand Up @@ -130,4 +141,10 @@ class TrackToTrackComparisonHists : public DQMEDAnalyzer {
unsigned int dxyRes_nbin;
double dzRes_rangeMin, dzRes_rangeMax;
unsigned int dzRes_nbin;
unsigned int ls_rangeMin, ls_rangeMax;
unsigned int ls_nbin;
double PU_rangeMin, PU_rangeMax;
unsigned int PU_nbin;
double onlinelumi_rangeMin, onlinelumi_rangeMax;
unsigned int onlinelumi_nbin;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import FWCore.ParameterSet.Config as cms

from DQM.TrackingMonitorSource.trackToTrackComparisonHists_cfi import trackToTrackComparisonHists
from Configuration.Eras.Modifier_run3_common_cff import run3_common
from Configuration.Eras.Modifier_phase2_common_cff import phase2_common

TrackToTrackComparisonHists = trackToTrackComparisonHists.clone()

run3_common.toModify(TrackToTrackComparisonHists.histoPSet, onlinelumi_nbin=375, onlinelumi_rangeMin=200., onlinelumi_rangeMax=25000.)
phase2_common.toModify(TrackToTrackComparisonHists.histoPSet, PU_nbin=200, PU_rangeMin=0., PU_rangeMax=200.)
88 changes: 82 additions & 6 deletions DQM/TrackingMonitorSource/src/TrackToTrackComparisonHists.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/Luminosity/interface/LumiSummary.h"

#include "DataFormats/Math/interface/deltaR.h"
#include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
Expand Down Expand Up @@ -35,6 +36,9 @@ TrackToTrackComparisonHists::TrackToTrackComparisonHists(const edm::ParameterSet
referenceBSToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("referenceBeamSpot"));
monitoredPVToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("monitoredPrimaryVertices"));
referencePVToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("referencePrimaryVertices"));
lumiScalersToken_ = consumes<LumiScalersCollection>(iConfig.getParameter<edm::InputTag>("scalers"));
onlineMetaDataDigisToken_ =
consumes<OnlineLuminosityRecord>(iConfig.getParameter<edm::InputTag>("onlineMetaDataDigis"));

referenceTracksMEs_.label = referenceTrackInputTag_.label();
matchedReferenceTracksMEs_.label = referenceTrackInputTag_.label() + "_matched";
Expand Down Expand Up @@ -68,6 +72,31 @@ void TrackToTrackComparisonHists::analyze(const edm::Event& iEvent, const edm::E
return;
}

//
// Get Lumi/LS Info
//

unsigned int ls = iEvent.id().luminosityBlock();

double onlinelumi = -1.f;
double PU = -1.f;

auto const lumiScalersHandle = iEvent.getHandle(lumiScalersToken_);
auto const onlineMetaDataDigisHandle = iEvent.getHandle(onlineMetaDataDigisToken_);

if (onlineMetaDataDigisHandle.isValid()) {
onlinelumi = onlineMetaDataDigisHandle->instLumi();
PU = onlineMetaDataDigisHandle->avgPileUp();
} else if (lumiScalersHandle.isValid() and not lumiScalersHandle->empty()) {
edm::LogError("TrackToTrackComparisonHists") << "onlineMetaDataDigisHandle not found, trying SCAL";
auto const scalit = lumiScalersHandle->begin();
onlinelumi = scalit->instantLumi();
PU = scalit->pileup();
} else {
edm::LogError("TrackToTrackComparisonHists") << "lumiScalersHandle not found or empty, skipping event";
return;
}

//
// Get Reference Track Info
//
Expand Down Expand Up @@ -164,7 +193,7 @@ void TrackToTrackComparisonHists::analyze(const edm::Event& iEvent, const edm::E
if (fabs(dzWRTpv) > dzWRTPvCut_)
continue;

fill_generic_tracks_histos(*&referenceTracksMEs_, &track, &referenceBS, &referencePV);
fill_generic_tracks_histos(*&referenceTracksMEs_, &track, &referenceBS, &referencePV, ls, onlinelumi, PU);

std::map<double, int> trackDRmap = pItr->second;
if (trackDRmap.empty()) {
Expand All @@ -183,7 +212,7 @@ void TrackToTrackComparisonHists::analyze(const edm::Event& iEvent, const edm::E

if (matched) {
nMatchedReferenceTracks++;
fill_generic_tracks_histos(*&matchedReferenceTracksMEs_, &track, &referenceBS, &referencePV);
fill_generic_tracks_histos(*&matchedReferenceTracksMEs_, &track, &referenceBS, &referencePV, ls, onlinelumi, PU);
(matchedReferenceTracksMEs_.h_dRmin)->Fill(dRmin);
(matchedReferenceTracksMEs_.h_dRmin_l)->Fill(dRmin);

Expand All @@ -209,7 +238,7 @@ void TrackToTrackComparisonHists::analyze(const edm::Event& iEvent, const edm::E
if (fabs(dzWRTpv) > dzWRTPvCut_)
continue;

fill_generic_tracks_histos(*&monitoredTracksMEs_, &track, &monitoredBS, &monitoredPV);
fill_generic_tracks_histos(*&monitoredTracksMEs_, &track, &monitoredBS, &monitoredPV, ls, onlinelumi, PU);

std::map<double, int> trackDRmap = pItr->second;
if (trackDRmap.empty()) {
Expand All @@ -228,7 +257,8 @@ void TrackToTrackComparisonHists::analyze(const edm::Event& iEvent, const edm::E

if (!matched) {
nUnmatchedMonitoredTracks++;
fill_generic_tracks_histos(*&unMatchedMonitoredTracksMEs_, &track, &monitoredBS, &monitoredPV);
fill_generic_tracks_histos(
*&unMatchedMonitoredTracksMEs_, &track, &monitoredBS, &monitoredPV, ls, onlinelumi, PU);
(unMatchedMonitoredTracksMEs_.h_dRmin)->Fill(dRmin);
(unMatchedMonitoredTracksMEs_.h_dRmin_l)->Fill(dRmin);
}
Expand Down Expand Up @@ -282,6 +312,8 @@ void TrackToTrackComparisonHists::fillDescriptions(edm::ConfigurationDescription
desc.add<edm::InputTag>("referenceTrack", edm::InputTag("generalTracks"));
desc.add<edm::InputTag>("referenceBeamSpot", edm::InputTag("offlineBeamSpot"));
desc.add<edm::InputTag>("referencePrimaryVertices", edm::InputTag("offlinePrimaryVertices"));
desc.add<edm::InputTag>("scalers", edm::InputTag("scalersRawToDigi"));
desc.add<edm::InputTag>("onlineMetaDataDigis", edm::InputTag("onlineMetaDataDigis"));

desc.add<std::string>("topDirName", "HLT/Tracking/ValidationWRTOffline");
desc.add<double>("dRmin", 0.002);
Expand Down Expand Up @@ -380,6 +412,17 @@ void TrackToTrackComparisonHists::book_generic_tracks_histos(DQMStore::IBooker&
Pt_nbin,
Pt_rangeMin,
Pt_rangeMax);

// counts of tracks vs lumi
// for this moment, xmin,xmax and binning are hardcoded, maybe in future in a config file!
// have to add (declare) this in the .h file as well
(mes.h_onlinelumi) = ibooker.book1D(label + "_onlinelumi",
"number of tracks vs onlinelumi",
onlinelumi_nbin,
onlinelumi_rangeMin,
onlinelumi_rangeMax);
(mes.h_ls) = ibooker.book1D(label + "_ls", "number of tracks vs ls", ls_nbin, ls_rangeMin, ls_rangeMax);
(mes.h_PU) = ibooker.book1D(label + "_PU", "number of tracks vs PU", PU_nbin, PU_rangeMin, PU_rangeMax);
}

void TrackToTrackComparisonHists::book_matching_tracks_histos(DQMStore::IBooker& ibooker,
Expand Down Expand Up @@ -437,8 +480,14 @@ void TrackToTrackComparisonHists::book_matching_tracks_histos(DQMStore::IBooker&
(mes.h_dHits) = ibooker.book1D(label + "_dHits", "#Delta track number of hits", 39, -19.5, 19.5);
}

void TrackToTrackComparisonHists::fill_generic_tracks_histos(
generalME& mes, reco::Track* trk, reco::BeamSpot* bs, reco::Vertex* pv, bool requirePlateau) {
void TrackToTrackComparisonHists::fill_generic_tracks_histos(generalME& mes,
reco::Track* trk,
reco::BeamSpot* bs,
reco::Vertex* pv,
unsigned int ls,
double onlinelumi,
double PU,
bool requirePlateau) {
float pt = trk->pt();
float eta = trk->eta();
float phi = trk->phi();
Expand All @@ -463,6 +512,9 @@ void TrackToTrackComparisonHists::fill_generic_tracks_histos(
(mes.h_dzWRTpv)->Fill(dzWRTpv);
(mes.h_charge)->Fill(charge);
(mes.h_hits)->Fill(nhits);
(mes.h_onlinelumi)->Fill(onlinelumi);
(mes.h_ls)->Fill(ls);
(mes.h_PU)->Fill(PU);
}

if (pTOnPlateau || !requirePlateau) {
Expand Down Expand Up @@ -553,6 +605,18 @@ void TrackToTrackComparisonHists::initialize_parameter(const edm::ParameterSet&
dzRes_rangeMin = pset.getParameter<double>("dzRes_rangeMin");
dzRes_rangeMax = pset.getParameter<double>("dzRes_rangeMax");
dzRes_nbin = pset.getParameter<unsigned int>("dzRes_nbin");

ls_rangeMin = pset.getParameter<unsigned int>("ls_rangeMin");
ls_rangeMax = pset.getParameter<unsigned int>("ls_rangeMax");
ls_nbin = pset.getParameter<unsigned int>("ls_nbin");

onlinelumi_rangeMin = pset.getParameter<double>("onlinelumi_rangeMin");
onlinelumi_rangeMax = pset.getParameter<double>("onlinelumi_rangeMax");
onlinelumi_nbin = pset.getParameter<unsigned int>("onlinelumi_nbin");

PU_rangeMin = pset.getParameter<double>("PU_rangeMin");
PU_rangeMax = pset.getParameter<double>("PU_rangeMax");
PU_nbin = pset.getParameter<unsigned int>("PU_nbin");
}

void TrackToTrackComparisonHists::fillHistoPSetDescription(edm::ParameterSetDescription& pset) {
Expand Down Expand Up @@ -595,4 +659,16 @@ void TrackToTrackComparisonHists::fillHistoPSetDescription(edm::ParameterSetDesc
pset.add<double>("dzRes_rangeMin", -0.05);
pset.add<double>("dzRes_rangeMax", 0.05);
pset.add<unsigned int>("dzRes_nbin", 150);

pset.add<unsigned int>("ls_rangeMin", 0);
pset.add<unsigned int>("ls_rangeMax", 3000);
pset.add<unsigned int>("ls_nbin", 300);

pset.add<double>("onlinelumi_rangeMin", 0.0);
pset.add<double>("onlinelumi_rangeMax", 20000.0);
pset.add<unsigned int>("onlinelumi_nbin", 200);

pset.add<double>("PU_rangeMin", 0.0);
pset.add<double>("PU_rangeMax", 120.0);
pset.add<unsigned int>("PU_nbin", 120);
}
4 changes: 2 additions & 2 deletions DQMOffline/Trigger/python/BTVHLTOfflineSource_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
#
# Relative Online-Offline Track Monitoring
#
from DQM.TrackingMonitorSource.trackToTrackComparisonHists_cfi import trackToTrackComparisonHists
from DQM.TrackingMonitorSource.TrackToTrackComparisonHists_cfi import TrackToTrackComparisonHists

referenceTracksForHLTBTag = cms.EDFilter('TrackSelector',
src = cms.InputTag('generalTracks'),
cut = cms.string("quality('highPurity')")
)

bTagHLTTrackMonitoring_muPF1 = trackToTrackComparisonHists.clone(
bTagHLTTrackMonitoring_muPF1 = TrackToTrackComparisonHists.clone(
dzWRTPvCut = 0.1,
monitoredTrack = "hltMergedTracks",
referenceTrack = "referenceTracksForHLTBTag",
Expand Down
6 changes: 3 additions & 3 deletions DQMOffline/Trigger/python/TrackToTrackMonitoring_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from DQMServices.Core.DQM_cfg import *
DQMStore.collateHistograms =cms.untracked.bool(True)
from DQM.TrackingMonitorSource.trackToTrackComparisonHists_cfi import trackToTrackComparisonHists
from DQM.TrackingMonitorSource.TrackToTrackComparisonHists_cfi import TrackToTrackComparisonHists

trackSelector = cms.EDFilter('TrackSelector',
src = cms.InputTag('generalTracks'),
Expand All @@ -12,7 +12,7 @@
cut = "quality('highPurity')"
)

hltMerged2highPurity = trackToTrackComparisonHists.clone(
hltMerged2highPurity = TrackToTrackComparisonHists.clone(
monitoredTrack = "hltMergedTracks",
referenceTrack = "highPurityTracks",
monitoredBeamSpot = "hltOnlineBeamSpot",
Expand All @@ -22,7 +22,7 @@
monitoredPrimaryVertices = "hltVerticesPFSelector"
)

hltMerged2highPurityPV = trackToTrackComparisonHists.clone(
hltMerged2highPurityPV = TrackToTrackComparisonHists.clone(
dzWRTPvCut = 0.1,
monitoredTrack = "hltMergedTracks",
referenceTrack = "highPurityTracks",
Expand Down
6 changes: 6 additions & 0 deletions DQMOffline/Trigger/python/TrackingMonitoring_Client_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"Eff_dzWRTpv 'Relative Efficiency vs dzWRTpv;d_{z};relative efficiency' ref_matched_dzWRTpv ref_dzWRTpv eff",
"Eff_charge 'Relative Efficiency vs charge;charge;relative efficiency' ref_matched_charge ref_charge eff",
"Eff_hits 'Relative Efficiency vs hits;number of hits;relative efficiency' ref_matched_hits ref_hits eff",
"Eff_OnlineLumi 'Relative Efficiency vs OnlineLumi;OnlineLumi E30 [Hz cm^{-2}];relative efficiency' ref_matched_onlinelumi ref_onlinelumi eff",
"Eff_LS 'Relative Efficiency vs LS;LS;relative efficiency' ref_matched_ls ref_ls eff",
"Eff_PU 'Relative Efficiency vs PU;PU;relative efficiency' ref_matched_PU ref_PU eff",

"FakeRate_pt 'Relative Fake Rate vs Pt;#P_T;relative fake rate' mon_unMatched_pt mon_pt eff",
"FakeRate_eta 'Relative Fake Rate vs Eta;#eta;relative fake rate' mon_unMatched_eta mon_eta eff",
Expand All @@ -56,6 +59,9 @@
"FakeRate_dzWRTpv 'Relative Fake Rate vs dzWRTpv;d_{z};relative fake rate' mon_unMatched_dzWRTpv mon_dzWRTpv eff",
"FakeRate_charge 'Relative Fake Rate vs charge;charge;relative fake rate' mon_unMatched_charge mon_charge eff",
"FakeRate_hits 'Relative Fake Rate vs hits;number of hits;relative fake rate' mon_unMatched_hits mon_hits eff",
"FakeRate_OnlineLumi 'Relative Fake Rate vs OnlineLumi;OnlineLumi E30 [Hz cm^{-2}];relative efficiency' mon_unMatched_onlinelumi mon_onlinelumi eff",
"FakeRate_LS 'Relative Fake Rate vs LS;LS;relative efficiency' mon_unMatched_ls mon_ls eff",
"FakeRate_PU 'Relative Fake Rate vs PU;PU;relative efficiency' mon_unMatched_PU mon_PU eff",
),
)

Expand Down