00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <memory>
00011 #include <string>
00012
00013
00014 #include "FWCore/Framework/interface/EDProducer.h"
00015
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "FWCore/Framework/interface/MakerMacros.h"
00018
00019 #include "FWCore/Framework/interface/ESHandle.h"
00020
00021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00022
00023 #include "SimTracker/TrackAssociation/interface/TrackAssociatorBase.h"
00024 #include "SimTracker/Records/interface/TrackAssociatorRecord.h"
00025
00026 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028
00029
00030
00031
00032
00033 class TrackAssociatorEDProducer : public edm::EDProducer {
00034 public:
00035 explicit TrackAssociatorEDProducer(const edm::ParameterSet&);
00036 ~TrackAssociatorEDProducer();
00037
00038 private:
00039 virtual void beginJob(const edm::EventSetup&) ;
00040 virtual void produce(edm::Event&, const edm::EventSetup&);
00041 virtual void endJob() ;
00042
00043 edm::ESHandle<TrackAssociatorBase> theAssociator;
00044 edm::InputTag label_tr;
00045 edm::InputTag label_tp;
00046 std::string associator;
00047 };
00048
00049 TrackAssociatorEDProducer::TrackAssociatorEDProducer(const edm::ParameterSet& pset):
00050 label_tr(pset.getParameter< edm::InputTag >("label_tr")),
00051 label_tp(pset.getParameter< edm::InputTag >("label_tp")),
00052 associator(pset.getParameter< std::string >("associator"))
00053 {
00054 produces<reco::SimToRecoCollection>();
00055 produces<reco::RecoToSimCollection>();
00056 }
00057
00058
00059 TrackAssociatorEDProducer::~TrackAssociatorEDProducer() {
00060
00061 }
00062
00063
00064
00065
00066
00067
00068
00069 void
00070 TrackAssociatorEDProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00071 using namespace edm;
00072
00073 Handle<TrackingParticleCollection> TPCollection ;
00074 iEvent.getByLabel(label_tp, TPCollection);
00075
00076 Handle<edm::View<reco::Track> > trackCollection;
00077 iEvent.getByLabel (label_tr, trackCollection );
00078
00079
00080 LogTrace("TrackValidator") << "Calling associateRecoToSim method" << "\n";
00081 reco::RecoToSimCollection recSimColl=theAssociator->associateRecoToSim(trackCollection,
00082 TPCollection,
00083 &iEvent);
00084 LogTrace("TrackValidator") << "Calling associateSimToReco method" << "\n";
00085 reco::SimToRecoCollection simRecColl=theAssociator->associateSimToReco(trackCollection,
00086 TPCollection,
00087 &iEvent);
00088
00089 std::auto_ptr<reco::RecoToSimCollection> rts(new reco::RecoToSimCollection(recSimColl));
00090 std::auto_ptr<reco::SimToRecoCollection> str(new reco::SimToRecoCollection(simRecColl));
00091
00092 iEvent.put(rts);
00093 iEvent.put(str);
00094 }
00095
00096
00097 void
00098 TrackAssociatorEDProducer::beginJob(const edm::EventSetup& setup) {
00099
00100
00101 setup.get<TrackAssociatorRecord>().get(associator,theAssociator);
00102
00103 }
00104
00105
00106 void
00107 TrackAssociatorEDProducer::endJob() {
00108 }
00109
00110
00111 DEFINE_FWK_MODULE(TrackAssociatorEDProducer);