CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PFRecoTauDiscriminationByFlight Class Reference
Inheritance diagram for PFRecoTauDiscriminationByFlight:
TauDiscriminationProducerBase< TauType, TauDiscriminator > edm::stream::EDProducer<>

Public Member Functions

void beginEvent (const edm::Event &evt, const edm::EventSetup &es) override
 
double discriminate (const reco::PFTauRef &) const override
 
 PFRecoTauDiscriminationByFlight (const edm::ParameterSet &pset)
 
 ~PFRecoTauDiscriminationByFlight () override
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
virtual void endEvent (edm::Event &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
 ~TauDiscriminationProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

edm::Handle< reco::BeamSpotbeamspot_
 
edm::InputTag bsSource_
 
const TransientTrackBuilderbuilder_
 
double oneProngSig_
 
bool refitPV_
 
double threeProngSig_
 
edm::InputTag vertexSource_
 
edm::Handle< reco::VertexCollectionvertices_
 

Additional Inherited Members

- Public Types inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
typedef std::vector< TauType > TauCollection
 
typedef edm::Ref< TauCollectionTauRef
 
typedef edm::RefProd< TauCollectionTauRefProd
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Protected Attributes inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
std::string moduleLabel_
 
double prediscriminantFailValue_
 
edm::EDGetTokenT< TauCollectionTau_token
 
size_t tauIndex_
 
edm::InputTag TauProducer_
 

Detailed Description

Definition at line 13 of file RecoTauDiscriminationByFlight.cc.

Constructor & Destructor Documentation

PFRecoTauDiscriminationByFlight::PFRecoTauDiscriminationByFlight ( const edm::ParameterSet pset)

Definition at line 30 of file RecoTauDiscriminationByFlight.cc.

References bsSource_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), oneProngSig_, refitPV_, threeProngSig_, and vertexSource_.

32  vertexSource_ = pset.getParameter<edm::InputTag>("vertexSource");
33  oneProngSig_ = pset.exists("oneProngSigCut") ?
34  pset.getParameter<double>("oneProngSigCut") : -1.;
35  threeProngSig_ = pset.exists("threeProngSigCut") ?
36  pset.getParameter<double>("threeProngSigCut") : -1.;
37  refitPV_ = pset.getParameter<bool>("refitPV");
38  if (refitPV_)
39  bsSource_ = pset.getParameter<edm::InputTag>("beamspot");
40 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
TauDiscriminationProducerBase< reco::PFTau, reco::PFTauDiscriminator > PFTauDiscriminationProducerBase
PFRecoTauDiscriminationByFlight::~PFRecoTauDiscriminationByFlight ( )
inlineoverride

Definition at line 16 of file RecoTauDiscriminationByFlight.cc.

References beginEvent(), and discriminate().

16 {}

Member Function Documentation

void PFRecoTauDiscriminationByFlight::beginEvent ( const edm::Event evt,
const edm::EventSetup es 
)
overridevirtual

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 42 of file RecoTauDiscriminationByFlight.cc.

References beamspot_, bsSource_, builder_, edm::EventSetup::get(), edm::Event::getByLabel(), edm::ESHandle< T >::product(), refitPV_, vertexSource_, and vertices_.

Referenced by ~PFRecoTauDiscriminationByFlight().

43  {
45  if (refitPV_)
47  edm::ESHandle<TransientTrackBuilder> transTrackBuilder;
48  es.get<TransientTrackRecord>().get("TransientTrackBuilder",transTrackBuilder);
49  builder_ = transTrackBuilder.product();
50 }
edm::Handle< reco::VertexCollection > vertices_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
T get() const
Definition: EventSetup.h:68
T const * product() const
Definition: ESHandle.h:84
double PFRecoTauDiscriminationByFlight::discriminate ( const reco::PFTauRef tau) const
override

Definition at line 52 of file RecoTauDiscriminationByFlight.cc.

References beamspot_, TransientTrackBuilder::build(), builder_, reco::TemplatedSecondaryVertex< SV >::computeDist2d(), DEFINE_FWK_MODULE, TauDiscriminationProducerBase< TauType, TauDiscriminator >::prediscriminantFailValue_, MetAnalyzer::pv(), refitPV_, IPTools::signedTransverseImpactParameter(), Measurement1D::significance(), pfDeepBoostedJetPreprocessParams_cfi::sv, HiIsolationCommonParameters_cff::track, reco::Vertex::tracks_begin(), reco::Vertex::tracks_end(), and KalmanVertexFitter::vertex().

Referenced by ~PFRecoTauDiscriminationByFlight().

53  {
54 
55  KalmanVertexFitter kvf(true);
56  const std::vector<reco::PFCandidatePtr>& signalTracks =
57  tau->signalPFChargedHadrCands();
58  std::vector<reco::TransientTrack> signalTransTracks;
59  std::vector<reco::TrackRef> signalTrackPtrs;
60  for(auto const& pftrack : signalTracks) {
61  if (pftrack->trackRef().isNonnull()) {
62  signalTransTracks.push_back(
63  builder_->build(pftrack->trackRef()));
64  signalTrackPtrs.push_back(pftrack->trackRef());
65  }
66  }
67 
68  reco::Vertex pv = (*vertices_)[0];
69 
70  if (refitPV_) {
71  std::vector<reco::TrackRef> pvTrackRefs;
73  pvTrack != pv.tracks_end(); ++pvTrack ) {
74  pvTrackRefs.push_back(pvTrack->castTo<reco::TrackRef>());
75  }
76  // Get PV tracks not associated to the tau
77  std::sort(signalTrackPtrs.begin(), signalTrackPtrs.end());
78  std::sort(pvTrackRefs.begin(), pvTrackRefs.end());
79  std::vector<reco::TrackRef> uniquePVTracks;
80  uniquePVTracks.reserve(pvTrackRefs.size());
81  std::set_difference(pvTrackRefs.begin(), pvTrackRefs.end(),
82  signalTrackPtrs.begin(), signalTrackPtrs.end(),
83  std::back_inserter(uniquePVTracks));
84  // Check if we need to refit
85  if (uniquePVTracks.size() != pvTrackRefs.size()) {
86  std::vector<reco::TransientTrack> pvTransTracks;
87  // Build all our unique transient tracks in the PV
88  for(auto const& track : pvTrackRefs) {
89  pvTransTracks.push_back(builder_->build(track));
90  }
91  // Refit our PV
92  TransientVertex newPV = kvf.vertex(pvTransTracks, *beamspot_);
93  pv = newPV;
94  }
95  }
96 
97  // The tau direction, to determine the sign of the IP.
98  // In the case that it is a one prong, take the jet direction.
99  // This may give better result due to out-of-cone stuff.
100  GlobalVector direction = (tau->signalPFCands().size() == 1 ?
101  GlobalVector(
102  tau->jetRef()->px(), tau->jetRef()->py(), tau->jetRef()->pz()) :
103  GlobalVector(tau->px(), tau->py(), tau->pz()));
104 
105  // Now figure out of we are doing a SV fit or an IP significance
106  if (signalTransTracks.size() == 1) {
107  reco::TransientTrack track = signalTransTracks.front();
108  std::pair<bool,Measurement1D> ipsig =
109  IPTools::signedTransverseImpactParameter(track, direction, pv);
110  if (ipsig.first)
111  return ipsig.second.significance();
112  else
114  } else if (signalTransTracks.size() == 3) {
115  // Fit the decay vertex of the three prong
116  TransientVertex sv = kvf.vertex(signalTransTracks);
117  // the true parameter indicates include PV errors
119  pv, sv, direction, true);
120  double significance = svDist.significance();
121  // Make sure it is a sane value
122  if (significance > 40)
123  significance = 40;
124  if (significance < -20)
125  significance = -20;
126  return significance;
127  } else {
128  // Weird two prong or something
130  }
131 }
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
reco::TransientTrack build(const reco::Track *p) const
static Measurement1D computeDist2d(const reco::Vertex &pv, const SV &sv, const GlobalVector &direction, bool withPVError)
def pv(vc)
Definition: MetAnalyzer.py:7
double significance() const
Definition: Measurement1D.h:32
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
Global3DVector GlobalVector
Definition: GlobalVector.h:10

Member Data Documentation

edm::Handle<reco::BeamSpot> PFRecoTauDiscriminationByFlight::beamspot_
private

Definition at line 23 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent(), and discriminate().

edm::InputTag PFRecoTauDiscriminationByFlight::bsSource_
private

Definition at line 21 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent(), and PFRecoTauDiscriminationByFlight().

const TransientTrackBuilder* PFRecoTauDiscriminationByFlight::builder_
private

Definition at line 24 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent(), and discriminate().

double PFRecoTauDiscriminationByFlight::oneProngSig_
private

Definition at line 25 of file RecoTauDiscriminationByFlight.cc.

Referenced by PFRecoTauDiscriminationByFlight().

bool PFRecoTauDiscriminationByFlight::refitPV_
private
double PFRecoTauDiscriminationByFlight::threeProngSig_
private

Definition at line 26 of file RecoTauDiscriminationByFlight.cc.

Referenced by PFRecoTauDiscriminationByFlight().

edm::InputTag PFRecoTauDiscriminationByFlight::vertexSource_
private

Definition at line 20 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent(), and PFRecoTauDiscriminationByFlight().

edm::Handle<reco::VertexCollection> PFRecoTauDiscriminationByFlight::vertices_
private

Definition at line 22 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent().