CMS 3D CMS Logo

TSGFromL1Muon.cc
Go to the documentation of this file.
1 #include "TSGFromL1Muon.h"
2 
10 
13 
16 
18 
20 
22 
25 
27 
28 #include <vector>
29 
32 
33 using namespace reco;
34 using namespace l1extra;
35 
36 namespace {
37  template <class T>
38  T sqr(T t) {
39  return t * t;
40  }
41 } // namespace
42 
44  : theFieldToken(esConsumes()), theSFPTConfig(consumesCollector()) {
45  produces<L3MuonTrajectorySeedCollection>();
46  theSourceTag = cfg.getParameter<edm::InputTag>("L1MuonLabel");
47 
48  edm::ConsumesCollector iC = consumesCollector();
49  theFilterToken = consumes<PixelTrackFilter>(cfg.getParameter<edm::InputTag>("Filter"));
50 
51  edm::ParameterSet hitsfactoryPSet = cfg.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
52  std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
53  theHitGenerator = OrderedHitsGeneratorFactory::get()->create(hitsfactoryName, hitsfactoryPSet, iC);
54 
56 
58  std::make_unique<L1MuonRegionProducer>(cfg.getParameter<edm::ParameterSet>("RegionFactoryPSet"), iC);
59  theFitter = std::make_unique<L1MuonPixelTrackFitter>(cfg.getParameter<edm::ParameterSet>("FitterPSet"));
60 
61  edm::ParameterSet cleanerPSet = cfg.getParameter<edm::ParameterSet>("CleanerPSet");
62  theMerger = std::make_unique<L1MuonSeedsMerger>(cleanerPSet);
63 }
64 
66 
68  auto result = std::make_unique<L3MuonTrajectorySeedCollection>();
69 
71  ev.getByToken(theSourceToken, l1muon);
72 
74  ev.getByToken(theFilterToken, hfilter);
75  const PixelTrackFilter& filter = *hfilter;
76 
77  const auto& field = es.getData(theFieldToken);
78  LogDebug("TSGFromL1Muon") << l1muon->size() << " l1 muons to seed from.";
79 
80  L1MuonParticleCollection::const_iterator muItr = l1muon->begin();
81  L1MuonParticleCollection::const_iterator muEnd = l1muon->end();
82  for (size_t iL1 = 0; muItr < muEnd; ++muItr, ++iL1) {
83  if (muItr->gmtMuonCand().empty())
84  continue;
85 
86  const L1MuGMTCand& muon = muItr->gmtMuonCand();
87  l1extra::L1MuonParticleRef l1Ref(l1muon, iL1);
88 
89  theRegionProducer->setL1Constraint(muon);
90  theFitter->setL1Constraint(muon);
91 
92  typedef std::vector<std::unique_ptr<TrackingRegion> > Regions;
93  Regions regions = theRegionProducer->regions(es);
94  for (Regions::const_iterator ir = regions.begin(); ir != regions.end(); ++ir) {
96  const TrackingRegion& region = **ir;
98 
99  unsigned int nSets = candidates.size();
100  for (unsigned int ic = 0; ic < nSets; ic++) {
101  const SeedingHitSet& hits = candidates[ic];
102  std::vector<const TrackingRecHit*> trh;
103  for (unsigned int i = 0, nHits = hits.size(); i < nHits; ++i)
104  trh.push_back(hits[i]->hit());
105 
106  theFitter->setPxConstraint(hits);
107  reco::Track* track = theFitter->run(field, trh, region);
108  if (!track)
109  continue;
110 
111  if (!filter(track, trh)) {
112  delete track;
113  continue;
114  }
116  }
117 
118  if (theMerger)
119  theMerger->resolve(tracks);
120  for (L1MuonSeedsMerger::TracksAndHits::const_iterator it = tracks.begin(); it != tracks.end(); ++it) {
121  SeedFromProtoTrack seed(theSFPTConfig, *(it->first), it->second, es);
122  if (seed.isValid())
123  (*result).push_back(L3MuonTrajectorySeed(seed.trajectorySeed(), l1Ref));
124 
125  // GlobalError vtxerr( sqr(region->originRBound()), 0, sqr(region->originRBound()),
126  // 0, 0, sqr(region->originZBound()));
127  // SeedFromConsecutiveHits seed( candidates[ic],region->origin(), vtxerr, es);
128  // if (seed.isValid()) (*result).push_back( seed.TrajSeed() );
129  delete it->first;
130  }
131  }
132  }
133 
134  LogDebug("TSGFromL1Muon") << result->size() << " seeds to the event.";
135  ev.put(std::move(result));
136 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TSGFromL1Muon(const edm::ParameterSet &cfg)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
~TSGFromL1Muon() override
void produce(edm::Event &ev, const edm::EventSetup &es) override
std::unique_ptr< L1MuonPixelTrackFitter > theFitter
Definition: TSGFromL1Muon.h:44
std::unique_ptr< L1MuonRegionProducer > theRegionProducer
Definition: TSGFromL1Muon.h:42
edm::EDGetTokenT< PixelTrackFilter > theFilterToken
Definition: TSGFromL1Muon.h:38
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theFieldToken
Definition: TSGFromL1Muon.h:39
std::vector< TrackAndHits > TracksAndHits
edm::InputTag theSourceTag
Definition: TSGFromL1Muon.h:36
std::unique_ptr< OrderedHitsGenerator > theHitGenerator
Definition: TSGFromL1Muon.h:43
std::pair< const reco::Track *, SeedingHitSet > TrackAndHits
edm::EDGetTokenT< l1extra::L1MuonParticleCollection > theSourceToken
Definition: TSGFromL1Muon.h:37
fixed size matrix
std::unique_ptr< L1MuonSeedsMerger > theMerger
Definition: TSGFromL1Muon.h:45
Square< F >::type sqr(const F &f)
Definition: Square.h:14
const SeedFromProtoTrack::Config theSFPTConfig
Definition: TSGFromL1Muon.h:40
#define get
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
long double T
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)