CMS 3D CMS Logo

PFRecoTauDiscriminationByNProngs.cc
Go to the documentation of this file.
8 
9 /* class PFRecoTauDiscriminationByNProngs
10  * created : August 30 2010,
11  * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki)
12  * based on H+ tau ID by Lauri Wendland
13  * Modified April 16 2014 by S.Lehti
14  */
15 
16 using namespace reco;
17 using namespace std;
18 using namespace edm;
19 
21  public:
24 
25  void beginEvent(const edm::Event&, const edm::EventSetup&) override;
26  double discriminate(const reco::PFTauRef&) const override;
27 
28  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
29  private:
30  std::unique_ptr<tau::RecoTauQualityCuts> qcuts_;
31  std::unique_ptr<tau::RecoTauVertexAssociator> vertexAssociator_;
32 
33  uint32_t minN,maxN;
36 };
37 
40  qualityCuts(iConfig.getParameterSet("qualityCuts"))
41 {
42  minN = iConfig.getParameter<uint32_t>("MinN");
43  maxN = iConfig.getParameter<uint32_t>("MaxN");
44  booleanOutput = iConfig.getParameter<bool>("BooleanOutput");
45 
46  qcuts_.reset(new tau::RecoTauQualityCuts(qualityCuts.getParameterSet("signalQualityCuts")));
47  vertexAssociator_.reset(new tau::RecoTauVertexAssociator(qualityCuts,consumesCollector()));
48 }
49 
51  vertexAssociator_->setEvent(iEvent);
52 }
53 
55 
56  reco::VertexRef pv = vertexAssociator_->associatedVertex(*tau);
57  const CandidatePtr leadingTrack = tau->leadChargedHadrCand();
58 
59  uint np = 0;
60  if(leadingTrack.isNonnull() && pv.isNonnull()){
61  qcuts_->setPV(pv);
62  qcuts_->setLeadTrack(*tau->leadChargedHadrCand());
63 
64  for(auto const& cand : tau->signalChargedHadrCands() ) {
65  if ( qcuts_->filterCandRef(cand) ) np++;
66  }
67  }
68 
69  bool accepted = false;
70  if(maxN == 0){
71  if(np == 1 || np == 3) accepted = true;
72  }else{
73  if(np >= minN && np <= maxN) accepted = true;
74  }
75 
76  if(!accepted) np = 0;
77  if(booleanOutput) return accepted;
78  return np;
79 }
80 
81 void
83  // pfRecoTauDiscriminationByNProngs
85 
86  {
87  edm::ParameterSetDescription pset_signalQualityCuts;
88  pset_signalQualityCuts.add<double>("maxDeltaZ", 0.4);
89  pset_signalQualityCuts.add<double>("minTrackPt", 0.5);
90  pset_signalQualityCuts.add<double>("minTrackVertexWeight", -1.0);
91  pset_signalQualityCuts.add<double>("maxTrackChi2", 100.0);
92  pset_signalQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
93  pset_signalQualityCuts.add<double>("minGammaEt", 1.0);
94  pset_signalQualityCuts.add<unsigned int>("minTrackHits", 3);
95  pset_signalQualityCuts.add<double>("minNeutralHadronEt", 30.0);
96  pset_signalQualityCuts.add<double>("maxTransverseImpactParameter", 0.1);
97  pset_signalQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
98 
99  edm::ParameterSetDescription pset_vxAssocQualityCuts;
100  pset_vxAssocQualityCuts.add<double>("minTrackPt", 0.5);
101  pset_vxAssocQualityCuts.add<double>("minTrackVertexWeight", -1.0);
102  pset_vxAssocQualityCuts.add<double>("maxTrackChi2", 100.0);
103  pset_vxAssocQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
104  pset_vxAssocQualityCuts.add<double>("minGammaEt", 1.0);
105  pset_vxAssocQualityCuts.add<unsigned int>("minTrackHits", 3);
106  pset_vxAssocQualityCuts.add<double>("maxTransverseImpactParameter", 0.1);
107  pset_vxAssocQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
108 
109  edm::ParameterSetDescription pset_isolationQualityCuts;
110  pset_isolationQualityCuts.add<double>("maxDeltaZ", 0.2);
111  pset_isolationQualityCuts.add<double>("minTrackPt", 1.0);
112  pset_isolationQualityCuts.add<double>("minTrackVertexWeight", -1.0);
113  pset_isolationQualityCuts.add<double>("maxTrackChi2", 100.0);
114  pset_isolationQualityCuts.add<unsigned int>("minTrackPixelHits", 0);
115  pset_isolationQualityCuts.add<double>("minGammaEt", 1.5);
116  pset_isolationQualityCuts.add<unsigned int>("minTrackHits", 8);
117  pset_isolationQualityCuts.add<double>("maxTransverseImpactParameter", 0.03);
118  pset_isolationQualityCuts.addOptional<bool>("useTracksInsteadOfPFHadrons");
119 
120  edm::ParameterSetDescription pset_qualityCuts;
121  pset_qualityCuts.add<edm::ParameterSetDescription>("signalQualityCuts", pset_signalQualityCuts);
122  pset_qualityCuts.add<edm::ParameterSetDescription>("vxAssocQualityCuts", pset_vxAssocQualityCuts);
123  pset_qualityCuts.add<edm::ParameterSetDescription>("isolationQualityCuts", pset_isolationQualityCuts);
124  pset_qualityCuts.add<std::string>("leadingTrkOrPFCandOption", "leadPFCand");
125  pset_qualityCuts.add<std::string>("pvFindingAlgo", "closestInDeltaZ");
126  pset_qualityCuts.add<edm::InputTag>("primaryVertexSrc", edm::InputTag("offlinePrimaryVertices"));
127  pset_qualityCuts.add<bool>("vertexTrackFiltering", false);
128  pset_qualityCuts.add<bool>("recoverLeadingTrk", false);
129 
130  desc.add<edm::ParameterSetDescription>("qualityCuts", pset_qualityCuts);
131  }
132 
133  {
135  psd0.add<std::string>("BooleanOperator", "and");
136  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
137  }
138 
139  desc.add<bool>("BooleanOutput", true);
140  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("combinatoricRecoTaus"));
141  desc.add<unsigned int>("MinN", 1);
142  desc.add<unsigned int>("MaxN", 0);
143  descriptions.add("pfRecoTauDiscriminationByNProngs", desc);
144 }
145 
T getParameter(std::string const &) const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
double discriminate(const reco::PFTauRef &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::unique_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int np
Definition: AMPTWrapper.h:33
def pv(vc)
Definition: MetAnalyzer.py:7
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
void beginEvent(const edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterSet const & getParameterSet(std::string const &) const
bool accepted(std::vector< std::string_view > const &, std::string_view)
def uint(string)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
std::unique_ptr< tau::RecoTauQualityCuts > qcuts_