CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecoTauDiscriminationByFlightPathSignificance.cc
Go to the documentation of this file.
3 
4 /* class CaloRecoTauDiscriminationByFlightPathSignificance
5  * created : September 23 2010,
6  * contributors : Sami Lehti (sami.lehti@cern.ch ; HIP, Helsinki)
7  * based on H+ tau ID by Lauri Wendland
8  */
9 
16 
17 #include "TLorentzVector.h"
18 
19 namespace {
20 
21 using namespace reco;
22 using namespace std;
23 
24 class CaloRecoTauDiscriminationByFlightPathSignificance final : public CaloTauDiscriminationProducerBase {
25  public:
26  explicit CaloRecoTauDiscriminationByFlightPathSignificance(
27  const edm::ParameterSet& iConfig)
29  flightPathSig = iConfig.getParameter<double>("flightPathSig");
30  withPVError = iConfig.getParameter<bool>("UsePVerror");
31 
32  PVProducer = iConfig.getParameter<edm::InputTag>("PVProducer");
33 
34  booleanOutput = iConfig.getParameter<bool>("BooleanOutput");
35  }
36  ~CaloRecoTauDiscriminationByFlightPathSignificance(){}
37  void beginEvent(const edm::Event&, const edm::EventSetup&) override;
38  double discriminate(const reco::CaloTauRef&) const override;
39 
40  private:
41  double threeProngFlightPathSig(const CaloTauRef&) const ;
42  double vertexSignificance(reco::Vertex const&,reco::Vertex const &,GlobalVector const &) const ;
43 
44  double flightPathSig;
45  bool withPVError;
46 
48  const TransientTrackBuilder* transientTrackBuilder;
49  edm::InputTag PVProducer;
50 
51  bool booleanOutput;
52 };
53 
54 void CaloRecoTauDiscriminationByFlightPathSignificance::beginEvent(
55  const edm::Event& iEvent, const edm::EventSetup& iSetup){
56  //Primary vertex
58  iEvent.getByLabel(PVProducer, vertexHandle);
59  const edm::View<reco::Vertex>& vertexCollection(*vertexHandle);
60  primaryVertex = *(vertexCollection.begin());
61  // Transient Tracks
63  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
64  transientTrackBuilder = builder.product();
65 }
66 
67 double
68 CaloRecoTauDiscriminationByFlightPathSignificance::discriminate(
69  const CaloTauRef& tau) const {
70  if(booleanOutput)
71  return ( threeProngFlightPathSig(tau) > flightPathSig ? 1. : 0. );
72  return threeProngFlightPathSig(tau);
73 }
74 
75 double
76 CaloRecoTauDiscriminationByFlightPathSignificance::threeProngFlightPathSig(
77  const CaloTauRef& tau) const {
78  double flightPathSignificance = 0;
79  //Secondary vertex
80  reco::TrackRefVector signalTracks = tau->signalTracks();
81  vector<TransientTrack> transientTracks;
82  for(size_t i = 0; i < signalTracks.size(); ++i){
83  const TransientTrack transientTrack =
84  transientTrackBuilder->build(signalTracks[i]);
85  transientTracks.push_back(transientTrack);
86  }
87  if(transientTracks.size() > 1) {
88  KalmanVertexFitter kvf(true);
89  TransientVertex tv = kvf.vertex(transientTracks);
90  if(tv.isValid()){
91  GlobalVector tauDir(tau->px(), tau->py(), tau->pz());
92  Vertex secVer = tv;
93  flightPathSignificance = vertexSignificance(primaryVertex,secVer,tauDir);
94  }
95  }
96  return flightPathSignificance;
97 }
98 
99 double
100 CaloRecoTauDiscriminationByFlightPathSignificance::vertexSignificance(
101  reco::Vertex const & pv, Vertex const & sv,GlobalVector const & direction) const {
103  pv,sv,direction,withPVError).significance();
104 }
105 
106 }
107 DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByFlightPathSignificance);
108 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static Measurement1D computeDist3d(const reco::Vertex &pv, const SV &sv, const GlobalVector &direction, bool withPVError)
tuple vertexCollection
int iEvent
Definition: GenABIO.cc:230
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
double significance() const
Definition: Measurement1D.h:32
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
size_type size() const
Size of the RefVector.
Definition: RefVector.h:99
bool isValid() const