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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 12 of file IsolatedTrackCleaner.cc.

Constructor & Destructor Documentation

◆ IsolatedTrackCleaner()

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

Definition at line 14 of file IsolatedTrackCleaner.cc.

References leptons_, submitPVValidationJobs::params, and makeGlobalPositionRcd_cfg::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::~IsolatedTrackCleaner ( )
inlineoverride

Definition at line 23 of file IsolatedTrackCleaner.cc.

23 {}

Member Function Documentation

◆ produce()

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

Definition at line 25 of file IsolatedTrackCleaner.cc.

References cut_, mps_fire::i, iEvent, HLT_2024v14_cff::leptons, leptons_, eostools::move(), dqmiodumpmetadata::n, MillePedeFileConverter_cfg::out, edm::refToPtr(), jetUpdater_cfi::sort, unpackBuffers-CaloStage2::token, HLT_2024v14_cff::track, DiMuonV_cfg::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  }
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
int iEvent
Definition: GenABIO.cc:224
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

◆ cut_

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

Definition at line 61 of file IsolatedTrackCleaner.cc.

Referenced by produce().

◆ leptons_

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

Definition at line 62 of file IsolatedTrackCleaner.cc.

Referenced by IsolatedTrackCleaner(), and produce().

◆ tracks_

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

Definition at line 60 of file IsolatedTrackCleaner.cc.

Referenced by produce().