CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
SeedGeneratorFromProtoTracksEDProducer Class Reference

#include <SeedGeneratorFromProtoTracksEDProducer.h>

Inheritance diagram for SeedGeneratorFromProtoTracksEDProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 
 SeedGeneratorFromProtoTracksEDProducer (const edm::ParameterSet &cfg)
 
virtual ~SeedGeneratorFromProtoTracksEDProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

std::string builderName
 
double originHalfLength
 
double originRadius
 
edm::ParameterSet theConfig
 
edm::InputTag theInputCollectionTag
 
edm::InputTag theInputVertexCollectionTag
 
bool useEventsWithNoVertex
 
bool useProtoTrackKinematics
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 11 of file SeedGeneratorFromProtoTracksEDProducer.h.

Constructor & Destructor Documentation

SeedGeneratorFromProtoTracksEDProducer::SeedGeneratorFromProtoTracksEDProducer ( const edm::ParameterSet cfg)

Definition at line 35 of file SeedGeneratorFromProtoTracksEDProducer.cc.

36  : theConfig(cfg),
37  theInputCollectionTag(cfg.getParameter<InputTag>("InputCollection")),
38  theInputVertexCollectionTag(cfg.getParameter<InputTag>("InputVertexCollection")),
39  originHalfLength(cfg.getParameter<double>("originHalfLength")),
40  originRadius(cfg.getParameter<double>("originRadius")),
41  useProtoTrackKinematics(cfg.getParameter<bool>("useProtoTrackKinematics")),
42  useEventsWithNoVertex(cfg.getParameter<bool>("useEventsWithNoVertex")),
43  builderName(cfg.getParameter<std::string>("TTRHBuilder"))
44 
45 {
46  produces<TrajectorySeedCollection>();
47 }
T getParameter(std::string const &) const
virtual SeedGeneratorFromProtoTracksEDProducer::~SeedGeneratorFromProtoTracksEDProducer ( )
inlinevirtual

Definition at line 14 of file SeedGeneratorFromProtoTracksEDProducer.h.

14 {}

Member Function Documentation

void SeedGeneratorFromProtoTracksEDProducer::produce ( edm::Event ev,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 49 of file SeedGeneratorFromProtoTracksEDProducer.cc.

References builderName, edm::EventSetup::get(), edm::Event::getByLabel(), SeedFromProtoTrack::isValid(), reco::TrackBase::momentum(), SeedingHitSet::nullPtr(), originHalfLength, originRadius, edm::Handle< T >::product(), edm::Event::put(), reco::Track::recHit(), reco::Track::recHitsSize(), query::result, SeedFromConsecutiveHitsCreator_cfi::SeedFromConsecutiveHitsCreator, python.multivaluedict::sort(), funct::sqr(), mathSSE::sqrt(), theInputCollectionTag, theInputVertexCollectionTag, SeedFromProtoTrack::trajectorySeed(), useEventsWithNoVertex, useProtoTrackKinematics, and reco::TrackBase::vertex().

50 {
51  std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
54 
55  const TrackCollection &protos = *(trks.product());
56 
58  bool foundVertices = ev.getByLabel(theInputVertexCollectionTag, vertices);
59  //const reco::VertexCollection & vertices = *(h_vertices.product());
60 
61  for (TrackCollection::const_iterator it=protos.begin(); it!= protos.end(); ++it) {
62  const Track & proto = (*it);
63  GlobalPoint vtx(proto.vertex().x(), proto.vertex().y(), proto.vertex().z());
64 
65  // check the compatibility with a primary vertex
66  bool keepTrack = false;
67  if ( !foundVertices ) {
68  if (useEventsWithNoVertex) keepTrack = true;
69  } else {
70  for (reco::VertexCollection::const_iterator iv=vertices->begin(); iv!= vertices->end(); ++iv) {
71  GlobalPoint aPV(iv->position().x(),iv->position().y(),iv->position().z());
72  double distR2 = sqr(vtx.x()-aPV.x()) +sqr(vtx.y()-aPV.y());
73  double distZ = fabs(vtx.z()-aPV.z());
74  if ( distR2 < sqr(originRadius) && distZ < originHalfLength ) {
75  keepTrack = true;
76  break;
77  }
78  }
79  }
80  if (!keepTrack) continue;
81 
83  SeedFromProtoTrack seedFromProtoTrack( proto, es);
84  if (seedFromProtoTrack.isValid()) (*result).push_back( seedFromProtoTrack.trajectorySeed() );
85  } else {
87  es.get<TransientRecHitRecord>().get(builderName,ttrhbESH);
88  std::vector<Hit> hits;
89  for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
90  TrackingRecHitRef refHit = proto.recHit(iHit);
91  if(refHit->isValid()) hits.push_back(ttrhbESH->build( &(*refHit) ));
92  }
93  sort(hits.begin(), hits.end(), HitLessByRadius());
94  assert(hits.size()<4);
95  if (hits.size() > 1) {
96  double mom_perp = sqrt(proto.momentum().x()*proto.momentum().x()+proto.momentum().y()*proto.momentum().y());
97  GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);
98  SeedFromConsecutiveHitsCreator().trajectorySeed(*result, SeedingHitSet(hits[0], hits[1], hits.size() >2 ? hits[2] : SeedingHitSet::nullPtr() ), region, es, 0);
99  }
100  }
101  }
102 
103  ev.put(result);
104 }
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:150
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:69
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
T sqrt(T t)
Definition: SSEVec.h:46
static ConstRecHitPointer nullPtr()
Definition: SeedingHitSet.h:11
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:156
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

Member Data Documentation

std::string SeedGeneratorFromProtoTracksEDProducer::builderName
private

Definition at line 24 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

double SeedGeneratorFromProtoTracksEDProducer::originHalfLength
private

Definition at line 20 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

double SeedGeneratorFromProtoTracksEDProducer::originRadius
private

Definition at line 21 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

edm::ParameterSet SeedGeneratorFromProtoTracksEDProducer::theConfig
private

Definition at line 17 of file SeedGeneratorFromProtoTracksEDProducer.h.

edm::InputTag SeedGeneratorFromProtoTracksEDProducer::theInputCollectionTag
private

Definition at line 18 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

edm::InputTag SeedGeneratorFromProtoTracksEDProducer::theInputVertexCollectionTag
private

Definition at line 19 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

bool SeedGeneratorFromProtoTracksEDProducer::useEventsWithNoVertex
private

Definition at line 23 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

bool SeedGeneratorFromProtoTracksEDProducer::useProtoTrackKinematics
private

Definition at line 22 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().