CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PFTauVertexSelector Class Reference

#include <PFTauVertexSelector.h>

Inheritance diagram for PFTauVertexSelector:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PFTauVertexSelector (const edm::ParameterSet &iConfig)
 
 ~PFTauVertexSelector ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpotSrc_
 
double dZ_
 
uint32_t filterOnNTaus_
 
std::vector< edm::EDGetTokenT
< edm::View
< reco::RecoCandidate > > > 
recoCandidateSrc_
 
std::vector< edm::InputTagrecoCandidateSrcIT_
 
edm::EDGetTokenT< edm::View
< reco::PFTau > > 
tauSrc_
 
std::vector< edm::EDGetTokenT
< edm::View< reco::Track > > > 
trackSrc_
 
std::vector< edm::InputTagtrackSrcIT_
 
edm::EDGetTokenT
< trigger::TriggerFilterObjectWithRefs
triggerFilterElectronsSrc_
 
edm::EDGetTokenT
< trigger::TriggerFilterObjectWithRefs
triggerFilterMuonsSrc_
 
bool useBeamSpot_
 
bool useLeadingRecoCandidate_
 
bool useLeadingTrack_
 
bool useTriggerFilterElectrons_
 
bool useTriggerFilterMuons_
 
bool useVertex_
 
edm::EDGetTokenT< edm::View
< reco::Vertex > > 
vertexSrc_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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)
 

Detailed Description

Definition at line 24 of file PFTauVertexSelector.h.

Constructor & Destructor Documentation

PFTauVertexSelector::PFTauVertexSelector ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 26 of file PFTauVertexSelector.h.

References beamSpotSrc_, dZ_, filterOnNTaus_, edm::ParameterSet::getParameter(), recoCandidateSrc_, recoCandidateSrcIT_, tauSrc_, trackSrc_, trackSrcIT_, triggerFilterElectronsSrc_, triggerFilterMuonsSrc_, useBeamSpot_, useLeadingRecoCandidate_, useLeadingTrack_, useTriggerFilterElectrons_, useTriggerFilterMuons_, useVertex_, and vertexSrc_.

26  {
27  tauSrc_ = consumes<edm::View<reco::PFTau> >(iConfig.getParameter<edm::InputTag>("tauSrc"));
28  useVertex_ = iConfig.getParameter<bool>("useVertex");
29  vertexSrc_ = consumes<edm::View<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("vertexSrc"));
30  useBeamSpot_ = iConfig.getParameter<bool>("useBeamSpot");
31  beamSpotSrc_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotSrc"));
32  useLeadingTrack_ = iConfig.getParameter<bool>("useLeadingTrack");
33  trackSrcIT_ = iConfig.getParameter<std::vector<edm::InputTag> >("trackSrc");
34  for( std::vector<edm::InputTag>::const_iterator it = trackSrcIT_.begin(); it != trackSrcIT_.end(); ++it ) {
35  edm::EDGetTokenT<edm::View<reco::Track> > aToken = consumes<edm::View<reco::Track> >( *it );
36  trackSrc_.push_back(aToken);
37  }
38  useLeadingRecoCandidate_ = iConfig.getParameter<bool>("useLeadingRecoCandidate");
39  recoCandidateSrcIT_ = iConfig.getParameter<std::vector<edm::InputTag> >("recoCandidateSrc");
40  for( std::vector<edm::InputTag>::const_iterator it = recoCandidateSrcIT_.begin(); it != recoCandidateSrcIT_.end(); ++it ) {
41  edm::EDGetTokenT<edm::View<reco::RecoCandidate> > aToken = consumes<edm::View<reco::RecoCandidate> >( *it );
42  recoCandidateSrc_.push_back(aToken);
43  }
44  useTriggerFilterElectrons_ = iConfig.getParameter<bool>("useTriggerFilterElectrons");
45  triggerFilterElectronsSrc_ = consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("triggerFilterElectronsSrc"));
46  useTriggerFilterMuons_ = iConfig.getParameter<bool>("useTriggerFilterMuons");
47  triggerFilterMuonsSrc_ = consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("triggerFilterMuonsSrc"));
48  dZ_ = iConfig.getParameter<double>("dZ");
49  filterOnNTaus_ = iConfig.getParameter<uint32_t>("filterOnNTaus");
50  produces<reco::PFTauCollection>();
51  }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::PFTau > > tauSrc_
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterElectronsSrc_
edm::EDGetTokenT< reco::BeamSpot > beamSpotSrc_
std::vector< edm::InputTag > recoCandidateSrcIT_
std::vector< edm::EDGetTokenT< edm::View< reco::RecoCandidate > > > recoCandidateSrc_
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterMuonsSrc_
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > trackSrc_
edm::EDGetTokenT< edm::View< reco::Vertex > > vertexSrc_
std::vector< edm::InputTag > trackSrcIT_
PFTauVertexSelector::~PFTauVertexSelector ( )
inline

Definition at line 52 of file PFTauVertexSelector.h.

52 {}

Member Function Documentation

bool PFTauVertexSelector::filter ( edm::Event event,
const edm::EventSetup eventSetup 
)
overrideprivatevirtual

Implements edm::EDFilter.

Definition at line 15 of file PFTauVertexSelector.cc.

References beamSpotSrc_, reco::TrackBase::dz(), dZ_, filterOnNTaus_, i, edm::HandleBase::isValid(), RecoTauCleanerPlugins::pt, recoCandidateSrc_, tauSrc_, testEve_cfg::tracks, trackSrc_, trigger::TriggerElectron, triggerFilterElectronsSrc_, triggerFilterMuonsSrc_, trigger::TriggerMuon, useBeamSpot_, useLeadingRecoCandidate_, useLeadingTrack_, useTriggerFilterElectrons_, useTriggerFilterMuons_, useVertex_, and vertexSrc_.

15  {
16 
17  math::XYZPoint vertexPoint;
18  bool vertexAvailable=false;
19 
20  if(useBeamSpot_)
21  {
22  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
23  event.getByToken(beamSpotSrc_,recoBeamSpotHandle);
24  if (recoBeamSpotHandle.isValid()){
25  vertexPoint = recoBeamSpotHandle->position();
26  vertexAvailable = true;
27  }
28  }
29 
30  if(useVertex_)
31  {
32  edm::Handle<edm::View<reco::Vertex> > recoVertexHandle;
33  event.getByToken(vertexSrc_,recoVertexHandle);
34  if ((recoVertexHandle.isValid()) && (recoVertexHandle->size()>0)){
35  vertexPoint = recoVertexHandle->at(0).position();
36  vertexAvailable = true;
37  }
38  }
39 
40  const reco::Track* track=0;
41  double maxpt=0.;
42 
43  if (useLeadingTrack_)
44  {
46  for( std::vector<edm::EDGetTokenT<edm::View<reco::Track> > >::const_iterator trackSrc = trackSrc_.begin(); trackSrc != trackSrc_.end(); ++ trackSrc ) {
47  event.getByToken(*trackSrc, tracks);
48  if ((tracks.isValid())&&(tracks->size()>0)){
49  for (unsigned i = 0; i < tracks->size(); ++i) {
50  double pt=tracks->ptrAt(i)->pt();
51  if(pt>maxpt)
52  {
53  track = &*tracks->ptrAt(i);
54  maxpt=pt;
55  }
56  }
57  }
58  }
59  }
60 
62  {
64  for( std::vector<edm::EDGetTokenT<edm::View<reco::RecoCandidate> > >::const_iterator recoCandidateSrc = recoCandidateSrc_.begin(); recoCandidateSrc != recoCandidateSrc_.end(); ++ recoCandidateSrc ) {
65  event.getByToken(*recoCandidateSrc, recocandidates);
66  if ((recocandidates.isValid())&&(recocandidates->size()>0)){
67  for (unsigned i = 0; i < recocandidates->size(); ++i) {
68  double pt=recocandidates->ptrAt(i)->pt();
69  if(pt>maxpt)
70  {
71  track = dynamic_cast<const reco::Track*>(recocandidates->ptrAt(i)->bestTrack());
72  maxpt=pt;
73  }
74  }
75  }
76  }
77  }
78 
80  {
82  event.getByToken(triggerFilterElectronsSrc_, triggerfilter);
83  std::vector<reco::ElectronRef> recocandidates;
84  triggerfilter->getObjects(trigger::TriggerElectron,recocandidates);
85  if ((recocandidates.size()>0)){
86  for (unsigned i = 0; i < recocandidates.size(); ++i) {
87  double pt=recocandidates.at(i)->pt();
88  if(pt>maxpt)
89  {
90  track = dynamic_cast<const reco::Track*>(recocandidates.at(i)->bestTrack());
91  maxpt=pt;
92  }
93  }
94  }
95  }
96 
98  {
100  event.getByToken(triggerFilterMuonsSrc_, triggerfilter);
101  std::vector<reco::RecoChargedCandidateRef> recocandidates;
102  triggerfilter->getObjects(trigger::TriggerMuon,recocandidates);
103  if ((recocandidates.size()>0)){
104  for (unsigned i = 0; i < recocandidates.size(); ++i) {
105  double pt=recocandidates.at(i)->pt();
106  if(pt>maxpt)
107  {
108  track = dynamic_cast<const reco::Track*>(recocandidates.at(i)->bestTrack());
109  maxpt=pt;
110  }
111  }
112  }
113  }
114 
117  event.getByToken(tauSrc_, taus);
118  for( edm::View<reco::PFTau>::const_iterator pfTau = taus->begin(); pfTau != taus->end(); ++ pfTau ) {
119  // if no leading track assigned skip
120  if ((!pfTau->leadPFChargedHadrCand().isNonnull())||
121  (!pfTau->leadPFChargedHadrCand()->trackRef().isNonnull()))
122  continue;
123 
124  if(vertexAvailable)
125  {
126  // select by z position of leading track at vertex
128  {
129  if((track)&&(fabs(pfTau->leadPFChargedHadrCand()->trackRef()->dz(vertexPoint) - track->dz(vertexPoint)) < dZ_))
130  selTaus->push_back(*pfTau);
131  }
132  // select by z position of leading vertex
133  else
134  {
135  if (fabs(pfTau->leadPFChargedHadrCand()->trackRef()->dz(vertexPoint))<dZ_)
136  selTaus->push_back(*pfTau);
137  }
138  }
139  else
140  {
141  // select by z position of leading track at (0,0,0)
143  {
144  if((track)&&(fabs(pfTau->leadPFChargedHadrCand()->trackRef()->dz() - track->dz()) < dZ_))
145  selTaus->push_back(*pfTau);
146  }
147  }
148  }
149  unsigned filterTaus=selTaus->size();
150  std::auto_ptr<reco::PFTauCollection> selectedTaus(selTaus);
151  event.put(selectedTaus);
152 
153  return (filterTaus>=filterOnNTaus_);
154 }
int i
Definition: DBlmapReader.cc:9
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
edm::EDGetTokenT< edm::View< reco::PFTau > > tauSrc_
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterElectronsSrc_
edm::EDGetTokenT< reco::BeamSpot > beamSpotSrc_
bool isValid() const
Definition: HandleBase.h:76
std::vector< edm::EDGetTokenT< edm::View< reco::RecoCandidate > > > recoCandidateSrc_
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:585
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterMuonsSrc_
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< edm::EDGetTokenT< edm::View< reco::Track > > > trackSrc_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
edm::EDGetTokenT< edm::View< reco::Vertex > > vertexSrc_

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> PFTauVertexSelector::beamSpotSrc_
private

Definition at line 59 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

double PFTauVertexSelector::dZ_
private

Definition at line 70 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

uint32_t PFTauVertexSelector::filterOnNTaus_
private

Definition at line 71 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

std::vector<edm::EDGetTokenT<edm::View<reco::RecoCandidate> > > PFTauVertexSelector::recoCandidateSrc_
private

Definition at line 65 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

std::vector<edm::InputTag> PFTauVertexSelector::recoCandidateSrcIT_
private

Definition at line 64 of file PFTauVertexSelector.h.

Referenced by PFTauVertexSelector().

edm::EDGetTokenT<edm::View<reco::PFTau> > PFTauVertexSelector::tauSrc_
private

Definition at line 55 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

std::vector<edm::EDGetTokenT<edm::View<reco::Track> > > PFTauVertexSelector::trackSrc_
private

Definition at line 62 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

std::vector<edm::InputTag> PFTauVertexSelector::trackSrcIT_
private

Definition at line 61 of file PFTauVertexSelector.h.

Referenced by PFTauVertexSelector().

edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> PFTauVertexSelector::triggerFilterElectronsSrc_
private

Definition at line 67 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> PFTauVertexSelector::triggerFilterMuonsSrc_
private

Definition at line 69 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useBeamSpot_
private

Definition at line 58 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useLeadingRecoCandidate_
private

Definition at line 63 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useLeadingTrack_
private

Definition at line 60 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useTriggerFilterElectrons_
private

Definition at line 66 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useTriggerFilterMuons_
private

Definition at line 68 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useVertex_
private

Definition at line 56 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

edm::EDGetTokenT<edm::View<reco::Vertex> > PFTauVertexSelector::vertexSrc_
private

Definition at line 57 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().