Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-20 23:20:21

0001 //-------------------------------------------------
0002 //
0003 /**  \class L2MuonProducer
0004  * 
0005  *   L2 muon reconstructor:
0006  *   reconstructs muons using DT, CSC and RPC
0007  *   information,<BR>
0008  *   starting from internal seeds (L2 muon track segments).
0009  *
0010  *
0011  *
0012  *   \author  R.Bellan - INFN TO
0013  *
0014  *   modified by A. Sharma to add fillDescription function
0015  */
0016 //
0017 //--------------------------------------------------
0018 
0019 #include <memory>
0020 #include <string>
0021 
0022 #include "DataFormats/Common/interface/Handle.h"
0023 #include "DataFormats/Common/interface/View.h"
0024 #include "DataFormats/MuonSeed/interface/L2MuonTrajectorySeedCollection.h"
0025 #include "DataFormats/TrackReco/interface/Track.h"
0026 #include "DataFormats/TrackReco/interface/TrackToTrackMap.h"
0027 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0028 #include "FWCore/Framework/interface/ConsumesCollector.h"
0029 #include "FWCore/Framework/interface/Event.h"
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 #include "FWCore/Framework/interface/stream/EDProducer.h"
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0035 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0036 #include "FWCore/Utilities/interface/InputTag.h"
0037 #include "RecoMuon/StandAloneTrackFinder/interface/ExhaustiveMuonTrajectoryBuilder.h"
0038 #include "RecoMuon/StandAloneTrackFinder/interface/StandAloneTrajectoryBuilder.h"
0039 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0040 #include "RecoMuon/TrackingTools/interface/MuonTrackFinder.h"
0041 #include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"
0042 #include "RecoMuon/TrackingTools/interface/MuonTrajectoryCleaner.h"
0043 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0044 
0045 class L2MuonProducer : public edm::stream::EDProducer<> {
0046 public:
0047   /// constructor with config
0048   L2MuonProducer(const edm::ParameterSet&);
0049 
0050   /// destructor
0051   ~L2MuonProducer() override;
0052 
0053   /// reconstruct muons
0054   void produce(edm::Event&, const edm::EventSetup&) override;
0055   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0056 
0057 private:
0058   // MuonSeed Collection Label
0059   edm::InputTag theSeedCollectionLabel;
0060 
0061   /// the track finder
0062   std::unique_ptr<MuonTrackFinder> theTrackFinder;  //It isn't the same as in ORCA
0063 
0064   /// the event setup proxy, it takes care the services update
0065   std::unique_ptr<MuonServiceProxy> theService;
0066 
0067   edm::EDGetTokenT<edm::View<TrajectorySeed>> seedsToken;
0068 };
0069 
0070 /// constructor with config
0071 L2MuonProducer::L2MuonProducer(const edm::ParameterSet& parameterSet) {
0072   LogTrace("Muon|RecoMuon|L2MuonProducer") << "constructor called" << endl;
0073 
0074   // Parameter set for the Builder
0075   edm::ParameterSet trajectoryBuilderParameters =
0076       parameterSet.getParameter<edm::ParameterSet>("L2TrajBuilderParameters");
0077 
0078   // MuonSeed Collection Label
0079   theSeedCollectionLabel = parameterSet.getParameter<edm::InputTag>("InputObjects");
0080   seedsToken = consumes<edm::View<TrajectorySeed>>(theSeedCollectionLabel);
0081   // service parameters
0082   edm::ParameterSet serviceParameters = parameterSet.getParameter<edm::ParameterSet>("ServiceParameters");
0083 
0084   // TrackLoader parameters
0085   edm::ParameterSet trackLoaderParameters = parameterSet.getParameter<edm::ParameterSet>("TrackLoaderParameters");
0086 
0087   // the services
0088   theService = std::make_unique<MuonServiceProxy>(serviceParameters, consumesCollector());
0089 
0090   std::unique_ptr<MuonTrajectoryBuilder> trajectoryBuilder = nullptr;
0091   // instantiate the concrete trajectory builder in the Track Finder
0092 
0093   edm::ConsumesCollector iC = consumesCollector();
0094   string typeOfBuilder = parameterSet.getParameter<string>("MuonTrajectoryBuilder");
0095   if (typeOfBuilder == "StandAloneMuonTrajectoryBuilder" || typeOfBuilder.empty())
0096     trajectoryBuilder =
0097         std::make_unique<StandAloneMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
0098   else if (typeOfBuilder == "Exhaustive")
0099     trajectoryBuilder =
0100         std::make_unique<ExhaustiveMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
0101   else {
0102     edm::LogWarning("Muon|RecoMuon|StandAloneMuonProducer")
0103         << "No Trajectory builder associated with " << typeOfBuilder
0104         << ". Falling down to the default (StandAloneMuonTrajectoryBuilder)";
0105     trajectoryBuilder =
0106         std::make_unique<StandAloneMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
0107   }
0108   theTrackFinder =
0109       std::make_unique<MuonTrackFinder>(std::move(trajectoryBuilder),
0110                                         std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get()),
0111                                         std::make_unique<MuonTrajectoryCleaner>(true),
0112                                         iC);
0113 
0114   produces<reco::TrackCollection>();
0115   produces<reco::TrackCollection>("UpdatedAtVtx");
0116   produces<TrackingRecHitCollection>();
0117   produces<reco::TrackExtraCollection>();
0118   produces<reco::TrackToTrackMap>();
0119 
0120   produces<std::vector<Trajectory>>();
0121   produces<TrajTrackAssociationCollection>();
0122 
0123   produces<edm::AssociationMap<edm::OneToMany<std::vector<L2MuonTrajectorySeed>, std::vector<L2MuonTrajectorySeed>>>>();
0124 }
0125 
0126 /// destructor
0127 L2MuonProducer::~L2MuonProducer() {
0128   LogTrace("Muon|RecoMuon|L2eMuonProducer") << "L2MuonProducer destructor called" << endl;
0129 }
0130 
0131 /// reconstruct muons
0132 void L2MuonProducer::produce(edm::Event& event, const edm::EventSetup& eventSetup) {
0133   const std::string metname = "Muon|RecoMuon|L2MuonProducer";
0134 
0135   LogTrace(metname) << endl << endl << endl;
0136   LogTrace(metname) << "L2 Muon Reconstruction Started" << endl;
0137 
0138   // Take the seeds container
0139   LogTrace(metname) << "Taking the seeds: " << theSeedCollectionLabel.label() << endl;
0140   edm::Handle<edm::View<TrajectorySeed>> seeds;
0141   event.getByToken(seedsToken, seeds);
0142 
0143   // Update the services
0144   theService->update(eventSetup);
0145 
0146   // Reconstruct
0147   LogTrace(metname) << "Track Reconstruction" << endl;
0148   theTrackFinder->reconstruct(seeds, event, eventSetup);
0149 
0150   LogTrace(metname) << "edm::Event loaded"
0151                     << "================================" << endl
0152                     << endl;
0153 }
0154 
0155 void L2MuonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0156   edm::ParameterSetDescription desc;
0157   {
0158     edm::ParameterSetDescription psd0;
0159     psd0.addUntracked<std::vector<std::string>>("Propagators",
0160                                                 {
0161                                                     "hltESPFastSteppingHelixPropagatorAny"
0162                                                     "hltESPFastSteppingHelixPropagatorOpposite",
0163                                                 });
0164     psd0.add<bool>("RPCLayers", true);
0165     psd0.addUntracked<bool>("UseMuonNavigation", true);
0166     desc.add<edm::ParameterSetDescription>("ServiceParameters", psd0);
0167   }
0168 
0169   desc.add<edm::InputTag>("InputObjects", edm::InputTag("hltL2MuonSeeds"));
0170   {
0171     edm::ParameterSetDescription psd0;
0172     psd0.add<std::string>("Fitter", "hltESPKFFittingSmootherForL2Muon");
0173     psd0.add<std::string>("MuonRecHitBuilder", "hltESPMuonTransientTrackingRecHitBuilder");
0174     psd0.add<unsigned int>("NMinRecHits", 2);
0175     psd0.add<bool>("UseSubRecHits", false);
0176     psd0.add<std::string>("Propagator", "hltESPFastSteppingHelixPropagatorAny");
0177     psd0.add<double>("RescaleError", 100.0);
0178     desc.add<edm::ParameterSetDescription>("SeedTransformerParameters", psd0);
0179   }
0180 
0181   {
0182     edm::ParameterSetDescription psd0;
0183     psd0.add<bool>("DoRefit", false);
0184     psd0.add<std::string>("SeedPropagator", "hltESPFastSteppingHelixPropagatorAny");
0185     {
0186       edm::ParameterSetDescription psd1;
0187       psd1.add<double>("NumberOfSigma", 3.0);
0188       psd1.add<std::string>("FitDirection", "insideOut");
0189       psd1.add<edm::InputTag>("DTRecSegmentLabel", edm::InputTag("hltDt4DSegments"));
0190       psd1.add<double>("MaxChi2", 1000.0);
0191       {
0192         edm::ParameterSetDescription psd2;
0193         psd2.add<double>("MaxChi2", 25.0);
0194         psd2.add<double>("RescaleErrorFactor", 100.0);
0195         psd2.add<int>("Granularity", 0);
0196         psd2.add<bool>("ExcludeRPCFromFit", false);
0197         psd2.add<bool>("UseInvalidHits", true);
0198         psd2.add<bool>("RescaleError", false);
0199         psd1.add<edm::ParameterSetDescription>("MuonTrajectoryUpdatorParameters", psd2);
0200       }
0201       psd1.add<bool>("EnableRPCMeasurement", true);
0202       psd1.add<edm::InputTag>("CSCRecSegmentLabel", edm::InputTag("hltCscSegments"));
0203       psd1.add<bool>("EnableDTMeasurement", true);
0204       psd1.add<edm::InputTag>("RPCRecSegmentLabel", edm::InputTag("hltRpcRecHits"));
0205       psd1.add<std::string>("Propagator", "hltESPFastSteppingHelixPropagatorAny");
0206       psd1.add<bool>("EnableGEMMeasurement", false);
0207       psd1.add<edm::InputTag>("GEMRecSegmentLabel", edm::InputTag("gemRecHits"));
0208       psd1.add<bool>("EnableME0Measurement", false);
0209       psd1.add<edm::InputTag>("ME0RecSegmentLabel", edm::InputTag("me0Segments"));
0210       psd1.add<bool>("EnableCSCMeasurement", true);
0211       psd0.add<edm::ParameterSetDescription>("FilterParameters", psd1);
0212     }
0213     psd0.add<std::string>("NavigationType", "Standard");
0214     {
0215       edm::ParameterSetDescription psd1;
0216       psd1.add<std::string>("Fitter", "hltESPKFFittingSmootherForL2Muon");
0217       psd1.add<std::string>("MuonRecHitBuilder", "hltESPMuonTransientTrackingRecHitBuilder");
0218       psd1.add<unsigned int>("NMinRecHits", 2);
0219       psd1.add<bool>("UseSubRecHits", false);
0220       psd1.add<std::string>("Propagator", "hltESPFastSteppingHelixPropagatorAny");
0221       psd1.add<double>("RescaleError", 100.0);
0222       psd0.add<edm::ParameterSetDescription>("SeedTransformerParameters", psd1);
0223     }
0224     psd0.add<bool>("DoBackwardFilter", true);
0225     psd0.add<std::string>("SeedPosition", "in");
0226     {
0227       edm::ParameterSetDescription psd1;
0228       psd1.add<double>("NumberOfSigma", 3.0);
0229       psd1.add<edm::InputTag>("CSCRecSegmentLabel", edm::InputTag("hltCscSegments"));
0230       psd1.add<std::string>("FitDirection", "outsideIn");
0231       psd1.add<edm::InputTag>("DTRecSegmentLabel", edm::InputTag("hltDt4DSegments"));
0232       psd1.add<double>("MaxChi2", 100.0);
0233       {
0234         edm::ParameterSetDescription psd2;
0235         psd2.add<double>("MaxChi2", 25.0);
0236         psd2.add<double>("RescaleErrorFactor", 100.0);
0237         psd2.add<int>("Granularity", 0);
0238         psd2.add<bool>("ExcludeRPCFromFit", false);
0239         psd2.add<bool>("UseInvalidHits", true);
0240         psd2.add<bool>("RescaleError", false);
0241         psd1.add<edm::ParameterSetDescription>("MuonTrajectoryUpdatorParameters", psd2);
0242       }
0243       psd1.add<bool>("EnableRPCMeasurement", true);
0244       psd1.add<std::string>("BWSeedType", "fromGenerator");
0245       psd1.add<bool>("EnableDTMeasurement", true);
0246       psd1.add<edm::InputTag>("RPCRecSegmentLabel", edm::InputTag("hltRpcRecHits"));
0247       psd1.add<std::string>("Propagator", "hltESPFastSteppingHelixPropagatorAny");
0248       psd1.add<bool>("EnableGEMMeasurement", false);
0249       psd1.add<edm::InputTag>("GEMRecSegmentLabel", edm::InputTag("gemRecHits"));
0250       psd1.add<bool>("EnableME0Measurement", false);
0251       psd1.add<edm::InputTag>("ME0RecSegmentLabel", edm::InputTag("me0Segments"));
0252       psd1.add<bool>("EnableCSCMeasurement", true);
0253       psd0.add<edm::ParameterSetDescription>("BWFilterParameters", psd1);
0254     }
0255     psd0.add<bool>("DoSeedRefit", false);
0256     desc.add<edm::ParameterSetDescription>("L2TrajBuilderParameters", psd0);
0257   }
0258   desc.add<bool>("DoSeedRefit", false);
0259   {
0260     edm::ParameterSetDescription psd0;
0261     psd0.add<std::string>("Smoother", "hltESPKFTrajectorySmootherForMuonTrackLoader");
0262     psd0.add<bool>("DoSmoothing", false);
0263     psd0.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
0264     {
0265       edm::ParameterSetDescription psd1;
0266       psd1.add<double>("MaxChi2", 1000000.0);
0267       psd1.add<std::vector<double>>("BeamSpotPosition",
0268                                     {
0269                                         0.0,
0270                                         0.0,
0271                                         0.0,
0272                                     });
0273       psd1.add<std::string>("Propagator", "hltESPFastSteppingHelixPropagatorOpposite");
0274       psd1.add<std::vector<double>>("BeamSpotPositionErrors",
0275                                     {
0276                                         0.1,
0277                                         0.1,
0278                                         5.3,
0279                                     });
0280       psd0.add<edm::ParameterSetDescription>("MuonUpdatorAtVertexParameters", psd1);
0281     }
0282     psd0.add<bool>("VertexConstraint", true);
0283     psd0.add<std::string>("TTRHBuilder", "hltESPTTRHBWithTrackAngle");
0284     desc.add<edm::ParameterSetDescription>("TrackLoaderParameters", psd0);
0285   }
0286   desc.add<std::string>("MuonTrajectoryBuilder", "Exhaustive");
0287   descriptions.add("L2MuonProducer", desc);
0288 }
0289 
0290 // declare as a framework plugin
0291 #include "FWCore/Framework/interface/MakerMacros.h"
0292 DEFINE_FWK_MODULE(L2MuonProducer);