Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-12 03:21:14

0001 #include "Calibration/IsolatedParticles/interface/TrackSelection.h"
0002 #include "DataFormats/TrackReco/interface/HitPattern.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include <sstream>
0006 
0007 namespace spr {
0008 
0009   bool goodTrack(const reco::Track* pTrack,
0010                  math::XYZPoint leadPV,
0011                  spr::trackSelectionParameters parameters,
0012                  bool debug) {
0013     bool select = pTrack->quality(parameters.minQuality);
0014     double dxy = pTrack->dxy(leadPV);
0015     double dz = pTrack->dz(leadPV);
0016     double dpbyp = 999;
0017     if (std::abs(pTrack->qoverp()) > 0.0000001)
0018       dpbyp = std::abs(pTrack->qoverpError() / pTrack->qoverp());
0019 
0020     if (debug)
0021       edm::LogVerbatim("IsoTrack") << "Track:: Pt " << pTrack->pt() << " dxy " << dxy << " dz " << dz << " Chi2 "
0022                                    << pTrack->normalizedChi2() << " dpbyp " << dpbyp << " Quality " << select;
0023 
0024     if (pTrack->pt() < parameters.minPt)
0025       select = false;
0026     if (dxy > parameters.maxDxyPV || dz > parameters.maxDzPV)
0027       select = false;
0028     if (pTrack->normalizedChi2() > parameters.maxChi2)
0029       select = false;
0030     if (dpbyp > parameters.maxDpOverP)
0031       select = false;
0032 
0033     if (parameters.minLayerCrossed > 0 || parameters.minOuterHit > 0) {
0034       const reco::HitPattern& hitp = pTrack->hitPattern();
0035       if (parameters.minLayerCrossed > 0 && hitp.trackerLayersWithMeasurement() < parameters.minLayerCrossed)
0036         select = false;
0037       if (parameters.minOuterHit > 0 &&
0038           (hitp.stripTOBLayersWithMeasurement() + hitp.stripTECLayersWithMeasurement()) < parameters.minOuterHit)
0039         select = false;
0040 
0041       if (debug) {
0042         edm::LogVerbatim("IsoTrack") << "Default Hit Pattern with "
0043                                      << hitp.numberOfAllHits(reco::HitPattern::TRACK_HITS) << " hits";
0044         for (int i = 0; i < hitp.numberOfAllHits(reco::HitPattern::TRACK_HITS); i++) {
0045           std::ostringstream st1;
0046           hitp.printHitPattern(reco::HitPattern::TRACK_HITS, i, st1);
0047           edm::LogVerbatim("IsoTrack") << st1.str();
0048         }
0049       }
0050     }
0051     if (parameters.maxInMiss >= 0) {
0052       const reco::HitPattern& hitp = pTrack->hitPattern();
0053       if (hitp.trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_INNER_HITS) > parameters.maxInMiss)
0054         select = false;
0055       if (debug) {
0056         edm::LogVerbatim("IsoTrack") << "Inner Hit Pattern with "
0057                                      << hitp.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS) << " hits";
0058         for (int i = 0; i < hitp.numberOfAllHits(reco::HitPattern::MISSING_INNER_HITS); i++) {
0059           std::ostringstream st1;
0060           hitp.printHitPattern(reco::HitPattern::MISSING_INNER_HITS, i, st1);
0061           edm::LogVerbatim("IsoTrack") << st1.str();
0062         }
0063       }
0064     }
0065     if (parameters.maxOutMiss >= 0) {
0066       const reco::HitPattern& hitp = pTrack->hitPattern();
0067       if (hitp.trackerLayersWithoutMeasurement(reco::HitPattern::MISSING_OUTER_HITS) > parameters.maxOutMiss)
0068         select = false;
0069       if (debug) {
0070         edm::LogVerbatim("IsoTrack") << "Outer Hit Pattern with "
0071                                      << hitp.numberOfAllHits(reco::HitPattern::MISSING_OUTER_HITS) << " hits";
0072         for (int i = 0; i < hitp.numberOfAllHits(reco::HitPattern::MISSING_OUTER_HITS); i++) {
0073           std::ostringstream st1;
0074           hitp.printHitPattern(reco::HitPattern::MISSING_OUTER_HITS, i, st1);
0075           edm::LogVerbatim("IsoTrack") << st1.str();
0076         }
0077       }
0078     }
0079     if (debug)
0080       edm::LogVerbatim("IsoTrack") << "Final Selection Result " << select;
0081     return select;
0082   }
0083 }  // namespace spr