CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
bool empty() const
Definition: ParameterSet.h:201
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > theTTopoToken
Definition: TSGFromL2Muon.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
tuple cfg
Definition: looper.py:296
void produce(edm::Event &ev, const edm::EventSetup &es) override
std::unique_ptr< TrackerSeedGenerator > theTkSeedGenerator
Definition: TSGFromL2Muon.h:38
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void setAllowAnything()
allow any parameter label/value pairs
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
bool ev
TSGFromL2Muon(const edm::ParameterSet &cfg)
edm::InputTag theL2CollectionLabel
Definition: TSGFromL2Muon.h:34
tuple result
Definition: mps_fire.py:311
bool getData(T &iHolder) const
Definition: EventSetup.h:128
std::unique_ptr< TrackerSeedCleaner > theSeedCleaner
Definition: TSGFromL2Muon.h:39
def move
Definition: eostools.py:511
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::unique_ptr< MuonServiceProxy > theService
Definition: TSGFromL2Muon.h:35
#define get
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Definition: Run.h:45
#define LogDebug(id)