Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-23 22:40:21

0001 #include "RecoVertex/PrimaryVertexProducer/interface/TrackFilterForPVFinding.h"
0002 #include <cmath>
0003 
0004 TrackFilterForPVFinding::TrackFilterForPVFinding(const edm::ParameterSet& conf) {
0005   maxD0Sig_ = conf.getParameter<double>("maxD0Significance");
0006   maxD0Error_ = conf.getParameter<double>("maxD0Error");
0007   maxDzError_ = conf.getParameter<double>("maxDzError");
0008   minPt_ = conf.getParameter<double>("minPt");
0009   maxEta_ = conf.getParameter<double>("maxEta");
0010   maxNormChi2_ = conf.getParameter<double>("maxNormalizedChi2");
0011   minSiLayers_ = conf.getParameter<int>("minSiliconLayersWithHits");
0012   minPxLayers_ = conf.getParameter<int>("minPixelLayersWithHits");
0013 
0014   // the next few lines are taken from RecoBTag/SecondaryVertex/interface/TrackSelector.h"
0015   std::string qualityClass = conf.getParameter<std::string>("trackQuality");
0016   if (qualityClass == "any" || qualityClass == "Any" || qualityClass == "ANY" || qualityClass.empty()) {
0017     quality_ = reco::TrackBase::undefQuality;
0018   } else {
0019     quality_ = reco::TrackBase::qualityByName(qualityClass);
0020   }
0021 }
0022 
0023 // select a single track
0024 bool TrackFilterForPVFinding::operator()(const reco::TransientTrack& tk) const {
0025   if (!tk.stateAtBeamLine().isValid())
0026     return false;
0027   bool IPSigCut = (tk.stateAtBeamLine().transverseImpactParameter().significance() < maxD0Sig_) &&
0028                   (tk.stateAtBeamLine().transverseImpactParameter().error() < maxD0Error_) &&
0029                   (tk.track().dzError() < maxDzError_);
0030   bool pTCut = tk.impactPointState().globalMomentum().transverse() > minPt_;
0031   bool etaCut = std::fabs(tk.impactPointState().globalMomentum().eta()) < maxEta_;
0032   bool normChi2Cut = tk.normalizedChi2() < maxNormChi2_;
0033   bool nPxLayCut = tk.hitPattern().pixelLayersWithMeasurement() >= minPxLayers_;
0034   bool nSiLayCut = tk.hitPattern().trackerLayersWithMeasurement() >= minSiLayers_;
0035   bool trackQualityCut = (quality_ == reco::TrackBase::undefQuality) || tk.track().quality(quality_);
0036 
0037   return IPSigCut && pTCut && etaCut && normChi2Cut && nPxLayCut && nSiLayCut && trackQualityCut;
0038 }
0039 
0040 // select the vector of tracks that pass the filter cuts
0041 std::vector<reco::TransientTrack> TrackFilterForPVFinding::select(
0042     const std::vector<reco::TransientTrack>& tracks) const {
0043   std::vector<reco::TransientTrack> seltks;
0044   for (std::vector<reco::TransientTrack>::const_iterator itk = tracks.begin(); itk != tracks.end(); itk++) {
0045     if (operator()(*itk))
0046       seltks.push_back(*itk);  //  calls the filter function for single tracks
0047   }
0048   return seltks;
0049 }
0050 
0051 // select the vector of tracks that pass the filter cuts with a tighter pt selection
0052 std::vector<reco::TransientTrack> TrackFilterForPVFinding::selectTight(const std::vector<reco::TransientTrack>& tracks,
0053                                                                        double minPtTight) const {
0054   std::vector<reco::TransientTrack> seltks;
0055   for (std::vector<reco::TransientTrack>::const_iterator itk = tracks.begin(); itk != tracks.end(); itk++) {
0056     if (itk->impactPointState().globalMomentum().transverse() < minPtTight)
0057       continue;
0058     if (operator()(*itk))
0059       seltks.push_back(*itk);  //  calls the filter function for single tracks
0060   }
0061   return seltks;
0062 }
0063 
0064 void TrackFilterForPVFinding::fillPSetDescription(edm::ParameterSetDescription& desc) {
0065   desc.add<double>("maxNormalizedChi2", 10.0);
0066   desc.add<double>("minPt", 0.0);
0067   desc.add<std::string>("algorithm", "filter");
0068   desc.add<double>("maxEta", 2.4);
0069   desc.add<double>("maxD0Significance", 4.0);
0070   desc.add<double>("maxD0Error", 1.0);
0071   desc.add<double>("maxDzError", 1.0);
0072   desc.add<std::string>("trackQuality", "any");
0073   desc.add<int>("minPixelLayersWithHits", 2);
0074   desc.add<int>("minSiliconLayersWithHits", 5);
0075 }