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 
34 
35 #include <vector>
36 
41 
42 using namespace reco;
43 using namespace ctfseeding;
44 using namespace l1extra;
45 
46 template <class T> T sqr( T t) {return t*t;}
47 
48 
50  : theConfig(cfg),theRegionProducer(0),theHitGenerator(0),theFitter(0),theFilter(0),theMerger(0)
51 {
52  produces<L3MuonTrajectorySeedCollection>();
53  theSourceTag = cfg.getParameter<edm::InputTag>("L1MuonLabel");
54 }
55 
57 {
58  delete theMerger;
59  delete theFilter;
60  delete theFitter;
61  delete theHitGenerator;
62  delete theRegionProducer;
63 }
64 
66 {
67  edm::ParameterSet regfactoryPSet = theConfig.getParameter<edm::ParameterSet>("RegionFactoryPSet");
68  std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
70  TrackingRegionProducerFactory::get()->create(regfactoryName,regfactoryPSet);
71  theRegionProducer = dynamic_cast<L1MuonRegionProducer* >(p);
72 
73  edm::ParameterSet hitsfactoryPSet =
74  theConfig.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
75  std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
76  theHitGenerator = OrderedHitsGeneratorFactory::get()->create( hitsfactoryName, hitsfactoryPSet);
77 
78  edm::ParameterSet fitterPSet = theConfig.getParameter<edm::ParameterSet>("FitterPSet");
79  std::string fitterName = fitterPSet.getParameter<std::string>("ComponentName");
80  PixelFitter * f = PixelFitterFactory::get()->create( fitterName, fitterPSet);
81  theFitter = dynamic_cast<L1MuonPixelTrackFitter* >(f);
82 
83  edm::ParameterSet filterPSet = theConfig.getParameter<edm::ParameterSet>("FilterPSet");
84  std::string filterName = filterPSet.getParameter<std::string>("ComponentName");
85  theFilter = PixelTrackFilterFactory::get()->create( filterName, filterPSet);
86 
87  edm::ParameterSet cleanerPSet = theConfig.getParameter<edm::ParameterSet>("CleanerPSet");
88  std::string cleanerName = cleanerPSet.getParameter<std::string>("ComponentName");
89 // theMerger = PixelTrackCleanerFactory::get()->create( cleanerName, cleanerPSet);
90  theMerger = new L1MuonSeedsMerger(cleanerPSet);
91 }
92 
93 
95 {
96  std::auto_ptr<L3MuonTrajectorySeedCollection> result(new L3MuonTrajectorySeedCollection());
97 
99  ev.getByLabel(theSourceTag, l1muon);
100 
101  LogDebug("TSGFromL1Muon")<<l1muon->size()<<" l1 muons to seed from.";
102 
103  L1MuonParticleCollection::const_iterator muItr = l1muon->begin();
104  L1MuonParticleCollection::const_iterator muEnd = l1muon->end();
105  for ( size_t iL1 = 0; muItr < muEnd; ++muItr, ++iL1) {
106 
107  if (muItr->gmtMuonCand().empty()) continue;
108 
109  const L1MuGMTCand & muon = muItr->gmtMuonCand();
110  l1extra::L1MuonParticleRef l1Ref(l1muon, iL1);
111 
113  theFitter->setL1Constraint(muon);
114 
115  typedef std::vector<TrackingRegion * > Regions;
116  Regions regions = theRegionProducer->regions(ev,es);
117  for (Regions::const_iterator ir=regions.begin(); ir != regions.end(); ++ir) {
118 
120  const TrackingRegion & region = **ir;
121  const OrderedSeedingHits & candidates = theHitGenerator->run(region,ev,es);
122 
123  unsigned int nSets = candidates.size();
124  for (unsigned int ic= 0; ic <nSets; ic++) {
125 
126  const SeedingHitSet & hits = candidates[ic];
127  std::vector<const TrackingRecHit *> trh;
128  for (unsigned int i= 0, nHits = hits.size(); i< nHits; ++i) trh.push_back( hits[i]->hit() );
129 
130  theFitter->setPxConstraint(hits);
131  reco::Track* track = theFitter->run(es, trh, region);
132  if (!track) continue;
133 
134  if (!(*theFilter)(track) ) { delete track; continue; }
135  tracks.push_back(L1MuonSeedsMerger::TrackAndHits(track, hits));
136  }
137 
138  if(theMerger) theMerger->resolve(tracks);
139  for (L1MuonSeedsMerger::TracksAndHits::const_iterator it = tracks.begin();
140  it != tracks.end(); ++it) {
141 
142  SeedFromProtoTrack seed( *(it->first), it->second, es);
143  if (seed.isValid()) (*result).push_back(L3MuonTrajectorySeed(seed.trajectorySeed(),l1Ref));
144 
145 // GlobalError vtxerr( sqr(region->originRBound()), 0, sqr(region->originRBound()),
146 // 0, 0, sqr(region->originZBound()));
147 // SeedFromConsecutiveHits seed( candidates[ic],region->origin(), vtxerr, es);
148 // if (seed.isValid()) (*result).push_back( seed.TrajSeed() );
149  delete it->first;
150  }
151  }
152  for (Regions::const_iterator it=regions.begin(); it != regions.end(); ++it) delete (*it);
153  }
154 
155  LogDebug("TSGFromL1Muon")<<result->size()<<" seeds to the event.";
156  ev.put(result);
157 }
158 
#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:84
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:359
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:14
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)
T get(const Candidate &c)
Definition: component.h:56
Definition: Run.h:31