CMS 3D CMS Logo

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

#include <JetPlusTrackAddonSeedProducer.cc>

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

Public Member Functions

 JetPlusTrackAddonSeedProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) 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
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

const double dRcone_
 
const edm::EDGetTokenT
< CaloTowerCollection
input_ctw_token_
 
const edm::EDGetTokenT
< edm::View< reco::CaloJet > > 
input_jets_token_
 
const edm::EDGetTokenT
< edm::View< reco::TrackJet > > 
input_trackjets_token_
 
const edm::EDGetTokenT
< reco::VertexCollection
input_vertex_token_
 
const edm::EDGetTokenT
< std::vector
< pat::PackedCandidate > > 
tokenPFCandidates_
 
const bool usePAT_
 

Additional Inherited Members

- 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
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 48 of file JetPlusTrackAddonSeedProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 64 of file JetPlusTrackAddonSeedProducer.cc.

65  : dRcone_(iConfig.getParameter<double>("dRcone")),
66  usePAT_(iConfig.getParameter<bool>("UsePAT")),
67  input_jets_token_(consumes<edm::View<reco::CaloJet> >(iConfig.getParameter<edm::InputTag>("srcCaloJets"))),
68  input_trackjets_token_(consumes<edm::View<reco::TrackJet> >(iConfig.getParameter<edm::InputTag>("srcTrackJets"))),
69  input_vertex_token_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("srcPVs"))),
70  tokenPFCandidates_(consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("PFCandidates"))),
71  input_ctw_token_(consumes<CaloTowerCollection>(iConfig.getParameter<edm::InputTag>("towerMaker"))) {
72  //register your products
73  produces<reco::CaloJetCollection>();
74 }
const edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
const edm::EDGetTokenT< edm::View< reco::CaloJet > > input_jets_token_
const edm::EDGetTokenT< CaloTowerCollection > input_ctw_token_
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > tokenPFCandidates_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< edm::View< reco::TrackJet > > input_trackjets_token_

Member Function Documentation

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

Definition at line 76 of file JetPlusTrackAddonSeedProducer.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

76  {
78  desc.add<double>("dRcone", 0.4);
79  desc.add<bool>("UsePAT", false);
80  desc.add<edm::InputTag>("srcCaloJets", edm::InputTag("ak4CaloJets"));
81  desc.add<edm::InputTag>("srcTrackJets", edm::InputTag("ak4TrackJets"));
82  desc.add<edm::InputTag>("srcPVs", edm::InputTag("primaryVertex"));
83  desc.add<edm::InputTag>("PFCandidates", edm::InputTag("PFCandidates"));
84  desc.add<edm::InputTag>("towerMaker", edm::InputTag("towerMaker"));
85  iDescriptions.addWithDefaultLabel(desc);
86 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void JetPlusTrackAddonSeedProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 89 of file JetPlusTrackAddonSeedProducer.cc.

References funct::abs(), reco::deltaR2(), dRcone_, edm::Event::get(), input_ctw_token_, input_jets_token_, input_trackjets_token_, metsig::jet, fwrapper::jets, M_PI, eostools::move(), reco::CaloJet::Specific::mTowersArea, slimmedMuons_cfi::pfCandidates, edm::Event::put(), reco::Jet::setJetArea(), tokenPFCandidates_, and usePAT_.

89  {
90  using namespace edm;
91  // get stuff from Event
92  auto const& jets = iEvent.get(input_jets_token_);
93  auto const& jetsTrackJets = iEvent.get(input_trackjets_token_);
94  auto pCaloOut = std::make_unique<reco::CaloJetCollection>();
95 
96  for (auto const& jet : jetsTrackJets) {
97  int iflag = 0;
98  for (auto const& oldjet : jets) {
99  double dr2 = deltaR2(jet, oldjet);
100  if (dr2 < dRcone_ * dRcone_) {
101  iflag = 1;
102  }
103  } // Calojets
104 
105  if (iflag == 1)
106  continue;
107  double caloen = 0.;
108  double hadinho = 0.;
109  double hadinhb = 0.;
110  double hadinhe = 0.;
111  double hadinhf = 0.;
112  double emineb = 0.;
113  double eminee = 0.;
114  double eminhf = 0.;
115  double eefraction = 0.;
116  double hhfraction = 0.;
117  int ncand = 0;
118 
119  if (usePAT_) {
120  auto const& pfCandidates = iEvent.get(tokenPFCandidates_);
121  for (auto const& pf : pfCandidates) {
122  double dr2 = deltaR2(jet, pf);
123  if (dr2 > dRcone_ * dRcone_)
124  continue;
125  // jetconstit
126  caloen = caloen + pf.energy() * pf.caloFraction();
127  hadinho += 0.;
128  if (std::abs(pf.eta()) <= 1.4) {
129  hadinhb += pf.energy() * pf.caloFraction() * pf.hcalFraction();
130  emineb += pf.energy() * pf.caloFraction() * (1. - pf.hcalFraction());
131  } else if (std::abs(pf.eta()) < 3.) {
132  hadinhe += pf.energy() * pf.caloFraction() * pf.hcalFraction();
133  eminee += pf.energy() * pf.caloFraction() * (1. - pf.hcalFraction());
134  } else {
135  hadinhf += pf.energy() * pf.caloFraction() * pf.hcalFraction();
136  eminhf += pf.energy() * pf.caloFraction() * (1. - pf.hcalFraction());
137  }
138  ncand++;
139  } // pfcandidates
140  } else {
141  auto const& cts = iEvent.get(input_ctw_token_);
142  for (auto const& ct : cts) {
143  double dr2 = deltaR2(jet, ct);
144  if (dr2 > dRcone_ * dRcone_)
145  continue;
146  caloen = caloen + ct.energy();
147  hadinho += ct.energyInHO();
148  hadinhb += ct.energyInHB();
149  hadinhe += ct.energyInHE();
150  hadinhf += 0.5 * ct.energyInHF();
151  emineb += ct.energy() - ct.energyInHB() - ct.energyInHO();
152  eminee += ct.energy() - ct.energyInHE();
153  eminhf += 0.5 * ct.energyInHF();
154  ncand++;
155  }
156  }
157  eefraction = (emineb + eminee) / caloen;
158  hhfraction = (hadinhb + hadinhe + hadinhf + hadinho) / caloen;
159 
160  double trackp = jet.p();
161  if (caloen <= 0.)
162  caloen = 0.001;
163  math::XYZTLorentzVector pcalo4(caloen * jet.p4() / trackp);
164  reco::CaloJet::Specific calospe;
165  calospe.mTowersArea = -1 * ncand;
166  calospe.mHadEnergyInHO = hadinho;
167  calospe.mHadEnergyInHB = hadinhb;
168  calospe.mHadEnergyInHE = hadinhe;
169  calospe.mHadEnergyInHF = hadinhf;
170  calospe.mEmEnergyInEB = emineb;
171  calospe.mEmEnergyInEE = eminee;
172  calospe.mEmEnergyInHF = eminhf;
173  calospe.mEnergyFractionEm = eefraction / caloen;
174  calospe.mEnergyFractionHadronic = hhfraction / caloen;
175 
176  reco::CaloJet mycalo(pcalo4, jet.primaryVertex()->position(), calospe);
177  mycalo.setJetArea(M_PI * dRcone_ * dRcone_);
178  pCaloOut->push_back(mycalo);
179 
180  } // trackjets
181  iEvent.put(std::move(pCaloOut));
182 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Jets made from CaloTowers.
Definition: CaloJet.h:27
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
virtual void setJetArea(float fArea)
set jet area
Definition: Jet.h:101
vector< PseudoJet > jets
def move
Definition: eostools.py:511
const edm::EDGetTokenT< edm::View< reco::CaloJet > > input_jets_token_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::EDGetTokenT< CaloTowerCollection > input_ctw_token_
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
#define M_PI
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > tokenPFCandidates_
const edm::EDGetTokenT< edm::View< reco::TrackJet > > input_trackjets_token_
float mTowersArea
Area of contributing CaloTowers.
Definition: CaloJet.h:70

Member Data Documentation

const double JetPlusTrackAddonSeedProducer::dRcone_
private

Definition at line 55 of file JetPlusTrackAddonSeedProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<CaloTowerCollection> JetPlusTrackAddonSeedProducer::input_ctw_token_
private

Definition at line 61 of file JetPlusTrackAddonSeedProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::View<reco::CaloJet> > JetPlusTrackAddonSeedProducer::input_jets_token_
private

Definition at line 57 of file JetPlusTrackAddonSeedProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::View<reco::TrackJet> > JetPlusTrackAddonSeedProducer::input_trackjets_token_
private

Definition at line 58 of file JetPlusTrackAddonSeedProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCollection> JetPlusTrackAddonSeedProducer::input_vertex_token_
private

Definition at line 59 of file JetPlusTrackAddonSeedProducer.cc.

const edm::EDGetTokenT<std::vector<pat::PackedCandidate> > JetPlusTrackAddonSeedProducer::tokenPFCandidates_
private

Definition at line 60 of file JetPlusTrackAddonSeedProducer.cc.

Referenced by produce().

const bool JetPlusTrackAddonSeedProducer::usePAT_
private

Definition at line 56 of file JetPlusTrackAddonSeedProducer.cc.

Referenced by produce().