Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:05

0001 #include "TrackSelector.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
0004 
0005 using namespace muonisolation;
0006 using namespace reco;
0007 
0008 TrackSelector::result_type TrackSelector::operator()(const TrackSelector::input_type& tracks) const {
0009   static const std::string metname = "MuonIsolation|TrackSelector";
0010   result_type result;
0011   auto const dr2Max = thePars.drMax * thePars.drMax;
0012   for (auto const& tk : tracks) {
0013     //! pick/read variables in order to cut down on unnecessary calls
0014     //! someone will have some fun reading the log if Debug is on
0015     //! the biggest reason is the numberOfValidHits call (the rest are not as costly)
0016 
0017     float tZ = tk.vz();
0018     float tPt = tk.pt();
0019     float tD0 = fabs(tk.d0());
0020     float tD0Cor = fabs(tk.dxy(thePars.beamPoint));
0021     float tChi2Ndof = tk.normalizedChi2();
0022     LogTrace(metname) << "Tk vz: " << tZ << ",  pt: " << tPt << ",  d0: " << tD0 << ",  d0wrtBeam: " << tD0Cor
0023                       << ", eta: " << tk.eta() << ", phi: " << tk.phi() << ", chi2Norm: " << tChi2Ndof;
0024     //! access to the remaining vars is slow
0025 
0026     if (!thePars.zRange.inside(tZ))
0027       continue;
0028     if (tPt < thePars.ptMin)
0029       continue;
0030     if (!thePars.rRange.inside(tD0Cor))
0031       continue;
0032     if (tChi2Ndof > thePars.chi2NdofMax)
0033       continue;
0034     float tEta = tk.eta();
0035     float tPhi = tk.phi();
0036     if (thePars.dir.deltaR2(reco::isodeposit::Direction(tEta, tPhi)) > dr2Max)
0037       continue;
0038 
0039     //! skip if min Hits == 0; assumes any track has at least one valid hit
0040     if (thePars.nHitsMin > 0) {
0041       unsigned int tHits = tk.numberOfValidHits();
0042       LogTrace(metname) << ", nHits: " << tHits;
0043       if (tHits < thePars.nHitsMin)
0044         continue;
0045     }
0046 
0047     //! similarly here
0048     if (thePars.chi2ProbMin > 0) {
0049       float tChi2Prob = ChiSquaredProbability(tk.chi2(), tk.ndof());
0050       LogTrace(metname) << ", chi2Prob: " << tChi2Prob << std::endl;
0051       if (tChi2Prob < thePars.chi2ProbMin)
0052         continue;
0053     }
0054 
0055     LogTrace(metname) << " ..... accepted" << std::endl;
0056     result.push_back(&tk);
0057   }
0058   return result;
0059 }