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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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
 

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 filterToken, fitterToken, reco::get(), edm::ParameterSet::getParameter(), seedProducerToken, AlCaHLTBitMon_QueryRunRegistry::string, and theRegionProducer.

35  :
36  theRegionProducer(nullptr)
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
edm::EDGetTokenT< PixelTrackFilter > filterToken
edm::EDGetTokenT< PixelFitter > fitterToken
T get(const Candidate &c)
Definition: component.h:55
PixelTracksProducer::~PixelTracksProducer ( )
override

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

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->empty()) {
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*>(nullptr));
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
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
T get() const
Definition: EventSetup.h:63
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().