CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SoftKillerProducer Class Reference

#include <CommonTools/PileupAlgos/plugins/SoftKillerProducer.cc>

Inheritance diagram for SoftKillerProducer:
edm::stream::EDProducer<>

Public Types

typedef math::XYZTLorentzVector LorentzVector
 
typedef std::vector
< LorentzVector
LorentzVectorCollection
 
typedef std::vector
< reco::PFCandidate
PFOutputCollection
 
- 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
 

Public Member Functions

 SoftKillerProducer (const edm::ParameterSet &)
 
 ~SoftKillerProducer () 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
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double Rho_EtaMax_
 
double rParam_
 
edm::EDGetTokenT
< reco::CandidateView
tokenPFCandidates_
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 42 of file SoftKillerProducer.cc.

Member Typedef Documentation

Definition at line 44 of file SoftKillerProducer.cc.

Definition at line 45 of file SoftKillerProducer.cc.

Definition at line 46 of file SoftKillerProducer.cc.

Constructor & Destructor Documentation

SoftKillerProducer::SoftKillerProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 71 of file SoftKillerProducer.cc.

References edm::ParameterSet::getParameter(), and tokenPFCandidates_.

72  : Rho_EtaMax_(iConfig.getParameter<double>("Rho_EtaMax")), rParam_(iConfig.getParameter<double>("rParam")) {
73  tokenPFCandidates_ = consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("PFCandidates"));
74 
75  produces<edm::ValueMap<LorentzVector> >("SoftKillerP4s");
76  produces<PFOutputCollection>();
77 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::CandidateView > tokenPFCandidates_
SoftKillerProducer::~SoftKillerProducer ( )
override

Definition at line 79 of file SoftKillerProducer.cc.

79 {}

Member Function Documentation

void SoftKillerProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 86 of file SoftKillerProducer.cc.

References reco::Candidate::charge(), edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), mps_fire::i, gpuClustering::id, edm::helper::Filler< Map >::insert(), dqmiolumiharvest::j, eostools::move(), reco::Candidate::p4(), reco::Candidate::pdgId(), slimmedMuons_cfi::pfCandidates, edm::Event::put(), Rho_EtaMax_, rParam_, reco::LeafCandidate::setP4(), tokenPFCandidates_, reco::PFCandidate::translatePdgIdToType(), and hgcalPerformanceValidation::val.

86  {
87  std::unique_ptr<PFOutputCollection> pOutput(new PFOutputCollection);
88 
89  // get PF Candidates
91  iEvent.getByToken(tokenPFCandidates_, pfCandidates);
92 
93  std::vector<fastjet::PseudoJet> fjInputs;
94  for (auto i = pfCandidates->begin(), ibegin = pfCandidates->begin(), iend = pfCandidates->end(); i != iend; ++i) {
95  fjInputs.push_back(fastjet::PseudoJet(i->px(), i->py(), i->pz(), i->energy()));
96  fjInputs.back().set_user_index(i - ibegin);
97  }
98 
99  // soft killer:
100  fastjet::contrib::SoftKiller soft_killer(Rho_EtaMax_, rParam_);
101 
102  double pt_threshold = 0.;
103  std::vector<fastjet::PseudoJet> soft_killed_event;
104  soft_killer.apply(fjInputs, soft_killed_event, pt_threshold);
105 
106  std::unique_ptr<edm::ValueMap<LorentzVector> > p4SKOut(new edm::ValueMap<LorentzVector>());
108 
109  static const reco::PFCandidate dummySinceTranslateIsNotStatic;
110 
111  // To satisfy the value map, the size of the "killed" collection needs to be the
112  // same size as the input collection, so if the constituent is killed, just set E = 0
113  for (auto j = fjInputs.begin(), jend = fjInputs.end(); j != jend; ++j) {
114  const reco::Candidate& cand = pfCandidates->at(j->user_index());
115  auto id = dummySinceTranslateIsNotStatic.translatePdgIdToType(cand.pdgId());
116  const reco::PFCandidate* pPF = dynamic_cast<const reco::PFCandidate*>(&cand);
117  reco::PFCandidate pCand(pPF ? *pPF : reco::PFCandidate(cand.charge(), cand.p4(), id));
118  auto val = j->user_index();
119  auto skmatch = find_if(soft_killed_event.begin(), soft_killed_event.end(), [&val](fastjet::PseudoJet const& i) {
120  return i.user_index() == val;
121  });
122  LorentzVector pVec;
123  if (skmatch != soft_killed_event.end()) {
124  pVec.SetPxPyPzE(skmatch->px(), skmatch->py(), skmatch->pz(), skmatch->E());
125  } else {
126  pVec.SetPxPyPzE(0., 0., 0., 0.);
127  }
128  pCand.setP4(pVec);
129  skP4s.push_back(pVec);
130  pOutput->push_back(pCand);
131  }
132 
133  //Compute the modified p4s
134  edm::ValueMap<LorentzVector>::Filler p4SKFiller(*p4SKOut);
135  p4SKFiller.insert(pfCandidates, skP4s.begin(), skP4s.end());
136  p4SKFiller.fill();
137 
138  iEvent.put(std::move(p4SKOut), "SoftKillerP4s");
139  iEvent.put(std::move(pOutput));
140 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
uint16_t *__restrict__ id
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
def move
Definition: eostools.py:511
math::XYZTLorentzVector LorentzVector
virtual int charge() const =0
electric charge
std::vector< LorentzVector > LorentzVectorCollection
std::vector< reco::PFCandidate > PFOutputCollection
virtual int pdgId() const =0
PDG identifier.
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:231
edm::EDGetTokenT< reco::CandidateView > tokenPFCandidates_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector

Member Data Documentation

double SoftKillerProducer::Rho_EtaMax_
private

Definition at line 56 of file SoftKillerProducer.cc.

Referenced by produce().

double SoftKillerProducer::rParam_
private

Definition at line 57 of file SoftKillerProducer.cc.

Referenced by produce().

edm::EDGetTokenT<reco::CandidateView> SoftKillerProducer::tokenPFCandidates_
private

Definition at line 54 of file SoftKillerProducer.cc.

Referenced by produce(), and SoftKillerProducer().