CMS 3D CMS Logo

TSGFromL1Muon.cc
Go to the documentation of this file.
1 #include "TSGFromL1Muon.h"
2 
10 
13 
16 
18 
20 
23 
26 
27 #include <vector>
28 
31 
32 using namespace reco;
33 using namespace l1extra;
34 
35 template <class T> T sqr( T t) {return t*t;}
36 
37 
39  : theConfig(cfg),theHitGenerator(nullptr),theMerger(nullptr)
40 {
41  produces<L3MuonTrajectorySeedCollection>();
42  theSourceTag = cfg.getParameter<edm::InputTag>("L1MuonLabel");
43 
44  edm::ConsumesCollector iC = consumesCollector();
45  theFilterToken = consumes<PixelTrackFilter>(cfg.getParameter<edm::InputTag>("Filter"));
46 
47  edm::ParameterSet hitsfactoryPSet =
48  theConfig.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
49  std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
50  theHitGenerator = OrderedHitsGeneratorFactory::get()->create( hitsfactoryName, hitsfactoryPSet, iC);
51 
53 
54  theRegionProducer = std::make_unique<L1MuonRegionProducer>(theConfig.getParameter<edm::ParameterSet>("RegionFactoryPSet"));
55  theFitter = std::make_unique<L1MuonPixelTrackFitter>(cfg.getParameter<edm::ParameterSet>("FitterPSet"));
56 }
57 
59 {
60  delete theMerger;
61  delete theHitGenerator;
62 }
63 
65 {
66  edm::ParameterSet cleanerPSet = theConfig.getParameter<edm::ParameterSet>("CleanerPSet");
67  theMerger = new L1MuonSeedsMerger(cleanerPSet);
68 }
69 
70 
72 {
73  auto result = std::make_unique<L3MuonTrajectorySeedCollection>();
74 
76  ev.getByToken(theSourceToken, l1muon);
77 
79  ev.getByToken(theFilterToken, hfilter);
80  const PixelTrackFilter& filter = *hfilter;
81 
82  LogDebug("TSGFromL1Muon")<<l1muon->size()<<" l1 muons to seed from.";
83 
84  L1MuonParticleCollection::const_iterator muItr = l1muon->begin();
85  L1MuonParticleCollection::const_iterator muEnd = l1muon->end();
86  for ( size_t iL1 = 0; muItr < muEnd; ++muItr, ++iL1) {
87 
88  if (muItr->gmtMuonCand().empty()) continue;
89 
90  const L1MuGMTCand & muon = muItr->gmtMuonCand();
91  l1extra::L1MuonParticleRef l1Ref(l1muon, iL1);
92 
93  theRegionProducer->setL1Constraint(muon);
94  theFitter->setL1Constraint(muon);
95 
96  typedef std::vector<std::unique_ptr<TrackingRegion> > Regions;
97  Regions regions = theRegionProducer->regions();
98  for (Regions::const_iterator ir=regions.begin(); ir != regions.end(); ++ir) {
99 
101  const TrackingRegion & region = **ir;
102  const OrderedSeedingHits & candidates = theHitGenerator->run(region,ev,es);
103 
104  unsigned int nSets = candidates.size();
105  for (unsigned int ic= 0; ic <nSets; ic++) {
106 
107  const SeedingHitSet & hits = candidates[ic];
108  std::vector<const TrackingRecHit *> trh;
109  for (unsigned int i= 0, nHits = hits.size(); i< nHits; ++i) trh.push_back( hits[i]->hit() );
110 
111  theFitter->setPxConstraint(hits);
112  reco::Track* track = theFitter->run(es, trh, region);
113  if (!track) continue;
114 
115  if (!filter(track, trh) ) { delete track; continue; }
116  tracks.push_back(L1MuonSeedsMerger::TrackAndHits(track, hits));
117  }
118 
119  if(theMerger) theMerger->resolve(tracks);
120  for (L1MuonSeedsMerger::TracksAndHits::const_iterator it = tracks.begin();
121  it != tracks.end(); ++it) {
122 
123  SeedFromProtoTrack seed( *(it->first), it->second, es);
124  if (seed.isValid()) (*result).push_back(L3MuonTrajectorySeed(seed.trajectorySeed(),l1Ref));
125 
126 // GlobalError vtxerr( sqr(region->originRBound()), 0, sqr(region->originRBound()),
127 // 0, 0, sqr(region->originZBound()));
128 // SeedFromConsecutiveHits seed( candidates[ic],region->origin(), vtxerr, es);
129 // if (seed.isValid()) (*result).push_back( seed.TrajSeed() );
130  delete it->first;
131  }
132  }
133  }
134 
135  LogDebug("TSGFromL1Muon")<<result->size()<<" seeds to the event.";
136  ev.put(std::move(result));
137 }
138 
#define LogDebug(id)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
edm::ParameterSet theConfig
Definition: TSGFromL1Muon.h:33
TSGFromL1Muon(const edm::ParameterSet &cfg)
~TSGFromL1Muon() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::pair< const reco::Track *, SeedingHitSet > TrackAndHits
void produce(edm::Event &ev, const edm::EventSetup &es) override
T sqr(T t)
bool ev
std::unique_ptr< L1MuonPixelTrackFitter > theFitter
Definition: TSGFromL1Muon.h:40
#define nullptr
OrderedHitsGenerator * theHitGenerator
Definition: TSGFromL1Muon.h:39
TrajectorySeed trajectorySeed() const
std::unique_ptr< L1MuonRegionProducer > theRegionProducer
Definition: TSGFromL1Muon.h:38
edm::EDGetTokenT< PixelTrackFilter > theFilterToken
Definition: TSGFromL1Muon.h:36
virtual const OrderedSeedingHits & run(const TrackingRegion &reg, const edm::Event &ev, const edm::EventSetup &es)=0
std::vector< TrackAndHits > TracksAndHits
L1MuonSeedsMerger * theMerger
Definition: TSGFromL1Muon.h:41
edm::InputTag theSourceTag
Definition: TSGFromL1Muon.h:34
virtual void resolve(TracksAndHits &) const
virtual unsigned int size() const =0
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
edm::EDGetTokenT< l1extra::L1MuonParticleCollection > theSourceToken
Definition: TSGFromL1Muon.h:35
fixed size matrix
unsigned int size() const
Definition: SeedingHitSet.h:46
long double T
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:44