Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009
00010
00011 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00012 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00013 #include "FWCore/Framework/interface/Event.h"
00014 #include "DataFormats/Common/interface/View.h"
00015 #include "DataFormats/JetReco/interface/Jet.h"
00016 #include "DataFormats/JetReco/interface/CaloJet.h"
00017 #include "DataFormats/TrackReco/interface/Track.h"
00018 #include "DataFormats/JetReco/interface/JetTracksAssociation.h"
00019
00020
00021
00022 #include "JetTracksAssociatorAtCaloFace.h"
00023
00024 JetTracksAssociatorAtCaloFace::JetTracksAssociatorAtCaloFace(const edm::ParameterSet& fConfig)
00025 : mJets (fConfig.getParameter<edm::InputTag> ("jets")),
00026 mExtrapolations (fConfig.getParameter<edm::InputTag> ("extrapolations")),
00027 firstRun(true),
00028 dR_(fConfig.getParameter<double>("coneSize"))
00029 {
00030 produces<reco::JetTracksAssociation::Container> ();
00031 }
00032
00033 void JetTracksAssociatorAtCaloFace::produce(edm::Event& fEvent, const edm::EventSetup& fSetup) {
00034
00035
00036
00037 if ( firstRun ) {
00038 fSetup.get<CaloGeometryRecord>().get(pGeo);
00039 firstRun = false;
00040 }
00041
00042 if ( !pGeo.isValid() ) {
00043 throw cms::Exception("InvalidInput") << "Did not get geometry" << std::endl;
00044 }
00045
00046
00047 edm::Handle <edm::View <reco::Jet> > jets_h;
00048 fEvent.getByLabel (mJets, jets_h);
00049 edm::Handle <std::vector<reco::TrackExtrapolation> > extrapolations_h;
00050 fEvent.getByLabel (mExtrapolations, extrapolations_h);
00051
00052
00053 if ( jets_h->size() == 0 ) return;
00054
00055 reco::CaloJet const * caloJet0 = dynamic_cast<reco::CaloJet const *>( & (jets_h->at(0)) );
00056
00057 if ( caloJet0 == 0 ) {
00058 throw cms::Exception("InvalidInput") << " Jet-track association is only defined for CaloJets.";
00059 }
00060
00061 std::auto_ptr<reco::JetTracksAssociation::Container> jetTracks (new reco::JetTracksAssociation::Container (reco::JetRefBaseProd(jets_h)));
00062
00063
00064
00065 std::vector <edm::RefToBase<reco::Jet> > allJets;
00066 allJets.reserve (jets_h->size());
00067 for (unsigned i = 0; i < jets_h->size(); ++i) allJets.push_back (jets_h->refAt(i));
00068 mAssociator.produce (&*jetTracks, allJets, *extrapolations_h, *pGeo, dR_ );
00069
00070
00071
00072 fEvent.put (jetTracks);
00073 }
00074
00075
00076 void JetTracksAssociatorAtCaloFace::beginRun( edm::Run const & run, edm::EventSetup const & setup)
00077 {
00078 }