CMS 3D CMS Logo

PFTauMiniAODPrimaryVertexProducer.cc
Go to the documentation of this file.
5 
8 public:
11 
12  void beginEvent(const edm::Event &, const edm::EventSetup &) override;
13  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
14 
15 protected:
16  void nonTauTracksInPV(const reco::VertexRef &,
17  const std::vector<edm::Ptr<reco::TrackBase> > &,
18  std::vector<const reco::Track *> &) override;
19 
20 private:
21  void nonTauTracksInPVFromPackedCands(const size_t &,
23  const std::vector<edm::Ptr<reco::TrackBase> > &,
24  std::vector<const reco::Track *> &);
25 
28 };
29 
32  packedCandsToken_(
33  consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedCandidatesTag"))),
34  lostCandsToken_(
35  consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("lostCandidatesTag"))) {}
36 
38 
40  //Get candidate collections
42  iEvent.getByToken(lostCandsToken_, lostCands_);
43 }
44 
46  const std::vector<edm::Ptr<reco::TrackBase> > &tauTracks,
47  std::vector<const reco::Track *> &nonTauTracks) {
48  //Find non-tau tracks associated to thePV
49  //PackedCandidates first...
50  if (packedCands_.isValid()) {
51  nonTauTracksInPVFromPackedCands(thePVRef.key(), *packedCands_, tauTracks, nonTauTracks);
52  }
53  //then lostCandidates
54  if (lostCands_.isValid()) {
55  nonTauTracksInPVFromPackedCands(thePVRef.key(), *lostCands_, tauTracks, nonTauTracks);
56  }
57 }
58 
60  const size_t &thePVkey,
62  const std::vector<edm::Ptr<reco::TrackBase> > &tauTracks,
63  std::vector<const reco::Track *> &nonTauTracks) {
64  //Find candidates/tracks associated to thePV
65  for (const auto &cand : cands) {
66  if (cand.vertexRef().isNull())
67  continue;
68  int quality = cand.pvAssociationQuality();
69  if (cand.vertexRef().key() != thePVkey ||
71  continue;
72  const reco::Track *track = cand.bestTrack();
73  if (track == nullptr)
74  continue;
75  //Remove signal (tau) tracks
76  //MB: Only deltaR deltaPt overlap removal possible (?)
77  //MB: It should be fine as pat objects stores same track info with same presision
78  bool matched = false;
79  for (const auto &tauTrack : tauTracks) {
80  if (std::abs(tauTrack->eta() - track->eta()) < 0.005 &&
81  std::abs(deltaPhi(tauTrack->phi(), track->phi())) < 0.005 &&
82  std::abs(tauTrack->pt() / track->pt() - 1.) < 0.005) {
83  matched = true;
84  break;
85  }
86  }
87  if (!matched)
88  nonTauTracks.push_back(track);
89  }
90 }
91 
94  desc.add<edm::InputTag>("lostCandidatesTag", edm::InputTag("lostTracks"));
95  desc.add<edm::InputTag>("packedCandidatesTag", edm::InputTag("packedPFCandidates"));
96 
97  descriptions.add("pfTauMiniAODPrimaryVertexProducer", desc);
98 }
99 
muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
PFTauMiniAODPrimaryVertexProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFTauMiniAODPrimaryVertexProducer.cc:92
edm::EDGetTokenT< pat::PackedCandidateCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Handle< pat::PackedCandidateCollection >
pat::PackedCandidate::UsedInFitLoose
Definition: PackedCandidate.h:726
edm::Ref< VertexCollection >
PFTauMiniAODPrimaryVertexProducer::PFTauMiniAODPrimaryVertexProducer
PFTauMiniAODPrimaryVertexProducer(const edm::ParameterSet &iConfig)
Definition: PFTauMiniAODPrimaryVertexProducer.cc:30
deltaR.h
PFTauMiniAODPrimaryVertexProducer
MiniAOD implementation of the PFTauPrimaryVertexProducer plugin.
Definition: PFTauMiniAODPrimaryVertexProducer.cc:7
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
reco::Track
Definition: Track.h:27
PFTauMiniAODPrimaryVertexProducer::packedCands_
edm::Handle< pat::PackedCandidateCollection > packedCands_
Definition: PFTauMiniAODPrimaryVertexProducer.cc:27
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPV
void nonTauTracksInPV(const reco::VertexRef &, const std::vector< edm::Ptr< reco::TrackBase > > &, std::vector< const reco::Track * > &) override
Definition: PFTauMiniAODPrimaryVertexProducer.cc:45
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
PackedCandidate.h
cand
Definition: decayParser.h:34
iEvent
int iEvent
Definition: GenABIO.cc:224
PFTauMiniAODPrimaryVertexProducer::nonTauTracksInPVFromPackedCands
void nonTauTracksInPVFromPackedCands(const size_t &, const pat::PackedCandidateCollection &, const std::vector< edm::Ptr< reco::TrackBase > > &, std::vector< const reco::Track * > &)
Definition: PFTauMiniAODPrimaryVertexProducer.cc:59
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
edm::Ptr
Definition: AssociationVector.h:31
pat::PackedCandidateCollection
std::vector< pat::PackedCandidate > PackedCandidateCollection
Definition: PackedCandidate.h:1130
PFTauPrimaryVertexProducerBase.h
qcdUeDQM_cfi.quality
quality
Definition: qcdUeDQM_cfi.py:31
PFTauMiniAODPrimaryVertexProducer::~PFTauMiniAODPrimaryVertexProducer
~PFTauMiniAODPrimaryVertexProducer() override
Definition: PFTauMiniAODPrimaryVertexProducer.cc:37
PFTauPrimaryVertexProducerBase::getDescriptionsBase
static edm::ParameterSetDescription getDescriptionsBase()
Definition: PFTauPrimaryVertexProducerBase.cc:220
PFTauMiniAODPrimaryVertexProducer::beginEvent
void beginEvent(const edm::Event &, const edm::EventSetup &) override
Definition: PFTauMiniAODPrimaryVertexProducer.cc:39
HLT_2018_cff.cands
cands
Definition: HLT_2018_cff.py:13762
PFTauPrimaryVertexProducerBase
Definition: PFTauPrimaryVertexProducerBase.h:39
PFTauMiniAODPrimaryVertexProducer::packedCandsToken_
edm::EDGetTokenT< pat::PackedCandidateCollection > packedCandsToken_
Definition: PFTauMiniAODPrimaryVertexProducer.cc:26
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PFTauMiniAODPrimaryVertexProducer::lostCands_
edm::Handle< pat::PackedCandidateCollection > lostCands_
Definition: PFTauMiniAODPrimaryVertexProducer.cc:27
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
pat::PackedCandidate::UsedInFitTight
Definition: PackedCandidate.h:727
PFTauMiniAODPrimaryVertexProducer::lostCandsToken_
edm::EDGetTokenT< pat::PackedCandidateCollection > lostCandsToken_
Definition: PFTauMiniAODPrimaryVertexProducer.cc:26
edm::InputTag
Definition: InputTag.h:15