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