Go to the documentation of this file.00001 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h"
00002 #include "FWCore/Utilities/interface/InputTag.h"
00003
00004
00005
00006
00007
00008
00009
00010 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00011 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00012 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00013 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h"
00014 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00015 #include "RecoBTag/SecondaryVertex/interface/SecondaryVertex.h"
00016
00017 #include "TLorentzVector.h"
00018
00019 using namespace reco;
00020 using namespace std;
00021
00022 class CaloRecoTauDiscriminationByFlightPathSignificance : public CaloTauDiscriminationProducerBase {
00023 public:
00024 explicit CaloRecoTauDiscriminationByFlightPathSignificance(
00025 const edm::ParameterSet& iConfig)
00026 :CaloTauDiscriminationProducerBase(iConfig) {
00027 flightPathSig = iConfig.getParameter<double>("flightPathSig");
00028 withPVError = iConfig.getParameter<bool>("UsePVerror");
00029
00030 PVProducer = iConfig.getParameter<edm::InputTag>("PVProducer");
00031
00032 booleanOutput = iConfig.getParameter<bool>("BooleanOutput");
00033 }
00034 ~CaloRecoTauDiscriminationByFlightPathSignificance(){}
00035 void beginEvent(const edm::Event&, const edm::EventSetup&);
00036 double discriminate(const reco::CaloTauRef&);
00037
00038 private:
00039 double threeProngFlightPathSig(const CaloTauRef&);
00040 double vertexSignificance(reco::Vertex&,reco::Vertex&,GlobalVector&);
00041
00042 double flightPathSig;
00043 bool withPVError;
00044
00045 reco::Vertex primaryVertex;
00046 const TransientTrackBuilder* transientTrackBuilder;
00047 edm::InputTag PVProducer;
00048
00049 bool booleanOutput;
00050 };
00051
00052 void CaloRecoTauDiscriminationByFlightPathSignificance::beginEvent(
00053 const edm::Event& iEvent, const edm::EventSetup& iSetup){
00054
00055 edm::Handle<edm::View<reco::Vertex> > vertexHandle;
00056 iEvent.getByLabel(PVProducer, vertexHandle);
00057 const edm::View<reco::Vertex>& vertexCollection(*vertexHandle);
00058 primaryVertex = *(vertexCollection.begin());
00059
00060 edm::ESHandle<TransientTrackBuilder> builder;
00061 iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
00062 transientTrackBuilder = builder.product();
00063 }
00064
00065 double
00066 CaloRecoTauDiscriminationByFlightPathSignificance::discriminate(
00067 const CaloTauRef& tau){
00068 if(booleanOutput)
00069 return ( threeProngFlightPathSig(tau) > flightPathSig ? 1. : 0. );
00070 return threeProngFlightPathSig(tau);
00071 }
00072
00073 double
00074 CaloRecoTauDiscriminationByFlightPathSignificance::threeProngFlightPathSig(
00075 const CaloTauRef& tau){
00076 double flightPathSignificance = 0;
00077
00078 reco::TrackRefVector signalTracks = tau->signalTracks();
00079 vector<TransientTrack> transientTracks;
00080 for(size_t i = 0; i < signalTracks.size(); ++i){
00081 const TransientTrack transientTrack =
00082 transientTrackBuilder->build(signalTracks[i]);
00083 transientTracks.push_back(transientTrack);
00084 }
00085 if(transientTracks.size() > 1) {
00086 KalmanVertexFitter kvf(true);
00087 TransientVertex tv = kvf.vertex(transientTracks);
00088 if(tv.isValid()){
00089 GlobalVector tauDir(tau->px(), tau->py(), tau->pz());
00090 Vertex secVer = tv;
00091 flightPathSignificance = vertexSignificance(primaryVertex,secVer,tauDir);
00092 }
00093 }
00094 return flightPathSignificance;
00095 }
00096
00097 double
00098 CaloRecoTauDiscriminationByFlightPathSignificance::vertexSignificance(
00099 reco::Vertex& pv, Vertex& sv,GlobalVector& direction){
00100 return SecondaryVertex::computeDist3d(
00101 pv,sv,direction,withPVError).significance();
00102 }
00103
00104 DEFINE_FWK_MODULE(CaloRecoTauDiscriminationByFlightPathSignificance);
00105