CMS 3D CMS Logo

IsolatedTrackCleaner.cc
Go to the documentation of this file.
9 
10 #include <vector>
11 
13 public:
15  : tracks_(consumes<std::vector<pat::IsolatedTrack>>(params.getParameter<edm::InputTag>("tracks"))),
16  cut_(params.getParameter<std::string>("cut")) {
17  for (const edm::InputTag& tag : params.getParameter<std::vector<edm::InputTag>>("finalLeptons")) {
18  leptons_.push_back(consumes<reco::CandidateView>(tag));
19  }
20  produces<std::vector<pat::IsolatedTrack>>();
21  }
22 
23  ~IsolatedTrackCleaner() override {}
24 
25  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override {
26  auto out = std::make_unique<std::vector<pat::IsolatedTrack>>();
27 
28  std::vector<reco::CandidatePtr> leptonPfCands;
30  for (const auto& token : leptons_) {
31  iEvent.getByToken(token, leptons);
32  for (const auto& lep : *leptons) {
33  for (unsigned int i = 0, n = lep.numberOfSourceCandidatePtrs(); i < n; ++i) {
34  auto ptr = lep.sourceCandidatePtr(i);
35  if (ptr.isNonnull())
36  leptonPfCands.push_back(ptr);
37  }
38  }
39  }
40  std::sort(leptonPfCands.begin(), leptonPfCands.end());
41 
43  iEvent.getByToken(tracks_, tracks);
44  for (const auto& track : *tracks) {
45  if (!cut_(track))
46  continue;
47  if (track.packedCandRef().isNonnull()) {
48  reco::CandidatePtr pfCand(edm::refToPtr(track.packedCandRef()));
49  if (std::binary_search(leptonPfCands.begin(), leptonPfCands.end(), pfCand)) {
50  continue;
51  }
52  }
53  out->push_back(track);
54  }
55 
56  iEvent.put(std::move(out));
57  }
58 
59 protected:
62  std::vector<edm::EDGetTokenT<reco::CandidateView>> leptons_;
63 };
64 
IsolatedTrackCleaner::IsolatedTrackCleaner
IsolatedTrackCleaner(edm::ParameterSet const &params)
Definition: IsolatedTrackCleaner.cc:14
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
IsolatedTrackCleaner::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: IsolatedTrackCleaner.cc:25
EDProducer.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::refToPtr
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
MakerMacros.h
IsolatedTrackCleaner::~IsolatedTrackCleaner
~IsolatedTrackCleaner() override
Definition: IsolatedTrackCleaner.cc:23
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
IsolatedTrack.h
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
IsolatedTrackCleaner
Definition: IsolatedTrackCleaner.cc:12
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
HLT_2018_cff.leptons
leptons
Definition: HLT_2018_cff.py:24820
iEvent
int iEvent
Definition: GenABIO.cc:224
RefToPtr.h
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
edm::Ptr< Candidate >
IsolatedTrackCleaner::leptons_
std::vector< edm::EDGetTokenT< reco::CandidateView > > leptons_
Definition: IsolatedTrackCleaner.cc:62
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
StringCutObjectSelector.h
StringCutObjectSelector< pat::IsolatedTrack >
IsolatedTrackCleaner::cut_
StringCutObjectSelector< pat::IsolatedTrack > cut_
Definition: IsolatedTrackCleaner.cc:61
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
Candidate.h
ParameterSet.h
IsolatedTrackCleaner::tracks_
edm::EDGetTokenT< std::vector< pat::IsolatedTrack > > tracks_
Definition: IsolatedTrackCleaner.cc:60
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316