CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
PATPuppiJetSpecificProducer Class Reference
Inheritance diagram for PATPuppiJetSpecificProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATPuppiJetSpecificProducer (const edm::ParameterSet &cfg)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~PATPuppiJetSpecificProducer ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::EDGetTokenT< edm::View< pat::Jet > > jets_token
 
edm::InputTag srcjets_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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

Definition at line 24 of file PATPuppiJetSpecificsProducer.cc.

Constructor & Destructor Documentation

PATPuppiJetSpecificProducer::PATPuppiJetSpecificProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 40 of file PATPuppiJetSpecificsProducer.cc.

References edm::ParameterSet::getParameter(), jets_token, and srcjets_.

41 {
42  srcjets_ = cfg.getParameter<edm::InputTag>("src");
43  jets_token = consumes<edm::View<pat::Jet> >(srcjets_);
44 
45  produces<edm::ValueMap<float> >("puppiMultiplicity");
46  produces<edm::ValueMap<float> >("neutralPuppiMultiplicity");
47  produces<edm::ValueMap<float> >("neutralHadronPuppiMultiplicity");
48  produces<edm::ValueMap<float> >("photonPuppiMultiplicity");
49  produces<edm::ValueMap<float> >("HFHadronPuppiMultiplicity");
50  produces<edm::ValueMap<float> >("HFEMPuppiMultiplicity");
51 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< pat::Jet > > jets_token
PATPuppiJetSpecificProducer::~PATPuppiJetSpecificProducer ( )
inline

Definition at line 29 of file PATPuppiJetSpecificsProducer.cc.

References fillDescriptions(), and produce().

29 {}

Member Function Documentation

void PATPuppiJetSpecificProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 143 of file PATPuppiJetSpecificsProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and DEFINE_FWK_MODULE.

Referenced by ~PATPuppiJetSpecificProducer().

143  {
145  desc.add<edm::InputTag>("src", edm::InputTag("slimmedJets"));
146  descriptions.add("patPuppiJetSpecificProducer", desc);
147 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PATPuppiJetSpecificProducer::produce ( edm::StreamID  ,
edm::Event evt,
const edm::EventSetup es 
) const
override

Definition at line 53 of file PATPuppiJetSpecificsProducer.cc.

References funct::abs(), EnergyCorrector::c, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), mps_fire::i, edm::helper::Filler< Map >::insert(), fwrapper::jets, jets_token, eostools::move(), pat::PackedCandidate::pdgId(), pat::PackedCandidate::puppiWeight(), edm::Event::put(), and mps_merge::weight.

Referenced by ~PATPuppiJetSpecificProducer().

54 {
56  evt.getByToken(jets_token, jets);
57 
58  std::vector<float> puppiMultiplicities;
59  std::vector<float> neutralPuppiMultiplicities;
60  std::vector<float> neutralHadronPuppiMultiplicities;
61  std::vector<float> photonPuppiMultiplicities;
62  std::vector<float> HFHadronPuppiMultiplicities;
63  std::vector<float> HFEMPuppiMultiplicities;
64 
65  for( auto const& c : *jets ) {
66  float puppiMultiplicity = 0;
67  float neutralPuppiMultiplicity = 0;
68  float neutralHadronPuppiMultiplicity = 0;
69  float photonPuppiMultiplicity = 0;
70  float HFHadronPuppiMultiplicity = 0;
71  float HFEMPuppiMultiplicity = 0;
72 
73  for (unsigned i = 0; i < c.numberOfDaughters(); i++) {
74  const pat::PackedCandidate &dau = static_cast<const pat::PackedCandidate &>(*c.daughter(i));
75  auto weight = dau.puppiWeight();
76  puppiMultiplicity += weight;
77  // This logic is taken from RecoJets/JetProducers/src/JetSpecific.cc
78  switch (std::abs(dau.pdgId())) {
79  case 130: //PFCandidate::h0 : // neutral hadron
80  neutralHadronPuppiMultiplicity += weight;
81  neutralPuppiMultiplicity += weight;
82  break;
83  case 22: //PFCandidate::gamma: // photon
84  photonPuppiMultiplicity += weight;
85  neutralPuppiMultiplicity += weight;
86  break;
87  case 1: // PFCandidate::h_HF : // hadron in HF
88  HFHadronPuppiMultiplicity += weight;
89  neutralPuppiMultiplicity += weight;
90  break;
91  case 2: //PFCandidate::egamma_HF : // electromagnetic in HF
92  HFEMPuppiMultiplicity += weight;
93  neutralPuppiMultiplicity += weight;
94  break;
95  }
96  }
97 
98  puppiMultiplicities.push_back(puppiMultiplicity);
99  neutralPuppiMultiplicities.push_back(neutralPuppiMultiplicity);
100  neutralHadronPuppiMultiplicities.push_back(neutralHadronPuppiMultiplicity);
101  photonPuppiMultiplicities.push_back(photonPuppiMultiplicity);
102  HFHadronPuppiMultiplicities.push_back(HFHadronPuppiMultiplicity);
103  HFEMPuppiMultiplicities.push_back(HFEMPuppiMultiplicity);
104  }
105 
106  std::unique_ptr<edm::ValueMap<float> > puppiMultiplicities_out(new edm::ValueMap<float>());
107  edm::ValueMap<float>::Filler puppiMultiplicities_filler(*puppiMultiplicities_out);
108  puppiMultiplicities_filler.insert(jets,puppiMultiplicities.begin(),puppiMultiplicities.end());
109  puppiMultiplicities_filler.fill();
110  evt.put(std::move(puppiMultiplicities_out),"puppiMultiplicity");
111 
112  std::unique_ptr<edm::ValueMap<float> > neutralPuppiMultiplicities_out(new edm::ValueMap<float>());
113  edm::ValueMap<float>::Filler neutralPuppiMultiplicities_filler(*neutralPuppiMultiplicities_out);
114  neutralPuppiMultiplicities_filler.insert(jets,neutralPuppiMultiplicities.begin(),neutralPuppiMultiplicities.end());
115  neutralPuppiMultiplicities_filler.fill();
116  evt.put(std::move(neutralPuppiMultiplicities_out),"neutralPuppiMultiplicity");
117 
118  std::unique_ptr<edm::ValueMap<float> > neutralHadronPuppiMultiplicities_out(new edm::ValueMap<float>());
119  edm::ValueMap<float>::Filler neutralHadronPuppiMultiplicities_filler(*neutralHadronPuppiMultiplicities_out);
120  neutralHadronPuppiMultiplicities_filler.insert(jets,neutralHadronPuppiMultiplicities.begin(),neutralHadronPuppiMultiplicities.end());
121  neutralHadronPuppiMultiplicities_filler.fill();
122  evt.put(std::move(neutralHadronPuppiMultiplicities_out),"neutralHadronPuppiMultiplicity");
123 
124  std::unique_ptr<edm::ValueMap<float> > photonPuppiMultiplicities_out(new edm::ValueMap<float>());
125  edm::ValueMap<float>::Filler photonPuppiMultiplicities_filler(*photonPuppiMultiplicities_out);
126  photonPuppiMultiplicities_filler.insert(jets,photonPuppiMultiplicities.begin(),photonPuppiMultiplicities.end());
127  photonPuppiMultiplicities_filler.fill();
128  evt.put(std::move(photonPuppiMultiplicities_out),"photonPuppiMultiplicity");
129 
130  std::unique_ptr<edm::ValueMap<float> > HFHadronPuppiMultiplicities_out(new edm::ValueMap<float>());
131  edm::ValueMap<float>::Filler HFHadronPuppiMultiplicities_filler(*HFHadronPuppiMultiplicities_out);
132  HFHadronPuppiMultiplicities_filler.insert(jets,HFHadronPuppiMultiplicities.begin(),HFHadronPuppiMultiplicities.end());
133  HFHadronPuppiMultiplicities_filler.fill();
134  evt.put(std::move(HFHadronPuppiMultiplicities_out),"HFHadronPuppiMultiplicity");
135 
136  std::unique_ptr<edm::ValueMap<float> > HFEMPuppiMultiplicities_out(new edm::ValueMap<float>());
137  edm::ValueMap<float>::Filler HFEMPuppiMultiplicities_filler(*HFEMPuppiMultiplicities_out);
138  HFEMPuppiMultiplicities_filler.insert(jets,HFEMPuppiMultiplicities.begin(),HFEMPuppiMultiplicities.end());
139  HFEMPuppiMultiplicities_filler.fill();
140  evt.put(std::move(HFEMPuppiMultiplicities_out),"HFEMPuppiMultiplicity");
141 }
float puppiWeight() const
Set both weights at once (with option for only full PUPPI)
edm::EDGetTokenT< edm::View< pat::Jet > > jets_token
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
int pdgId() const override
PDG identifier.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
Definition: weight.py:1
vector< PseudoJet > jets
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::EDGetTokenT<edm::View<pat::Jet> > PATPuppiJetSpecificProducer::jets_token
private

Definition at line 36 of file PATPuppiJetSpecificsProducer.cc.

Referenced by PATPuppiJetSpecificProducer(), and produce().

edm::InputTag PATPuppiJetSpecificProducer::srcjets_
private

Definition at line 35 of file PATPuppiJetSpecificsProducer.cc.

Referenced by PATPuppiJetSpecificProducer().