CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TSGFromL1Muon.cc
Go to the documentation of this file.
1 #include "TSGFromL1Muon.h"
2 
10 
13 
18 
23 
26 
29 
32 
35 
36 #include <vector>
37 
40 
41 using namespace reco;
42 using namespace ctfseeding;
43 using namespace l1extra;
44 
45 template <class T> T sqr( T t) {return t*t;}
46 
47 
49  : theConfig(cfg),theRegionProducer(0),theHitGenerator(0),theFitter(0),theMerger(0)
50 {
51  produces<L3MuonTrajectorySeedCollection>();
52  theSourceTag = cfg.getParameter<edm::InputTag>("L1MuonLabel");
53 
55  edm::ParameterSet filterPSet = theConfig.getParameter<edm::ParameterSet>("FilterPSet");
56  std::string filterName = filterPSet.getParameter<std::string>("ComponentName");
57  theFilter.reset(PixelTrackFilterFactory::get()->create( filterName, filterPSet, iC));
58 
59  edm::ParameterSet hitsfactoryPSet =
60  theConfig.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
61  std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
62  theHitGenerator = OrderedHitsGeneratorFactory::get()->create( hitsfactoryName, hitsfactoryPSet, iC);
63 
65 }
66 
68 {
69  delete theMerger;
70  delete theFitter;
71  delete theHitGenerator;
72  delete theRegionProducer;
73 }
74 
76 {
77  edm::ParameterSet regfactoryPSet = theConfig.getParameter<edm::ParameterSet>("RegionFactoryPSet");
78  std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
80  TrackingRegionProducerFactory::get()->create(regfactoryName,regfactoryPSet, consumesCollector());
81  theRegionProducer = dynamic_cast<L1MuonRegionProducer* >(p);
82 
83  edm::ParameterSet fitterPSet = theConfig.getParameter<edm::ParameterSet>("FitterPSet");
84  std::string fitterName = fitterPSet.getParameter<std::string>("ComponentName");
85  PixelFitter * f = PixelFitterFactory::get()->create( fitterName, fitterPSet);
86  theFitter = dynamic_cast<L1MuonPixelTrackFitter* >(f);
87 
88  edm::ParameterSet cleanerPSet = theConfig.getParameter<edm::ParameterSet>("CleanerPSet");
89  std::string cleanerName = cleanerPSet.getParameter<std::string>("ComponentName");
90 // theMerger = PixelTrackCleanerFactory::get()->create( cleanerName, cleanerPSet);
91  theMerger = new L1MuonSeedsMerger(cleanerPSet);
92 }
93 
94 
96 {
97  std::auto_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
98 
100  ev.getByToken(theSourceToken, l1muon);
101 
102  LogDebug("TSGFromL1Muon")<<l1muon->size()<<" l1 muons to seed from.";
103 
104  L1MuonParticleCollection::const_iterator muItr = l1muon->begin();
105  L1MuonParticleCollection::const_iterator muEnd = l1muon->end();
106  for ( size_t iL1 = 0; muItr < muEnd; ++muItr, ++iL1) {
107 
108  if (muItr->gmtMuonCand().empty()) continue;
109 
110  const L1MuGMTCand & muon = muItr->gmtMuonCand();
111  l1extra::L1MuonParticleRef l1Ref(l1muon, iL1);
112 
114  theFitter->setL1Constraint(muon);
115 
116  typedef std::vector<TrackingRegion * > Regions;
117  Regions regions = theRegionProducer->regions(ev,es);
118  for (Regions::const_iterator ir=regions.begin(); ir != regions.end(); ++ir) {
119 
121  const TrackingRegion & region = **ir;
122  const OrderedSeedingHits & candidates = theHitGenerator->run(region,ev,es);
123 
124  unsigned int nSets = candidates.size();
125  for (unsigned int ic= 0; ic <nSets; ic++) {
126 
127  const SeedingHitSet & hits = candidates[ic];
128  std::vector<const TrackingRecHit *> trh;
129  for (unsigned int i= 0, nHits = hits.size(); i< nHits; ++i) trh.push_back( hits[i]->hit() );
130 
131  theFitter->setPxConstraint(hits);
132  reco::Track* track = theFitter->run(es, trh, region);
133  if (!track) continue;
134 
135  if (!(*theFilter)(track) ) { delete track; continue; }
136  tracks.push_back(L1MuonSeedsMerger::TrackAndHits(track, hits));
137  }
138 
139  if(theMerger) theMerger->resolve(tracks);
140  for (L1MuonSeedsMerger::TracksAndHits::const_iterator it = tracks.begin();
141  it != tracks.end(); ++it) {
142 
143  SeedFromProtoTrack seed( *(it->first), it->second, es);
144  if (seed.isValid()) (*result).push_back(L3MuonTrajectorySeed(seed.trajectorySeed(),l1Ref));
145 
146 // GlobalError vtxerr( sqr(region->originRBound()), 0, sqr(region->originRBound()),
147 // 0, 0, sqr(region->originZBound()));
148 // SeedFromConsecutiveHits seed( candidates[ic],region->origin(), vtxerr, es);
149 // if (seed.isValid()) (*result).push_back( seed.TrajSeed() );
150  delete it->first;
151  }
152  }
153  for (Regions::const_iterator it=regions.begin(); it != regions.end(); ++it) delete (*it);
154  }
155 
156  LogDebug("TSGFromL1Muon")<<result->size()<<" seeds to the event.";
157  ev.put(result);
158 }
159 
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::ParameterSet theConfig
Definition: TSGFromL1Muon.h:33
TSGFromL1Muon(const edm::ParameterSet &cfg)
void setPxConstraint(const SeedingHitSet &hits)
virtual std::vector< TrackingRegion * > regions(const edm::Event &ev, const edm::EventSetup &es) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
L1MuonRegionProducer * theRegionProducer
Definition: TSGFromL1Muon.h:37
std::vector< L3MuonTrajectorySeed > L3MuonTrajectorySeedCollection
std::pair< const reco::Track *, SeedingHitSet > TrackAndHits
virtual void produce(edm::Event &ev, const edm::EventSetup &es) override
bool ev
virtual unsigned int size() const =0
virtual ~TSGFromL1Muon()
OrderedHitsGenerator * theHitGenerator
Definition: TSGFromL1Muon.h:38
L1MuonPixelTrackFitter * theFitter
Definition: TSGFromL1Muon.h:39
TrajectorySeed trajectorySeed() const
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::InputTag theSourceTag
Definition: TSGFromL1Muon.h:34
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::unique_ptr< PixelTrackFilter > theFilter
Definition: TSGFromL1Muon.h:40
virtual reco::Track * run(const edm::EventSetup &es, const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region) const
tuple result
Definition: query.py:137
virtual void resolve(TracksAndHits &) const
double f[11][100]
virtual void beginRun(const edm::Run &run, const edm::EventSetup &es) override
tuple tracks
Definition: testEve_cfg.py:39
edm::EDGetTokenT< l1extra::L1MuonParticleCollection > theSourceToken
Definition: TSGFromL1Muon.h:35
Square< F >::type sqr(const F &f)
Definition: Square.h:13
unsigned int size() const
Definition: SeedingHitSet.h:44
void setL1Constraint(const L1MuGMTCand &muon)
void setL1Constraint(const L1MuGMTCand &muon)
long double T
SurfaceDeformation * create(int type, const std::vector< double > &params)
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:41