CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFTauExtractor.cc
Go to the documentation of this file.
2 
4 
11 
13 
15 {
16  tauSource_ = cfg.getParameter<edm::InputTag>("tauSource");
17  candidateSource_ = cfg.getParameter<edm::InputTag>("candidateSource");
18  maxDxyTrack_ = cfg.getParameter<double>("Diff_r");
19  maxDzTrack_ = cfg.getParameter<double>("Diff_z");
20  dRmatchPFTau_ = cfg.getParameter<double>("dRmatchPFTau");
21  dRVetoCone_ = cfg.getParameter<double>("DR_Veto");
22  dRIsoCone_ = cfg.getParameter<double>("DR_Max");
23  dRvetoPFTauSignalConeConstituents_ = cfg.getParameter<double>("dRvetoPFTauSignalConeConstituents");
24 }
25 
26 template<typename T>
27 reco::IsoDeposit PFTauExtractor::depositFromObject(const edm::Event& evt, const edm::EventSetup& es, const T& tauCandidate) const
28 {
29 //--- create IsoDeposit to be returned;
30 // set "direction" of IsoDeposit cone to jet-axis of tauCandidate
31  reco::isodeposit::Direction tauCandidateDirection(tauCandidate.eta(), tauCandidate.phi());
32  reco::IsoDeposit isoDeposit(tauCandidateDirection);
33  isoDeposit.addCandEnergy(tauCandidate.pt());
34 
35 //--- find PFTau closest to tauDirection
37  evt.getByLabel(tauSource_, pfTaus);
38 
39  double dR_min = -1.;
40  const reco::PFTau* pfTau_matched = 0;
41  for ( reco::PFTauCollection::const_iterator pfTau = pfTaus->begin();
42  pfTau != pfTaus->end(); ++pfTau ) {
43  double dR = deltaR(pfTau->eta(), pfTau->phi(), tauCandidate.eta(), tauCandidate.phi());
44  if ( pfTau_matched == 0 || dR < dR_min ) {
45  dR_min = dR;
46  pfTau_matched = &(*pfTau);
47  }
48  }
49 
50 //--- compute IsoDeposit for matched PFTau
51  if ( pfTau_matched != 0 && dR_min < dRmatchPFTau_ ) {
53  evt.getByLabel(candidateSource_, candidates);
54 
55  const reco::Particle::Point& tauVertex = pfTau_matched->vertex();
56  double dRsignalCone_max = 0.;
57  for ( edm::View<reco::Candidate>::const_iterator candidate = candidates->begin();
58  candidate != candidates->end(); ++candidate ) {
59  double dR = deltaR(candidate->momentum(), pfTau_matched->momentum());
60 
61 //--- check that candidate is inbetween veto and isolation cone,
62 // and is compatible with originating from the same primary event vertex as the PFTau
63  if ( dR > dRVetoCone_ && dR < dRIsoCone_ &&
64  (candidate->vertex() - tauVertex).Rho() < maxDxyTrack_ &&
65  fabs(candidate->vertex().z() - tauVertex.z()) < maxDzTrack_ ) {
66 
67 //--- check that the candidate is not associated to one of the tau decay products
68 // within the signal cone of the PFTau
69  bool isSignalCone = false;
70  for ( reco::PFCandidateRefVector::const_iterator tauSignalConeConstituent = pfTau_matched->signalPFCands().begin();
71  tauSignalConeConstituent != pfTau_matched->signalPFCands().end(); ++tauSignalConeConstituent ) {
72  double dR = deltaR(candidate->momentum(), (*tauSignalConeConstituent)->momentum());
73  if ( dR <= dRvetoPFTauSignalConeConstituents_ ) isSignalCone = true;
74  }
75 
76  if ( !isSignalCone ) {
77  reco::isodeposit::Direction candidateDirection(candidate->eta(), candidate->phi());
78  isoDeposit.addDeposit(candidateDirection, candidate->pt());
79  }
80  }
81  }
82 
83 //--- set size of veto cone of IsoDeposit to largest distance
84 // of any tau decay product within the signal cone of the PFTau
85 // (add a small positive number in order to avoid issues
86 // with rounding errors and "<" versus "<=" comparisson)
87  reco::IsoDeposit::Veto isoDepositVeto;
88  isoDepositVeto.vetoDir = tauCandidateDirection;
89  isoDepositVeto.dR = dRsignalCone_max + 1.e-3;
90  isoDeposit.setVeto(isoDepositVeto);
91  } else {
92  edm::LogWarning ("PFTauExtractor::depositFromObject") << " Failed to match PFTau to tauCandidate direction given by"
93  << " eta = " << tauCandidate.eta() << ", phi = " << tauCandidate.phi()
94  << " --> skipping computation of IsoDeposit !!";
95  }
96 
97  return isoDeposit;
98 }
99 
101 
103 
T getParameter(std::string const &) const
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
double dRvetoPFTauSignalConeConstituents_
tuple pfTaus
Definition: pfTaus_cff.py:119
virtual const Point & vertex() const
vertex position
edm::InputTag candidateSource_
virtual Vector momentum() const
spatial momentum vector
reco::IsoDeposit depositFromObject(const edm::Event &, const edm::EventSetup &, const T &) const
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
const PFCandidateRefVector & signalPFCands() const
PFCandidates in signal region.
Definition: PFTau.cc:73
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
math::XYZPoint Point
point in the space
Definition: Particle.h:29
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double dRmatchPFTau_
PFTauExtractor(const edm::ParameterSet &)
edm::InputTag tauSource_
configuration parameters
#define DEFINE_EDM_PLUGIN(factory, type, name)
long double T