CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFTauVertexSelector.cc
Go to the documentation of this file.
11 
12 /*
13  * class PFTauVertexSelector
14  * created : January 26 2012,
15  * revised : Wed Jan 26 11:13:04 PDT 2012
16  * Authors : Andreas Hinzmann (CERN)
17  */
18 
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_
virtual bool filter(edm::Event &, const edm::EventSetup &)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
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