CMS 3D CMS Logo

PFRecoTauDiscriminationAgainstMuon.cc
Go to the documentation of this file.
1 /*
2  * class PFRecoTauDiscriminationAgainstMuon
3  * created : May 07 2008,
4  * revised : always,
5  * Authors : Sho Maruyama,M.Bachtis
6  */
7 
10 
12 
16 
17 #include <string>
18 
19 using namespace reco;
20 
22 public:
25  discriminatorOption_ = iConfig.getParameter<std::string>("discriminatorOption");
26  hop_ = iConfig.getParameter<double>("HoPMin");
27  a = iConfig.getParameter<double>("a");
28  b = iConfig.getParameter<double>("b");
29  c = iConfig.getParameter<double>("c");
30  maxNumberOfMatches_ = iConfig.getParameter<int>("maxNumberOfMatches");
31  checkNumMatches_ = iConfig.getParameter<bool>("checkNumMatches");
32  }
33 
35 
36  double discriminate(const PFTauRef& pfTau) const override;
37 
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
39 
40 private:
42  double hop_;
43  double a;
44  double b;
45  double c;
48 };
49 
51  bool decision = true;
52 
53  if (thePFTauRef->hasMuonReference()) {
54  MuonRef muonref = thePFTauRef->leadPFChargedHadrCand()->muonRef();
55  if (discriminatorOption_ == "noSegMatch") {
56  if (muonref->numberOfMatches() > maxNumberOfMatches_)
57  decision = false;
58  } else if (discriminatorOption_ == "twoDCut") {
59  double seg = muon::segmentCompatibility(*muonref);
60  double calo = muonref->caloCompatibility();
61  double border = calo * a + seg * b + c;
62  if (border > 0)
63  decision = false;
64  } else if (discriminatorOption_ == "merePresence") {
65  decision = false;
66  } else if (discriminatorOption_ == "combined") { // testing purpose only
67  unsigned int muType = 0;
68  if (muonref->isGlobalMuon())
69  muType = 1;
70  else if (muonref->isCaloMuon())
71  muType = 2;
72  else if (muonref->isTrackerMuon())
73  muType = 3;
74  float muonEnergyFraction = 0.;
75  const reco::PFJet* pfJetPtr = dynamic_cast<const reco::PFJet*>(thePFTauRef->pfTauTagInfoRef()->pfjetRef().get());
76  if (pfJetPtr) {
78  } else
79  throw cms::Exception("Type Mismatch") << "The PFTau was not made from PFJets, and this outdated algorithm was "
80  "not updated to cope with PFTaus made from other Jets.\n";
81  bool eta_veto = false;
82  bool phi_veto = false;
83  if (fabs(muonref->eta()) > 2.3 || (fabs(muonref->eta()) > 1.4 && fabs(muonref->eta()) < 1.6))
84  eta_veto = true;
85  if (muonref->phi() < 0.1 && muonref->phi() > -0.1)
86  phi_veto = true;
87  if (muType != 1 || muonref->numberOfMatches() > 0 || eta_veto || phi_veto || muonEnergyFraction > 0.9)
88  decision = false; // as place holder
89  } else if (discriminatorOption_ == "noAllArbitrated" || discriminatorOption_ == "noAllArbitratedWithHOP") {
90  if (checkNumMatches_ && muonref->numberOfMatches() > maxNumberOfMatches_)
91  decision = false;
93  decision = false;
94  } else if (discriminatorOption_ == "HOP") {
95  decision = true; // only calo. muon cut requested: keep all tau candidates, regardless of signals in muon system
96  } else {
98  << " Invalid Discriminator option = " << discriminatorOption_ << " --> please check cfi file !!\n";
99  }
100  } // valid muon ref
101 
102  // Additional calo. muon cut: veto one prongs compatible with MIP signature
103  if (discriminatorOption_ == "HOP" || discriminatorOption_ == "noAllArbitratedWithHOP") {
104  if (thePFTauRef->leadPFChargedHadrCand().isNonnull()) {
105  double muonCaloEn =
106  thePFTauRef->leadPFChargedHadrCand()->hcalEnergy() + thePFTauRef->leadPFChargedHadrCand()->ecalEnergy();
107  if (thePFTauRef->decayMode() == 0 && muonCaloEn < (hop_ * thePFTauRef->leadPFChargedHadrCand()->p()))
108  decision = false;
109  }
110  }
111 
112  return (decision ? 1. : 0.);
113 }
114 
116  // pfRecoTauDiscriminationAgainstMuon
118  desc.add<double>("a", 0.5);
119  desc.add<double>("c", 0.0);
120  desc.add<double>("b", 0.5);
121  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfRecoTauProducer"));
122  {
124  psd0.add<std::string>("BooleanOperator", "and");
125  {
127  psd1.add<double>("cut");
128  psd1.add<edm::InputTag>("Producer");
129  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
130  }
131  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
132  }
133  desc.add<std::string>("discriminatorOption", "noSegMatch");
134  desc.add<double>("HoPMin", 0.2);
135  desc.add<int>("maxNumberOfMatches", 0);
136  desc.add<bool>("checkNumMatches", false);
137  descriptions.add("pfRecoTauDiscriminationAgainstMuon", desc);
138 }
139 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
Jets made from PFObjects.
Definition: PFJet.h:20
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double b
Definition: hdecay.h:120
void add(std::string const &label, ParameterSetDescription const &psetDescription)
PFRecoTauDiscriminationAgainstMuon(const edm::ParameterSet &iConfig)
double discriminate(const PFTauRef &pfTau) const override
fixed size matrix
double a
Definition: hdecay.h:121
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
Definition: Common.h:9
float chargedMuEnergyFraction() const
chargedMuEnergyFraction
Definition: PFJet.h:145