CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetTracksAssociatorAtCaloFace.cc
Go to the documentation of this file.
1 // \class JetTracksAssociatorAtCaloFace JetTracksAssociatorAtCaloFace.cc
2 //
3 // Original Author: Andrea Rizzi
4 // Created: Wed Apr 12 11:12:49 CEST 2006
5 // Accommodated for Jet Package by: Fedor Ratnikov Jul. 30, 2007
6 // $Id: JetTracksAssociatorAtCaloFace.cc,v 1.5 2010/03/16 21:45:55 srappocc Exp $
7 //
9 
10 
19 
20 
21 
23 
25  : mJets (fConfig.getParameter<edm::InputTag> ("jets")),
26  mExtrapolations (fConfig.getParameter<edm::InputTag> ("extrapolations")),
27  firstRun(true),
28  dR_(fConfig.getParameter<double>("coneSize"))
29 {
30  produces<reco::JetTracksAssociation::Container> ();
31 }
32 
34 
35 
36  // Get geometry
37  if ( firstRun ) {
38  fSetup.get<CaloGeometryRecord>().get(pGeo);
39  firstRun = false;
40  }
41 
42  if ( !pGeo.isValid() ) {
43  throw cms::Exception("InvalidInput") << "Did not get geometry" << std::endl;
44  }
45 
46  // get stuff from Event
48  fEvent.getByLabel (mJets, jets_h);
50  fEvent.getByLabel (mExtrapolations, extrapolations_h);
51 
52  // Check to make sure we have inputs
53  if ( jets_h->size() == 0 ) return;
54  // Check to make sure the inputs are calo jets
55  reco::CaloJet const * caloJet0 = dynamic_cast<reco::CaloJet const *>( & (jets_h->at(0)) );
56  // Disallowed non-CaloJet inputs
57  if ( caloJet0 == 0 ) {
58  throw cms::Exception("InvalidInput") << " Jet-track association is only defined for CaloJets.";
59  }
60 
61  std::auto_ptr<reco::JetTracksAssociation::Container> jetTracks (new reco::JetTracksAssociation::Container (reco::JetRefBaseProd(jets_h)));
62 
63 
64  // format inputs
65  std::vector <edm::RefToBase<reco::Jet> > allJets;
66  allJets.reserve (jets_h->size());
67  for (unsigned i = 0; i < jets_h->size(); ++i) allJets.push_back (jets_h->refAt(i));
68  mAssociator.produce (&*jetTracks, allJets, *extrapolations_h, *pGeo, dR_ );
69 
70 
71  // store output
72  fEvent.put (jetTracks);
73 }
74 
75 
77 {
78 }
std::vector< reco::JetBaseRef > allJets(const Container &)
fill list of all jets associated with values. Return # of jets in the list
int i
Definition: DBlmapReader.cc:9
Jets made from CaloTowers.
Definition: CaloJet.h:30
virtual void produce(edm::Event &, const edm::EventSetup &)
string firstRun
Definition: dataset.py:395
JetTracksAssociationXtrpCalo mAssociator
edm::ESHandle< CaloGeometry > pGeo
virtual void beginRun(edm::Run const &run, edm::EventSetup const &setup)
void produce(Association *, JetRefs const &, std::vector< reco::TrackExtrapolation > const &, CaloGeometry const &, double dR)
Associates tracks to jets.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const T & get() const
Definition: EventSetup.h:55
bool isValid() const
Definition: ESHandle.h:37
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Definition: Run.h:33