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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &ev, const edm::EventSetup &es) override
 
 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 &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 
)
overridevirtual

need optimization: all es stuff should go out of the loop

Implements edm::EDProducer.

Definition at line 49 of file SeedGeneratorFromProtoTracksEDProducer.cc.

References builderName, edm::EventSetup::get(), edm::Event::getByLabel(), SeedFromConsecutiveHitsCreator::init(), SeedFromProtoTrack::isValid(), SeedFromConsecutiveHitsCreator::makeSeed(), reco::TrackBase::momentum(), SeedingHitSet::nullPtr(), originHalfLength, originRadius, edm::Handle< T >::product(), edm::Event::put(), reco::Track::recHit(), reco::Track::recHitsSize(), query::result, 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 
64  for (TrackCollection::const_iterator it=protos.begin(); it!= protos.end(); ++it) {
65  const Track & proto = (*it);
66  GlobalPoint vtx(proto.vertex().x(), proto.vertex().y(), proto.vertex().z());
67 
68  // check the compatibility with a primary vertex
69  bool keepTrack = false;
70  if ( !foundVertices ) {
71  if (useEventsWithNoVertex) keepTrack = true;
72  } else {
73  for (reco::VertexCollection::const_iterator iv=vertices->begin(); iv!= vertices->end(); ++iv) {
74  GlobalPoint aPV(iv->position().x(),iv->position().y(),iv->position().z());
75  double distR2 = sqr(vtx.x()-aPV.x()) +sqr(vtx.y()-aPV.y());
76  double distZ = fabs(vtx.z()-aPV.z());
77  if ( distR2 < sqr(originRadius) && distZ < originHalfLength ) {
78  keepTrack = true;
79  break;
80  }
81  }
82  }
83  if (!keepTrack) continue;
84 
86  SeedFromProtoTrack seedFromProtoTrack( proto, es);
87  if (seedFromProtoTrack.isValid()) (*result).push_back( seedFromProtoTrack.trajectorySeed() );
88  } else {
90  es.get<TransientRecHitRecord>().get(builderName,ttrhbESH);
91  std::vector<Hit> hits;
92  for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
93  TrackingRecHitRef refHit = proto.recHit(iHit);
94  if(refHit->isValid()) hits.push_back(ttrhbESH->build( &(*refHit) ));
95  }
96  sort(hits.begin(), hits.end(), HitLessByRadius());
97  assert(hits.size()<4);
98  if (hits.size() > 1) {
99  double mom_perp = sqrt(proto.momentum().x()*proto.momentum().x()+proto.momentum().y()*proto.momentum().y());
100  GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);
101  SeedFromConsecutiveHitsCreator seedCreator;
102  seedCreator.init(region, es, 0);
103  seedCreator.makeSeed(*result, SeedingHitSet(hits[0], hits[1], hits.size() >2 ? hits[2] : SeedingHitSet::nullPtr() ));
104  }
105  }
106  }
107 
108  ev.put(result);
109 }
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:94
T sqrt(T t)
Definition: SSEVec.h:48
virtual void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter) GCC11_FINAL
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:361
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
virtual void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits) GCC11_FINAL

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().