Skip to content

Commit

Permalink
Merge pull request #19029 from makortel/selectorPhi
Browse files Browse the repository at this point in the history
Add minPhi+maxPhi to RecoTrackSelectorBase and TrackingParticleSelector
  • Loading branch information
cmsbuild committed Jun 28, 2017
2 parents c475a3a + ca093f4 commit b4e8e82
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 7 deletions.
22 changes: 21 additions & 1 deletion CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h
Expand Up @@ -11,7 +11,7 @@
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

#include "DataFormats/Math/interface/deltaPhi.h"

class RecoTrackSelectorBase {
public:
Expand All @@ -20,6 +20,8 @@ class RecoTrackSelectorBase {
ptMin_(cfg.getParameter<double>("ptMin")),
minRapidity_(cfg.getParameter<double>("minRapidity")),
maxRapidity_(cfg.getParameter<double>("maxRapidity")),
meanPhi_((cfg.getParameter<double>("minPhi")+cfg.getParameter<double>("maxPhi"))/2.),
rangePhi_((cfg.getParameter<double>("maxPhi")-cfg.getParameter<double>("minPhi"))/2.),
tip_(cfg.getParameter<double>("tip")),
lip_(cfg.getParameter<double>("lip")),
maxChi2_(cfg.getParameter<double>("maxChi2")),
Expand All @@ -29,6 +31,18 @@ class RecoTrackSelectorBase {
min3DLayer_(cfg.getParameter<int>("min3DLayer")),
usePV_(cfg.getParameter<bool>("usePV")),
bsSrcToken_(iC.consumes<reco::BeamSpot>(cfg.getParameter<edm::InputTag>("beamSpot"))) {
const auto minPhi = cfg.getParameter<double>("minPhi");
const auto maxPhi = cfg.getParameter<double>("maxPhi");
if(minPhi >= maxPhi) {
throw cms::Exception("Configuration") << "RecoTrackSelectorPhase: 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") << "RecoTrackSelectorPhase: 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") << "RecoTrackSelectorPhase: maxPhi (" << maxPhi << ") must be larger than -PI. The range is constructed from minPhi to maxPhi around their average.";
}

if (usePV_)
vertexToken_ = iC.consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertexTag"));
for(const std::string& quality: cfg.getParameter<std::vector<std::string> >("quality"))
Expand Down Expand Up @@ -80,6 +94,9 @@ class RecoTrackSelectorBase {
return t.algoMask()[algo];
}) == algorithmMask_.end()) algo_ok = false;
}

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

return
(
(algo_ok & quality_ok) &&
Expand All @@ -90,6 +107,7 @@ class RecoTrackSelectorBase {
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_
Expand All @@ -101,6 +119,8 @@ class RecoTrackSelectorBase {
double ptMin_;
double minRapidity_;
double maxRapidity_;
double meanPhi_;
double rangePhi_;
double tip_;
double lip_;
double maxChi2_;
Expand Down
2 changes: 2 additions & 0 deletions CommonTools/RecoAlgos/python/recoTrackSelectorPSet_cfi.py
Expand Up @@ -8,6 +8,8 @@
lip = cms.double(300.0),
ptMin = cms.double(0.1),
maxRapidity = cms.double(5.0),
minPhi = cms.double(-3.2),
maxPhi = cms.double(3.2),
quality = cms.vstring('loose'),
algorithm = cms.vstring(),
originalAlgorithm = cms.vstring(),
Expand Down
Expand Up @@ -12,7 +12,9 @@
lip = cms.double(30.0),
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.4),
minHit = cms.int32(0)
minHit = cms.int32(0),
minPhi = cms.double(-3.2),
maxPhi = cms.double(3.2),
)


Expand Down
9 changes: 9 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Expand Up @@ -181,6 +181,14 @@ def customiseFor19181_pixel_phase0(process):
producer.ClusterThreshold_L1 = cms.int32(4000)
return process

# Add new parameters to RecoTrackRefSelector
def customiseFor19029(process):
for producer in producers_by_type(process, "RecoTrackRefSelector"):
if not hasattr(producer, "minPhi"):
producer.minPhi = cms.double(-3.2)
producer.maxPhi = cms.double(3.2)
return process

def customiseFor19181_pixel_phase1(process):
for producer in producers_by_type(process, "SiPixelClusterProducer"):
producer.VCaltoElectronGain = cms.int32(47)
Expand Down Expand Up @@ -211,5 +219,6 @@ def customizeHLTforCMSSW(process, menuType="GRun"):
process = customiseFor19181_pixel_phase0(process)
else:
process = customiseFor19181_pixel_phase1(process)
process = customiseFor19029(process)

return process
Expand Up @@ -12,7 +12,9 @@
lip = cms.double(30.0),
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.4),
minHit = cms.int32(0)
minHit = cms.int32(0),
minPhi = cms.double(-3.2),
maxPhi = cms.double(3.2),
)


Expand Down
25 changes: 22 additions & 3 deletions SimTracker/Common/interface/TrackingParticleSelector.h
Expand Up @@ -11,16 +11,29 @@
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/Math/interface/PtEtaPhiMass.h"
#include "DataFormats/Math/interface/deltaPhi.h"

class TrackingParticleSelector {

public:
TrackingParticleSelector(){}
TrackingParticleSelector ( double ptMin,double minRapidity,double maxRapidity,
double tip,double lip,int minHit, bool signalOnly, bool intimeOnly, bool chargedOnly, bool stableOnly,
const std::vector<int>& pdgId = std::vector<int>()) :
const std::vector<int>& pdgId = std::vector<int>(),
double minPhi=-3.2, double maxPhi=3.2) :
ptMin2_( ptMin*ptMin ), minRapidity_( minRapidity ), maxRapidity_( maxRapidity ),
tip2_( tip*tip ), lip_( lip ), minHit_( minHit ), signalOnly_(signalOnly), intimeOnly_(intimeOnly), chargedOnly_(chargedOnly), stableOnly_(stableOnly), pdgId_( pdgId ) { }
meanPhi_((minPhi+maxPhi)/2.), rangePhi_((maxPhi-minPhi)/2.),
tip2_( tip*tip ), lip_( lip ), minHit_( minHit ), signalOnly_(signalOnly), intimeOnly_(intimeOnly), chargedOnly_(chargedOnly), stableOnly_(stableOnly), pdgId_( pdgId ) {
if(minPhi >= maxPhi) {
throw cms::Exception("Configuration") << "TrackingParticleSelector: 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") << "TrackingParticleSelector: 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") << "TrackingParticleSelector: 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 TrackingParticle & tp ) const {
Expand Down Expand Up @@ -56,10 +69,12 @@ class TrackingParticleSelector {
}

auto etaOk = [&](const TrackingParticle& p)->bool{ float eta= etaFromXYZ(p.px(),p.py(),p.pz()); return (eta>= minRapidity_) & (eta<=maxRapidity_);};
auto phiOk = [&](const TrackingParticle& p) { float dphi = deltaPhi(atan2f(p.py(),p.px()), meanPhi_); return dphi >= -rangePhi_ && dphi <= rangePhi_; };
return (
tp.numberOfTrackerLayers() >= minHit_ &&
tp.p4().perp2() >= ptMin2_ &&
etaOk(tp) &&
phiOk(tp) &&
std::abs(tp.vertex().z()) <= lip_ && // vertex last to avoid to load it if not striclty necessary...
tp.vertex().perp2() <= tip2_
);
Expand All @@ -69,6 +84,8 @@ class TrackingParticleSelector {
double ptMin2_;
float minRapidity_;
float maxRapidity_;
float meanPhi_;
float rangePhi_;
double tip2_;
double lip_;
int minHit_;
Expand Down Expand Up @@ -100,7 +117,9 @@ namespace reco {
cfg.getParameter<bool>( "intimeOnly" ),
cfg.getParameter<bool>( "chargedOnly" ),
cfg.getParameter<bool>( "stableOnly" ),
cfg.getParameter<std::vector<int> >( "pdgId" ));
cfg.getParameter<std::vector<int> >( "pdgId" ),
cfg.getParameter<double>( "minPhi" ),
cfg.getParameter<double>( "maxPhi" ));
}
};

Expand Down
Expand Up @@ -11,7 +11,9 @@
minHit = cms.int32(0),
ptMin = cms.double(0.9),
maxRapidity = cms.double(2.5),
tip = cms.double(3.5)
tip = cms.double(3.5),
minPhi = cms.double(-3.2),
maxPhi = cms.double(3.2),
)

from Configuration.Eras.Modifier_fastSim_cff import fastSim
Expand Down

0 comments on commit b4e8e82

Please sign in to comment.