CMS 3D CMS Logo

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

Public Member Functions

 LeptonInJetProducer (const edm::ParameterSet &iConfig)
 
 ~LeptonInJetProducer () 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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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 > calculateLSF (std::vector< fastjet::PseudoJet > iCParticles, std::vector< fastjet::PseudoJet > &ljets, float ilPt, float ilEta, float ilPhi, int ilId, double dr, int nsj) const
 
void produce (edm::StreamID, edm::Event &, edm::EventSetup const &) const override
 

Static Private Member Functions

static bool orderPseudoJet (fastjet::PseudoJet j1, fastjet::PseudoJet j2)
 

Private Attributes

edm::EDGetTokenT< edm::View< pat::Electron > > srcEle_
 
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
 
edm::EDGetTokenT< edm::View< pat::Muon > > srcMu_
 

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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 LeptonInJetProducer< T >

Definition at line 31 of file LeptonInJetProducer.cc.

Constructor & Destructor Documentation

◆ LeptonInJetProducer()

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

Definition at line 33 of file LeptonInJetProducer.cc.

37  produces<edm::ValueMap<float>>("lsf3");
38  produces<edm::ValueMap<int>>("muIdx3SJ");
39  produces<edm::ValueMap<int>>("eleIdx3SJ");
40  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::View< pat::Electron > > srcEle_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
edm::EDGetTokenT< edm::View< pat::Muon > > srcMu_

◆ ~LeptonInJetProducer()

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

Definition at line 41 of file LeptonInJetProducer.cc.

41 {};

Member Function Documentation

◆ calculateLSF()

template<typename T >
std::tuple< float, float > LeptonInJetProducer< T >::calculateLSF ( std::vector< fastjet::PseudoJet >  iCParticles,
std::vector< fastjet::PseudoJet > &  ljets,
float  ilPt,
float  ilEta,
float  ilPhi,
int  ilId,
double  dr,
int  nsj 
) const
private

Definition at line 163 of file LeptonInJetProducer.cc.

References reco::deltaR(), HGC3DClusterGenMatchSelector_cfi::dR, l1ctLayer1_cff::dr, HLT_2022v15_cff::dRmin, PVValHelper::eta, visualization-live-secondInstance_cfg::m, PVValHelper::phi, and DiDispStaMuonMonitor_cfi::pt.

170  {
171  float lsf(-1), lmd(-1);
172  if (ilPt > 0 && (ilId == 11 || ilId == 13)) {
173  TLorentzVector ilep;
174  if (ilId == 11)
175  ilep.SetPtEtaPhiM(ilPt, ilEta, ilPhi, 0.000511);
176  if (ilId == 13)
177  ilep.SetPtEtaPhiM(ilPt, ilEta, ilPhi, 0.105658);
178  fastjet::JetDefinition lCJet_def(fastjet::kt_algorithm, dr);
179  fastjet::ClusterSequence lCClust_seq(iCParticles, lCJet_def);
180  if (dr > 0.5) {
181  lsubjets = sorted_by_pt(lCClust_seq.exclusive_jets_up_to(nsj));
182  } else {
183  lsubjets = sorted_by_pt(lCClust_seq.inclusive_jets());
184  }
185  int lId(-1);
186  double dRmin = 999.;
187  for (unsigned int i0 = 0; i0 < lsubjets.size(); i0++) {
188  double dR = reco::deltaR(lsubjets[i0].eta(), lsubjets[i0].phi(), ilep.Eta(), ilep.Phi());
189  if (dR < dRmin) {
190  dRmin = dR;
191  lId = i0;
192  }
193  }
194  if (lId != -1) {
195  TLorentzVector pVec;
196  pVec.SetPtEtaPhiM(lsubjets[lId].pt(), lsubjets[lId].eta(), lsubjets[lId].phi(), lsubjets[lId].m());
197  lsf = ilep.Pt() / pVec.Pt();
198  lmd = (ilep - pVec).M() / pVec.M();
199  }
200  }
201  return std::tuple<float, float>(lsf, lmd);
202 }
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30

◆ fillDescriptions()

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

Definition at line 205 of file LeptonInJetProducer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), and submitPVResolutionJobs::desc.

205  {
207  desc.add<edm::InputTag>("src")->setComment("jet input collection");
208  desc.add<edm::InputTag>("srcEle")->setComment("electron input collection");
209  desc.add<edm::InputTag>("srcMu")->setComment("muon input collection");
210  descriptions.addWithDefaultLabel(desc);
211 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ orderPseudoJet()

template<typename T >
bool LeptonInJetProducer< T >::orderPseudoJet ( fastjet::PseudoJet  j1,
fastjet::PseudoJet  j2 
)
staticprivate

Definition at line 158 of file LeptonInJetProducer.cc.

158  {
159  return j1.perp2() > j2.perp2();
160 }

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 65 of file LeptonInJetProducer.cc.

References ztail::d, pat::Jet::daughterPtrVector(), reco::deltaR(), HLT_2022v15_cff::dRmin, reco::LeafCandidate::eta(), iEvent, matchByCommonSourceCandidatePtr(), eostools::move(), l1ctLayer1_cff::nMu, AlCaHLTBitMon_ParallelJobs::p, reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), jetsAK4_CHS_cff::sort, and electrons_cff::srcJet.

65  {
66  // needs jet collection (srcJet), leptons collection
67  auto srcJet = iEvent.getHandle(srcJet_);
68  const auto &eleProd = iEvent.get(srcEle_);
69  const auto &muProd = iEvent.get(srcMu_);
70 
71  unsigned int nJet = srcJet->size();
72  unsigned int nEle = eleProd.size();
73  unsigned int nMu = muProd.size();
74 
75  std::vector<float> vlsf3;
76  std::vector<int> vmuIdx3SJ;
77  std::vector<int> veleIdx3SJ;
78 
79  int ele_pfmatch_index = -1;
80  int mu_pfmatch_index = -1;
81 
82  // Find leptons in jets
83  for (unsigned int ij = 0; ij < nJet; ij++) {
84  const pat::Jet &itJet = (*srcJet)[ij];
85  if (itJet.pt() <= 10)
86  continue;
87  std::vector<fastjet::PseudoJet> lClusterParticles;
88  float lepPt(-1), lepEta(-1), lepPhi(-1);
89  int lepId(-1);
90  for (auto const &d : itJet.daughterPtrVector()) {
91  fastjet::PseudoJet p(d->px(), d->py(), d->pz(), d->energy());
92  lClusterParticles.emplace_back(p);
93  }
94 
95  // match to leading and closest electron or muon
96  double dRmin(0.8), dRele(999), dRmu(999), dRtmp(999);
97  for (unsigned int il(0); il < nEle; il++) {
98  const auto &lep = eleProd.at(il);
99  if (matchByCommonSourceCandidatePtr(lep, itJet)) {
100  dRtmp = reco::deltaR(itJet.eta(), itJet.phi(), lep.eta(), lep.phi());
101  if (dRtmp < dRmin && dRtmp < dRele && lep.pt() > lepPt) {
102  lepPt = lep.pt();
103  lepEta = lep.eta();
104  lepPhi = lep.phi();
105  lepId = 11;
106  ele_pfmatch_index = il;
107  dRele = dRtmp;
108  break;
109  }
110  }
111  }
112  for (unsigned int il(0); il < nMu; il++) {
113  const auto &lep = muProd.at(il);
114  if (matchByCommonSourceCandidatePtr(lep, itJet)) {
115  dRtmp = reco::deltaR(itJet.eta(), itJet.phi(), lep.eta(), lep.phi());
116  if (dRtmp < dRmin && dRtmp < dRele && dRtmp < dRmu && lep.pt() > lepPt) {
117  lepPt = lep.pt();
118  lepEta = lep.eta();
119  lepPhi = lep.phi();
120  lepId = 13;
121  ele_pfmatch_index = -1;
122  mu_pfmatch_index = il;
123  dRmu = dRtmp;
124  break;
125  }
126  }
127  }
128 
129  std::vector<fastjet::PseudoJet> psub_3;
130  std::sort(lClusterParticles.begin(), lClusterParticles.end(), orderPseudoJet);
131  auto lsf_3 = calculateLSF(lClusterParticles, psub_3, lepPt, lepEta, lepPhi, lepId, 2.0, 3);
132  vlsf3.push_back(std::get<0>(lsf_3));
133  veleIdx3SJ.push_back(ele_pfmatch_index);
134  vmuIdx3SJ.push_back(mu_pfmatch_index);
135  }
136 
137  // Filling table
138  auto lsf3V = std::make_unique<edm::ValueMap<float>>();
139  edm::ValueMap<float>::Filler fillerlsf3(*lsf3V);
140  fillerlsf3.insert(srcJet, vlsf3.begin(), vlsf3.end());
141  fillerlsf3.fill();
142  iEvent.put(std::move(lsf3V), "lsf3");
143 
144  auto muIdx3SJV = std::make_unique<edm::ValueMap<int>>();
145  edm::ValueMap<int>::Filler fillermuIdx3SJ(*muIdx3SJV);
146  fillermuIdx3SJ.insert(srcJet, vmuIdx3SJ.begin(), vmuIdx3SJ.end());
147  fillermuIdx3SJ.fill();
148  iEvent.put(std::move(muIdx3SJV), "muIdx3SJ");
149 
150  auto eleIdx3SJV = std::make_unique<edm::ValueMap<int>>();
151  edm::ValueMap<int>::Filler fillereleIdx3SJ(*eleIdx3SJV);
152  fillereleIdx3SJ.insert(srcJet, veleIdx3SJ.begin(), veleIdx3SJ.end());
153  fillereleIdx3SJ.fill();
154  iEvent.put(std::move(eleIdx3SJV), "eleIdx3SJ");
155 }
double pt() const final
transverse momentum
edm::EDGetTokenT< edm::View< pat::Electron > > srcEle_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
bool matchByCommonSourceCandidatePtr(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:9
std::tuple< float, float > calculateLSF(std::vector< fastjet::PseudoJet > iCParticles, std::vector< fastjet::PseudoJet > &ljets, float ilPt, float ilEta, float ilPhi, int ilId, double dr, int nsj) const
d
Definition: ztail.py:151
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
Analysis-level calorimeter jet class.
Definition: Jet.h:77
const reco::CompositePtrCandidate::daughters & daughterPtrVector() const override
references to daughtes
static bool orderPseudoJet(fastjet::PseudoJet j1, fastjet::PseudoJet j2)
edm::EDGetTokenT< edm::View< pat::Muon > > srcMu_
double phi() const final
momentum azimuthal angle
def move(src, dest)
Definition: eostools.py:511
double eta() const final
momentum pseudorapidity

Member Data Documentation

◆ srcEle_

template<typename T >
edm::EDGetTokenT<edm::View<pat::Electron> > LeptonInJetProducer< T >::srcEle_
private

Definition at line 59 of file LeptonInJetProducer.cc.

◆ srcJet_

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

Definition at line 58 of file LeptonInJetProducer.cc.

◆ srcMu_

template<typename T >
edm::EDGetTokenT<edm::View<pat::Muon> > LeptonInJetProducer< T >::srcMu_
private

Definition at line 60 of file LeptonInJetProducer.cc.