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  // Loop over the rechits
102  std::vector<const TrackingRecHit*> TripletHits(3, static_cast<const TrackingRecHit*>(nullptr));
103  unsigned int iRecHit = 0;
104  for (auto const& recHit : aSeed->recHits()) {
105  TripletHits[iRecHit] = &recHit;
106  ++iRecHit;
107  }
108 
109  // fitting the triplet
110  std::unique_ptr<reco::Track> track = fitter.run(TripletHits, region, es);
111 
112  // decide if track should be skipped according to filter
113  if (!theFilter(track.get(), TripletHits)) {
114  continue;
115  }
116 
117  // add tracks
118  pixeltracks.push_back(TrackWithRecHits(track.release(), TripletHits));
119  }
120  }
121 
122  int cc = 0;
123  int nTracks = pixeltracks.size();
124  for (int i = 0; i < nTracks; ++i) {
125  reco::Track* track = pixeltracks.at(i).first;
126  const RecHits& hits = pixeltracks.at(i).second;
127 
128  for (unsigned int k = 0; k < hits.size(); k++) {
129  TrackingRecHit* hit = (hits.at(k))->clone();
130  track->appendHitPattern(*hit, ttopo);
131  recHits->push_back(hit);
132  }
133 
134  tracks->push_back(*track);
135  delete track;
136  }
137 
140 
141  for (int k = 0; k < nTracks; ++k) {
142  // reco::TrackExtra* theTrackExtra = new reco::TrackExtra();
143  reco::TrackExtra theTrackExtra;
144 
145  //fill the TrackExtra with TrackingRecHitRef
146  // unsigned int nHits = tracks->at(k).numberOfValidHits();
147  const unsigned nHits = 3; // We are dealing with triplets!
148  theTrackExtra.setHits(ohRHProd, cc, nHits);
149  cc += nHits;
150 
151  trackExtras->push_back(theTrackExtra);
152  //trackExtras->push_back(*theTrackExtra);
153  //delete theTrackExtra;
154  }
155 
157 
158  for (int k = 0; k < nTracks; k++) {
159  const reco::TrackExtraRef theTrackExtraRef(ohTE, k);
160  (tracks->at(k)).setExtra(theTrackExtraRef);
161  }
162 
163  e.put(std::move(tracks));
164 }
165 
edm::RefProd< TrackingRecHitCollection >
TrackExtra.h
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
PixelTracksProducer::~PixelTracksProducer
~PixelTracksProducer() override
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
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
BeamSpotPI::nTracks
Definition: BeamSpotPayloadInspectorHelper.h:42
edm::Handle
Definition: AssociativeIterator.h:50
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
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:87
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
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
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
PixelTracksProducer::seedProducerToken
edm::EDGetTokenT< TrajectorySeedCollection > seedProducerToken
Definition: PixelTracksProducer.h:33
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
pixeltrackfitting::TracksWithRecHits
std::vector< TrackWithRecHits > TracksWithRecHits
Definition: TracksWithHits.h:13
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
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
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::TrackExtraBase::setHits
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
Definition: TrackExtraBase.h:30
TrackingRecHit
Definition: TrackingRecHit.h:21
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
PixelTracksProducer
Definition: PixelTracksProducer.h:21
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrackingRegion
Definition: TrackingRegion.h:41
AlignmentPI::regions
regions
Definition: AlignmentPayloadInspectorHelper.h:78
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