Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:14

0001 /**  \class StandAloneMuonProducer
0002  * 
0003  *   StandAlone muon reconstructor:
0004  *   reconstructs muons using DT, CSC and RPC
0005  *   information,<BR>
0006  *   starting from internal seeds (L2 muon track segments).
0007  *
0008  *
0009  *
0010  *   \author  R.Bellan - INFN TO
0011  */
0012 
0013 // Framework
0014 #include "FWCore/Framework/interface/ConsumesCollector.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 
0020 #include "RecoMuon/StandAloneMuonProducer/src/StandAloneMuonProducer.h"
0021 
0022 // TrackFinder and Specific STA Trajectory Builder
0023 #include "RecoMuon/StandAloneTrackFinder/interface/StandAloneTrajectoryBuilder.h"
0024 #include "RecoMuon/StandAloneTrackFinder/interface/ExhaustiveMuonTrajectoryBuilder.h"
0025 #include "RecoMuon/TrackingTools/interface/DirectMuonTrajectoryBuilder.h"
0026 
0027 #include "RecoMuon/TrackingTools/interface/MuonTrackFinder.h"
0028 #include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"
0029 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0030 
0031 // Input and output collection
0032 
0033 #include "DataFormats/Common/interface/View.h"
0034 #include "DataFormats/TrackReco/interface/Track.h"
0035 #include "DataFormats/TrackReco/interface/TrackToTrackMap.h"
0036 
0037 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0038 
0039 #include <string>
0040 
0041 using namespace edm;
0042 using namespace std;
0043 
0044 /// constructor with config
0045 StandAloneMuonProducer::StandAloneMuonProducer(const ParameterSet& parameterSet) {
0046   LogTrace("Muon|RecoMuon|StandAloneMuonProducer") << "constructor called" << endl;
0047 
0048   // Parameter set for the Builder
0049   ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("STATrajBuilderParameters");
0050 
0051   // MuonSeed Collection Label
0052   theSeedCollectionLabel = parameterSet.getParameter<InputTag>("InputObjects");
0053 
0054   // service parameters
0055   ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
0056 
0057   // TrackLoader parameters
0058   ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
0059   edm::ConsumesCollector iC = consumesCollector();
0060 
0061   // the services
0062   theService = std::make_unique<MuonServiceProxy>(serviceParameters, consumesCollector());
0063 
0064   auto trackLoader = std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get());
0065   std::unique_ptr<MuonTrajectoryBuilder> trajectoryBuilder;
0066   // instantiate the concrete trajectory builder in the Track Finder
0067   string typeOfBuilder = parameterSet.getParameter<string>("MuonTrajectoryBuilder");
0068   if (typeOfBuilder == "StandAloneMuonTrajectoryBuilder")
0069     trajectoryBuilder =
0070         std::make_unique<StandAloneMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
0071   else if (typeOfBuilder == "DirectMuonTrajectoryBuilder")
0072     trajectoryBuilder =
0073         std::make_unique<DirectMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
0074   else if (typeOfBuilder == "Exhaustive")
0075     trajectoryBuilder =
0076         std::make_unique<ExhaustiveMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
0077   else {
0078     LogWarning("Muon|RecoMuon|StandAloneMuonProducer")
0079         << "No Trajectory builder associated with " << typeOfBuilder
0080         << ". Falling down to the default (StandAloneMuonTrajectoryBuilder)";
0081     trajectoryBuilder =
0082         std::make_unique<StandAloneMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
0083   }
0084   theTrackFinder = std::make_unique<MuonTrackFinder>(std::move(trajectoryBuilder), std::move(trackLoader), iC);
0085 
0086   setAlias(parameterSet.getParameter<std::string>("@module_label"));
0087 
0088   produces<reco::TrackCollection>().setBranchAlias(theAlias + "Tracks");
0089   produces<reco::TrackCollection>("UpdatedAtVtx").setBranchAlias(theAlias + "UpdatedAtVtxTracks");
0090   produces<TrackingRecHitCollection>().setBranchAlias(theAlias + "RecHits");
0091   produces<reco::TrackExtraCollection>().setBranchAlias(theAlias + "TrackExtras");
0092   produces<reco::TrackToTrackMap>().setBranchAlias(theAlias + "TrackToTrackMap");
0093 
0094   produces<std::vector<Trajectory> >().setBranchAlias(theAlias + "Trajectories");
0095   produces<TrajTrackAssociationCollection>().setBranchAlias(theAlias + "TrajToTrackMap");
0096 
0097   seedToken = consumes<edm::View<TrajectorySeed> >(theSeedCollectionLabel);
0098 }
0099 
0100 /// destructor
0101 StandAloneMuonProducer::~StandAloneMuonProducer() {
0102   LogTrace("Muon|RecoMuon|StandAloneMuonProducer") << "StandAloneMuonProducer destructor called" << endl;
0103 }
0104 
0105 /// reconstruct muons
0106 void StandAloneMuonProducer::produce(Event& event, const EventSetup& eventSetup) {
0107   const std::string metname = "Muon|RecoMuon|StandAloneMuonProducer";
0108 
0109   LogTrace(metname) << endl << endl << endl;
0110   LogTrace(metname) << "Stand Alone Muon Reconstruction Started" << endl;
0111 
0112   // Take the seeds container
0113   LogTrace(metname) << "Taking the seeds: " << theSeedCollectionLabel.label() << endl;
0114   Handle<View<TrajectorySeed> > seeds;
0115   event.getByToken(seedToken, seeds);
0116 
0117   // Update the services
0118   theService->update(eventSetup);
0119 
0120   // Reconstruct
0121   LogTrace(metname) << "Track Reconstruction" << endl;
0122   theTrackFinder->reconstruct(seeds, event, eventSetup);
0123 
0124   LogTrace(metname) << "Event loaded"
0125                     << "================================" << endl
0126                     << endl;
0127 }