CMS 3D CMS Logo

PFRecoTauDiscriminationByFlightPathSignificance.cc
Go to the documentation of this file.
3 
6 
7 /* class PFRecoTauDiscriminationByFlightPathSignificance
8  * created : August 30 2010,
9  * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki)
10  * based on H+ tau ID by Lauri Wendland
11  */
12 
20 
21 #include "TLorentzVector.h"
22 
23 using namespace reco;
24 using namespace std;
25 using namespace edm;
26 
29  public:
32  flightPathSig = iConfig.getParameter<double>("flightPathSig");
33  withPVError = iConfig.getParameter<bool>("UsePVerror");
34  booleanOutput = iConfig.getParameter<bool>("BooleanOutput");
35  // edm::ConsumesCollector iC(consumesCollector());
36  vertexAssociator_ = new reco::tau::RecoTauVertexAssociator(iConfig.getParameter<ParameterSet>("qualityCuts"),consumesCollector());
37  }
38 
40 
41  void beginEvent(const edm::Event&, const edm::EventSetup&) override;
42  double discriminate(const reco::PFTauRef&) const override;
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
45  private:
46  double threeProngFlightPathSig(const PFTauRef&) const ;
47  double vertexSignificance(reco::Vertex const&,reco::Vertex const &,GlobalVector const&) const;
48 
50 
52  double flightPathSig;
54 
56 };
57 
59  const Event& iEvent, const EventSetup& iSetup){
60 
61  vertexAssociator_->setEvent(iEvent);
62 
63  // Transient Tracks
65  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
66  transientTrackBuilder = builder.product();
67 
68 }
69 
71 
72  if(booleanOutput) return ( threeProngFlightPathSig(tau) > flightPathSig ? 1. : 0. );
73  return threeProngFlightPathSig(tau);
74 }
75 
77  const PFTauRef& tau) const {
78  double flightPathSignificance = 0;
79 
80  reco::VertexRef primaryVertex = vertexAssociator_->associatedVertex(*tau);
81 
82  if (primaryVertex.isNull()) {
83  edm::LogError("FlightPathSignficance") << "Could not get vertex associated"
84  << " to tau, returning -999!" << std::endl;
85  return -999;
86  }
87 
88  //Secondary vertex
89  vector<TransientTrack> transientTracks;
90  for(const auto& pfSignalCand : tau->signalPFChargedHadrCands()){
91  if(pfSignalCand->trackRef().isNonnull()){
92  const TransientTrack transientTrack = transientTrackBuilder->build(pfSignalCand->trackRef());
93  transientTracks.push_back(transientTrack);
94  }
95  else if(pfSignalCand->gsfTrackRef().isNonnull()){
96  const TransientTrack transientTrack = transientTrackBuilder->build(pfSignalCand->gsfTrackRef());
97  transientTracks.push_back(transientTrack);
98  }
99  }
100  if(transientTracks.size() > 1){
101  KalmanVertexFitter kvf(true);
102  TransientVertex tv = kvf.vertex(transientTracks);
103 
104  if(tv.isValid()){
105  GlobalVector tauDir(tau->px(),
106  tau->py(),
107  tau->pz());
108  Vertex secVer = tv;
109  // We have to un-const the PV for some reason
110  reco::Vertex primaryVertexNonConst = *primaryVertex;
111  flightPathSignificance = vertexSignificance(primaryVertexNonConst,secVer,tauDir);
112  }
113  }
114  return flightPathSignificance;
115 }
116 
118  reco::Vertex const & pv, Vertex const & sv,GlobalVector const & direction) const {
119  return SecondaryVertex::computeDist3d(pv,sv,direction,withPVError).significance();
120 }
121 
122 void
124  // pfRecoTauDiscriminationByFlightPathSignificance
126  desc.add<double>("flightPathSig", 1.5);
127  desc.add<edm::InputTag>("PVProducer", edm::InputTag("offlinePrimaryVertices"));
128  desc.add<bool>("BooleanOutput", true);
129  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfRecoTauProducer"));
130  {
132  psd0.add<std::string>("BooleanOperator", "and");
133  {
135  psd1.add<double>("cut");
136  psd1.add<edm::InputTag>("Producer");
137  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
138  }
139  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
140  }
141  desc.add<bool>("UsePVerror", true);
142  descriptions.add("pfRecoTauDiscriminationByFlightPathSignificance", desc);
143 }
144 
T getParameter(std::string const &) const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void beginEvent(const edm::Event &, const edm::EventSetup &) override
static Measurement1D computeDist3d(const reco::Vertex &pv, const SV &sv, const GlobalVector &direction, bool withPVError)
double vertexSignificance(reco::Vertex const &, reco::Vertex const &, GlobalVector const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
def pv(vc)
Definition: MetAnalyzer.py:7
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNull() const
Checks for null.
Definition: Ref.h:248
double significance() const
Definition: Measurement1D.h:29
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
bool isValid() const