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 
8 
11 
16 
21 
24 
27 
30 
33 
34 #include <vector>
35 
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),theFilter(0),theMerger(0)
50 {
51  produces<L3MuonTrajectorySeedCollection>();
52  theSourceTag = cfg.getParameter<edm::InputTag>("L1MuonLabel");
53 }
54 
56 {
57  delete theMerger;
58  delete theFilter;
59  delete theFitter;
60  delete theHitGenerator;
61  delete theRegionProducer;
62 }
63 
65 {
66  edm::ParameterSet regfactoryPSet = theConfig.getParameter<edm::ParameterSet>("RegionFactoryPSet");
67  std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
69  TrackingRegionProducerFactory::get()->create(regfactoryName,regfactoryPSet);
70  theRegionProducer = dynamic_cast<L1MuonRegionProducer* >(p);
71 
72  edm::ParameterSet hitsfactoryPSet =
73  theConfig.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
74  std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
75  theHitGenerator = OrderedHitsGeneratorFactory::get()->create( hitsfactoryName, hitsfactoryPSet);
76 
77  edm::ParameterSet fitterPSet = theConfig.getParameter<edm::ParameterSet>("FitterPSet");
78  std::string fitterName = fitterPSet.getParameter<std::string>("ComponentName");
79  PixelFitter * f = PixelFitterFactory::get()->create( fitterName, fitterPSet);
80  theFitter = dynamic_cast<L1MuonPixelTrackFitter* >(f);
81 
82  edm::ParameterSet filterPSet = theConfig.getParameter<edm::ParameterSet>("FilterPSet");
83  std::string filterName = filterPSet.getParameter<std::string>("ComponentName");
84  theFilter = PixelTrackFilterFactory::get()->create( filterName, filterPSet);
85 
86  edm::ParameterSet cleanerPSet = theConfig.getParameter<edm::ParameterSet>("CleanerPSet");
87  std::string cleanerName = cleanerPSet.getParameter<std::string>("ComponentName");
88 // theMerger = PixelTrackCleanerFactory::get()->create( cleanerName, cleanerPSet);
89  theMerger = new L1MuonSeedsMerger(cleanerPSet);
90 }
91 
92 
94 {
95  std::auto_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
96 
98  ev.getByLabel(theSourceTag, l1muon);
99 
100  LogDebug("TSGFromL1Muon")<<l1muon->size()<<" l1 muons to seed from.";
101 
102  L1MuonParticleCollection::const_iterator muItr = l1muon->begin();
103  L1MuonParticleCollection::const_iterator muEnd = l1muon->end();
104  for ( size_t iL1 = 0; muItr < muEnd; ++muItr, ++iL1) {
105 
106  if (muItr->gmtMuonCand().empty()) continue;
107 
108  const L1MuGMTCand & muon = muItr->gmtMuonCand();
109  l1extra::L1MuonParticleRef l1Ref(l1muon, iL1);
110 
112  theFitter->setL1Constraint(muon);
113 
114  typedef std::vector<TrackingRegion * > Regions;
115  Regions regions = theRegionProducer->regions(ev,es);
116  for (Regions::const_iterator ir=regions.begin(); ir != regions.end(); ++ir) {
117 
119  const TrackingRegion & region = **ir;
120  const OrderedSeedingHits & candidates = theHitGenerator->run(region,ev,es);
121 
122  unsigned int nSets = candidates.size();
123  for (unsigned int ic= 0; ic <nSets; ic++) {
124 
125  const SeedingHitSet & hits = candidates[ic];
126  std::vector<const TrackingRecHit *> trh;
127  for (unsigned int i= 0, nHits = hits.size(); i< nHits; ++i) trh.push_back( hits[i]->hit() );
128 
129  theFitter->setPxConstraint(hits);
130  reco::Track* track = theFitter->run(es, trh, region);
131  if (!track) continue;
132 
133  if (!(*theFilter)(track) ) { delete track; continue; }
134  tracks.push_back(L1MuonSeedsMerger::TrackAndHits(track, hits));
135  }
136 
137  if(theMerger) theMerger->resolve(tracks);
138  for (L1MuonSeedsMerger::TracksAndHits::const_iterator it = tracks.begin();
139  it != tracks.end(); ++it) {
140 
141  SeedFromProtoTrack seed( *(it->first), it->second, es);
142  if (seed.isValid()) (*result).push_back(L3MuonTrajectorySeed(seed.trajectorySeed(),l1Ref));
143 
144 // GlobalError vtxerr( sqr(region->originRBound()), 0, sqr(region->originRBound()),
145 // 0, 0, sqr(region->originZBound()));
146 // SeedFromConsecutiveHits seed( candidates[ic],region->origin(), vtxerr, es);
147 // if (seed.isValid()) (*result).push_back( seed.TrajSeed() );
148  delete it->first;
149  }
150  }
151  for (Regions::const_iterator it=regions.begin(); it != regions.end(); ++it) delete (*it);
152  }
153 
154  LogDebug("TSGFromL1Muon")<<result->size()<<" seeds to the event.";
155  ev.put(result);
156 }
157 
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::ParameterSet theConfig
Definition: TSGFromL1Muon.h:31
TSGFromL1Muon(const edm::ParameterSet &cfg)
void setPxConstraint(const SeedingHitSet &hits)
virtual std::vector< TrackingRegion * > regions(const edm::Event &ev, const edm::EventSetup &es) const
PixelTrackFilter * theFilter
Definition: TSGFromL1Muon.h:38
L1MuonRegionProducer * theRegionProducer
Definition: TSGFromL1Muon.h:35
std::vector< L3MuonTrajectorySeed > L3MuonTrajectorySeedCollection
std::pair< const reco::Track *, SeedingHitSet > TrackAndHits
virtual unsigned int size() const =0
virtual ~TSGFromL1Muon()
OrderedHitsGenerator * theHitGenerator
Definition: TSGFromL1Muon.h:36
L1MuonPixelTrackFitter * theFitter
Definition: TSGFromL1Muon.h:37
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:39
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
edm::InputTag theSourceTag
Definition: TSGFromL1Muon.h:32
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]
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
tuple tracks
Definition: testEve_cfg.py:39
Square< F >::type sqr(const F &f)
Definition: Square.h:13
unsigned int size() const
Definition: SeedingHitSet.h:31
void setL1Constraint(const L1MuGMTCand &muon)
virtual void beginRun(edm::Run &run, const edm::EventSetup &es)
virtual void produce(edm::Event &ev, const edm::EventSetup &es)
void setL1Constraint(const L1MuGMTCand &muon)
long double T
T get(const Candidate &c)
Definition: component.h:56
Definition: Run.h:33