CMS 3D CMS Logo

JetExtender.cc
Go to the documentation of this file.
1 // \class JetExtender JetExtender.cc
2 //
3 // Combines different Jet associations into single compact object
4 // which extends basic Jet information
5 // Fedor Ratnikov Sep. 10, 2007
6 //
8 
12 
13 #include "JetExtender.h"
14 
16  : mJets(fConfig.getParameter<edm::InputTag>("jets")),
17  mJet2TracksAtVX(fConfig.getParameter<edm::InputTag>("jet2TracksAtVX")),
18  mJet2TracksAtCALO(fConfig.getParameter<edm::InputTag>("jet2TracksAtCALO")) {
19  token_mJets = consumes<edm::View<reco::Jet> >(mJets);
20  if (!(mJet2TracksAtVX.label().empty()))
21  token_mJet2TracksAtVX = consumes<reco::JetTracksAssociation::Container>(mJet2TracksAtVX);
22  if (!(mJet2TracksAtCALO.label().empty()))
23  token_mJet2TracksAtCALO = consumes<reco::JetTracksAssociation::Container>(mJet2TracksAtCALO);
24 
25  produces<reco::JetExtendedAssociation::Container>();
26 }
27 
29 
31  // get stuff from Event
33  fEvent.getByToken(token_mJets, jets_h);
35  if (!(mJet2TracksAtVX.label().empty()))
36  fEvent.getByToken(token_mJet2TracksAtVX, j2tVX_h);
38  if (!(mJet2TracksAtCALO.label().empty()))
39  fEvent.getByToken(token_mJet2TracksAtCALO, j2tCALO_h);
40 
41  auto jetExtender = std::make_unique<reco::JetExtendedAssociation::Container>(reco::JetRefBaseProd(jets_h));
42 
43  // loop over jets (make sure jets in associations are the same as in collection
44 
45  for (unsigned j = 0; j < jets_h->size(); ++j) {
46  edm::RefToBase<reco::Jet> jet = jets_h->refAt(j);
48  if (j2tVX_h.isValid()) { // fill tracks@VX summary
49  try {
52  } catch (cms::Exception const&) {
53  edm::LogError("MismatchedJets") << "Jets in original collection " << mJets
54  << " mismatch jets in j2t VX association " << mJet2TracksAtVX
55  << ". Wrong collections?";
56  throw;
57  }
58  }
59  if (j2tCALO_h.isValid()) { // fill tracks@CALO summary
60  try {
62  extendedData.mTracksAtCaloP4 = reco::JetTracksAssociation::tracksP4(*j2tCALO_h, jet);
63  } catch (cms::Exception const&) {
64  edm::LogError("MismatchedJets") << "Jets in original collection " << mJets
65  << " mismatch jets in j2t CALO association " << mJet2TracksAtCALO
66  << ". Wrong collections?";
67  throw;
68  }
69  }
70  reco::JetExtendedAssociation::setValue(&*jetExtender, jet, extendedData);
71  }
72  fEvent.put(std::move(jetExtender));
73 }
~JetExtender() override
Definition: JetExtender.cc:28
std::string const & label() const
Definition: InputTag.h:36
Log< level::Error, false > LogError
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
Definition: JetCollection.h:13
edm::InputTag mJet2TracksAtCALO
Definition: JetExtender.h:32
edm::EDGetTokenT< reco::JetTracksAssociation::Container > token_mJet2TracksAtCALO
Definition: JetExtender.h:29
JetExtender(const edm::ParameterSet &)
Definition: JetExtender.cc:15
edm::InputTag mJet2TracksAtVX
Definition: JetExtender.h:31
LorentzVector tracksP4(const Container &, const reco::JetBaseRef)
Get LorentzVector as sum of all tracks associated with jet.
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
edm::InputTag mJets
Definition: JetExtender.h:30
int tracksNumber(const Container &, const reco::JetBaseRef)
Get number of tracks associated with jet.
void produce(edm::Event &, const edm::EventSetup &) override
Definition: JetExtender.cc:30
edm::EDGetTokenT< edm::View< reco::Jet > > token_mJets
Definition: JetExtender.h:27
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< reco::JetTracksAssociation::Container > token_mJet2TracksAtVX
Definition: JetExtender.h:28