CMS 3D CMS Logo

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