Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:42

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "RecoParticleFlow/PFTracking/interface/PFTrackAlgoTools.h"
0003 
0004 namespace PFTrackAlgoTools {
0005 
0006   double dPtCut(const reco::TrackBase::TrackAlgorithm& algo,
0007                 const std::vector<double>& cuts,
0008                 bool hltIterativeTracking = true) {
0009     switch (algo) {
0010       case reco::TrackBase::ctf:
0011       case reco::TrackBase::duplicateMerge:
0012       case reco::TrackBase::initialStep:
0013       case reco::TrackBase::highPtTripletStep:
0014       case reco::TrackBase::lowPtQuadStep:
0015       case reco::TrackBase::lowPtTripletStep:
0016       case reco::TrackBase::pixelPairStep:
0017       case reco::TrackBase::jetCoreRegionalStep:
0018         return cuts[0];
0019       case reco::TrackBase::detachedQuadStep:
0020       case reco::TrackBase::detachedTripletStep:
0021         return cuts[1];
0022       case reco::TrackBase::mixedTripletStep:
0023         return cuts[2];
0024       case reco::TrackBase::pixelLessStep:
0025         return cuts[3];
0026       case reco::TrackBase::tobTecStep:
0027         return cuts[4];
0028       case reco::TrackBase::muonSeededStepInOut:
0029       case reco::TrackBase::muonSeededStepOutIn:
0030         return cuts.at(5);
0031       case reco::TrackBase::hltIter0:
0032       case reco::TrackBase::hltIter1:
0033       case reco::TrackBase::hltIter2:
0034         return cuts[0];
0035       case reco::TrackBase::hltIter3:
0036         return hltIterativeTracking ? cuts[1] : cuts[0];
0037       case reco::TrackBase::hltIter4:
0038         return hltIterativeTracking ? cuts[2] : cuts[0];
0039       case reco::TrackBase::hltIterX:
0040         return cuts[0];
0041       default:
0042         return hltIterativeTracking ? cuts.at(5) : cuts[0];
0043     }
0044   }
0045 
0046   unsigned int nHitCut(const reco::TrackBase::TrackAlgorithm& algo,
0047                        const std::vector<unsigned int>& cuts,
0048                        bool hltIterativeTracking = true) {
0049     switch (algo) {
0050       case reco::TrackBase::ctf:
0051       case reco::TrackBase::duplicateMerge:
0052       case reco::TrackBase::initialStep:
0053       case reco::TrackBase::highPtTripletStep:
0054       case reco::TrackBase::lowPtQuadStep:
0055       case reco::TrackBase::lowPtTripletStep:
0056       case reco::TrackBase::pixelPairStep:
0057       case reco::TrackBase::jetCoreRegionalStep:
0058         return cuts[0];
0059       case reco::TrackBase::detachedQuadStep:
0060       case reco::TrackBase::detachedTripletStep:
0061         return cuts[1];
0062       case reco::TrackBase::mixedTripletStep:
0063         return cuts[2];
0064       case reco::TrackBase::pixelLessStep:
0065         return cuts[3];
0066       case reco::TrackBase::tobTecStep:
0067         return cuts[4];
0068       case reco::TrackBase::muonSeededStepInOut:
0069       case reco::TrackBase::muonSeededStepOutIn:
0070         return cuts.at(5);
0071       case reco::TrackBase::hltIter0:
0072       case reco::TrackBase::hltIter1:
0073       case reco::TrackBase::hltIter2:
0074         return cuts[0];
0075       case reco::TrackBase::hltIter3:
0076         return hltIterativeTracking ? cuts[1] : cuts[0];
0077       case reco::TrackBase::hltIter4:
0078         return hltIterativeTracking ? cuts[2] : cuts[0];
0079       case reco::TrackBase::hltIterX:
0080         return cuts[0];
0081       default:
0082         return hltIterativeTracking ? cuts.at(5) : cuts[0];
0083     }
0084   }
0085 
0086   double errorScale(const reco::TrackBase::TrackAlgorithm& algo, const std::vector<double>& errorScale) {
0087     switch (algo) {
0088       case reco::TrackBase::ctf:
0089       case reco::TrackBase::duplicateMerge:
0090       case reco::TrackBase::initialStep:
0091       case reco::TrackBase::highPtTripletStep:
0092       case reco::TrackBase::lowPtQuadStep:
0093       case reco::TrackBase::lowPtTripletStep:
0094       case reco::TrackBase::pixelPairStep:
0095       case reco::TrackBase::jetCoreRegionalStep:
0096       case reco::TrackBase::muonSeededStepInOut:
0097       case reco::TrackBase::muonSeededStepOutIn:
0098       case reco::TrackBase::detachedQuadStep:
0099       case reco::TrackBase::detachedTripletStep:
0100       case reco::TrackBase::mixedTripletStep:
0101       case reco::TrackBase::hltIter0:
0102       case reco::TrackBase::hltIter1:
0103       case reco::TrackBase::hltIter2:
0104       case reco::TrackBase::hltIter3:
0105       case reco::TrackBase::hltIter4:
0106       case reco::TrackBase::hltIterX:
0107         return 1.0;
0108       case reco::TrackBase::pixelLessStep:
0109         return errorScale[0];
0110       case reco::TrackBase::tobTecStep:
0111         return errorScale[1];
0112       default:
0113         return 1E9;
0114     }
0115   }
0116 
0117   bool isGoodForEGM(const reco::TrackBase::TrackAlgorithm& algo) {
0118     switch (algo) {
0119       case reco::TrackBase::ctf:
0120       case reco::TrackBase::duplicateMerge:
0121       case reco::TrackBase::initialStep:
0122       case reco::TrackBase::highPtTripletStep:
0123       case reco::TrackBase::lowPtQuadStep:
0124       case reco::TrackBase::lowPtTripletStep:
0125       case reco::TrackBase::pixelPairStep:
0126       case reco::TrackBase::jetCoreRegionalStep:
0127       case reco::TrackBase::detachedQuadStep:
0128       case reco::TrackBase::detachedTripletStep:
0129       case reco::TrackBase::mixedTripletStep:
0130       case reco::TrackBase::muonSeededStepInOut:
0131       case reco::TrackBase::muonSeededStepOutIn:
0132       case reco::TrackBase::hltIter0:
0133       case reco::TrackBase::hltIter1:
0134       case reco::TrackBase::hltIter2:
0135       case reco::TrackBase::hltIter3:
0136       case reco::TrackBase::hltIter4:
0137       case reco::TrackBase::hltIterX:
0138         return true;
0139       default:
0140         return false;
0141     }
0142   }
0143 
0144   bool isGoodForEGMPrimary(const reco::TrackBase::TrackAlgorithm& algo) {
0145     switch (algo) {
0146       case reco::TrackBase::ctf:
0147       case reco::TrackBase::duplicateMerge:
0148       case reco::TrackBase::cosmics:
0149       case reco::TrackBase::initialStep:
0150       case reco::TrackBase::highPtTripletStep:
0151       case reco::TrackBase::lowPtQuadStep:
0152       case reco::TrackBase::lowPtTripletStep:
0153       case reco::TrackBase::pixelPairStep:
0154       case reco::TrackBase::detachedQuadStep:
0155       case reco::TrackBase::detachedTripletStep:
0156       case reco::TrackBase::mixedTripletStep:
0157         return true;
0158       default:
0159         return false;
0160     }
0161   }
0162 
0163   bool isFifthStep(const reco::TrackBase::TrackAlgorithm& algo) {
0164     switch (algo) {
0165       case reco::TrackBase::ctf:
0166       case reco::TrackBase::duplicateMerge:
0167       case reco::TrackBase::initialStep:
0168       case reco::TrackBase::highPtTripletStep:
0169       case reco::TrackBase::lowPtQuadStep:
0170       case reco::TrackBase::lowPtTripletStep:
0171       case reco::TrackBase::pixelPairStep:
0172       case reco::TrackBase::jetCoreRegionalStep:
0173       case reco::TrackBase::detachedQuadStep:
0174       case reco::TrackBase::detachedTripletStep:
0175       case reco::TrackBase::mixedTripletStep:
0176       case reco::TrackBase::pixelLessStep:
0177       case reco::TrackBase::muonSeededStepInOut:
0178       case reco::TrackBase::muonSeededStepOutIn:
0179       case reco::TrackBase::hltIter0:
0180       case reco::TrackBase::hltIter1:
0181       case reco::TrackBase::hltIter2:
0182       case reco::TrackBase::hltIter3:
0183       case reco::TrackBase::hltIter4:
0184       case reco::TrackBase::hltIterX:
0185         return false;
0186       case reco::TrackBase::tobTecStep:
0187         return true;
0188       default:
0189         return true;
0190     }
0191   }
0192 
0193   bool highQuality(const reco::TrackBase::TrackAlgorithm& algo) {
0194     switch (algo) {
0195       case reco::TrackBase::initialStep:
0196       case reco::TrackBase::highPtTripletStep:
0197       case reco::TrackBase::lowPtQuadStep:
0198       case reco::TrackBase::lowPtTripletStep:
0199       case reco::TrackBase::pixelPairStep:
0200       case reco::TrackBase::detachedQuadStep:
0201       case reco::TrackBase::detachedTripletStep:
0202       case reco::TrackBase::duplicateMerge:
0203       case reco::TrackBase::jetCoreRegionalStep:
0204         return true;
0205       default:
0206         return false;
0207     }
0208   }
0209 
0210   bool nonIterative(const reco::TrackBase::TrackAlgorithm& algo) {
0211     switch (algo) {
0212       case reco::TrackBase::undefAlgorithm:
0213       case reco::TrackBase::ctf:
0214       case reco::TrackBase::cosmics:
0215         return true;
0216       default:
0217         return false;
0218     }
0219   }
0220 
0221   bool step45(const reco::TrackBase::TrackAlgorithm& algo) {
0222     switch (algo) {
0223       case reco::TrackBase::mixedTripletStep:
0224       case reco::TrackBase::pixelLessStep:
0225       case reco::TrackBase::tobTecStep:
0226         return true;
0227       default:
0228         return false;
0229     }
0230   }
0231 
0232   bool step5(const reco::TrackBase::TrackAlgorithm& algo) {
0233     return (algo == reco::TrackBase::tobTecStep || algo == reco::TrackBase::pixelLessStep);
0234   }
0235 
0236   bool goodPtResolution(const reco::TrackRef& trackref,
0237                         const std::vector<double>& DPtovPtCut,
0238                         const std::vector<unsigned>& NHitCut,
0239                         bool useIterTracking,
0240                         reco::TrackBase::TrackQuality trackQuality) {
0241     //check quality of tracks
0242     if (!trackref->quality(trackQuality))
0243       return false;
0244 
0245     const double p = trackref->p();
0246     const double pT = trackref->pt();
0247     const double dpT = trackref->ptError();
0248     const unsigned int nHit = trackref->hitPattern().trackerLayersWithMeasurement();
0249     const unsigned int nLostHit = trackref->hitPattern().trackerLayersWithoutMeasurement(reco::HitPattern::TRACK_HITS);
0250     const unsigned int lostHits = trackref->numberOfLostHits();
0251     const double sigmaHad = std::sqrt(1.20 * 1.20 / p + 0.06 * 0.06) / (1. + lostHits);
0252 
0253     // Protection against 0 momentum tracks
0254     if (p < 0.05)
0255       return false;
0256 
0257     LogDebug("goodPtResolution") << " PFBlockAlgo: PFrecTrack->Track Pt= " << pT << " DPt = " << dpT << std::endl;
0258 
0259     double dptCut = dPtCut(trackref->algo(), DPtovPtCut, useIterTracking);
0260     unsigned int nhitCut = nHitCut(trackref->algo(), NHitCut, useIterTracking);
0261 
0262     if ((dptCut > 0. && dpT / pT > dptCut * sigmaHad) || nHit < nhitCut) {
0263       LogDebug("goodPtResolution") << " PFBlockAlgo: skip badly measured track"
0264                                    << ", P = " << p << ", Pt = " << pT << " DPt = " << dpT << ", N(hits) = " << nHit
0265                                    << " (Lost : " << lostHits << "/" << nLostHit << ")"
0266                                    << ", Algo = " << trackref->algo() << std::endl;
0267       LogDebug("goodPtResolution") << " cut is DPt/Pt < " << dptCut * sigmaHad << std::endl;
0268       LogDebug("goodPtResolution") << " cut is NHit >= " << nhitCut << std::endl;
0269       return false;
0270     }
0271 
0272     return true;
0273   }
0274 
0275 }  // namespace PFTrackAlgoTools