CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
IsolatedTrackCleaner Class Reference
Inheritance diagram for IsolatedTrackCleaner:
edm::stream::EDProducer<>

Public Member Functions

 IsolatedTrackCleaner (edm::ParameterSet const &params)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~IsolatedTrackCleaner () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Protected Attributes

StringCutObjectSelector< pat::IsolatedTrackcut_
 
std::vector< edm::EDGetTokenT< reco::CandidateView > > leptons_
 
edm::EDGetTokenT< std::vector< pat::IsolatedTrack > > tracks_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 12 of file IsolatedTrackCleaner.cc.

Constructor & Destructor Documentation

IsolatedTrackCleaner::IsolatedTrackCleaner ( edm::ParameterSet const &  params)
inline

Definition at line 14 of file IsolatedTrackCleaner.cc.

References edm::ParameterSet::getParameter(), leptons_, and GlobalPosition_Frontier_DevDB_cff::tag.

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  }
edm::EDGetTokenT< std::vector< pat::IsolatedTrack > > tracks_
StringCutObjectSelector< pat::IsolatedTrack > cut_
std::vector< edm::EDGetTokenT< reco::CandidateView > > leptons_
IsolatedTrackCleaner::~IsolatedTrackCleaner ( )
inlineoverride

Definition at line 23 of file IsolatedTrackCleaner.cc.

23 {}

Member Function Documentation

void IsolatedTrackCleaner::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverride

Definition at line 25 of file IsolatedTrackCleaner.cc.

References cut_, edm::Event::getByToken(), mps_fire::i, HLT_2018_cff::leptons, leptons_, eostools::move(), dqmiodumpmetadata::n, MillePedeFileConverter_cfg::out, edm::Event::put(), edm::refToPtr(), unpackBuffers-CaloStage2::token, HLT_2018_cff::track, PDWG_EXOHSCP_cff::tracks, and tracks_.

25  {
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  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< std::vector< pat::IsolatedTrack > > tracks_
StringCutObjectSelector< pat::IsolatedTrack > cut_
def move(src, dest)
Definition: eostools.py:511
std::vector< edm::EDGetTokenT< reco::CandidateView > > leptons_

Member Data Documentation

StringCutObjectSelector<pat::IsolatedTrack> IsolatedTrackCleaner::cut_
protected

Definition at line 61 of file IsolatedTrackCleaner.cc.

Referenced by produce().

std::vector<edm::EDGetTokenT<reco::CandidateView> > IsolatedTrackCleaner::leptons_
protected

Definition at line 62 of file IsolatedTrackCleaner.cc.

Referenced by IsolatedTrackCleaner(), and produce().

edm::EDGetTokenT<std::vector<pat::IsolatedTrack> > IsolatedTrackCleaner::tracks_
protected

Definition at line 60 of file IsolatedTrackCleaner.cc.

Referenced by produce().