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.
7 
8 /*
9  * class PFTauVertexSelector
10  * created : January 26 2012,
11  * revised : Wed Jan 26 11:13:04 PDT 2012
12  * Authors : Andreas Hinzmann (CERN)
13  */
14 
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
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
edm::EDGetTokenT< edm::View< reco::PFTau > > tauSrc_
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > triggerFilterElectronsSrc_
edm::EDGetTokenT< reco::BeamSpot > beamSpotSrc_
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
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:125
virtual bool filter(edm::Event &, const edm::EventSetup &) override
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_
edm::EDGetTokenT< edm::View< reco::Vertex > > vertexSrc_