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 }
46 
48 
50  //update muon proxy service
51  bool duringEvent = false;
52  theService->update(es, duringEvent);
53  theTkSeedGenerator->init(theService.get());
54  if (theSeedCleaner)
55  theSeedCleaner->init(theService.get());
56 }
57 
59  auto result = std::make_unique<L3MuonTrajectorySeedCollection>();
60 
61  //Retrieve tracker topology from geometry
63  es.get<TrackerTopologyRcd>().get(tTopoHand);
64  const TrackerTopology* tTopo = tTopoHand.product();
65 
66  //intialize tools
67  theService->update(es);
68  theTkSeedGenerator->setEvent(ev);
69  if (theRegionBuilder)
70  theRegionBuilder->setEvent(ev);
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  }
94 
95  //Make seeds container
96  std::vector<TrajectorySeed> tkSeeds;
97 
98  //Make TrackCand
99  std::pair<const Trajectory*, reco::TrackRef> staCand((Trajectory*)nullptr, muRef);
100 
101  //Run seed generator to fill seed container
102  theTkSeedGenerator->trackerSeeds(staCand, *region, tTopo, tkSeeds);
103 
104  //Seed Cleaner From Direction
105  if (theSeedCleaner) {
106  theSeedCleaner->clean(muRef, *region, tkSeeds);
107  }
108 
109  for (unsigned int is = 0; is != tkSeeds.size(); ++is) {
110  result->push_back(L3MuonTrajectorySeed(tkSeeds[is], muRef));
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
125  desc.setAllowAnything();
126 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TrackerSeedCleaner.h
edm::Run
Definition: Run.h:45
TSGFromL2Muon::theSeedCleaner
std::unique_ptr< TrackerSeedCleaner > theSeedCleaner
Definition: TSGFromL2Muon.h:38
TrackerTopology
Definition: TrackerTopology.h:16
TrackerSeedGeneratorFactory.h
TSGFromL2Muon::theService
std::unique_ptr< MuonServiceProxy > theService
Definition: TSGFromL2Muon.h:34
TrackerSeedGenerator.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TSGFromL2Muon::produce
void produce(edm::Event &ev, const edm::EventSetup &es) override
Definition: TSGFromL2Muon.cc:58
MuonTrackingRegionBuilder.h
TSGFromL2Muon::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TSGFromL2Muon.cc:123
edm::Handle< reco::TrackCollection >
edm::Ref< TrackCollection >
TSGFromL2Muon::theRegionBuilder
std::unique_ptr< MuonTrackingRegionBuilder > theRegionBuilder
Definition: TSGFromL2Muon.h:36
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
MuonServiceProxy::UseEventSetupIn::RunAndEvent
TSGFromL2Muon::thePCut
double thePCut
Definition: TSGFromL2Muon.h:35
edm::ESHandle< TrackerTopology >
TSGFromL2Muon.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
TSGFromL2Muon::theTkSeedGenerator
std::unique_ptr< TrackerSeedGenerator > theTkSeedGenerator
Definition: TSGFromL2Muon.h:37
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88267
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
TSGFromL2Muon::~TSGFromL2Muon
~TSGFromL2Muon() override
looper.cfg
cfg
Definition: looper.py:297
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TSGFromL2Muon::TSGFromL2Muon
TSGFromL2Muon(const edm::ParameterSet &cfg)
Definition: TSGFromL2Muon.cc:10
Trajectory
Definition: Trajectory.h:38
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
MuonServiceProxy.h
TSGFromL2Muon::theL2CollectionLabel
edm::InputTag theL2CollectionLabel
Definition: TSGFromL2Muon.h:33
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TSGFromL2Muon::thePtCut
double thePtCut
Definition: TSGFromL2Muon.h:35
mps_fire.result
result
Definition: mps_fire.py:311
ConsumesCollector.h
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
TSGFromL2Muon::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: TSGFromL2Muon.cc:49
edm::Event
Definition: Event.h:73
TSGFromL2Muon::l2muonToken
edm::EDGetTokenT< reco::TrackCollection > l2muonToken
Definition: TSGFromL2Muon.h:39
L3MuonTrajectorySeed
Definition: L3MuonTrajectorySeed.h:16
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
edm::ParameterSet::empty
bool empty() const
Definition: ParameterSet.h:201