00001 #include "Calibration/IsolatedParticles/interface/TrackSelection.h" 00002 #include "DataFormats/TrackReco/interface/HitPattern.h" 00003 00004 #include<iostream> 00005 00006 namespace spr{ 00007 00008 bool goodTrack (const reco::Track* pTrack, math::XYZPoint leadPV, spr::trackSelectionParameters parameters, bool debug) { 00009 00010 bool select = pTrack->quality(parameters.minQuality); 00011 double dxy = pTrack->dxy(leadPV); 00012 double dz = pTrack->dz(leadPV); 00013 double dpbyp = 999; 00014 if (std::abs(pTrack->qoverp()) > 0.0000001) 00015 dpbyp = std::abs(pTrack->qoverpError()/pTrack->qoverp()); 00016 00017 if (debug) std::cout << "Track:: Pt " << pTrack->pt() << " dxy " << dxy << " dz " << dz << " Chi2 " << pTrack->normalizedChi2() << " dpbyp " << dpbyp << " Quality " << select << std::endl; 00018 00019 if (pTrack->pt() < parameters.minPt) select = false; 00020 if (dxy > parameters.maxDxyPV || dz > parameters.maxDzPV) select = false; 00021 if (pTrack->normalizedChi2() > parameters.maxChi2) select = false; 00022 if (dpbyp > parameters.maxDpOverP) select = false; 00023 00024 if (parameters.minLayerCrossed>0 || parameters.minOuterHit>0) { 00025 const reco::HitPattern& hitp = pTrack->hitPattern(); 00026 if (parameters.minLayerCrossed>0 && hitp.trackerLayersWithMeasurement() < parameters.minLayerCrossed) select = false; 00027 if (parameters.minOuterHit>0 && (hitp.stripTOBLayersWithMeasurement()+hitp.stripTECLayersWithMeasurement() ) < parameters.minOuterHit) select = false; 00028 if (debug) { 00029 std::cout << "Default Hit Pattern with " << hitp.numberOfHits() << " hits" << std::endl; 00030 for (int i=0; i<hitp.numberOfHits(); i++) 00031 hitp.printHitPattern(i, std::cout); 00032 } 00033 } 00034 if (parameters.maxInMiss >= 0) { 00035 const reco::HitPattern& hitp = pTrack->trackerExpectedHitsInner(); 00036 if (hitp.trackerLayersWithoutMeasurement() > parameters.maxInMiss) select = false; 00037 if (debug) { 00038 std::cout << "Inner Hit Pattern with " << hitp.numberOfHits() << " hits" << std::endl; 00039 for (int i=0; i<hitp.numberOfHits(); i++) 00040 hitp.printHitPattern(i, std::cout); 00041 } 00042 } 00043 if (parameters.maxOutMiss >= 0) { 00044 const reco::HitPattern& hitp = pTrack->trackerExpectedHitsOuter(); 00045 if (hitp.trackerLayersWithoutMeasurement() > parameters.maxOutMiss) select = false; 00046 if (debug) { 00047 std::cout << "Outer Hit Pattern with " << hitp.numberOfHits() << " hits" << std::endl; 00048 for (int i=0; i<hitp.numberOfHits(); i++) 00049 hitp.printHitPattern(i, std::cout); 00050 } 00051 } 00052 if (debug) std::cout << "Final Selection Result " << select << std::endl; 00053 00054 return select; 00055 } 00056 }