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