CMS 3D CMS Logo

RecoTauDiscriminantInvariantWidth.cc
Go to the documentation of this file.
1 /*
2  * RecoTauDiscriminantInvariantWidth
3  *
4  * Compute a (hopefully) p_T independent quantity related to the
5  * opening angle.
6  *
7  * Author: Evan K. Friis (UC Davis)
8  *
9  */
10 
16 
17 #include <TFormula.h>
18 
19 namespace reco::tau {
20 
22  public:
24  const edm::ParameterSet& pset);
25  std::vector<double> operator()(const reco::PFTauRef& tau) const override;
26  private:
28  typedef boost::shared_ptr<TauFunc> TauFuncPtr;
29  typedef std::pair<TauFuncPtr, TauFuncPtr> MeanAndWidthFuncs;
30 
31  std::map<reco::PFTau::hadronicDecayMode, MeanAndWidthFuncs> transforms_;
32  MeanAndWidthFuncs defaultTransform_;
33 };
34 
37  typedef std::vector<edm::ParameterSet> VPSet;
38  // Add each of the transformations
39  for(auto const& dm : pset.getParameter<VPSet>("decayModes")) {
40  uint32_t nCharged = dm.getParameter<uint32_t>("nCharged");
41  uint32_t nPiZeros = dm.getParameter<uint32_t>("nPiZeros");
43  functions.first.reset(new TauFunc(dm.getParameter<std::string>("mean")));
44  functions.second.reset(new TauFunc(dm.getParameter<std::string>("rms")));
45  transforms_[translateDecayMode(nCharged, nPiZeros)] = functions;
46  }
47  defaultTransform_.first.reset(
48  new TauFunc(pset.getParameter<std::string>("defaultMean")));
49  defaultTransform_.second.reset(
50  new TauFunc(pset.getParameter<std::string>("defaultRMS")));
51 }
52 
54  const reco::PFTauRef& tau) const {
55  double weightedDeltaR = disc::OpeningDeltaR(*tau);
56 
57  std::map<reco::PFTau::hadronicDecayMode, MeanAndWidthFuncs>::const_iterator
58  transform = transforms_.find(tau->decayMode());
59 
60  const TauFunc* meanFunc = defaultTransform_.first.get();
61  const TauFunc* rmsFunc = defaultTransform_.second.get();
62 
63  if (transform != transforms_.end()) {
64  meanFunc = transform->second.first.get();
65  rmsFunc = transform->second.second.get();
66  }
67 
68  double mean = (*meanFunc)(*tau);
69  double rms = (*rmsFunc)(*tau);
70 
71  double result = (rms > 0) ? (weightedDeltaR - mean)/rms : -1.;
72 
73  return std::vector<double>(1, result);
74 }
75 
76 } // end namespace reco::tau
77 
81  "RecoTauDiscriminantInvariantWidth");
T getParameter(std::string const &) const
PFTau::hadronicDecayMode translateDecayMode(unsigned int nCharged, unsigned int nPiZero)
std::vector< double > operator()(const reco::PFTauRef &tau) const override
std::map< reco::PFTau::hadronicDecayMode, MeanAndWidthFuncs > transforms_
#define DEFINE_EDM_PLUGIN(factory, type, name)