CMS 3D CMS Logo

PFTauExtractor.cc
Go to the documentation of this file.
2 
4 
9 
11 
13  tauSourceToken_ = iC.consumes<reco::PFTauCollection>(cfg.getParameter<edm::InputTag>("tauSource"));
15  iC.mayConsume<edm::View<reco::Candidate> >(cfg.getParameter<edm::InputTag>("candidateSource"));
16  maxDxyTrack_ = cfg.getParameter<double>("Diff_r");
17  maxDzTrack_ = cfg.getParameter<double>("Diff_z");
18  dRmatchPFTau_ = cfg.getParameter<double>("dRmatchPFTau");
19  dRVetoCone_ = cfg.getParameter<double>("DR_Veto");
20  dRIsoCone_ = cfg.getParameter<double>("DR_Max");
21  dRvetoPFTauSignalConeConstituents_ = cfg.getParameter<double>("dRvetoPFTauSignalConeConstituents");
22 }
23 
24 template <typename T>
26  const edm::EventSetup& es,
27  const T& tauCandidate) const {
28  //--- create IsoDeposit to be returned;
29  // set "direction" of IsoDeposit cone to jet-axis of tauCandidate
30  reco::isodeposit::Direction tauCandidateDirection(tauCandidate.eta(), tauCandidate.phi());
31  reco::IsoDeposit isoDeposit(tauCandidateDirection);
32  isoDeposit.addCandEnergy(tauCandidate.pt());
33 
34  //--- find PFTau closest to tauDirection
36  evt.getByToken(tauSourceToken_, pfTaus);
37 
38  double dR_min = -1.;
39  const reco::PFTau* pfTau_matched = nullptr;
40  for (reco::PFTauCollection::const_iterator pfTau = pfTaus->begin(); pfTau != pfTaus->end(); ++pfTau) {
41  double dR = deltaR(pfTau->eta(), pfTau->phi(), tauCandidate.eta(), tauCandidate.phi());
42  if (pfTau_matched == nullptr || dR < dR_min) {
43  dR_min = dR;
44  pfTau_matched = &(*pfTau);
45  }
46  }
47 
48  //--- compute IsoDeposit for matched PFTau
49  if (pfTau_matched != nullptr && dR_min < dRmatchPFTau_) {
52 
53  const reco::Particle::Point& tauVertex = pfTau_matched->vertex();
54  double dRsignalCone_max = 0.;
55  for (edm::View<reco::Candidate>::const_iterator candidate = candidates->begin(); candidate != candidates->end();
56  ++candidate) {
57  double dR = deltaR(candidate->momentum(), pfTau_matched->momentum());
58 
59  //--- check that candidate is inbetween veto and isolation cone,
60  // and is compatible with originating from the same primary event vertex as the PFTau
61  if (dR > dRVetoCone_ && dR < dRIsoCone_ && (candidate->vertex() - tauVertex).Rho() < maxDxyTrack_ &&
62  fabs(candidate->vertex().z() - tauVertex.z()) < maxDzTrack_) {
63  //--- check that the candidate is not associated to one of the tau decay products
64  // within the signal cone of the PFTau
65  bool isSignalCone = false;
66  for (std::vector<reco::CandidatePtr>::const_iterator tauSignalConeConstituent =
67  pfTau_matched->signalCands().begin();
68  tauSignalConeConstituent != pfTau_matched->signalCands().end();
69  ++tauSignalConeConstituent) {
70  double dR = deltaR(candidate->momentum(), (*tauSignalConeConstituent)->momentum());
72  isSignalCone = true;
73  }
74 
75  if (!isSignalCone) {
76  reco::isodeposit::Direction candidateDirection(candidate->eta(), candidate->phi());
77  isoDeposit.addDeposit(candidateDirection, candidate->pt());
78  }
79  }
80  }
81 
82  //--- set size of veto cone of IsoDeposit to largest distance
83  // of any tau decay product within the signal cone of the PFTau
84  // (add a small positive number in order to avoid issues
85  // with rounding errors and "<" versus "<=" comparisson)
86  reco::IsoDeposit::Veto isoDepositVeto;
87  isoDepositVeto.vetoDir = tauCandidateDirection;
88  isoDepositVeto.dR = dRsignalCone_max + 1.e-3;
89  isoDeposit.setVeto(isoDepositVeto);
90  } else {
91  edm::LogWarning("PFTauExtractor::depositFromObject")
92  << " 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 
reco::IsoDeposit::Veto::dR
float dR
Definition: IsoDeposit.h:61
PFTauExtractor::maxDxyTrack_
double maxDxyTrack_
Definition: PFTauExtractor.h:40
reco::LeafCandidate::momentum
Vector momentum() const final
spatial momentum vector
Definition: LeafCandidate.h:118
Handle.h
reco::PFTau::signalCands
const std::vector< reco::CandidatePtr > & signalCands() const
Candidates in signal region.
Definition: PFTau.cc:74
MessageLogger.h
PFTauExtractor::dRIsoCone_
double dRIsoCone_
Definition: PFTauExtractor.h:44
PFTauExtractor::depositFromObject
reco::IsoDeposit depositFromObject(const edm::Event &, const edm::EventSetup &, const T &) const
Definition: PFTauExtractor.cc:25
reco::PFTau
Definition: PFTau.h:36
PFTauExtractor::dRVetoCone_
double dRVetoCone_
Definition: PFTauExtractor.h:43
reco::IsoDeposit::Veto
Definition: IsoDeposit.h:59
edm::Handle
Definition: AssociativeIterator.h:50
IsoDepositDirection.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
PFTauExtractor::dRvetoPFTauSignalConeConstituents_
double dRvetoPFTauSignalConeConstituents_
Definition: PFTauExtractor.h:45
CandidateFwd.h
MakerMacros.h
reco::IsoDeposit::Veto::vetoDir
Direction vetoDir
Definition: IsoDeposit.h:60
reco::PFTauCollection
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
PFTauExtractor::tauSourceToken_
edm::EDGetTokenT< reco::PFTauCollection > tauSourceToken_
configuration parameters
Definition: PFTauExtractor.h:38
PFTauExtractor::maxDzTrack_
double maxDzTrack_
Definition: PFTauExtractor.h:41
edm::View
Definition: CaloClusterFwd.h:14
PFTauExtractor::dRmatchPFTau_
double dRmatchPFTau_
Definition: PFTauExtractor.h:42
edm::ParameterSet
Definition: ParameterSet.h:47
deltaR.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
PFTauExtractor
Definition: PFTauExtractor.h:20
edm::EventSetup
Definition: EventSetup.h:58
reco::LeafCandidate::vertex
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: LeafCandidate.h:165
PFTauExtractor.h
looper.cfg
cfg
Definition: looper.py:296
PFTauExtractor::PFTauExtractor
PFTauExtractor(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
Definition: PFTauExtractor.cc:12
PFTauExtractor::candidateSourceToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > candidateSourceToken_
Definition: PFTauExtractor.h:39
T
long double T
Definition: Basic3DVectorLD.h:48
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:55017
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
IsoDepositExtractorFactory.h
reco::IsoDeposit
Definition: IsoDeposit.h:49
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::Particle::Point
math::XYZPoint Point
point in the space
Definition: Particle.h:25
Candidate.h
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45