CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoMuon/StandAloneMuonProducer/src/StandAloneMuonProducer.cc

Go to the documentation of this file.
00001 
00015 // Framework
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "FWCore/Framework/interface/EventSetup.h"
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 
00021 #include "RecoMuon/StandAloneMuonProducer/src/StandAloneMuonProducer.h"
00022 
00023 // TrackFinder and Specific STA Trajectory Builder
00024 #include "RecoMuon/StandAloneTrackFinder/interface/StandAloneTrajectoryBuilder.h"
00025 #include "RecoMuon/StandAloneTrackFinder/interface/ExhaustiveMuonTrajectoryBuilder.h"
00026 #include "RecoMuon/TrackingTools/interface/DirectMuonTrajectoryBuilder.h"
00027 
00028 #include "RecoMuon/TrackingTools/interface/MuonTrackFinder.h"
00029 #include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"
00030 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00031 
00032 // Input and output collection
00033 
00034 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00035 #include "DataFormats/Common/interface/View.h"
00036 #include "DataFormats/TrackReco/interface/Track.h"
00037 #include "DataFormats/TrackReco/interface/TrackToTrackMap.h"
00038 
00039 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00040 #include "TrackingTools/DetLayers/interface/NavigationSetter.h"
00041 
00042 #include <string>
00043 
00044 using namespace edm;
00045 using namespace std;
00046 
00048 StandAloneMuonProducer::StandAloneMuonProducer(const ParameterSet& parameterSet){
00049   LogTrace("Muon|RecoMuon|StandAloneMuonProducer")<<"constructor called"<<endl;
00050 
00051   // Parameter set for the Builder
00052   ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("STATrajBuilderParameters");
00053   
00054   // MuonSeed Collection Label
00055   theSeedCollectionLabel = parameterSet.getParameter<InputTag>("InputObjects");
00056   
00057   // service parameters
00058   ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
00059   
00060   // TrackLoader parameters
00061   ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
00062   
00063   // the services
00064   theService = new MuonServiceProxy(serviceParameters);
00065 
00066   MuonTrackLoader * trackLoader = new MuonTrackLoader(trackLoaderParameters,theService);
00067   MuonTrajectoryBuilder * trajectoryBuilder = 0;
00068   // instantiate the concrete trajectory builder in the Track Finder
00069   string typeOfBuilder = parameterSet.getParameter<string>("MuonTrajectoryBuilder");
00070   if(typeOfBuilder == "StandAloneMuonTrajectoryBuilder")
00071     trajectoryBuilder = new StandAloneMuonTrajectoryBuilder(trajectoryBuilderParameters,theService);
00072   else if(typeOfBuilder == "DirectMuonTrajectoryBuilder")
00073     trajectoryBuilder = new DirectMuonTrajectoryBuilder(trajectoryBuilderParameters,theService);
00074   else if(typeOfBuilder == "Exhaustive")
00075     trajectoryBuilder = new ExhaustiveMuonTrajectoryBuilder(trajectoryBuilderParameters,theService);
00076   else{
00077     LogWarning("Muon|RecoMuon|StandAloneMuonProducer") << "No Trajectory builder associated with "<<typeOfBuilder
00078                                                        << ". Falling down to the default (StandAloneMuonTrajectoryBuilder)";
00079      trajectoryBuilder = new StandAloneMuonTrajectoryBuilder(trajectoryBuilderParameters,theService);
00080   }
00081   theTrackFinder = new MuonTrackFinder(trajectoryBuilder, trackLoader);
00082 
00083   setAlias(parameterSet.getParameter<std::string>("@module_label"));
00084   
00085   produces<reco::TrackCollection>().setBranchAlias(theAlias + "Tracks");
00086   produces<reco::TrackCollection>("UpdatedAtVtx").setBranchAlias(theAlias + "UpdatedAtVtxTracks");
00087   produces<TrackingRecHitCollection>().setBranchAlias(theAlias + "RecHits");
00088   produces<reco::TrackExtraCollection>().setBranchAlias(theAlias + "TrackExtras");
00089   produces<reco::TrackToTrackMap>().setBranchAlias(theAlias + "TrackToTrackMap");
00090   
00091   produces<std::vector<Trajectory> >().setBranchAlias(theAlias + "Trajectories");
00092   produces<TrajTrackAssociationCollection>().setBranchAlias(theAlias + "TrajToTrackMap");
00093 }
00094   
00096 StandAloneMuonProducer::~StandAloneMuonProducer(){
00097   LogTrace("Muon|RecoMuon|StandAloneMuonProducer")<<"StandAloneMuonProducer destructor called"<<endl;
00098   if (theService) delete theService;
00099   if (theTrackFinder) delete theTrackFinder;
00100 }
00101 
00103 void StandAloneMuonProducer::produce(Event& event, const EventSetup& eventSetup){
00104   const std::string metname = "Muon|RecoMuon|StandAloneMuonProducer";
00105   
00106   LogTrace(metname)<<endl<<endl<<endl;
00107   LogTrace(metname)<<"Stand Alone Muon Reconstruction Started"<<endl;
00108 
00109   // Take the seeds container
00110   LogTrace(metname)<<"Taking the seeds: "<<theSeedCollectionLabel.label()<<endl;
00111   Handle<View<TrajectorySeed> > seeds; 
00112   event.getByLabel(theSeedCollectionLabel,seeds);
00113 
00114   // Update the services
00115   theService->update(eventSetup);
00116   NavigationSetter setter(*theService->muonNavigationSchool());
00117 
00118   // Reconstruct 
00119   LogTrace(metname)<<"Track Reconstruction"<<endl;
00120   theTrackFinder->reconstruct(seeds,event);
00121  
00122   LogTrace(metname)<<"Event loaded"
00123                    <<"================================"
00124                    <<endl<<endl;
00125 }
00126