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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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)
 
virtual ~PFRecoTauDiscriminationByFlight ()
 
- Public Member Functions inherited from TauDiscriminationProducerBase< TauType, TauDiscriminator >
virtual double discriminate (const TauRef &tau) const =0
 
virtual void endEvent (edm::Event &evt)
 
void produce (edm::Event &, const edm::EventSetup &)
 
 TauDiscriminationProducerBase (const edm::ParameterSet &iConfig)
 
 TauDiscriminationProducerBase ()
 
virtual ~TauDiscriminationProducerBase ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- 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 14 of file RecoTauDiscriminationByFlight.cc.

Constructor & Destructor Documentation

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

Definition at line 31 of file RecoTauDiscriminationByFlight.cc.

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

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

Definition at line 17 of file RecoTauDiscriminationByFlight.cc.

References beginEvent(), and discriminate().

17 {}

Member Function Documentation

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

Reimplemented from TauDiscriminationProducerBase< TauType, TauDiscriminator >.

Definition at line 43 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().

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

Definition at line 53 of file RecoTauDiscriminationByFlight.cc.

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

Referenced by ~PFRecoTauDiscriminationByFlight().

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

Referenced by beginEvent(), and discriminate().

edm::InputTag PFRecoTauDiscriminationByFlight::bsSource_
private

Definition at line 22 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent(), and PFRecoTauDiscriminationByFlight().

const TransientTrackBuilder* PFRecoTauDiscriminationByFlight::builder_
private

Definition at line 25 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent(), and discriminate().

double PFRecoTauDiscriminationByFlight::oneProngSig_
private

Definition at line 26 of file RecoTauDiscriminationByFlight.cc.

Referenced by PFRecoTauDiscriminationByFlight().

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

Definition at line 27 of file RecoTauDiscriminationByFlight.cc.

Referenced by PFRecoTauDiscriminationByFlight().

edm::InputTag PFRecoTauDiscriminationByFlight::vertexSource_
private

Definition at line 21 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent(), and PFRecoTauDiscriminationByFlight().

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

Definition at line 23 of file RecoTauDiscriminationByFlight.cc.

Referenced by beginEvent().