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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 13 of file IsolatedTrackCleaner.cc.

Constructor & Destructor Documentation

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

Definition at line 15 of file IsolatedTrackCleaner.cc.

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

15  :
16  tracks_(consumes<std::vector<pat::IsolatedTrack>>(params.getParameter<edm::InputTag>("tracks"))),
17  cut_(params.getParameter<std::string>("cut"))
18  {
19  for (const edm::InputTag & tag : params.getParameter<std::vector<edm::InputTag>>("finalLeptons")) {
20  leptons_.push_back(consumes<reco::CandidateView>(tag));
21  }
22  produces<std::vector<pat::IsolatedTrack>>();
23  }
edm::EDGetTokenT< std::vector< pat::IsolatedTrack > > tracks_
StringCutObjectSelector< pat::IsolatedTrack > cut_
std::vector< edm::EDGetTokenT< reco::CandidateView > > leptons_
IsolatedTrackCleaner::~IsolatedTrackCleaner ( )
inlineoverride

Definition at line 25 of file IsolatedTrackCleaner.cc.

25 {}

Member Function Documentation

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

Definition at line 27 of file IsolatedTrackCleaner.cc.

References cut_, edm::Event::getByToken(), mps_fire::i, AK4GenJetFlavourInfos_cfi::leptons, leptons_, eostools::move(), gen::n, MillePedeFileConverter_cfg::out, edm::Event::put(), edm::refToPtr(), HiIsolationCommonParameters_cff::track, l1t::tracks, and tracks_.

27  {
28  auto out = std::make_unique<std::vector<pat::IsolatedTrack>>();
29 
30  std::vector<reco::CandidatePtr> leptonPfCands;
32  for (const auto & token : leptons_) {
33  iEvent.getByToken(token, leptons);
34  for (const auto & lep : *leptons) {
35  for (unsigned int i = 0, n = lep.numberOfSourceCandidatePtrs(); i < n; ++i) {
36  auto ptr = lep.sourceCandidatePtr(i);
37  if (ptr.isNonnull()) leptonPfCands.push_back(ptr);
38  }
39  }
40  }
41  std::sort(leptonPfCands.begin(), leptonPfCands.end());
42 
44  iEvent.getByToken(tracks_, tracks);
45  for (const auto & track : *tracks) {
46  if (!cut_(track)) 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:136
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:519
edm::EDGetTokenT< std::vector< pat::IsolatedTrack > > tracks_
StringCutObjectSelector< pat::IsolatedTrack > cut_
def move(src, dest)
Definition: eostools.py:510
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().