CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
15 
17 
19  : mGeometry(esConsumes()), dR_(fConfig.getParameter<double>("coneSize")) {
20  mJets = consumes<edm::View<reco::Jet> >(fConfig.getParameter<edm::InputTag>("jets"));
22  consumes<std::vector<reco::TrackExtrapolation> >(fConfig.getParameter<edm::InputTag>("extrapolations")),
23 
24  produces<reco::JetTracksAssociation::Container>();
25 }
26 
28  // Get geometry
29  auto const& geo = fSetup.getData(mGeometry);
30 
31  // get stuff from Event
33  fEvent.getByToken(mJets, jets_h);
35  fEvent.getByToken(mExtrapolations, extrapolations_h);
36 
37  auto jetTracks = std::make_unique<reco::JetTracksAssociation::Container>(reco::JetRefBaseProd(jets_h));
38 
39  // Check to make sure we have inputs
40  if (jets_h->empty()) {
41  // store output regardless the size of the inputs
42  fEvent.put(std::move(jetTracks));
43  return;
44  }
45  // Check to make sure the inputs are calo jets
46  reco::CaloJet const* caloJet0 = dynamic_cast<reco::CaloJet const*>(&(jets_h->at(0)));
47  // Disallowed non-CaloJet inputs
48  if (caloJet0 == nullptr) {
49  throw cms::Exception("InvalidInput") << " Jet-track association is only defined for CaloJets.";
50  }
51 
52  // format inputs
53  std::vector<edm::RefToBase<reco::Jet> > allJets;
54  allJets.reserve(jets_h->size());
55  for (unsigned i = 0; i < jets_h->size(); ++i)
56  allJets.push_back(jets_h->refAt(i));
57  mAssociator.produce(&*jetTracks, allJets, *extrapolations_h, geo, dR_);
58 
59  // store output
60  fEvent.put(std::move(jetTracks));
61 }
std::vector< reco::JetBaseRef > allJets(const Container &)
fill list of all jets associated with values. Return # of jets in the list
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Jets made from CaloTowers.
Definition: CaloJet.h:27
edm::EDGetTokenT< edm::View< reco::Jet > > mJets
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > mGeometry
JetTracksAssociationXtrpCalo mAssociator
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::RefToBaseProd< reco::Jet > JetRefBaseProd
Definition: JetCollection.h:13
void produce(Association *, JetRefs const &, std::vector< reco::TrackExtrapolation > const &, CaloGeometry const &, double dR)
Associates tracks to jets.
def move
Definition: eostools.py:511
edm::EDGetTokenT< std::vector< reco::TrackExtrapolation > > mExtrapolations
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::Event &, const edm::EventSetup &) override
JetTracksAssociatorAtCaloFace(const edm::ParameterSet &)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283