CMS 3D CMS Logo

PFRecoTauDiscriminationByNProngs.cc
Go to the documentation of this file.
5 
6 #include <memory>
7 
11 
12 /* class PFRecoTauDiscriminationByNProngs
13  * created : August 30 2010,
14  * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki)
15  * based on H+ tau ID by Lauri Wendland
16  * Modified April 16 2014 by S.Lehti
17  */
18 
19 using namespace reco;
20 using namespace std;
21 using namespace edm;
22 
24 public:
27 
28  void beginEvent(const edm::Event&, const edm::EventSetup&) override;
29  double discriminate(const reco::PFTauRef&) const override;
30 
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33 private:
34  std::unique_ptr<tau::RecoTauQualityCuts> qcuts_;
35  std::unique_ptr<tau::RecoTauVertexAssociator> vertexAssociator_;
36 
37  uint32_t minN, maxN;
40 };
41 
43  : PFTauDiscriminationProducerBase(iConfig), qualityCuts(iConfig.getParameterSet("qualityCuts")) {
44  minN = iConfig.getParameter<uint32_t>("MinN");
45  maxN = iConfig.getParameter<uint32_t>("MaxN");
46  booleanOutput = iConfig.getParameter<bool>("BooleanOutput");
47 
48  qcuts_ = std::make_unique<tau::RecoTauQualityCuts>(qualityCuts.getParameterSet("signalQualityCuts"));
49  vertexAssociator_ = std::make_unique<tau::RecoTauVertexAssociator>(qualityCuts, consumesCollector());
50 }
51 
53  vertexAssociator_->setEvent(iEvent);
54 }
55 
57  reco::VertexRef pv = vertexAssociator_->associatedVertex(*tau);
58  const CandidatePtr leadingTrack = tau->leadChargedHadrCand();
59 
60  uint np = 0;
61  if (leadingTrack.isNonnull() && pv.isNonnull()) {
62  qcuts_->setPV(pv);
63  qcuts_->setLeadTrack(*tau->leadChargedHadrCand());
64 
65  for (auto const& cand : tau->signalChargedHadrCands()) {
66  if (qcuts_->filterCandRef(cand))
67  np++;
68  }
69  }
70 
71  bool accepted = false;
72  if (maxN == 0) {
73  if (np == 1 || np == 3)
74  accepted = true;
75  } else {
76  if (np >= minN && np <= maxN)
77  accepted = true;
78  }
79 
80  if (!accepted)
81  np = 0;
82  if (booleanOutput)
83  return accepted;
84  return np;
85 }
86 
88  // pfRecoTauDiscriminationByNProngs
90 
91  edm::ParameterSetDescription desc_qualityCuts;
93  desc.add<edm::ParameterSetDescription>("qualityCuts", desc_qualityCuts);
94 
95  {
97  psd0.add<std::string>("BooleanOperator", "and");
98  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
99  }
100 
101  desc.add<bool>("BooleanOutput", true);
102  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("combinatoricRecoTaus"));
103  desc.add<unsigned int>("MinN", 1);
104  desc.add<unsigned int>("MaxN", 0);
105  descriptions.add("pfRecoTauDiscriminationByNProngs", desc);
106 }
107 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ParameterSetDescription &descriptions)
Declare all parameters read from python config file.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterSet const & getParameterSet(std::string const &) const
std::unique_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
int iEvent
Definition: GenABIO.cc:224
double discriminate(const reco::PFTauRef &) const override
int np
Definition: AMPTWrapper.h:43
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:148
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void beginEvent(const edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ParameterSet const & getParameterSet(ParameterSetID const &id)
fixed size matrix
HLT enums.
std::unique_ptr< tau::RecoTauQualityCuts > qcuts_