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 = 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 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Jets made from CaloTowers.
Definition: CaloJet.h:27
std::vector< pat::PackedCandidate > PackedCandidateCollection
JetPlusTrackAddonSeedProducer(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< Vertex > VertexCollection
Definition: Vertex.h:31
Definition: HeavyIon.h:7
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
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
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_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
#define M_PI
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > tokenPFCandidates_
const edm::EDGetTokenT< edm::View< reco::TrackJet > > input_trackjets_token_
fixed size matrix
HLT enums.
float mTowersArea
Area of contributing CaloTowers.
Definition: CaloJet.h:70
def move(src, dest)
Definition: eostools.py:511