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::ProductRegistryHelper

Public Member Functions

 PFTauVertexSelector (const edm::ParameterSet &iConfig)
 
 ~PFTauVertexSelector ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

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

Private Attributes

edm::InputTag beamSpotSrc_
 
double dZ_
 
uint32_t filterOnNTaus_
 
std::vector< edm::InputTagrecoCandidateSrc_
 
edm::InputTag tauSrc_
 
std::vector< edm::InputTagtrackSrc_
 
edm::InputTag triggerFilterElectronsSrc_
 
edm::InputTag triggerFilterMuonsSrc_
 
bool useBeamSpot_
 
bool useLeadingRecoCandidate_
 
bool useLeadingTrack_
 
bool useTriggerFilterElectrons_
 
bool useTriggerFilterMuons_
 
bool useVertex_
 
edm::InputTag vertexSrc_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
typedef WorkerT< EDFilterWorkerType
 
- 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::EDFilter
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 23 of file PFTauVertexSelector.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file PFTauVertexSelector.h.

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

25  {
26  tauSrc_ = iConfig.getParameter<edm::InputTag>("tauSrc");
27  useVertex_ = iConfig.getParameter<bool>("useVertex");
28  vertexSrc_ = iConfig.getParameter<edm::InputTag>("vertexSrc");
29  useBeamSpot_ = iConfig.getParameter<bool>("useBeamSpot");
30  beamSpotSrc_ = iConfig.getParameter<edm::InputTag>("beamSpotSrc");
31  useLeadingTrack_ = iConfig.getParameter<bool>("useLeadingTrack");
32  trackSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >("trackSrc");
33  useLeadingRecoCandidate_ = iConfig.getParameter<bool>("useLeadingRecoCandidate");
34  recoCandidateSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >("recoCandidateSrc");
35  useTriggerFilterElectrons_ = iConfig.getParameter<bool>("useTriggerFilterElectrons");
36  triggerFilterElectronsSrc_ = iConfig.getParameter<edm::InputTag>("triggerFilterElectronsSrc");
37  useTriggerFilterMuons_ = iConfig.getParameter<bool>("useTriggerFilterMuons");
38  triggerFilterMuonsSrc_ = iConfig.getParameter<edm::InputTag>("triggerFilterMuonsSrc");
39  dZ_ = iConfig.getParameter<double>("dZ");
40  filterOnNTaus_ = iConfig.getParameter<uint32_t>("filterOnNTaus");
41  produces<reco::PFTauCollection>();
42  }
edm::InputTag triggerFilterElectronsSrc_
T getParameter(std::string const &) const
std::vector< edm::InputTag > recoCandidateSrc_
std::vector< edm::InputTag > trackSrc_
edm::InputTag triggerFilterMuonsSrc_
edm::InputTag beamSpotSrc_
PFTauVertexSelector::~PFTauVertexSelector ( )
inline

Definition at line 43 of file PFTauVertexSelector.h.

43 {}

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 19 of file PFTauVertexSelector.cc.

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

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

Member Data Documentation

edm::InputTag PFTauVertexSelector::beamSpotSrc_
private

Definition at line 50 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

double PFTauVertexSelector::dZ_
private

Definition at line 59 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

uint32_t PFTauVertexSelector::filterOnNTaus_
private

Definition at line 60 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

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

Definition at line 54 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

edm::InputTag PFTauVertexSelector::tauSrc_
private

Definition at line 46 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

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

Definition at line 52 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

edm::InputTag PFTauVertexSelector::triggerFilterElectronsSrc_
private

Definition at line 56 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

edm::InputTag PFTauVertexSelector::triggerFilterMuonsSrc_
private

Definition at line 58 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useBeamSpot_
private

Definition at line 49 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useLeadingRecoCandidate_
private

Definition at line 53 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useLeadingTrack_
private

Definition at line 51 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useTriggerFilterElectrons_
private

Definition at line 55 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useTriggerFilterMuons_
private

Definition at line 57 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

bool PFTauVertexSelector::useVertex_
private

Definition at line 47 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().

edm::InputTag PFTauVertexSelector::vertexSrc_
private

Definition at line 48 of file PFTauVertexSelector.h.

Referenced by filter(), and PFTauVertexSelector().