00001
00013
00014 #include "FastSimulation/Muons/plugins/FastL3MuonProducer.h"
00015 #include "FastSimulation/Muons/interface/FastL3MuonTrajectoryBuilder.h"
00016 #include "RecoMuon/TrackingTools/interface/MuonTrackFinder.h"
00017 #include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"
00018 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00019
00020
00021 #include "DataFormats/TrackReco/interface/Track.h"
00022 #include "DataFormats/TrackReco/interface/TrackToTrackMap.h"
00023
00024 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00025
00026
00027
00028
00029 FastL3MuonProducer::FastL3MuonProducer(const edm::ParameterSet& parameterSet) {
00030
00031 LogTrace("FastL3MuonProducer") << "constructor called" << std::endl;
00032
00033
00034 edm::ParameterSet trajectoryBuilderParameters =
00035 parameterSet.getParameter<edm::ParameterSet>("L3TrajBuilderParameters");
00036
00037
00038 theL2CollectionLabel =
00039 parameterSet.getParameter<edm::InputTag>("MuonCollectionLabel");
00040 updatedAtVtx = (theL2CollectionLabel.instance() == "UpdatedAtVtx");
00041
00042
00043 edm::ParameterSet serviceParameters =
00044 parameterSet.getParameter<edm::ParameterSet>("ServiceParameters");
00045
00046
00047 edm::ParameterSet trackLoaderParameters =
00048 parameterSet.getParameter<edm::ParameterSet>("TrackLoaderParameters");
00049
00050
00051 theService = new MuonServiceProxy(serviceParameters);
00052
00053
00054 MuonTrackLoader* mtl = new MuonTrackLoader(trackLoaderParameters,theService);
00055 l3mtb = new FastL3MuonTrajectoryBuilder(trajectoryBuilderParameters, theService);
00056 theTrackFinder = new MuonTrackFinder(l3mtb, mtl);
00057
00058 theL2SeededTkLabel = trackLoaderParameters.getUntrackedParameter<std::string>("MuonSeededTracksInstance",std::string());
00059
00060 produces<reco::TrackCollection>(theL2SeededTkLabel);
00061 produces<TrackingRecHitCollection>(theL2SeededTkLabel);
00062 produces<reco::TrackExtraCollection>(theL2SeededTkLabel);
00063 produces<std::vector<Trajectory> >(theL2SeededTkLabel) ;
00064 produces<TrajTrackAssociationCollection>(theL2SeededTkLabel);
00065
00066 produces<reco::TrackCollection>();
00067 produces<TrackingRecHitCollection>();
00068 produces<reco::TrackExtraCollection>();
00069 produces<std::vector<Trajectory> >() ;
00070 produces<TrajTrackAssociationCollection>();
00071
00072 produces<reco::MuonTrackLinksCollection>();
00073
00074 }
00075
00076
00077
00078
00079
00080 FastL3MuonProducer::~FastL3MuonProducer() {
00081
00082 LogTrace("FastL3MuonProducer") << "destructor called" << std::endl;
00083 if (theService) delete theService;
00084 if (theTrackFinder) delete theTrackFinder;
00085
00086 }
00087
00088
00089
00090
00091
00092 void FastL3MuonProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) {
00093
00094
00095
00096
00097 typedef std::vector<Trajectory> TrajColl;
00098
00099
00100 theService->update(eventSetup);
00101
00102
00103
00104
00105 edm::Handle<reco::TrackCollection> L2Muons;
00106 event.getByLabel(theL2CollectionLabel,L2Muons);
00107
00108 edm::Handle<std::vector<Trajectory> > L2MuonsTraj;
00109 std::vector<MuonTrajectoryBuilder::TrackCand> L2TrackCands;
00110
00111 event.getByLabel(theL2CollectionLabel.label(), L2MuonsTraj);
00112
00113 edm::Handle<TrajTrackAssociationCollection> L2AssoMap;
00114 event.getByLabel(theL2CollectionLabel.label(),L2AssoMap);
00115
00116 edm::Handle<reco::TrackToTrackMap> updatedL2AssoMap;
00117 event.getByLabel(theL2CollectionLabel.label(),updatedL2AssoMap);
00118
00119 TrajTrackAssociationCollection::const_iterator it = L2AssoMap->begin();
00120 TrajTrackAssociationCollection::const_iterator lt = L2AssoMap->end();
00121
00122 for( ; it!=lt; ++it){
00123
00124 const edm::Ref<std::vector<Trajectory> > traj = it->key;
00125 const reco::TrackRef tk
00126 = updatedAtVtx && updatedL2AssoMap->find(it->val) != updatedL2AssoMap->end() ?
00127 (*updatedL2AssoMap)[it->val] : it->val;
00128 MuonTrajectoryBuilder::TrackCand L2Cand = MuonTrajectoryBuilder::TrackCand(0,tk);
00129 if( traj->isValid() ) L2Cand.first = &*traj ;
00130 L2TrackCands.push_back(L2Cand);
00131
00132 }
00133
00134 theTrackFinder->reconstruct(L2TrackCands, event);
00135 l3mtb->clear();
00136
00137
00138
00139
00140
00141
00142 }