Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-12 22:39:47

0001 /**  \class L3MuonProducer
0002  *
0003  *   L3 muon reconstructor:
0004  *   reconstructs muons using DT, CSC, RPC and tracker
0005  *   information,<BR>
0006  *   starting from a L2 reonstructed muon.
0007  *
0008  *   \author  A. Everett - Purdue University
0009  */
0010 
0011 // Framework
0012 #include "FWCore/Framework/interface/ConsumesCollector.h"
0013 #include "FWCore/Framework/interface/EDProducer.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include "DataFormats/Common/interface/Handle.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 
0020 #include "RecoMuon/L3MuonProducer/src/L3MuonProducer.h"
0021 
0022 // TrackFinder and specific GLB Trajectory Builder
0023 #include "RecoMuon/L3TrackFinder/interface/L3MuonTrajectoryBuilder.h"
0024 #include "RecoMuon/TrackingTools/interface/MuonTrackFinder.h"
0025 #include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"
0026 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0027 #include "RecoMuon/GlobalTrackingTools/interface/MuonTrackingRegionBuilder.h"
0028 
0029 using namespace edm;
0030 using namespace std;
0031 
0032 //
0033 // constructor with config
0034 //
0035 L3MuonProducer::L3MuonProducer(const ParameterSet& parameterSet) {
0036   LogTrace("L3MuonProducer") << "constructor called" << endl;
0037 
0038   // Parameter set for the Builder
0039   ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("L3TrajBuilderParameters");
0040 
0041   // L2 Muon Collection Label
0042   theL2CollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
0043   l2MuonToken_ = consumes<reco::TrackCollection>(theL2CollectionLabel);
0044   l2MuonTrajToken_ = consumes<std::vector<Trajectory>>(theL2CollectionLabel.label());
0045   l2AssoMapToken_ = consumes<TrajTrackAssociationCollection>(theL2CollectionLabel.label());
0046   updatedL2AssoMapToken_ = consumes<reco::TrackToTrackMap>(theL2CollectionLabel.label());
0047 
0048   // service parameters
0049   ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
0050 
0051   // TrackLoader parameters
0052   ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
0053 
0054   // the services
0055   theService = std::make_unique<MuonServiceProxy>(serviceParameters, consumesCollector());
0056   ConsumesCollector iC = consumesCollector();
0057 
0058   // instantiate the concrete trajectory builder in the Track Finder
0059   auto mtl = std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get());
0060   auto l3mtb = std::make_unique<L3MuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
0061   theTrackFinder = std::make_unique<MuonTrackFinder>(std::move(l3mtb), std::move(mtl), iC);
0062 
0063   theL2SeededTkLabel =
0064       trackLoaderParameters.getUntrackedParameter<std::string>("MuonSeededTracksInstance", std::string());
0065 
0066   produces<reco::TrackCollection>(theL2SeededTkLabel);
0067   produces<TrackingRecHitCollection>(theL2SeededTkLabel);
0068   produces<reco::TrackExtraCollection>(theL2SeededTkLabel);
0069   produces<vector<Trajectory>>(theL2SeededTkLabel);
0070   produces<TrajTrackAssociationCollection>(theL2SeededTkLabel);
0071 
0072   produces<reco::TrackCollection>();
0073   produces<TrackingRecHitCollection>();
0074   produces<reco::TrackExtraCollection>();
0075   produces<vector<Trajectory>>();
0076   produces<TrajTrackAssociationCollection>();
0077 
0078   produces<reco::MuonTrackLinksCollection>();
0079 }
0080 
0081 //
0082 // destructor
0083 //
0084 L3MuonProducer::~L3MuonProducer() { LogTrace("L3MuonProducer") << "destructor called" << endl; }
0085 
0086 //
0087 // reconstruct muons
0088 //
0089 void L3MuonProducer::produce(Event& event, const EventSetup& eventSetup) {
0090   const string metname = "Muon|RecoMuon|L3MuonProducer";
0091   LogTrace(metname) << endl << endl << endl;
0092   LogTrace(metname) << "L3 Muon Reconstruction started" << endl;
0093 
0094   typedef vector<Trajectory> TrajColl;
0095 
0096   // Update the services
0097   theService->update(eventSetup);
0098 
0099   // Take the L2 muon container(s)
0100   LogTrace(metname) << "Taking the L2 Muons " << theL2CollectionLabel << endl;
0101 
0102   Handle<reco::TrackCollection> L2Muons;
0103   event.getByToken(l2MuonToken_, L2Muons);
0104 
0105   Handle<vector<Trajectory>> L2MuonsTraj;
0106   vector<MuonTrajectoryBuilder::TrackCand> L2TrackCands;
0107 
0108   event.getByToken(l2MuonTrajToken_, L2MuonsTraj);
0109 
0110   edm::Handle<TrajTrackAssociationCollection> L2AssoMap;
0111   event.getByToken(l2AssoMapToken_, L2AssoMap);
0112 
0113   edm::Handle<reco::TrackToTrackMap> updatedL2AssoMap;
0114   event.getByToken(updatedL2AssoMapToken_, updatedL2AssoMap);
0115 
0116   for (TrajTrackAssociationCollection::const_iterator it = L2AssoMap->begin(); it != L2AssoMap->end(); ++it) {
0117     const Ref<vector<Trajectory>> traj = it->key;
0118     const reco::TrackRef tkRegular = it->val;
0119     reco::TrackRef tkUpdated;
0120     reco::TrackToTrackMap::const_iterator iEnd;
0121     reco::TrackToTrackMap::const_iterator iii;
0122     if (theL2CollectionLabel.instance() == "UpdatedAtVtx") {
0123       iEnd = updatedL2AssoMap->end();
0124       iii = updatedL2AssoMap->find(it->val);
0125       if (iii != iEnd)
0126         tkUpdated = (*updatedL2AssoMap)[it->val];
0127     }
0128 
0129     const reco::TrackRef tk = (tkUpdated.isNonnull()) ? tkUpdated : tkRegular;
0130 
0131     MuonTrajectoryBuilder::TrackCand L2Cand = MuonTrajectoryBuilder::TrackCand((Trajectory*)nullptr, tk);
0132     if (traj->isValid())
0133       L2Cand.first = &*traj;
0134     L2TrackCands.push_back(L2Cand);
0135   }
0136 
0137   theTrackFinder->reconstruct(L2TrackCands, event, eventSetup);
0138 
0139   LogTrace(metname) << "Event loaded"
0140                     << "================================" << endl
0141                     << endl;
0142 }
0143 
0144 void L3MuonProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0145   edm::ParameterSetDescription desc;
0146   {
0147     edm::ParameterSetDescription psd0;
0148     psd0.addUntracked<std::vector<std::string>>("Propagators",
0149                                                 {
0150                                                     "hltESPSmartPropagatorAny",
0151                                                     "SteppingHelixPropagatorAny",
0152                                                     "hltESPSmartPropagator",
0153                                                     "hltESPSteppingHelixPropagatorOpposite",
0154                                                 });
0155     psd0.add<bool>("RPCLayers", true);
0156     psd0.addUntracked<bool>("UseMuonNavigation", true);
0157     desc.add<edm::ParameterSetDescription>("ServiceParameters", psd0);
0158   }
0159   desc.add<edm::InputTag>("MuonCollectionLabel", edm::InputTag("hltL2Muons", "UpdatedAtVtx"));
0160   {
0161     edm::ParameterSetDescription psd0;
0162     psd0.addUntracked<bool>("PutTkTrackIntoEvent", false);
0163     psd0.add<std::string>("TTRHBuilder", "hltESPTTRHBWithTrackAngle");
0164     psd0.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
0165     psd0.addUntracked<bool>("SmoothTkTrack", false);
0166     psd0.addUntracked<std::string>("MuonSeededTracksInstance", "L2Seeded");
0167     psd0.add<std::string>("Smoother", "hltESPKFTrajectorySmootherForMuonTrackLoader");
0168     {
0169       edm::ParameterSetDescription psd1;
0170       psd1.add<double>("MaxChi2", 1000000.0);
0171       psd1.add<std::string>("Propagator", "hltESPSteppingHelixPropagatorOpposite");
0172       psd1.add<std::vector<double>>("BeamSpotPositionErrors",
0173                                     {
0174                                         0.1,
0175                                         0.1,
0176                                         5.3,
0177                                     });
0178       psd0.add<edm::ParameterSetDescription>("MuonUpdatorAtVertexParameters", psd1);
0179     }
0180     psd0.add<bool>("VertexConstraint", false);
0181     psd0.add<bool>("DoSmoothing", false);
0182     desc.add<edm::ParameterSetDescription>("TrackLoaderParameters", psd0);
0183   }
0184   {
0185     edm::ParameterSetDescription psd0;
0186     psd0.add<double>("ScaleTECyFactor", -1.0);
0187     psd0.add<edm::InputTag>("tkTrajVertex", edm::InputTag("hltPixelVertices"));
0188     psd0.add<bool>("tkTrajUseVertex", false);
0189     {
0190       edm::ParameterSetDescription psd1;
0191       psd1.add<int>("TrackerSkipSection", -1);
0192       psd1.add<bool>("DoPredictionsOnly", false);
0193       psd1.add<bool>("PropDirForCosmics", false);
0194       psd1.add<int>("HitThreshold", 1);
0195       psd1.add<int>("MuonHitsOption", 1);
0196       psd1.add<bool>("RefitFlag", true);
0197       psd1.add<std::string>("Fitter", "hltESPL3MuKFTrajectoryFitter");
0198       psd1.add<int>("SkipStation", -1);
0199       psd1.add<std::string>("TrackerRecHitBuilder", "hltESPTTRHBWithTrackAngle");
0200       psd1.add<double>("Chi2CutRPC", 1.0);
0201       psd1.add<std::string>("MuonRecHitBuilder", "hltESPMuonTransientTrackingRecHitBuilder");
0202       psd1.add<std::string>("RefitDirection", "insideOut");
0203       psd1.add<edm::InputTag>("CSCRecSegmentLabel", edm::InputTag("hltCscSegments"));
0204       psd1.add<edm::InputTag>("GEMRecHitLabel", edm::InputTag("gemRecHits"));
0205       psd1.add<edm::InputTag>("ME0RecHitLabel", edm::InputTag("me0Segments"));
0206       psd1.add<std::vector<int>>("DYTthrs",
0207                                  {
0208                                      30,
0209                                      15,
0210                                  });
0211       psd1.add<int>("DYTselector", 1);
0212       psd1.add<bool>("DYTupdator", false);
0213       psd1.add<bool>("DYTuseAPE", false);
0214       psd1.add<bool>("DYTuseThrsParametrization", true);
0215       {
0216         edm::ParameterSetDescription psd2;
0217         psd2.add<std::vector<double>>("eta0p8", {1, -0.919853, 0.990742});
0218         psd2.add<std::vector<double>>("eta1p2", {1, -0.897354, 0.987738});
0219         psd2.add<std::vector<double>>("eta2p0", {1, -0.986855, 0.998516});
0220         psd2.add<std::vector<double>>("eta2p2", {1, -0.940342, 0.992955});
0221         psd2.add<std::vector<double>>("eta2p4", {1, -0.947633, 0.993762});
0222         psd1.add<edm::ParameterSetDescription>("DYTthrsParameters", psd2);
0223       }
0224       psd1.add<double>("Chi2CutCSC", 150.0);
0225       psd1.add<double>("Chi2CutDT", 10.0);
0226       psd1.add<double>("Chi2CutGEM", 1.0);
0227       psd1.add<double>("Chi2CutME0", 1.0);
0228       psd1.add<bool>("RefitRPCHits", true);
0229       psd1.add<edm::InputTag>("DTRecSegmentLabel", edm::InputTag("hltDt4DSegments"));
0230       psd1.add<std::string>("Propagator", "hltESPSmartPropagatorAny");
0231       psd1.add<int>("TrackerSkipSystem", -1);
0232       psd0.add<edm::ParameterSetDescription>("GlbRefitterParameters", psd1);
0233     }
0234     psd0.add<double>("tkTrajMaxChi2", 9999.0);
0235     psd0.add<double>("ScaleTECxFactor", -1.0);
0236     psd0.add<std::string>("TrackerRecHitBuilder", "hltESPTTRHBWithTrackAngle");
0237     psd0.add<edm::InputTag>("tkTrajBeamSpot", edm::InputTag("hltOnlineBeamSpot"));
0238     psd0.add<std::string>("MuonRecHitBuilder", "hltESPMuonTransientTrackingRecHitBuilder");
0239     psd0.add<double>("tkTrajMaxDXYBeamSpot", 9999.0);
0240     psd0.add<std::string>("TrackerPropagator", "SteppingHelixPropagatorAny");
0241     {
0242       edm::ParameterSetDescription psd1;
0243       psd1.add<bool>("precise", true);
0244       psd1.add<bool>("Eta_fixed", true);
0245       psd1.add<double>("Eta_min", 0.1);
0246       psd1.add<bool>("Z_fixed", false);
0247       psd1.add<edm::InputTag>("MeasurementTrackerName", edm::InputTag("hltESPMeasurementTracker"));
0248       psd1.add<int>("maxRegions", 2);
0249       psd1.add<double>("Pt_min", 3.0);
0250       psd1.add<double>("Rescale_Dz", 4.0);
0251       psd1.add<double>("PhiR_UpperLimit_Par1", 0.6);
0252       psd1.add<double>("PhiR_UpperLimit_Par2", 0.2);
0253       psd1.add<edm::InputTag>("vertexCollection", edm::InputTag("pixelVertices"));
0254       psd1.add<bool>("Phi_fixed", true);
0255       psd1.add<edm::InputTag>("input", edm::InputTag("hltL2Muons", "UpdatedAtVtx"));
0256       psd1.add<double>("DeltaR", 0.025);
0257       psd1.add<int>("OnDemand", -1);
0258       psd1.add<double>("DeltaZ", 24.2);
0259       psd1.add<double>("Rescale_phi", 3.0);
0260       psd1.add<double>("Rescale_eta", 3.0);
0261       psd1.add<double>("DeltaEta", 0.04);
0262       psd1.add<double>("DeltaPhi", 0.15);
0263       psd1.add<double>("Phi_min", 0.1);
0264       psd1.add<bool>("UseVertex", false);
0265       psd1.add<double>("EtaR_UpperLimit_Par1", 0.25);
0266       psd1.add<double>("EtaR_UpperLimit_Par2", 0.15);
0267       psd1.add<edm::InputTag>("beamSpot", edm::InputTag("hltOnlineBeamSpot"));
0268       psd1.add<bool>("Pt_fixed", false);
0269       psd0.add<edm::ParameterSetDescription>("MuonTrackingRegionBuilder", psd1);
0270     }
0271     psd0.add<bool>("RefitRPCHits", true);
0272     psd0.add<double>("PCut", 2.5);
0273     {
0274       edm::ParameterSetDescription psd1;
0275       TrackTransformer::fillPSetDescription(psd1,
0276                                             false,                                           // do predictions only
0277                                             "hltESPL3MuKFTrajectoryFitter",                  // fitter
0278                                             "hltESPKFTrajectorySmootherForMuonTrackLoader",  // smoother
0279                                             "hltESPSmartPropagatorAny",                      // propagator
0280                                             "insideOut",                                     // refit direction
0281                                             true,                                            // refit rpc hits
0282                                             "hltESPTTRHBWithTrackAngle",                     // tracker rechit builder
0283                                             "hltESPMuonTransientTrackingRecHitBuilder"       // muon rechit builder
0284       );
0285       psd0.add<edm::ParameterSetDescription>("TrackTransformer", psd1);
0286     }
0287     {
0288       edm::ParameterSetDescription psd1;
0289       psd1.add<double>("Quality_3", 7.0);
0290       psd1.add<double>("DeltaRCut_1", 0.1);
0291       psd1.add<double>("MinP", 2.5);
0292       psd1.add<double>("MinPt", 1.0);
0293       psd1.add<double>("Quality_2", 15.0);
0294       psd1.add<double>("Pt_threshold2", 999999999.0);
0295       psd1.add<double>("LocChi2Cut", 0.001);
0296       psd1.add<double>("Eta_threshold", 1.2);
0297       psd1.add<double>("Pt_threshold1", 0.0);
0298       psd1.add<double>("Chi2Cut_1", 50.0);
0299       psd1.add<double>("Quality_1", 20.0);
0300       psd1.add<double>("Chi2Cut_3", 200.0);
0301       psd1.add<double>("DeltaRCut_3", 1.0);
0302       psd1.add<double>("DeltaRCut_2", 0.2);
0303       psd1.add<double>("DeltaDCut_1", 40.0);
0304       psd1.add<double>("DeltaDCut_2", 10.0);
0305       psd1.add<double>("DeltaDCut_3", 15.0);
0306       psd1.add<double>("Chi2Cut_2", 50.0);
0307       psd1.add<std::string>("Propagator", "hltESPSmartPropagator");
0308       psd0.add<edm::ParameterSetDescription>("GlobalMuonTrackMatcher", psd1);
0309     }
0310     psd0.add<double>("PtCut", 1.0);
0311     psd0.add<bool>("matchToSeeds", true);
0312     psd0.add<edm::InputTag>("tkTrajLabel", edm::InputTag("hltBRSMuonSeededTracksOutIn"));
0313     desc.add<edm::ParameterSetDescription>("L3TrajBuilderParameters", psd0);
0314   }
0315   descriptions.add("L3MuonProducer", desc);
0316 }