CMS 3D CMS Logo

JetPlusTrackAddonSeedProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: JetPlusTracks
4 // Class: JetPlusTrackAddonSeedProducer
5 //
13 //
14 // Original Author: Olga Kodolova,40 R-A12,+41227671273,
15 // Created: Fri Feb 19 10:14:02 CET 2010
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
23 
32 
41 
44 
45 #include <string>
46 
47 using namespace std;
49 public:
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52  void produce(edm::Event&, const edm::EventSetup&) override;
53 
54 private:
55  const double dRcone_;
56  const bool usePAT_;
62 };
63 
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 }
75 
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 }
87 
88 // ------------ method called to produce the data ------------
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 }
183 
184 //define this as a plug-in
186 
ConfigurationDescriptions.h
CaloJetCollection.h
reco::CaloJet
Jets made from CaloTowers.
Definition: CaloJet.h:27
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
CaloJet.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
MessageLogger.h
sistrip::View
View
Definition: ConstantsForView.h:26
JetPlusTrackAddonSeedProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: JetPlusTrackAddonSeedProducer.cc:89
deltaPhi.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
JetPlusTrackAddonSeedProducer::dRcone_
const double dRcone_
Definition: JetPlusTrackAddonSeedProducer.cc:55
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
btagElecInJet_cfi.CaloJet
CaloJet
Definition: btagElecInJet_cfi.py:4
EDProducer.h
edm::SortedCollection< CaloTower >
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
JetPlusTrackAddonSeedProducer::input_jets_token_
const edm::EDGetTokenT< edm::View< reco::CaloJet > > input_jets_token_
Definition: JetPlusTrackAddonSeedProducer.cc:57
TrackJet.h
reco::Jet::setJetArea
virtual void setJetArea(float fArea)
set jet area
Definition: Jet.h:101
JetPlusTrackAddonSeedProducer::input_vertex_token_
const edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
Definition: JetPlusTrackAddonSeedProducer.cc:59
JetPlusTrackAddonSeedProducer::usePAT_
const bool usePAT_
Definition: JetPlusTrackAddonSeedProducer.cc:56
MakerMacros.h
JetPlusTrackAddonSeedProducer::input_ctw_token_
const edm::EDGetTokenT< CaloTowerCollection > input_ctw_token_
Definition: JetPlusTrackAddonSeedProducer.cc:61
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
JetPlusTrackAddonSeedProducer::JetPlusTrackAddonSeedProducer
JetPlusTrackAddonSeedProducer(const edm::ParameterSet &)
Definition: JetPlusTrackAddonSeedProducer.cc:64
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TrackJetCollection.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
JetPlusTrackAddonSeedProducer::input_trackjets_token_
const edm::EDGetTokenT< edm::View< reco::TrackJet > > input_trackjets_token_
Definition: JetPlusTrackAddonSeedProducer.cc:58
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
JetPlusTrackAddonSeedProducer::tokenPFCandidates_
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > tokenPFCandidates_
Definition: JetPlusTrackAddonSeedProducer.cc:60
deltaR.h
PackedCandidate.h
reco::CaloJet::Specific::mTowersArea
float mTowersArea
Area of contributing CaloTowers.
Definition: CaloJet.h:70
iEvent
int iEvent
Definition: GenABIO.cc:224
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
pat
Definition: HeavyIon.h:7
InputTag.h
pat::PackedCandidateCollection
std::vector< pat::PackedCandidate > PackedCandidateCollection
Definition: PackedCandidate.h:1131
CaloTowerCollection.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
Frameworkfwd.h
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
JetPlusTrackAddonSeedProducer
Definition: JetPlusTrackAddonSeedProducer.cc:48
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
metsig::jet
Definition: SignAlgoResolutions.h:47
EventSetup.h
JetPlusTrackAddonSeedProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: JetPlusTrackAddonSeedProducer.cc:76
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
reco::CaloJet::Specific
Definition: CaloJet.h:32
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87