CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: JetExtender.cc,v 1.4 2007/10/01 19:24:45 fedor Exp $
7 //
9 
16 
17 #include "JetExtender.h"
18 
20  : mJets (fConfig.getParameter<edm::InputTag> ("jets")),
21  mJet2TracksAtVX (fConfig.getParameter<edm::InputTag> ("jet2TracksAtVX")),
22  mJet2TracksAtCALO (fConfig.getParameter<edm::InputTag> ("jet2TracksAtCALO"))
23 {
24  produces<reco::JetExtendedAssociation::Container> ();
25 }
26 
28 
29 void JetExtender::produce(edm::Event& fEvent, const edm::EventSetup& fSetup) {
30  // get stuff from Event
32  fEvent.getByLabel (mJets, jets_h);
34  if (!(mJet2TracksAtVX.label().empty())) fEvent.getByLabel (mJet2TracksAtVX, j2tVX_h);
36  if (!(mJet2TracksAtCALO.label().empty())) fEvent.getByLabel (mJet2TracksAtCALO, j2tCALO_h);
37 
38  std::auto_ptr<reco::JetExtendedAssociation::Container>
40 
41  // loop over jets (make sure jets in associations are the same as in collection
42 
43  for (unsigned j = 0; j < jets_h->size(); ++j) {
44  edm::RefToBase<reco::Jet> jet = jets_h->refAt(j);
46  if (j2tVX_h.isValid ()) { // fill tracks@VX summary
47  try {
49  extendedData.mTracksAtVertexP4 = reco::JetTracksAssociation::tracksP4 (*j2tVX_h, jet);
50  }
51  catch (cms::Exception e) {
52  edm::LogError ("MismatchedJets") << "Jets in original collection " << mJets
53  << " mismatch jets in j2t VX association " << mJet2TracksAtVX
54  << ". Wrong collections?";
55  throw e;
56  }
57  }
58  if (j2tCALO_h.isValid ()) { // fill tracks@CALO summary
59  try {
60  extendedData.mTracksAtCaloNumber = reco::JetTracksAssociation::tracksNumber (*j2tCALO_h, jet);
61  extendedData.mTracksAtCaloP4 = reco::JetTracksAssociation::tracksP4 (*j2tCALO_h, jet);
62  }
63  catch (cms::Exception e) {
64  edm::LogError ("MismatchedJets") << "Jets in original collection " << mJets
65  << " mismatch jets in j2t CALO association " << mJet2TracksAtCALO
66  << ". Wrong collections?";
67  throw e;
68  }
69  }
70  reco::JetExtendedAssociation::setValue (&*jetExtender, jet, extendedData);
71  }
72  fEvent.put (jetExtender);
73 }
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: JetExtender.cc:29
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
virtual ~JetExtender()
Definition: JetExtender.cc:27
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
edm::InputTag mJet2TracksAtCALO
Definition: JetExtender.h:27
int j
Definition: DBlmapReader.cc:9
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
JetExtender(const edm::ParameterSet &)
Definition: JetExtender.cc:19
edm::InputTag mJet2TracksAtVX
Definition: JetExtender.h:26
LorentzVector tracksP4(const Container &, const reco::JetBaseRef)
Get LorentzVector as sum of all tracks associated with jet.
std::string const & label() const
Definition: InputTag.h:42
edm::InputTag mJets
Definition: JetExtender.h:25
int tracksNumber(const Container &, const reco::JetBaseRef)
Get number of tracks associated with jet.