CMS 3D CMS Logo

TSGFromL2Muon.cc
Go to the documentation of this file.
1 #include "TSGFromL2Muon.h"
8 
10  produces<L3MuonTrajectorySeedCollection>();
11 
12  edm::ConsumesCollector iC = consumesCollector();
13 
14  edm::ParameterSet serviceParameters = cfg.getParameter<edm::ParameterSet>("ServiceParameters");
15  theService = std::make_unique<MuonServiceProxy>(serviceParameters);
16 
17  //Pt and P cuts
18  thePtCut = cfg.getParameter<double>("PtCut");
19  thePCut = cfg.getParameter<double>("PCut");
20 
21  //Region builder
22  edm::ParameterSet regionBuilderPSet = cfg.getParameter<edm::ParameterSet>("MuonTrackingRegionBuilder");
23  //ability to no define a region
24  if (!regionBuilderPSet.empty()){
25  theRegionBuilder = std::make_unique<MuonTrackingRegionBuilder>(regionBuilderPSet, iC);
26  }
27 
28  //Seed generator
29  edm::ParameterSet seedGenPSet = cfg.getParameter<edm::ParameterSet>("TkSeedGenerator");
30  std::string seedGenName = seedGenPSet.getParameter<std::string>("ComponentName");
31  theTkSeedGenerator = std::unique_ptr<TrackerSeedGenerator>{TrackerSeedGeneratorFactory::get()->create(seedGenName, seedGenPSet,iC)};
32 
33  //Seed cleaner
34  edm::ParameterSet trackerSeedCleanerPSet = cfg.getParameter<edm::ParameterSet>("TrackerSeedCleaner");
35  //To activate or not the cleaner
36  if (!trackerSeedCleanerPSet.empty()){
37  theSeedCleaner = std::make_unique<TrackerSeedCleaner>(trackerSeedCleanerPSet,iC);
38  }
39 
40  //L2 collection
41  theL2CollectionLabel = cfg.getParameter<edm::InputTag>("MuonCollectionLabel");
42  l2muonToken = consumes<reco::TrackCollection>(theL2CollectionLabel);
43 }
44 
45 
47 
48 
50  //update muon proxy service
51  theService->update(es);
52  theTkSeedGenerator->init(theService.get());
53  if (theSeedCleaner) theSeedCleaner->init(theService.get());
54 }
55 
56 
58  auto result = std::make_unique<L3MuonTrajectorySeedCollection>();
59 
60  //Retrieve tracker topology from geometry
62  es.get<TrackerTopologyRcd>().get(tTopoHand);
63  const TrackerTopology *tTopo=tTopoHand.product();
64 
65  //intialize tools
66  theService->update(es);
67  theTkSeedGenerator->setEvent(ev);
68  if (theRegionBuilder) theRegionBuilder->setEvent(ev);
69  if (theSeedCleaner) theSeedCleaner->setEvent(ev);
70 
71  //retrieve L2 track collection
73  ev.getByToken(l2muonToken ,l2muonH);
74 
75  // produce trajectory seed collection
76  LogDebug("TSGFromL2Muon")<<l2muonH->size()<<" l2 tracks.";
77 
78  for (unsigned int imu=0; imu != l2muonH->size(); ++imu){
79  //make a ref to l2 muon
80  reco::TrackRef muRef(l2muonH, imu);
81 
82  // cut on muons with low momenta
83  if ( muRef->pt() < thePtCut
84  || muRef->innerMomentum().Rho() < thePtCut
85  || muRef->innerMomentum().R() < thePCut ) continue;
86 
87  //define the region of interest
88  std::unique_ptr<RectangularEtaPhiTrackingRegion> region;
89  if(theRegionBuilder){
90  region = theRegionBuilder->region(muRef);
91  }
92 
93  //Make seeds container
94  std::vector<TrajectorySeed> tkSeeds;
95 
96  //Make TrackCand
97  std::pair<const Trajectory*,reco::TrackRef> staCand((Trajectory*)nullptr, muRef);
98 
99  //Run seed generator to fill seed container
100  theTkSeedGenerator->trackerSeeds(staCand, *region, tTopo,tkSeeds);
101 
102  //Seed Cleaner From Direction
103  if(theSeedCleaner){
104  theSeedCleaner->clean(muRef,*region,tkSeeds);
105  }
106 
107  for (unsigned int is=0; is != tkSeeds.size(); ++is){
108  result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef));
109  }
110 
111  }
112 
113 
114  //ADDME: remove seed duplicate, keeping the ref to L2
115 
116  LogDebug("TSGFromL2Muon")<<result->size()<<" trajectory seeds to the events";
117 
118  //put in the event
119  ev.put(std::move(result));
120 }
121 
122 // FillDescription generated from hltL3TrajSeedOIState with additions from OIHit and IOHit
123 void
126  desc.setAllowAnything();
127 }
128 
#define LogDebug(id)
~TSGFromL2Muon() override
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:191
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void produce(edm::Event &ev, const edm::EventSetup &es) override
std::unique_ptr< TrackerSeedGenerator > theTkSeedGenerator
Definition: TSGFromL2Muon.h:37
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void setAllowAnything()
allow any parameter label/value pairs
std::unique_ptr< MuonTrackingRegionBuilder > theRegionBuilder
Definition: TSGFromL2Muon.h:36
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
edm::EDGetTokenT< reco::TrackCollection > l2muonToken
Definition: TSGFromL2Muon.h:39
bool ev
TSGFromL2Muon(const edm::ParameterSet &cfg)
Definition: TSGFromL2Muon.cc:9
edm::InputTag theL2CollectionLabel
Definition: TSGFromL2Muon.h:33
std::unique_ptr< TrackerSeedCleaner > theSeedCleaner
Definition: TSGFromL2Muon.h:38
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T get() const
Definition: EventSetup.h:71
std::unique_ptr< MuonServiceProxy > theService
Definition: TSGFromL2Muon.h:34
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:45