CMS 3D CMS Logo

PFRecoTauDiscriminationByInvMass.cc
Go to the documentation of this file.
1 #include <boost/foreach.hpp>
2 
5 
6 /* class PFRecoTauDiscriminationByInvMass
7  * created : August 30 2010,
8  * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki)
9  * contributors : Evan Friis (UC Davis)
10  * based on H+ tau ID by Lauri Wendland
11  */
12 
14  public:
17  // If select is not set, just return the invariant mass
18  cut_ = pset.exists("select");
19  if (cut_) {
21  ("select");
22  // Get default cuts
23  min_default_ = select.getParameter<double>("min");
24  max_default_ = select.getParameter<double>("max");
25  // Get decay mode specific cuts
26  std::vector<std::string> decayModeCutNames =
28  BOOST_FOREACH(const std::string& dmName, decayModeCutNames) {
29  const edm::ParameterSet &dmPSet =
30  select.getParameter<edm::ParameterSet>(dmName);
31  unsigned int nCharged = dmPSet.getParameter<unsigned int>("charged");
32  unsigned int nPiZero = dmPSet.getParameter<unsigned int>("pizeros");
33  double minCut = dmPSet.getParameter<double>("min");
34  double maxCut = dmPSet.getParameter<double>("max");
35  // Add our dm-specific cut to the map
36  decayModeCuts_[std::make_pair(nCharged, nPiZero)] =
37  std::make_pair(minCut, maxCut);
38  }
39  }
40  }
42  double discriminate(const reco::PFTauRef&) const override;
43 
44  private:
45  typedef std::pair<unsigned int, unsigned int> IntPair;
46  typedef std::pair<double, double> DoublePair;
47  typedef std::map<IntPair, DoublePair> DecayModeCutMap;
48  DecayModeCutMap decayModeCuts_;
49  double min_default_;
50  double max_default_;
51  bool cut_;
52 };
53 
54 double
56  double mass = tau->mass();
57  if (cut_) {
58  unsigned int charged = tau->signalPFChargedHadrCands().size();
59  unsigned int pizeros = tau->signalPiZeroCandidates().size();
60  DecayModeCutMap::const_iterator specificCut = decayModeCuts_.find(
61  std::make_pair(charged, pizeros));
62  // Cut does not exist for this decay mode
63  if (specificCut == decayModeCuts_.end() )
64  return (mass > min_default_ && mass < max_default_);
65  else
66  return (mass > specificCut->second.first &&
67  mass < specificCut->second.second);
68  }
69  // If we dont' cut, just return the mass
70  return mass;
71 }
72 
74 
T getParameter(std::string const &) const
std::map< IntPair, DoublePair > DecayModeCutMap
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:194
U second(std::pair< T, U > const &p)
std::pair< unsigned int, unsigned int > IntPair
PFRecoTauDiscriminationByInvMass(const edm::ParameterSet &pset)
double discriminate(const reco::PFTauRef &) const override