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 using namespace reco;
20 using namespace std;
21 
23  public:
25  const edm::ParameterSet& iConfig)
27  flightPathSig = iConfig.getParameter<double>("flightPathSig");
28  withPVError = iConfig.getParameter<bool>("UsePVerror");
29 
30  PVProducer = iConfig.getParameter<edm::InputTag>("PVProducer");
31 
32  booleanOutput = iConfig.getParameter<bool>("BooleanOutput");
33  }
35  void beginEvent(const edm::Event&, const edm::EventSetup&) override;
36  double discriminate(const reco::CaloTauRef&) override;
37 
38  private:
39  double threeProngFlightPathSig(const CaloTauRef&);
40  double vertexSignificance(reco::Vertex&,reco::Vertex&,GlobalVector&);
41 
42  double flightPathSig;
44 
48 
50 };
51 
53  const edm::Event& iEvent, const edm::EventSetup& iSetup){
54  //Primary vertex
56  iEvent.getByLabel(PVProducer, vertexHandle);
57  const edm::View<reco::Vertex>& vertexCollection(*vertexHandle);
58  primaryVertex = *(vertexCollection.begin());
59  // Transient Tracks
61  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
62  transientTrackBuilder = builder.product();
63 }
64 
65 double
67  const CaloTauRef& tau){
68  if(booleanOutput)
69  return ( threeProngFlightPathSig(tau) > flightPathSig ? 1. : 0. );
70  return threeProngFlightPathSig(tau);
71 }
72 
73 double
75  const CaloTauRef& tau){
76  double flightPathSignificance = 0;
77  //Secondary vertex
78  reco::TrackRefVector signalTracks = tau->signalTracks();
79  vector<TransientTrack> transientTracks;
80  for(size_t i = 0; i < signalTracks.size(); ++i){
81  const TransientTrack transientTrack =
82  transientTrackBuilder->build(signalTracks[i]);
83  transientTracks.push_back(transientTrack);
84  }
85  if(transientTracks.size() > 1) {
86  KalmanVertexFitter kvf(true);
87  TransientVertex tv = kvf.vertex(transientTracks);
88  if(tv.isValid()){
89  GlobalVector tauDir(tau->px(), tau->py(), tau->pz());
90  Vertex secVer = tv;
91  flightPathSignificance = vertexSignificance(primaryVertex,secVer,tauDir);
92  }
93  }
94  return flightPathSignificance;
95 }
96 
97 double
99  reco::Vertex& pv, Vertex& sv,GlobalVector& direction){
101  pv,sv,direction,withPVError).significance();
102 }
103 
105 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
tuple vertexCollection
void beginEvent(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:243
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
static Measurement1D computeDist3d(const reco::Vertex &pv, const reco::Vertex &sv, const GlobalVector &direction, bool withPVError)
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
double significance() const
Definition: Measurement1D.h:32
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
double vertexSignificance(reco::Vertex &, reco::Vertex &, GlobalVector &)
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
const_iterator begin() const
bool isValid() const