CMS 3D CMS Logo

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

#include <PixelTracksProducer.h>

Inheritance diagram for PixelTracksProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PixelTracksProducer (const edm::ParameterSet &conf)
 
virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 
 ~PixelTracksProducer ()
 
- 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)
 

Private Attributes

edm::EDGetTokenT< PixelTrackFilterfilterToken
 
edm::EDGetTokenT< PixelFitterfitterToken
 
edm::EDGetTokenT< TrajectorySeedCollectionseedProducerToken
 
TrackingRegionProducertheRegionProducer
 

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
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 22 of file PixelTracksProducer.h.

Constructor & Destructor Documentation

PixelTracksProducer::PixelTracksProducer ( const edm::ParameterSet conf)
explicit

Definition at line 35 of file PixelTracksProducer.cc.

References edm::EDConsumerBase::consumesCollector(), filterToken, fitterToken, reco::get(), edm::ParameterSet::getParameter(), seedProducerToken, AlCaHLTBitMon_QueryRunRegistry::string, and theRegionProducer.

35  :
37 {
38 
39  produces<reco::TrackCollection>();
40  produces<TrackingRecHitCollection>();
41  produces<reco::TrackExtraCollection>();
42 
43  const edm::ParameterSet& regfactoryPSet = conf.getParameter<edm::ParameterSet>("RegionFactoryPSet");
44  std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
45  theRegionProducer = TrackingRegionProducerFactory::get()->create(regfactoryName,
46  regfactoryPSet, consumesCollector());
47 
48  fitterToken = consumes<PixelFitter>(conf.getParameter<edm::InputTag>("Fitter"));
49  filterToken = consumes<PixelTrackFilter>(conf.getParameter<edm::InputTag>("Filter"));
50 
51  // The name of the seed producer
52  auto seedProducer = conf.getParameter<edm::InputTag>("SeedProducer");
53  seedProducerToken = consumes<TrajectorySeedCollection>(seedProducer);
54 
55 }
T getParameter(std::string const &) const
TrackingRegionProducer * theRegionProducer
edm::EDGetTokenT< TrajectorySeedCollection > seedProducerToken
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< PixelTrackFilter > filterToken
edm::EDGetTokenT< PixelFitter > fitterToken
T get(const Candidate &c)
Definition: component.h:55
PixelTracksProducer::~PixelTracksProducer ( )

Definition at line 59 of file PixelTracksProducer.cc.

References theRegionProducer.

59  {
60 
61  delete theRegionProducer;
62 
63 }
TrackingRegionProducer * theRegionProducer

Member Function Documentation

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

Definition at line 68 of file PixelTracksProducer.cc.

References reco::TrackBase::appendHitPattern(), clone(), DEFINE_FWK_MODULE, filterToken, fitterToken, edm::EventSetup::get(), edm::Event::getByToken(), hfClusterShapes_cfi::hits, mps_fire::i, gen::k, eostools::move(), nTracks(), edm::Event::put(), TrackingRegionProducer::regions(), PixelFitter::run(), seedProducerToken, reco::TrackExtraBase::setHits(), theRegionProducer, HiIsolationCommonParameters_cff::track, and l1t::tracks.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

68  {
69 
70  std::unique_ptr<reco::TrackCollection> tracks(new reco::TrackCollection);
71  std::unique_ptr<TrackingRecHitCollection> recHits(new TrackingRecHitCollection);
72  std::unique_ptr<reco::TrackExtraCollection> trackExtras(new reco::TrackExtraCollection);
73  typedef std::vector<const TrackingRecHit *> RecHits;
74 
75  TracksWithRecHits pixeltracks;
76  TracksWithRecHits cleanedTracks;
77 
79  es.get<TrackerTopologyRcd>().get(httopo);
80  const TrackerTopology& ttopo = *httopo;
81 
83  e.getByToken(fitterToken, hfitter);
84  const PixelFitter& fitter = *hfitter;
85 
87  e.getByToken(filterToken, hfilter);
88  const PixelTrackFilter& theFilter = *hfilter;
89 
91  e.getByToken(seedProducerToken,theSeeds);
92 
93  // No seed -> output an empty track collection
94  if(theSeeds->size() == 0) {
95  e.put(std::move(tracks));
96  e.put(std::move(recHits));
97  e.put(std::move(trackExtras));
98  return;
99  }
100 
101  //only one region Global, but it is called at every event...
102  //maybe there is a smarter way to set it only once
103  //NEED TO FIX
104  typedef std::vector<std::unique_ptr<TrackingRegion> > Regions;
105  typedef Regions::const_iterator IR;
106  Regions regions = theRegionProducer->regions(e,es);
107  for (IR ir=regions.begin(), irEnd=regions.end(); ir < irEnd; ++ir) {
108  const TrackingRegion & region = **ir;
109 
110  // Loop over the seeds
111  TrajectorySeedCollection::const_iterator aSeed = theSeeds->begin();
112  TrajectorySeedCollection::const_iterator lastSeed = theSeeds->end();
113  for ( ; aSeed!=lastSeed; ++aSeed ) {
114 
115  // Find the first hit and last hit of the Seed
116  TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits();
117  edm::OwnVector<TrackingRecHit>::const_iterator aSeedingRecHit = theSeedingRecHitRange.first;
118  edm::OwnVector<TrackingRecHit>::const_iterator theLastSeedingRecHit = theSeedingRecHitRange.second;
119 
120  // Loop over the rechits
121  std::vector<const TrackingRecHit*> TripletHits(3,static_cast<const TrackingRecHit*>(0));
122  for ( unsigned i=0; aSeedingRecHit!=theLastSeedingRecHit; ++i,++aSeedingRecHit )
123  TripletHits[i] = &(*aSeedingRecHit);
124 
125  // fitting the triplet
126  std::unique_ptr<reco::Track> track = fitter.run(TripletHits, region);
127 
128  // decide if track should be skipped according to filter
129  if ( ! theFilter(track.get(), TripletHits) ) {
130  continue;
131  }
132 
133  // add tracks
134  pixeltracks.push_back(TrackWithRecHits(track.release(), TripletHits));
135 
136  }
137  }
138 
139  int cc=0;
140  int nTracks = pixeltracks.size();
141  for (int i = 0; i < nTracks; ++i) {
142 
143  reco::Track* track = pixeltracks.at(i).first;
144  const RecHits & hits = pixeltracks.at(i).second;
145 
146  for (unsigned int k = 0; k < hits.size(); k++) {
147  TrackingRecHit *hit = (hits.at(k))->clone();
148  track->appendHitPattern(*hit, ttopo);
149  recHits->push_back(hit);
150  }
151 
152  tracks->push_back(*track);
153  delete track;
154 
155  }
156 
159 
160  for (int k = 0; k < nTracks; ++k) {
161 
162  // reco::TrackExtra* theTrackExtra = new reco::TrackExtra();
163  reco::TrackExtra theTrackExtra;
164 
165  //fill the TrackExtra with TrackingRecHitRef
166  // unsigned int nHits = tracks->at(k).numberOfValidHits();
167  const unsigned nHits = 3; // We are dealing with triplets!
168  theTrackExtra.setHits( ohRHProd, cc, nHits);
169  cc += nHits;
170 
171  trackExtras->push_back(theTrackExtra);
172  //trackExtras->push_back(*theTrackExtra);
173  //delete theTrackExtra;
174  }
175 
177 
178  for (int k = 0; k < nTracks; k++) {
179 
180  const reco::TrackExtraRef theTrackExtraRef(ohTE,k);
181  (tracks->at(k)).setExtra(theTrackExtraRef);
182 
183  }
184 
185  e.put(std::move(tracks));
186 
187 }
const unsigned int nTracks(const reco::Vertex &sv)
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
TrackingRegionProducer * theRegionProducer
edm::EDGetTokenT< TrajectorySeedCollection > seedProducerToken
edm::EDGetTokenT< PixelTrackFilter > filterToken
std::pair< const_iterator, const_iterator > range
std::pair< reco::Track *, std::vector< const TrackingRecHit * > > TrackWithRecHits
int k[5][pyjets_maxn]
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
virtual std::vector< std::unique_ptr< TrackingRegion > > regions(const edm::Event &ev, const edm::EventSetup &es) const =0
const T & get() const
Definition: EventSetup.h:55
std::unique_ptr< reco::Track > run(const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region) const
Definition: PixelFitter.h:15
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
bool appendHitPattern(const TrackingRecHit &hit, const TrackerTopology &ttopo)
append a single hit to the HitPattern
Definition: TrackBase.h:456
std::vector< TrackWithRecHits > TracksWithRecHits
edm::EDGetTokenT< PixelFitter > fitterToken
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

edm::EDGetTokenT<PixelTrackFilter> PixelTracksProducer::filterToken
private

Definition at line 37 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().

edm::EDGetTokenT<PixelFitter> PixelTracksProducer::fitterToken
private

Definition at line 33 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().

edm::EDGetTokenT<TrajectorySeedCollection> PixelTracksProducer::seedProducerToken
private

Definition at line 36 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().

TrackingRegionProducer* PixelTracksProducer::theRegionProducer
private

Definition at line 34 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), produce(), and ~PixelTracksProducer().