File indexing completed on 2024-04-06 12:24:56
0001 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTrackSelector.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
0004
0005 using namespace egammaisolation;
0006 using namespace reco;
0007
0008 namespace {
0009 template <class T>
0010 bool inside(const T& value, std::pair<T, T> const& range) {
0011 return value >= range.first && range.second >= value;
0012 }
0013 }
0014
0015 EgammaTrackSelector::result_type EgammaTrackSelector::operator()(const EgammaTrackSelector::input_type& tracks) const {
0016 static const std::string metname = "EgammaIsolationAlgos|EgammaTrackSelector";
0017 result_type result;
0018 for (input_type::const_iterator it = tracks.begin(); it != tracks.end(); it++) {
0019
0020
0021
0022
0023 float tZ;
0024 switch (thePars.dzOption) {
0025 case dz:
0026 tZ = it->dz();
0027 break;
0028 case vz:
0029 tZ = it->vz();
0030 break;
0031 case bs:
0032 tZ = it->dz(thePars.beamPoint);
0033 break;
0034 default:
0035 tZ = it->vz();
0036 break;
0037 }
0038
0039 float tPt = it->pt();
0040
0041 float tD0Cor = fabs(it->dxy(thePars.beamPoint));
0042 float tEta = it->eta();
0043 float tPhi = it->phi();
0044 float tChi2Ndof = it->normalizedChi2();
0045
0046
0047
0048 if (!inside(tZ, thePars.zRange))
0049 continue;
0050 if (tPt < thePars.ptMin)
0051 continue;
0052 if (!inside(tD0Cor, thePars.rRange))
0053 continue;
0054 if (thePars.dir.deltaR(reco::isodeposit::Direction(tEta, tPhi)) > thePars.drMax)
0055 continue;
0056 if (tChi2Ndof > thePars.chi2NdofMax)
0057 continue;
0058
0059
0060 if (thePars.nHitsMin > 0) {
0061 unsigned int tHits = it->numberOfValidHits();
0062 if (tHits < thePars.nHitsMin)
0063 continue;
0064 }
0065
0066
0067 if (thePars.chi2ProbMin > 0) {
0068 float tChi2Prob = ChiSquaredProbability(it->chi2(), it->ndof());
0069 if (tChi2Prob < thePars.chi2ProbMin)
0070 continue;
0071 }
0072 result.push_back(&*it);
0073 }
0074 return result;
0075 }