CMS 3D CMS Logo

PixelTracksProducer.cc
Go to the documentation of this file.
1 #include <memory>
3 
8 
11 
13 
16 
17 //Pixel Specific stuff
20 
22 
26 
31 #include <vector>
32 
33 using namespace pixeltrackfitting;
34 
35 PixelTracksProducer::PixelTracksProducer(const edm::ParameterSet& conf) : 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 }
51 
52 // Virtual destructor needed.
54 
55 // Functions that gets called by framework every event
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 }
167 
edm::RefProd< TrackingRecHitCollection >
TrackExtra.h
nTracks
const unsigned int nTracks(const reco::Vertex &sv)
Definition: TemplatedVertexArbitrator.h:44
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
PixelTracksProducer::~PixelTracksProducer
~PixelTracksProducer() override
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
TrajectorySeed::range
std::pair< const_iterator, const_iterator > range
Definition: TrajectorySeed.h:21
TrackerTopology
Definition: TrackerTopology.h:16
PixelTrackFilter.h
PixelTracksProducer::produce
void produce(edm::Event &ev, const edm::EventSetup &es) override
Definition: PixelTracksProducer.cc:56
PixelTracksProducer::fitterToken
edm::EDGetTokenT< PixelFitter > fitterToken
Definition: PixelTracksProducer.h:30
PixelTracksProducer::filterToken
edm::EDGetTokenT< PixelTrackFilter > filterToken
Definition: PixelTracksProducer.h:34
edm::Handle
Definition: AssociativeIterator.h:50
PixelFitter
Definition: PixelFitter.h:8
edm::Ref< TrackExtraCollection >
cc
TrackingRegionProducer.h
TrackingRegionProducerFactory.h
reco::TrackExtra
Definition: TrackExtra.h:26
MakerMacros.h
TrackerTopology.h
TrackingRecHit.h
PixelFitter.h
TrackerTopologyRcd.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
PixelTracksProducer.h
OrphanHandle.h
reco::Track
Definition: Track.h:27
edm::ESHandle< TrackerTopology >
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
pixeltrackfitting
Definition: TracksWithHits.h:10
dqmdumpme.k
k
Definition: dqmdumpme.py:60
TracksWithHits.h
PixelTracksProducer::PixelTracksProducer
PixelTracksProducer(const edm::ParameterSet &conf)
Definition: PixelTracksProducer.cc:35
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
PixelTracksProducer::seedProducerToken
edm::EDGetTokenT< TrajectorySeedCollection > seedProducerToken
Definition: PixelTracksProducer.h:33
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
pixeltrackfitting::TracksWithRecHits
std::vector< TrackWithRecHits > TracksWithRecHits
Definition: TracksWithHits.h:13
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
PixelFitter::run
std::unique_ptr< reco::Track > run(const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region, const edm::EventSetup &setup) const
Definition: PixelFitter.h:15
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
reco::TrackExtraBase::setHits
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
Definition: TrackExtraBase.h:30
TrackingRecHit
Definition: TrackingRecHit.h:21
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
PixelTracksProducer
Definition: PixelTracksProducer.h:21
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
TrackingRegion
Definition: TrackingRegion.h:40
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
AlignmentPI::regions
regions
Definition: AlignmentPayloadInspectorHelper.h:76
ConsumesCollector.h
TrackingRegion.h
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
OwnVector.h
edm::Event
Definition: Event.h:73
PixelTracksProducer::theRegionProducer
std::unique_ptr< TrackingRegionProducer > theRegionProducer
Definition: PixelTracksProducer.h:31
pixeltrackfitting::TrackWithRecHits
std::pair< reco::Track *, std::vector< const TrackingRecHit * > > TrackWithRecHits
Definition: TracksWithHits.h:11
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
hit
Definition: SiStripHitEffFromCalibTree.cc:88
PixelTrackFilter
Definition: PixelTrackFilter.h:8
edm::OwnVector< TrackingRecHit >
SiPixelRawToDigiRegional_cfi.Regions
Regions
Definition: SiPixelRawToDigiRegional_cfi.py:7
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37