CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SeedGeneratorFromProtoTracksEDProducer.cc
Go to the documentation of this file.
2 
5 
8 
16 
19 
20 
23 #include <vector>
24 
25 using namespace edm;
26 using namespace reco;
27 
28 template <class T> T sqr( T t) {return t*t;}
30 
31 struct HitLessByRadius { bool operator() (const Hit& h1, const Hit & h2) { return h1->globalPosition().perp2() < h2->globalPosition().perp2(); } };
32 
34  : theConfig(cfg), theInputCollectionTag(cfg.getParameter<InputTag>("InputCollection"))
35 {
36  produces<TrajectorySeedCollection>();
37 }
38 
40 {
41  std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
44 
45  const TrackCollection &protos = *(trks.product());
46 
47  for (TrackCollection::const_iterator it=protos.begin(); it!= protos.end(); ++it) {
48  const Track & proto = (*it);
49 
50  if (theConfig.getParameter<bool>("useProtoTrackKinematics")) {
51  SeedFromProtoTrack seedFromProtoTrack( proto, es);
52  if (seedFromProtoTrack.isValid()) (*result).push_back( seedFromProtoTrack.trajectorySeed() );
53  } else {
55  std::string builderName = theConfig.getParameter<std::string>("TTRHBuilder");
56  es.get<TransientRecHitRecord>().get(builderName,ttrhbESH);
57  std::vector<Hit> hits;
58  for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
59  TrackingRecHitRef refHit = proto.recHit(iHit);
60  if(refHit->isValid()) hits.push_back(ttrhbESH->build( &(*refHit) ));
61  sort(hits.begin(), hits.end(), HitLessByRadius());
62  }
63  if (hits.size() >= 2) {
64  GlobalPoint vtx(proto.vertex().x(), proto.vertex().y(), proto.vertex().z());
65  double mom_perp = sqrt(proto.momentum().x()*proto.momentum().x()+proto.momentum().y()*proto.momentum().y());
66  GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);
67  SeedFromConsecutiveHitsCreator().trajectorySeed(*result, SeedingHitSet(hits), region, es);
68  }
69  }
70  }
71 
72  ev.put(result);
73 }
74 
T getParameter(std::string const &) const
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:149
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:69
virtual void produce(edm::Event &ev, const edm::EventSetup &es)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
TrajectorySeed trajectorySeed() const
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
T sqrt(T t)
Definition: SSEVec.h:28
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:155
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
Square< F >::type sqr(const F &f)
Definition: Square.h:13
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:67
TransientTrackingRecHit::ConstRecHitPointer Hit