CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
SeedGeneratorFromProtoTracksEDProducer Class Reference

#include <SeedGeneratorFromProtoTracksEDProducer.h>

Inheritance diagram for SeedGeneratorFromProtoTracksEDProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase 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::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

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

Private Attributes

const std::string builderName
 
const double originHalfLength
 
const double originRadius
 
const edm::ParameterSet theConfig
 
const edm::EDGetTokenT< reco::TrackCollectiontheInputCollectionTag
 
const edm::EDGetTokenT< reco::VertexCollectiontheInputVertexCollectionTag
 
const bool useEventsWithNoVertex
 
const bool useProtoTrackKinematics
 
const bool usePV_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 62 of file SeedGeneratorFromProtoTracksEDProducer.cc.

63  : theConfig(cfg)
64  , originHalfLength ( cfg.getParameter<double>("originHalfLength") )
65  , originRadius ( cfg.getParameter<double>("originRadius") )
66  , useProtoTrackKinematics ( cfg.getParameter<bool>("useProtoTrackKinematics") )
67  , useEventsWithNoVertex ( cfg.getParameter<bool>("useEventsWithNoVertex") )
68  , builderName ( cfg.getParameter<std::string>("TTRHBuilder") )
69  , usePV_ ( cfg.getParameter<bool>( "usePV" ) )
70  , theInputCollectionTag ( consumes<reco::TrackCollection> (cfg.getParameter<InputTag>("InputCollection")) )
71  , theInputVertexCollectionTag ( consumes<reco::VertexCollection>(cfg.getParameter<InputTag>("InputVertexCollection")) )
72 {
73  produces<TrajectorySeedCollection>();
74 
75 
76 
77 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::TrackCollection > theInputCollectionTag
const edm::EDGetTokenT< reco::VertexCollection > theInputVertexCollectionTag
virtual SeedGeneratorFromProtoTracksEDProducer::~SeedGeneratorFromProtoTracksEDProducer ( )
inlinevirtual

Definition at line 15 of file SeedGeneratorFromProtoTracksEDProducer.h.

References ev.

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 
48  psd0.add<std::string>("ComponentName",std::string("SeedFromConsecutiveHitsCreator"));
49  psd0.add<std::string>("propagator",std::string("PropagatorWithMaterial"));
50  psd0.add<double>("SeedMomentumForBOFF",5.0);
51  psd0.add<double>("OriginTransverseErrorMultiplier",1.0);
52  psd0.add<double>("MinOneOverPtError",1.0);
53  psd0.add<std::string>("magneticField",std::string(""));
54  psd0.add<std::string>("TTRHBuilder",std::string("WithTrackAngle"));
55  psd0.add<bool>("forceKinematicWithRegionDirection",false);
56  desc.add<edm::ParameterSetDescription>("SeedCreatorPSet",psd0);
57 
58  descriptions.add("SeedGeneratorFromProtoTracksEDProducer", desc);
59 }
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

Definition at line 80 of file SeedGeneratorFromProtoTracksEDProducer.cc.

References builderName, edm::EventSetup::get(), edm::Event::getByToken(), edm::ParameterSet::getParameter(), hfClusterShapes_cfi::hits, SeedFromProtoTrack::isValid(), reco::TrackBase::momentum(), eostools::move(), SeedingHitSet::nullPtr(), originHalfLength, originRadius, edm::Event::put(), reco::Track::recHit(), reco::Track::recHitsSize(), rpcPointValidation_cfi::refHit, mps_fire::result, SeedFromConsecutiveHitsCreator_cfi::SeedFromConsecutiveHitsCreator, sqr(), mathSSE::sqrt(), theConfig, theInputCollectionTag, theInputVertexCollectionTag, SeedFromProtoTrack::trajectorySeed(), useEventsWithNoVertex, useProtoTrackKinematics, usePV_, reco::TrackBase::vertex(), ecalDrivenElectronSeedsParameters_cff::vertices, and badGlobalMuonTaggersAOD_cff::vtx.

81 {
82  auto result = std::make_unique<TrajectorySeedCollection>();
85 
86  const TrackCollection &protos = *(trks.product());
87 
89  bool foundVertices = ev.getByToken(theInputVertexCollectionTag, vertices);
90  //const reco::VertexCollection & vertices = *(h_vertices.product());
91 
95  for (TrackCollection::const_iterator it=protos.begin(); it!= protos.end(); ++it) {
96  const Track & proto = (*it);
97  GlobalPoint vtx(proto.vertex().x(), proto.vertex().y(), proto.vertex().z());
98 
99  // check the compatibility with a primary vertex
100  bool keepTrack = false;
101  if ( (!foundVertices) || vertices->empty() ) {
102  if (useEventsWithNoVertex) keepTrack = true;
103  }
104  else if (usePV_){
105 
106  GlobalPoint aPV(vertices->begin()->position().x(),vertices->begin()->position().y(),vertices->begin()->position().z());
107  double distR2 = sqr(vtx.x()-aPV.x()) +sqr(vtx.y()-aPV.y());
108  double distZ = fabs(vtx.z()-aPV.z());
109  if ( distR2 < sqr(originRadius) && distZ < originHalfLength ) {
110  keepTrack = true;
111  }
112  }
113  else {
114  for (reco::VertexCollection::const_iterator iv=vertices->begin(); iv!= vertices->end(); ++iv) {
115  GlobalPoint aPV(iv->position().x(),iv->position().y(),iv->position().z());
116  double distR2 = sqr(vtx.x()-aPV.x()) +sqr(vtx.y()-aPV.y());
117  double distZ = fabs(vtx.z()-aPV.z());
118  if ( distR2 < sqr(originRadius) && distZ < originHalfLength ) {
119  keepTrack = true;
120  break;
121  }
122  }
123  }
124  if (!keepTrack) continue;
125 
126  if ( useProtoTrackKinematics ) {
127  SeedFromProtoTrack seedFromProtoTrack( proto, es);
128  if (seedFromProtoTrack.isValid()) (*result).push_back( seedFromProtoTrack.trajectorySeed() );
129  } else {
131  es.get<TransientRecHitRecord>().get(builderName,ttrhbESH);
132  std::vector<Hit> hits;
133  for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
134  TrackingRecHitRef refHit = proto.recHit(iHit);
135  if(refHit->isValid()) hits.push_back((Hit)&(*refHit));
136  }
137  sort(hits.begin(), hits.end(), HitLessByRadius());
138 
139  if (hits.size() > 1) {
140  double mom_perp = sqrt(proto.momentum().x()*proto.momentum().x()+proto.momentum().y()*proto.momentum().y());
141  GlobalTrackingRegion region(mom_perp, vtx, 0.2, 0.2);
142 
143  edm::ParameterSet seedCreatorPSet = theConfig.getParameter<edm::ParameterSet>("SeedCreatorPSet");
144  SeedFromConsecutiveHitsCreator seedCreator(seedCreatorPSet);
145  seedCreator.init(region, es, 0);
146  seedCreator.makeSeed(*result, SeedingHitSet(hits[0], hits[1], hits.size() >2 ? hits[2] : SeedingHitSet::nullPtr() ));
147  }
148  }
149  }
150 
151  ev.put(std::move(result));
152 }
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
Definition: Track.h:119
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:675
const edm::EDGetTokenT< reco::TrackCollection > theInputCollectionTag
const Point & vertex() const
reference point on the track. This method is DEPRECATED, please use referencePoint() instead ...
Definition: TrackBase.h:687
T sqrt(T t)
Definition: SSEVec.h:18
static ConstRecHitPointer nullPtr()
Definition: SeedingHitSet.h:13
const edm::EDGetTokenT< reco::VertexCollection > theInputVertexCollectionTag
const T & get() const
Definition: EventSetup.h:55
TrackingRecHitRef recHit(size_t i) const
Get i-th hit on the track.
Definition: Track.h:114
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

const std::string SeedGeneratorFromProtoTracksEDProducer::builderName
private

Definition at line 25 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

const double SeedGeneratorFromProtoTracksEDProducer::originHalfLength
private

Definition at line 21 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

const double SeedGeneratorFromProtoTracksEDProducer::originRadius
private

Definition at line 22 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

const edm::ParameterSet SeedGeneratorFromProtoTracksEDProducer::theConfig
private

Definition at line 20 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::TrackCollection> SeedGeneratorFromProtoTracksEDProducer::theInputCollectionTag
private

Definition at line 27 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCollection> SeedGeneratorFromProtoTracksEDProducer::theInputVertexCollectionTag
private

Definition at line 28 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

const bool SeedGeneratorFromProtoTracksEDProducer::useEventsWithNoVertex
private

Definition at line 24 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

const bool SeedGeneratorFromProtoTracksEDProducer::useProtoTrackKinematics
private

Definition at line 23 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().

const bool SeedGeneratorFromProtoTracksEDProducer::usePV_
private

Definition at line 26 of file SeedGeneratorFromProtoTracksEDProducer.h.

Referenced by produce().