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 //
8 
9 
16 
17 
18 
20 
22  : firstRun(true),
23  dR_(fConfig.getParameter<double>("coneSize"))
24 {
25  mJets = consumes<edm::View <reco::Jet> >(fConfig.getParameter<edm::InputTag> ("jets"));
26  mExtrapolations = consumes<std::vector<reco::TrackExtrapolation> >(fConfig.getParameter<edm::InputTag> ("extrapolations")),
27 
28  produces<reco::JetTracksAssociation::Container> ();
29 }
30 
32 
33 
34  // Get geometry
35  if ( firstRun ) {
36  fSetup.get<CaloGeometryRecord>().get(pGeo);
37  firstRun = false;
38  }
39 
40  if ( !pGeo.isValid() ) {
41  throw cms::Exception("InvalidInput") << "Did not get geometry" << std::endl;
42  }
43 
44  // get stuff from Event
46  fEvent.getByToken (mJets, jets_h);
48  fEvent.getByToken (mExtrapolations, extrapolations_h);
49 
50  // Check to make sure we have inputs
51  if ( jets_h->size() == 0 ) return;
52  // Check to make sure the inputs are calo jets
53  reco::CaloJet const * caloJet0 = dynamic_cast<reco::CaloJet const *>( & (jets_h->at(0)) );
54  // Disallowed non-CaloJet inputs
55  if ( caloJet0 == 0 ) {
56  throw cms::Exception("InvalidInput") << " Jet-track association is only defined for CaloJets.";
57  }
58 
59  std::auto_ptr<reco::JetTracksAssociation::Container> jetTracks (new reco::JetTracksAssociation::Container (reco::JetRefBaseProd(jets_h)));
60 
61 
62  // format inputs
63  std::vector <edm::RefToBase<reco::Jet> > allJets;
64  allJets.reserve (jets_h->size());
65  for (unsigned i = 0; i < jets_h->size(); ++i) allJets.push_back (jets_h->refAt(i));
66  mAssociator.produce (&*jetTracks, allJets, *extrapolations_h, *pGeo, dR_ );
67 
68 
69  // store output
70  fEvent.put (jetTracks);
71 }
72 
73 
std::vector< reco::JetBaseRef > allJets(const Container &)
fill list of all jets associated with values. Return # of jets in the list
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
Jets made from CaloTowers.
Definition: CaloJet.h:29
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
string firstRun
Definition: dataset.py:842
JetTracksAssociationXtrpCalo mAssociator
edm::ESHandle< CaloGeometry > pGeo
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:113
edm::EDGetTokenT< std::vector< reco::TrackExtrapolation > > mExtrapolations
const T & get() const
Definition: EventSetup.h:55
bool isValid() const
Definition: ESHandle.h:47
edm::EDGetTokenT< edm::View< reco::Jet > > mJets