CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
BetaStarVarProducer< T > Class Template Reference

#include <PhysicsTools/NanoAOD/plugins/BetaStarVarProducer.cc>

Inheritance diagram for BetaStarVarProducer< T >:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 BetaStarVarProducer (const edm::ParameterSet &iConfig)
 
 ~BetaStarVarProducer () override
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
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 Member Functions

std::tuple< float, float, float, float > calculateCHSEnergies (edm::Ptr< pat::Jet > const &jet, double chefrompv0) const
 
void fillValueMaps (std::string valueName, const std::vector< float > &values, edm::Handle< edm::View< pat::Jet >> &srcJet, edm::Event &iEvent) const
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

double maxDR_
 
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
 
edm::EDGetTokenT< edm::View< T > > srcPF_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

template<typename T>
class BetaStarVarProducer< T >

Description: This produces value maps to store CHS-related variables for JERC. This includes the charged hadrons associated to CHS jets, and those associated to PU that are within the CHS jet.

Implementation: This uses a ValueMap producer functionality, and loops over the input candidates (usually PackedCandidates) that are associated to each jet, counting the candidates associated to the PV and those not.

Definition at line 42 of file BetaStarVarProducer.cc.

Constructor & Destructor Documentation

◆ BetaStarVarProducer()

template<typename T >
BetaStarVarProducer< T >::BetaStarVarProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 44 of file BetaStarVarProducer.cc.

47  maxDR_(iConfig.getParameter<double>("maxDR")) {
48  produces<edm::ValueMap<float>>("chargedFromPV0EnergyFraction");
49  produces<edm::ValueMap<float>>("chargedFromPV1EnergyFraction");
50  produces<edm::ValueMap<float>>("chargedFromPV2EnergyFraction");
51  produces<edm::ValueMap<float>>("chargedFromPV3EnergyFraction");
52  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
edm::EDGetTokenT< edm::View< T > > srcPF_

◆ ~BetaStarVarProducer()

template<typename T >
BetaStarVarProducer< T >::~BetaStarVarProducer ( )
inlineoverride

Definition at line 53 of file BetaStarVarProducer.cc.

53 {};

Member Function Documentation

◆ calculateCHSEnergies()

template<typename T >
std::tuple< float, float, float, float > BetaStarVarProducer< T >::calculateCHSEnergies ( edm::Ptr< pat::Jet > const &  jet,
double  chefrompv0 
) const
private

Definition at line 134 of file BetaStarVarProducer.cc.

References pat::Jet::correctedP4(), pat::Jet::daughter(), pat::PackedCandidate::energy(), and pat::Jet::numberOfDaughters().

135  {
136  // Keep track of energy (present in the jet) for PU stuff
137  double chefrompv1 = 0.0;
138  double chefrompv2 = 0.0;
139  double chefrompv3 = 0.0;
140 
141  // Loop through the PF candidates within the jet.
142  // Store the sum of their energy, and their indices.
143  for (auto pidx = 0u; pidx < ijet->numberOfDaughters(); ++pidx) {
144  auto *dtr = dynamic_cast<const pat::PackedCandidate *>(ijet->daughter(pidx));
145  if (dtr->charge() == 0)
146  continue;
147  if (dtr->fromPV() == 1)
148  chefrompv1 += dtr->energy();
149  else if (dtr->fromPV() == 2)
150  chefrompv2 += dtr->energy();
151  else if (dtr->fromPV() == 3)
152  chefrompv3 += dtr->energy();
153  }
154 
155  // Now get the fractions relative to the raw jet.
156  auto rawP4 = ijet->correctedP4(0);
157  double chffpv0 = chefrompv0 / rawP4.energy();
158  double chffpv1 = chefrompv1 / rawP4.energy();
159  double chffpv2 = chefrompv2 / rawP4.energy();
160  double chffpv3 = chefrompv3 / rawP4.energy();
161 
162  return std::tuple<float, float, float, float>(chffpv0, chffpv1, chffpv2, chffpv3);
163 }
double energy() const override
energy

◆ fillDescriptions()

template<typename T >
void BetaStarVarProducer< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 166 of file BetaStarVarProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, timingPdfMaker::modname, and AlCaHLTBitMon_QueryRunRegistry::string.

166  {
168  desc.add<edm::InputTag>("srcJet")->setComment("jet input collection");
169  desc.add<edm::InputTag>("srcPF")->setComment("PF candidate input collection");
170  desc.add<double>("maxDR")->setComment("Maximum DR to consider for jet-->pf cand association");
171  std::string modname("BetaStarVarProducer");
172  descriptions.add(modname, desc);
173 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ fillValueMaps()

template<typename T >
void BetaStarVarProducer< T >::fillValueMaps ( std::string  valueName,
const std::vector< float > &  values,
edm::Handle< edm::View< pat::Jet >> &  srcJet,
edm::Event iEvent 
) const
private

Definition at line 122 of file BetaStarVarProducer.cc.

References edm::helper::Filler< Map >::fill(), iEvent, edm::helper::Filler< Map >::insert(), eostools::move(), electrons_cff::srcJet, and contentValuesCheck::values.

125  {
126  std::unique_ptr<edm::ValueMap<float>> valuesPtr(new edm::ValueMap<float>());
127  edm::ValueMap<float>::Filler valuesFiller(*valuesPtr);
128  valuesFiller.insert(srcJet, values.begin(), values.end());
129  valuesFiller.fill();
130  iEvent.put(std::move(valuesPtr), valueName);
131 }
int iEvent
Definition: GenABIO.cc:224
def move(src, dest)
Definition: eostools.py:511

◆ produce()

template<typename T >
void BetaStarVarProducer< T >::produce ( edm::StreamID  streamID,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 72 of file BetaStarVarProducer.cc.

References reco::deltaR(), HGC3DClusterGenMatchSelector_cfi::dR, HLT_2024v14_cff::dRMin, iEvent, metsig::jet, or, electrons_cff::srcJet, and jetsAK4_CHS_cff::srcPF.

72  {
74  iEvent.getByToken(srcJet_, srcJet);
76  iEvent.getByToken(srcPF_, srcPF);
77 
78  unsigned int nJet = srcJet->size();
79 
80  // Create an injective mapping from jets to charged PF candidates with fromPV==0 within the jet cone.
81  // These are the PF candidates supposedly removed by the CHS method - i.e. removed charged pileup.
82  std::vector<double> jet2pue(nJet, 0);
83  for (const auto &cand : *srcPF) {
84  if (cand.charge() == 0 or cand.fromPV() != 0)
85  continue;
86  // Looking for the closest match for this charged frompv==0 candidate
87  float dRMin = 999.;
88  int bestjet = -1, jetidx = 0;
89  for (const auto &jet : *srcJet) {
90  float dR = reco::deltaR(jet, cand);
91  if (dR < dRMin) {
92  dRMin = dR;
93  bestjet = jetidx;
94  }
95  ++jetidx;
96  }
97  // If the candidate is closer than the jet radius to the jet axis, this is a PU particle of interest for the selected jet
98  if (dRMin < maxDR_)
99  jet2pue[bestjet] += cand.energy();
100  }
101 
102  std::vector<float> chargedFromPV0EnergyFraction(nJet, -1);
103  std::vector<float> chargedFromPV1EnergyFraction(nJet, -1);
104  std::vector<float> chargedFromPV2EnergyFraction(nJet, -1);
105  std::vector<float> chargedFromPV3EnergyFraction(nJet, -1);
106 
107  for (unsigned int ij = 0; ij < nJet; ++ij) {
108  auto vals = calculateCHSEnergies(srcJet->ptrAt(ij), jet2pue[ij]);
109  chargedFromPV0EnergyFraction[ij] = std::get<0>(vals);
110  chargedFromPV1EnergyFraction[ij] = std::get<1>(vals);
111  chargedFromPV2EnergyFraction[ij] = std::get<2>(vals);
112  chargedFromPV3EnergyFraction[ij] = std::get<3>(vals);
113  }
114 
115  fillValueMaps("chargedFromPV0EnergyFraction", chargedFromPV0EnergyFraction, srcJet, iEvent);
116  fillValueMaps("chargedFromPV1EnergyFraction", chargedFromPV1EnergyFraction, srcJet, iEvent);
117  fillValueMaps("chargedFromPV2EnergyFraction", chargedFromPV2EnergyFraction, srcJet, iEvent);
118  fillValueMaps("chargedFromPV3EnergyFraction", chargedFromPV3EnergyFraction, srcJet, iEvent);
119 }
void fillValueMaps(std::string valueName, const std::vector< float > &values, edm::Handle< edm::View< pat::Jet >> &srcJet, edm::Event &iEvent) const
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
int iEvent
Definition: GenABIO.cc:224
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::EDGetTokenT< edm::View< T > > srcPF_
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
std::tuple< float, float, float, float > calculateCHSEnergies(edm::Ptr< pat::Jet > const &jet, double chefrompv0) const

Member Data Documentation

◆ maxDR_

template<typename T >
double BetaStarVarProducer< T >::maxDR_
private

Definition at line 68 of file BetaStarVarProducer.cc.

◆ srcJet_

template<typename T >
edm::EDGetTokenT<edm::View<pat::Jet> > BetaStarVarProducer< T >::srcJet_
private

Definition at line 66 of file BetaStarVarProducer.cc.

◆ srcPF_

template<typename T >
edm::EDGetTokenT<edm::View<T> > BetaStarVarProducer< T >::srcPF_
private

Definition at line 67 of file BetaStarVarProducer.cc.