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

Public Member Functions

 PixelTracksProducer (const edm::ParameterSet &conf)
 
void produce (edm::Event &ev, const edm::EventSetup &es) override
 
 ~PixelTracksProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::EDGetTokenT< PixelTrackFilterfilterToken
 
edm::EDGetTokenT< PixelFitterfitterToken
 
edm::EDGetTokenT< TrajectorySeedCollectionseedProducerToken
 
std::unique_ptr< 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
 

Detailed Description

Definition at line 21 of file PixelTracksProducer.h.

Constructor & Destructor Documentation

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

Definition at line 35 of file PixelTracksProducer.cc.

References filterToken, fitterToken, timingPdfMaker::get, edm::ParameterSet::getParameter(), seedProducerToken, AlCaHLTBitMon_QueryRunRegistry::string, theRegionProducer, and ~PixelTracksProducer().

35  : theRegionProducer(nullptr) {
36  produces<reco::TrackCollection>();
37  produces<TrackingRecHitCollection>();
38  produces<reco::TrackExtraCollection>();
39 
40  const edm::ParameterSet& regfactoryPSet = conf.getParameter<edm::ParameterSet>("RegionFactoryPSet");
41  std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
42  theRegionProducer = TrackingRegionProducerFactory::get()->create(regfactoryName, regfactoryPSet, consumesCollector());
43 
44  fitterToken = consumes<PixelFitter>(conf.getParameter<edm::InputTag>("Fitter"));
45  filterToken = consumes<PixelTrackFilter>(conf.getParameter<edm::InputTag>("Filter"));
46 
47  // The name of the seed producer
48  auto seedProducer = conf.getParameter<edm::InputTag>("SeedProducer");
49  seedProducerToken = consumes<TrajectorySeedCollection>(seedProducer);
50 }
T getParameter(std::string const &) const
edm::EDGetTokenT< TrajectorySeedCollection > seedProducerToken
edm::EDGetTokenT< PixelTrackFilter > filterToken
std::unique_ptr< TrackingRegionProducer > theRegionProducer
edm::EDGetTokenT< PixelFitter > fitterToken
PixelTracksProducer::~PixelTracksProducer ( )
overridedefault

Referenced by PixelTracksProducer().

Member Function Documentation

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

Definition at line 56 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, dqmdumpme::k, eostools::move(), nTracks(), edm::Event::put(), FastTrackerRecHitMaskProducer_cfi::recHits, HLT_2018_cff::region, SiPixelRawToDigiRegional_cfi::Regions, PixelFitter::run(), seedProducerToken, reco::TrackExtraBase::setHits(), theRegionProducer, HLT_2018_cff::track, and PDWG_EXOHSCP_cff::tracks.

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

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

Member Data Documentation

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

Definition at line 34 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().

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

Definition at line 30 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().

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

Definition at line 33 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().

std::unique_ptr<TrackingRegionProducer> PixelTracksProducer::theRegionProducer
private

Definition at line 31 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().