CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef math::XYZTLorentzVector LorentzVector
 
typedef std::vector
< LorentzVector
LorentzVectorCollection
 
typedef std::vector
< reco::PFCandidate
PFOutputCollection
 
- 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 SoftKillerProducer (const edm::ParameterSet &)
 
 ~SoftKillerProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 45 of file SoftKillerProducer.cc.

Member Typedef Documentation

Definition at line 47 of file SoftKillerProducer.cc.

Definition at line 48 of file SoftKillerProducer.cc.

Definition at line 49 of file SoftKillerProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 76 of file SoftKillerProducer.cc.

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

76  :
77  Rho_EtaMax_( iConfig.getParameter<double>("Rho_EtaMax") ),
78  rParam_ ( iConfig.getParameter<double>("rParam") )
79 {
80 
82  = consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("PFCandidates"));
83 
84  produces<edm::ValueMap<LorentzVector> > ("SoftKillerP4s");
85  produces< PFOutputCollection >();
86 
87 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::CandidateView > tokenPFCandidates_
SoftKillerProducer::~SoftKillerProducer ( )

Definition at line 90 of file SoftKillerProducer.cc.

91 {
92 
93 }

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 102 of file SoftKillerProducer.cc.

References reco::Candidate::charge(), edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), i, edm::helper::Filler< Map >::insert(), j, reco::Candidate::p4(), reco::Candidate::pdgId(), reco::tau::pfCandidates(), edm::Event::put(), Rho_EtaMax_, rParam_, reco::LeafCandidate::setP4(), tokenPFCandidates_, and reco::PFCandidate::translatePdgIdToType().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

103 {
104 
105  std::auto_ptr< PFOutputCollection > pOutput( new PFOutputCollection );
106 
107  // get PF Candidates
109  iEvent.getByToken( tokenPFCandidates_, pfCandidates);
110 
111  std::vector<fastjet::PseudoJet> fjInputs;
112  for ( auto i = pfCandidates->begin(),
113  ibegin = pfCandidates->begin(),
114  iend = pfCandidates->end(); i != iend; ++i ) {
115  fjInputs.push_back( fastjet::PseudoJet( i->px(), i->py(), i->pz(), i->energy() ) );
116  fjInputs.back().set_user_index( i - ibegin );
117  }
118 
119  // soft killer:
120  fastjet::contrib::SoftKiller soft_killer(Rho_EtaMax_, rParam_);
121 
122  double pt_threshold = 0.;
123  std::vector<fastjet::PseudoJet> soft_killed_event;
124  soft_killer.apply(fjInputs, soft_killed_event, pt_threshold);
125 
126  std::auto_ptr<edm::ValueMap<LorentzVector> > p4SKOut(new edm::ValueMap<LorentzVector>());
128 
129  static const reco::PFCandidate dummySinceTranslateIsNotStatic;
130 
131  // To satisfy the value map, the size of the "killed" collection needs to be the
132  // same size as the input collection, so if the constituent is killed, just set E = 0
133  for ( auto j = fjInputs.begin(),
134  jend = fjInputs.end(); j != jend; ++j ) {
135  const reco::Candidate& cand = pfCandidates->at(j->user_index());
136  auto id = dummySinceTranslateIsNotStatic.translatePdgIdToType(cand.pdgId());
137  const reco::PFCandidate *pPF = dynamic_cast<const reco::PFCandidate*>(&cand);
138  reco::PFCandidate pCand( pPF ? *pPF : reco::PFCandidate(cand.charge(), cand.p4(), id) );
139  auto val = j->user_index();
140  auto skmatch = find_if( soft_killed_event.begin(), soft_killed_event.end(), [&val](fastjet::PseudoJet const & i){return i.user_index() == val;} );
141  LorentzVector pVec;
142  if ( skmatch != soft_killed_event.end() ) {
143  pVec.SetPxPyPzE(skmatch->px(),skmatch->py(),skmatch->pz(),skmatch->E());
144  } else {
145  pVec.SetPxPyPzE( 0., 0., 0., 0.);
146  }
147  pCand.setP4(pVec);
148  skP4s.push_back( pVec );
149  pOutput->push_back(pCand);
150  }
151 
152  //Compute the modified p4s
153  edm::ValueMap<LorentzVector>::Filler p4SKFiller(*p4SKOut);
154  p4SKFiller.insert(pfCandidates,skP4s.begin(), skP4s.end() );
155  p4SKFiller.fill();
156 
157  iEvent.put(p4SKOut,"SoftKillerP4s");
158  iEvent.put( pOutput );
159 
160 }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
math::XYZTLorentzVector LorentzVector
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
int j
Definition: DBlmapReader.cc:9
virtual int charge() const =0
electric charge
std::vector< LorentzVector > LorentzVectorCollection
virtual int pdgId() const =0
PDG identifier.
std::vector< reco::PFCandidate > PFOutputCollection
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:224
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
edm::EDGetTokenT< reco::CandidateView > tokenPFCandidates_
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector

Member Data Documentation

double SoftKillerProducer::Rho_EtaMax_
private

Definition at line 60 of file SoftKillerProducer.cc.

Referenced by produce().

double SoftKillerProducer::rParam_
private

Definition at line 61 of file SoftKillerProducer.cc.

Referenced by produce().

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

Definition at line 57 of file SoftKillerProducer.cc.

Referenced by produce(), and SoftKillerProducer().