CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static 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 ()
 
ModuleDescription const & moduleDescription () const
 
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 ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

std::string builderName
 
double originHalfLength
 
double originRadius
 
edm::ParameterSet theConfig
 
edm::EDGetTokenT
< reco::TrackCollection
theInputCollectionTag
 
edm::EDGetTokenT
< reco::VertexCollection
theInputVertexCollectionTag
 
bool useEventsWithNoVertex
 
bool useProtoTrackKinematics
 
bool usePV_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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 12 of file SeedGeneratorFromProtoTracksEDProducer.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file SeedGeneratorFromProtoTracksEDProducer.cc.

References builderName, edm::ParameterSet::getParameter(), originHalfLength, originRadius, AlCaHLTBitMon_QueryRunRegistry::string, theInputCollectionTag, theInputVertexCollectionTag, useEventsWithNoVertex, useProtoTrackKinematics, and usePV_.

50  :theConfig(cfg)
51 
52 {
53  produces<TrajectorySeedCollection>();
54  theInputCollectionTag = consumes<reco::TrackCollection>(cfg.getParameter<InputTag>("InputCollection"));
55  theInputVertexCollectionTag = consumes<reco::VertexCollection>(cfg.getParameter<InputTag>("InputVertexCollection"));
56  originHalfLength = cfg.getParameter<double>("originHalfLength");
57  originRadius = cfg.getParameter<double>("originRadius");
58  useProtoTrackKinematics = cfg.getParameter<bool>("useProtoTrackKinematics");
59  useEventsWithNoVertex = cfg.getParameter<bool>("useEventsWithNoVertex");
60  builderName = cfg.getParameter<std::string>("TTRHBuilder");
61  usePV_ = cfg.getParameter<bool>( "usePV" );
62 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > theInputVertexCollectionTag
edm::EDGetTokenT< reco::TrackCollection > theInputCollectionTag
virtual SeedGeneratorFromProtoTracksEDProducer::~SeedGeneratorFromProtoTracksEDProducer ( )
inlinevirtual

Definition at line 15 of file SeedGeneratorFromProtoTracksEDProducer.h.

15 {}

Member Function Documentation

void SeedGeneratorFromProtoTracksEDProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 36 of file SeedGeneratorFromProtoTracksEDProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

36  {
38  desc.add<InputTag>("InputCollection", InputTag("pixelTracks"));
39  desc.add<InputTag>("InputVertexCollection", InputTag(""));
40  desc.add<double>("originHalfLength", 1E9);
41  desc.add<double>("originRadius", 1E9);
42  desc.add<bool>("useProtoTrackKinematics", false);
43  desc.add<bool>("useEventsWithNoVertex", true);
44  desc.add<std::string>("TTRHBuilder", "TTRHBuilderWithoutAngle4PixelTriplets");
45  desc.add<bool>("usePV", false);
46  descriptions.add("SeedGeneratorFromProtoTracksEDProducer", desc);
47 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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 65 of file SeedGeneratorFromProtoTracksEDProducer.cc.

References builderName, edm::EventSetup::get(), edm::Event::getByToken(), 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, usePV_, and reco::TrackBase::vertex().

66 {
67  std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
70 
71  const TrackCollection &protos = *(trks.product());
72 
74  bool foundVertices = ev.getByToken(theInputVertexCollectionTag, vertices);
75  //const reco::VertexCollection & vertices = *(h_vertices.product());
76 
80  for (TrackCollection::const_iterator it=protos.begin(); it!= protos.end(); ++it) {
81  const Track & proto = (*it);
82  GlobalPoint vtx(proto.vertex().x(), proto.vertex().y(), proto.vertex().z());
83 
84  // check the compatibility with a primary vertex
85  bool keepTrack = false;
86  if ( (!foundVertices) || vertices->empty() ) {
87  if (useEventsWithNoVertex) keepTrack = true;
88  }
89  else if (usePV_){
90 
91  GlobalPoint aPV(vertices->begin()->position().x(),vertices->begin()->position().y(),vertices->begin()->position().z());
92  double distR2 = sqr(vtx.x()-aPV.x()) +sqr(vtx.y()-aPV.y());
93  double distZ = fabs(vtx.z()-aPV.z());
94  if ( distR2 < sqr(originRadius) && distZ < originHalfLength ) {
95  keepTrack = true;
96  }
97  }
98  else {
99  for (reco::VertexCollection::const_iterator iv=vertices->begin(); iv!= vertices->end(); ++iv) {
100  GlobalPoint aPV(iv->position().x(),iv->position().y(),iv->position().z());
101  double distR2 = sqr(vtx.x()-aPV.x()) +sqr(vtx.y()-aPV.y());
102  double distZ = fabs(vtx.z()-aPV.z());
103  if ( distR2 < sqr(originRadius) && distZ < originHalfLength ) {
104  keepTrack = true;
105  break;
106  }
107  }
108  }
109  if (!keepTrack) continue;
110 
111  if ( useProtoTrackKinematics ) {
112  SeedFromProtoTrack seedFromProtoTrack( proto, es);
113  if (seedFromProtoTrack.isValid()) (*result).push_back( seedFromProtoTrack.trajectorySeed() );
114  } else {
116  es.get<TransientRecHitRecord>().get(builderName,ttrhbESH);
117  std::vector<Hit> hits;
118  for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
119  TrackingRecHitRef refHit = proto.recHit(iHit);
120  if(refHit->isValid()) hits.push_back((Hit)&(*refHit));
121  }
122  sort(hits.begin(), hits.end(), HitLessByRadius());
123  assert(hits.size()<4);
124  if (hits.size() > 1) {
125  double mom_perp = sqrt(proto.momentum().x()*proto.momentum().x()+proto.momentum().y()*proto.momentum().y());
126  GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);
127  SeedFromConsecutiveHitsCreator seedCreator;
128  seedCreator.init(region, es, 0);
129  seedCreator.makeSeed(*result, SeedingHitSet(hits[0], hits[1], hits.size() >2 ? hits[2] : SeedingHitSet::nullPtr() ));
130  }
131  }
132  }
133 
134  ev.put(result);
135 }
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:148
edm::EDGetTokenT< reco::VertexCollection > theInputVertexCollectionTag
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void init(const TrackingRegion &region, const edm::EventSetup &es, const SeedComparitor *filter)
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
edm::EDGetTokenT< reco::TrackCollection > theInputCollectionTag
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
T sqrt(T t)
Definition: SSEVec.h:48
static ConstRecHitPointer nullPtr()
Definition: SeedingHitSet.h:13
tuple result
Definition: query.py:137
virtual void makeSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits)
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:154
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:81
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
double SeedGeneratorFromProtoTracksEDProducer::originHalfLength
private
double SeedGeneratorFromProtoTracksEDProducer::originRadius
private
edm::ParameterSet SeedGeneratorFromProtoTracksEDProducer::theConfig
private

Definition at line 20 of file SeedGeneratorFromProtoTracksEDProducer.h.

edm::EDGetTokenT<reco::TrackCollection> SeedGeneratorFromProtoTracksEDProducer::theInputCollectionTag
private
edm::EDGetTokenT<reco::VertexCollection> SeedGeneratorFromProtoTracksEDProducer::theInputVertexCollectionTag
private
bool SeedGeneratorFromProtoTracksEDProducer::useEventsWithNoVertex
private
bool SeedGeneratorFromProtoTracksEDProducer::useProtoTrackKinematics
private
bool SeedGeneratorFromProtoTracksEDProducer::usePV_
private