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

MTV phase2 high eta #27653

Merged
merged 2 commits into from Aug 29, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 50 additions & 5 deletions CommonTools/CandAlgos/interface/GenParticleCustomSelector.h
Expand Up @@ -18,15 +18,38 @@ class GenParticleCustomSelector {
double lip,
bool chargedOnly,
int status,
const std::vector<int>& pdgId = std::vector<int>())
const std::vector<int>& pdgId = std::vector<int>(),
bool invertRapidityCut = false,
double minPhi = -3.2,
double maxPhi = 3.2)
: ptMin_(ptMin),
minRapidity_(minRapidity),
maxRapidity_(maxRapidity),
meanPhi_((minPhi + maxPhi) / 2.),
rangePhi_((maxPhi - minPhi) / 2.),
tip_(tip),
lip_(lip),
chargedOnly_(chargedOnly),
status_(status),
pdgId_(pdgId) {}
pdgId_(pdgId),
invertRapidityCut_(invertRapidityCut) {
if (minPhi >= maxPhi) {
throw cms::Exception("Configuration")
<< "GenParticleCustomSelector: minPhi (" << minPhi << ") must be smaller than maxPhi (" << maxPhi
<< "). The range is constructed from minPhi to maxPhi around their "
"average.";
}
if (minPhi >= M_PI) {
throw cms::Exception("Configuration") << "GenParticleCustomSelector: minPhi (" << minPhi
<< ") must be smaller than PI. The range is constructed from minPhi "
"to maxPhi around their average.";
}
if (maxPhi <= -M_PI) {
throw cms::Exception("Configuration") << "GenParticleCustomSelector: maxPhi (" << maxPhi
<< ") must be larger than -PI. The range is constructed from minPhi "
"to maxPhi around their average.";
}
}

/// Operator() performs the selection: e.g. if (tPSelector(tp)) {...}
bool operator()(const reco::GenParticle& tp) const {
Expand All @@ -42,19 +65,38 @@ class GenParticleCustomSelector {
testId = true;
}

return (tp.pt() >= ptMin_ && tp.eta() >= minRapidity_ && tp.eta() <= maxRapidity_ &&
sqrt(tp.vertex().perp2()) <= tip_ && fabs(tp.vertex().z()) <= lip_ && tp.status() == status_ && testId);
auto etaOk = [&](const reco::GenParticle& p) -> bool {
float eta = p.eta();
if (!invertRapidityCut_)
return (eta >= minRapidity_) && (eta <= maxRapidity_);
else
return (eta < minRapidity_ || eta > maxRapidity_);
};
auto phiOk = [&](const reco::GenParticle& p) {
float dphi = deltaPhi(atan2f(p.py(), p.px()), meanPhi_);
return dphi >= -rangePhi_ && dphi <= rangePhi_;
};
auto ptOk = [&](const reco::GenParticle& p) {
double pt = p.pt();
return pt >= ptMin_;
};

return (ptOk(tp) && etaOk(tp) && phiOk(tp) && sqrt(tp.vertex().perp2()) <= tip_ && fabs(tp.vertex().z()) <= lip_ &&
tp.status() == status_ && testId);
}

private:
double ptMin_;
double minRapidity_;
double maxRapidity_;
float meanPhi_;
float rangePhi_;
double tip_;
double lip_;
bool chargedOnly_;
int status_;
std::vector<int> pdgId_;
bool invertRapidityCut_;
};

#include "FWCore/Framework/interface/ConsumesCollector.h"
Expand All @@ -77,7 +119,10 @@ namespace reco {
cfg.getParameter<double>("lip"),
cfg.getParameter<bool>("chargedOnly"),
cfg.getParameter<int>("status"),
cfg.getParameter<std::vector<int> >("pdgId"));
cfg.getParameter<std::vector<int> >("pdgId"),
cfg.getParameter<bool>("invertRapidityCut"),
cfg.getParameter<double>("minPhi"),
cfg.getParameter<double>("maxPhi"));
}
};

Expand Down
3 changes: 3 additions & 0 deletions CommonTools/CandAlgos/python/genParticleCustomSelector_cfi.py
Expand Up @@ -10,6 +10,9 @@
lip = cms.double(30.0),
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.4),
minPhi = cms.double(-3.2),
maxPhi = cms.double( 3.2),
invertRapidityCut = cms.bool(False)
)


Expand Down
17 changes: 13 additions & 4 deletions CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h
Expand Up @@ -29,7 +29,8 @@ class RecoTrackSelectorBase {
minPixelHit_(cfg.getParameter<int>("minPixelHit")),
minLayer_(cfg.getParameter<int>("minLayer")),
min3DLayer_(cfg.getParameter<int>("min3DLayer")),
usePV_(false) {
usePV_(false),
invertRapidityCut_(cfg.getParameter<bool>("invertRapidityCut")) {
const auto minPhi = cfg.getParameter<double>("minPhi");
const auto maxPhi = cfg.getParameter<double>("maxPhi");
if (minPhi >= maxPhi) {
Expand Down Expand Up @@ -114,14 +115,21 @@ class RecoTrackSelectorBase {

const auto dphi = deltaPhi(t.phi(), meanPhi_);

auto etaOk = [&](const reco::Track& p) -> bool {
float eta = p.eta();
if (!invertRapidityCut_)
return (eta >= minRapidity_) && (eta <= maxRapidity_);
else
return (eta < minRapidity_ || eta > maxRapidity_);
};

return ((algo_ok & quality_ok) && t.hitPattern().numberOfValidHits() >= minHit_ &&
t.hitPattern().numberOfValidPixelHits() >= minPixelHit_ &&
t.hitPattern().trackerLayersWithMeasurement() >= minLayer_ &&
t.hitPattern().pixelLayersWithMeasurement() + t.hitPattern().numberOfValidStripLayersWithMonoAndStereo() >=
min3DLayer_ &&
fabs(t.pt()) >= ptMin_ && t.eta() >= minRapidity_ && t.eta() <= maxRapidity_ && dphi >= -rangePhi_ &&
dphi <= rangePhi_ && fabs(t.dxy(vertex)) <= tip_ && fabs(t.dsz(vertex)) <= lip_ &&
t.normalizedChi2() <= maxChi2_);
fabs(t.pt()) >= ptMin_ && etaOk(t) && dphi >= -rangePhi_ && dphi <= rangePhi_ &&
fabs(t.dxy(vertex)) <= tip_ && fabs(t.dsz(vertex)) <= lip_ && t.normalizedChi2() <= maxChi2_);
}

private:
Expand All @@ -138,6 +146,7 @@ class RecoTrackSelectorBase {
int minLayer_;
int min3DLayer_;
bool usePV_;
bool invertRapidityCut_;

edm::EDGetTokenT<reco::BeamSpot> bsSrcToken_;
edm::EDGetTokenT<reco::VertexCollection> vertexToken_;
Expand Down
3 changes: 2 additions & 1 deletion CommonTools/RecoAlgos/python/recoTrackSelectorPSet_cfi.py
Expand Up @@ -20,5 +20,6 @@
minPixelHit = cms.int32(0),
beamSpot = cms.InputTag("offlineBeamSpot"),
usePV = cms.bool(False),
vertexTag = cms.InputTag('offlinePrimaryVertices')
vertexTag = cms.InputTag('offlinePrimaryVertices'),
invertRapidityCut = cms.bool(False)
)
Expand Up @@ -16,6 +16,7 @@
minHit = cms.int32(0),
minPhi = cms.double(-3.2),
maxPhi = cms.double(3.2),
invertRapidityCut = cms.bool(False)
)

from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2
Expand Down
12 changes: 12 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Expand Up @@ -17,6 +17,17 @@
# pset.minGoodStripCharge = cms.PSet(refToPSet_ = cms.string('HLTSiStripClusterChargeCutNone'))
# return process

def customiseFor27653(process):
""" PR27653 : RecoTrackRefSelector has new parameter: invertRapidityCut
default value (for back compatibility) : cms.bool(False)
"""
for prod in producers_by_type(process,"RecoTrackRefSelector"):
if not hasattr(prod,"invertRapidityCut"):
setattr(prod,"invertRapidityCut",cms.bool(False))
# for p in prod.parameterNames_():
# print p
return process

def customiseFor2017DtUnpacking(process):
"""Adapt the HLT to run the legacy DT unpacking
for pre2018 data/MC workflows as the default"""
Expand Down Expand Up @@ -52,5 +63,6 @@ def customizeHLTforCMSSW(process, menuType="GRun"):

# add call to action function in proper order: newest last!
# process = customiseFor12718(process)
process = customiseFor27653(process)

return process
19 changes: 2 additions & 17 deletions PhysicsTools/RecoAlgos/python/trackingParticleSelector_cfi.py
@@ -1,22 +1,7 @@
import FWCore.ParameterSet.Config as cms

trackingParticleSelector = cms.EDFilter("TrackingParticleSelector",
src = cms.InputTag("mix","MergedTrackTruth"),
chargedOnly = cms.bool(True),
stableOnly = cms.bool(False),
pdgId = cms.vint32(),
tip = cms.double(3.5),
signalOnly = cms.bool(True),
intimeOnly = cms.bool(False),
minRapidity = cms.double(-2.4),
lip = cms.double(30.0),
ptMin = cms.double(0.9),
ptMax = cms.double(1e100),
maxRapidity = cms.double(2.4),
minHit = cms.int32(0),
minPhi = cms.double(-3.2),
maxPhi = cms.double(3.2),
)
import SimTracker.Common.trackingParticleSelector_cfi
trackingParticleSelector = SimTracker.Common.trackingParticleSelector_cfi.trackingParticleSelector.clone()

from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2
premix_stage2.toModify(trackingParticleSelector, src = "mixData:MergedTrackTruth")
11 changes: 9 additions & 2 deletions SimTracker/Common/interface/TrackingParticleSelector.h
Expand Up @@ -28,6 +28,7 @@ class TrackingParticleSelector {
bool chargedOnly,
bool stableOnly,
const std::vector<int> &pdgId = std::vector<int>(),
bool invertRapidityCut = false,
double minPhi = -3.2,
double maxPhi = 3.2)
: ptMin2_(ptMin * ptMin),
Expand All @@ -43,7 +44,8 @@ class TrackingParticleSelector {
intimeOnly_(intimeOnly),
chargedOnly_(chargedOnly),
stableOnly_(stableOnly),
pdgId_(pdgId) {
pdgId_(pdgId),
invertRapidityCut_(invertRapidityCut) {
if (minPhi >= maxPhi) {
throw cms::Exception("Configuration")
<< "TrackingParticleSelector: minPhi (" << minPhi << ") must be smaller than maxPhi (" << maxPhi
Expand Down Expand Up @@ -103,7 +105,10 @@ class TrackingParticleSelector {

auto etaOk = [&](const TrackingParticle &p) -> bool {
float eta = etaFromXYZ(p.px(), p.py(), p.pz());
return (eta >= minRapidity_) & (eta <= maxRapidity_);
if (!invertRapidityCut_)
return (eta >= minRapidity_) && (eta <= maxRapidity_);
else
return (eta < minRapidity_ || eta > maxRapidity_);
};
auto phiOk = [&](const TrackingParticle &p) {
float dphi = deltaPhi(atan2f(p.py(), p.px()), meanPhi_);
Expand Down Expand Up @@ -134,6 +139,7 @@ class TrackingParticleSelector {
bool chargedOnly_;
bool stableOnly_;
std::vector<int> pdgId_;
bool invertRapidityCut_;
};

#include "CommonTools/UtilAlgos/interface/ParameterAdapter.h"
Expand Down Expand Up @@ -161,6 +167,7 @@ namespace reco {
cfg.getParameter<bool>("chargedOnly"),
cfg.getParameter<bool>("stableOnly"),
cfg.getParameter<std::vector<int>>("pdgId"),
cfg.getParameter<bool>("invertRapidityCut"),
cfg.getParameter<double>("minPhi"),
cfg.getParameter<double>("maxPhi"));
}
Expand Down
20 changes: 20 additions & 0 deletions SimTracker/Common/python/trackingParticleSelector_cfi.py
@@ -0,0 +1,20 @@
import FWCore.ParameterSet.Config as cms

trackingParticleSelector = cms.EDFilter("TrackingParticleSelector",
src = cms.InputTag("mix","MergedTrackTruth"),
chargedOnly = cms.bool(True),
stableOnly = cms.bool(False),
pdgId = cms.vint32(),
tip = cms.double(3.5),
signalOnly = cms.bool(True),
intimeOnly = cms.bool(False),
minRapidity = cms.double(-2.4),
lip = cms.double(30.0),
ptMin = cms.double(0.9),
ptMax = cms.double(1e100),
maxRapidity = cms.double(2.4),
minHit = cms.int32(0),
minPhi = cms.double(-3.2),
maxPhi = cms.double(3.2),
invertRapidityCut = cms.bool(False)
)
Expand Up @@ -142,8 +142,9 @@ struct MTVHistoProducerAlgoForTrackerHistograms {
std::vector<ConcurrentMonitorElement> h_assochi2, h_assochi2_prob;

//chi2 and # lost hits vs eta: to be used with doProfileX
std::vector<ConcurrentMonitorElement> chi2_vs_eta, nlosthits_vs_eta;
std::vector<ConcurrentMonitorElement> assoc_chi2_vs_eta, assoc_chi2prob_vs_eta;
std::vector<ConcurrentMonitorElement> chi2_vs_eta, chi2_vs_pt, nlosthits_vs_eta;
std::vector<ConcurrentMonitorElement> assoc_chi2_vs_eta, assoc_chi2_vs_pt, assoc_chi2prob_vs_eta,
assoc_chi2prob_vs_pt;

//resolution of track params: to be used with fitslicesytool
std::vector<ConcurrentMonitorElement> dxyres_vs_eta, ptres_vs_eta, dzres_vs_eta, phires_vs_eta, cotThetares_vs_eta;
Expand Down
6 changes: 4 additions & 2 deletions Validation/RecoTrack/plugins/MultiTrackValidator.cc
Expand Up @@ -166,7 +166,8 @@ MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset)
pset.getParameter<bool>("intimeOnlyTP"),
pset.getParameter<bool>("chargedOnlyTP"),
pset.getParameter<bool>("stableOnlyTP"),
pset.getParameter<std::vector<int>>("pdgIdTP"));
pset.getParameter<std::vector<int>>("pdgIdTP"),
pset.getParameter<bool>("invertRapidityCutTP"));

cosmictpSelector = CosmicTrackingParticleSelector(pset.getParameter<double>("ptMinTP"),
pset.getParameter<double>("minRapidityTP"),
Expand All @@ -189,7 +190,8 @@ MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset)
psetVsPhi.getParameter<bool>("intimeOnly"),
psetVsPhi.getParameter<bool>("chargedOnly"),
psetVsPhi.getParameter<bool>("stableOnly"),
psetVsPhi.getParameter<std::vector<int>>("pdgId"));
psetVsPhi.getParameter<std::vector<int>>("pdgId"),
psetVsPhi.getParameter<bool>("invertRapidityCut"));

dRTrackSelector = MTVHistoProducerAlgoForTracker::makeRecoTrackSelectorFromTPSelectorParameters(psetVsPhi);

Expand Down
Expand Up @@ -23,7 +23,10 @@
minRapidity = cms.double(-2.5),
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.5),
tip = cms.double(3.5)
tip = cms.double(3.5),
invertRapidityCut = cms.bool(False),
maxPhi = cms.double(3.2),
minPhi = cms.double(-3.2)
)


Expand All @@ -35,7 +38,10 @@
minRapidity = cms.double(-2.5),
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.5),
tip = cms.double(3.5)
tip = cms.double(3.5),
invertRapidityCut = cms.bool(False),
maxPhi = cms.double(3.2),
minPhi = cms.double(-3.2)
)

GpSelectorForEfficiencyVsPhiBlock = cms.PSet(
Expand All @@ -46,7 +52,10 @@
minRapidity = cms.double(-2.5),
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.5),
tip = cms.double(3.5)
tip = cms.double(3.5),
invertRapidityCut = cms.bool(False),
maxPhi = cms.double(3.2),
minPhi = cms.double(-3.2)
)

GpSelectorForEfficiencyVsPtBlock = cms.PSet(
Expand All @@ -58,6 +67,9 @@
ptMin = cms.double(0.050),
tip = cms.double(3.5),
lip = cms.double(30.0),
invertRapidityCut = cms.bool(False),
maxPhi = cms.double(3.2),
minPhi = cms.double(-3.2)
)

GpSelectorForEfficiencyVsVTXRBlock = cms.PSet(
Expand All @@ -68,7 +80,10 @@
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.5),
lip = cms.double(30.0),
tip = cms.double(30.0)
tip = cms.double(30.0),
invertRapidityCut = cms.bool(False),
maxPhi = cms.double(3.2),
minPhi = cms.double(-3.2)
)

GpSelectorForEfficiencyVsVTXZBlock = cms.PSet(
Expand All @@ -79,7 +94,10 @@
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.5),
lip = cms.double(35.0),
tip = cms.double(3.5)
tip = cms.double(3.5),
invertRapidityCut = cms.bool(False),
maxPhi = cms.double(3.2),
minPhi = cms.double(-3.2)
)

def _modifyForPhase1(pset):
Expand Down