Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-08 02:27:37

0001 #include "TSGFromL2Muon.h"
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0004 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0005 #include "RecoMuon/GlobalTrackingTools/interface/MuonTrackingRegionBuilder.h"
0006 #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGenerator.h"
0007 #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGeneratorFactory.h"
0008 #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedCleaner.h"
0009 
0010 TSGFromL2Muon::TSGFromL2Muon(const edm::ParameterSet& cfg) {
0011   produces<L3MuonTrajectorySeedCollection>();
0012 
0013   edm::ConsumesCollector iC = consumesCollector();
0014 
0015   edm::ParameterSet serviceParameters = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
0016   theService = std::make_unique<MuonServiceProxy>(
0017       serviceParameters, consumesCollector(), MuonServiceProxy::UseEventSetupIn::RunAndEvent);
0018 
0019   //Pt and P cuts
0020   thePtCut = cfg.getParameter<double>("PtCut");
0021   thePCut = cfg.getParameter<double>("PCut");
0022 
0023   //Region builder
0024   edm::ParameterSet regionBuilderPSet = cfg.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
0025   //ability to no define a region
0026   if (!regionBuilderPSet.empty()) {
0027     theRegionBuilder = std::make_unique<MuonTrackingRegionBuilder>(regionBuilderPSet, iC);
0028   }
0029 
0030   //Seed generator
0031   edm::ParameterSet seedGenPSet = cfg.getParameter<edm::ParameterSet>("TkSeedGenerator");
0032   std::string seedGenName = seedGenPSet.getParameter<std::string>("ComponentName");
0033   theTkSeedGenerator = TrackerSeedGeneratorFactory::get()->create(seedGenName, seedGenPSet, iC);
0034 
0035   //Seed cleaner
0036   edm::ParameterSet trackerSeedCleanerPSet = cfg.getParameter<edm::ParameterSet>("TrackerSeedCleaner");
0037   //To activate or not the cleaner
0038   if (!trackerSeedCleanerPSet.empty()) {
0039     theSeedCleaner = std::make_unique<TrackerSeedCleaner>(trackerSeedCleanerPSet, iC);
0040   }
0041 
0042   //L2 collection
0043   theL2CollectionLabel = cfg.getParameter<edm::InputTag>("MuonCollectionLabel");
0044   l2muonToken = consumes<reco::TrackCollection>(theL2CollectionLabel);
0045 
0046   theTTopoToken = esConsumes();
0047 }
0048 
0049 TSGFromL2Muon::~TSGFromL2Muon() = default;
0050 
0051 void TSGFromL2Muon::beginRun(const edm::Run& run, const edm::EventSetup& es) {
0052   //update muon proxy service
0053   bool duringEvent = false;
0054   theService->update(es, duringEvent);
0055   theTkSeedGenerator->init(theService.get());
0056   if (theSeedCleaner)
0057     theSeedCleaner->init(theService.get());
0058 }
0059 
0060 void TSGFromL2Muon::produce(edm::Event& ev, const edm::EventSetup& es) {
0061   auto result = std::make_unique<L3MuonTrajectorySeedCollection>();
0062 
0063   //Retrieve tracker topology from geometry
0064   const TrackerTopology* tTopo = &es.getData(theTTopoToken);
0065 
0066   //intialize tools
0067   theService->update(es);
0068   theTkSeedGenerator->setEvent(ev);
0069   if (theRegionBuilder)
0070     theRegionBuilder->setEvent(ev, es);
0071   if (theSeedCleaner)
0072     theSeedCleaner->setEvent(ev);
0073 
0074   //retrieve L2 track collection
0075   edm::Handle<reco::TrackCollection> l2muonH;
0076   ev.getByToken(l2muonToken, l2muonH);
0077 
0078   // produce trajectory seed collection
0079   LogDebug("TSGFromL2Muon") << l2muonH->size() << " l2 tracks.";
0080 
0081   for (unsigned int imu = 0; imu != l2muonH->size(); ++imu) {
0082     //make a ref to l2 muon
0083     reco::TrackRef muRef(l2muonH, imu);
0084 
0085     // cut on muons with low momenta
0086     if (muRef->pt() < thePtCut || muRef->innerMomentum().Rho() < thePtCut || muRef->innerMomentum().R() < thePCut)
0087       continue;
0088 
0089     //define the region of interest
0090     std::unique_ptr<RectangularEtaPhiTrackingRegion> region;
0091     if (theRegionBuilder) {
0092       region = theRegionBuilder->region(muRef);
0093     } else {
0094       region = std::make_unique<RectangularEtaPhiTrackingRegion>();
0095     }
0096 
0097     //Make seeds container
0098     std::vector<TrajectorySeed> tkSeeds;
0099 
0100     //Make TrackCand
0101     std::pair<const Trajectory*, reco::TrackRef> staCand((Trajectory*)nullptr, muRef);
0102 
0103     //Run seed generator to fill seed container
0104     theTkSeedGenerator->trackerSeeds(staCand, *region, tTopo, tkSeeds);
0105 
0106     //Seed Cleaner From Direction
0107     if (theSeedCleaner) {
0108       theSeedCleaner->clean(muRef, *region, tkSeeds);
0109     }
0110 
0111     for (unsigned int is = 0; is != tkSeeds.size(); ++is) {
0112       result->push_back(L3MuonTrajectorySeed(tkSeeds[is], muRef));
0113     }
0114   }
0115 
0116   //ADDME: remove seed duplicate, keeping the ref to L2
0117 
0118   LogDebug("TSGFromL2Muon") << result->size() << " trajectory seeds to the events";
0119 
0120   //put in the event
0121   ev.put(std::move(result));
0122 }
0123 
0124 // FillDescription generated from hltL3TrajSeedOIState with additions from OIHit and IOHit
0125 void TSGFromL2Muon::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0126   edm::ParameterSetDescription desc;
0127   desc.setAllowAnything();
0128 }