CMS 3D CMS Logo

PixelTrackProducer.cc
Go to the documentation of this file.
1 #include "PixelTrackProducer.h"
2 
10 
15 
18 
19 #include <vector>
20 
21 using namespace pixeltrackfitting;
22 using edm::ParameterSet;
23 
25  : theReconstruction(cfg, consumesCollector())
26 {
27  edm::LogInfo("PixelTrackProducer")<<" construction...";
28  produces<reco::TrackCollection>();
29  produces<TrackingRecHitCollection>();
30  produces<reco::TrackExtraCollection>();
31 }
32 
34 
37 
38  desc.add<std::string>("passLabel", "pixelTracks"); // What is this? It is not used anywhere in this code.
40 
41  descriptions.add("pixelTracksDefault", desc);
42 }
43 
45 {
46  LogDebug("PixelTrackProducer, produce")<<"event# :"<<ev.id();
47 
49  theReconstruction.run(tracks,ev,es);
50 
52  es.get<TrackerTopologyRcd>().get(httopo);
53 
54  // store tracks
55  store(ev, tracks, *httopo);
56 }
57 
58 void PixelTrackProducer::store(edm::Event& ev, const TracksWithTTRHs& tracksWithHits, const TrackerTopology& ttopo)
59 {
60  auto tracks = std::make_unique<reco::TrackCollection>();
61  auto recHits = std::make_unique<TrackingRecHitCollection>();
62  auto trackExtras = std::make_unique<reco::TrackExtraCollection>();
63 
64  int cc = 0, nTracks = tracksWithHits.size();
65 
66  for (int i = 0; i < nTracks; i++)
67  {
68  reco::Track* track = tracksWithHits.at(i).first;
69  const SeedingHitSet& hits = tracksWithHits.at(i).second;
70 
71  for (unsigned int k = 0; k < hits.size(); k++)
72  {
73  TrackingRecHit *hit = hits[k]->hit()->clone();
74 
75  track->appendHitPattern(*hit, ttopo);
76  recHits->push_back(hit);
77  }
78  tracks->push_back(*track);
79  delete track;
80 
81  }
82 
83  LogDebug("TrackProducer") << "put the collection of TrackingRecHit in the event" << "\n";
85 
87  for (int k = 0; k < nTracks; k++)
88  {
89  reco::TrackExtra theTrackExtra{};
90 
91  //fill the TrackExtra with TrackingRecHitRef
92  unsigned int nHits = tracks->at(k).numberOfValidHits();
93  theTrackExtra.setHits(hitCollProd, cc, nHits);
94  cc +=nHits;
95  trackExtras->push_back(theTrackExtra);
96  }
97 
98  LogDebug("TrackProducer") << "put the collection of TrackExtra in the event" << "\n";
100 
101  for (int k = 0; k < nTracks; k++)
102  {
103  const reco::TrackExtraRef theTrackExtraRef(ohTE,k);
104  (tracks->at(k)).setExtra(theTrackExtraRef);
105  }
106 
107  ev.put(std::move(tracks));
108 
109 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const unsigned int nTracks(const reco::Vertex &sv)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool ev
std::vector< TrackWithTTRHs > TracksWithTTRHs
virtual void produce(edm::Event &ev, const edm::EventSetup &es) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void run(pixeltrackfitting::TracksWithTTRHs &tah, edm::Event &ev, const edm::EventSetup &es)
int k[5][pyjets_maxn]
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const T & get() const
Definition: EventSetup.h:56
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool appendHitPattern(const TrackingRecHit &hit, const TrackerTopology &ttopo)
append a single hit to the HitPattern
Definition: TrackBase.h:455
PixelTrackReconstruction theReconstruction
edm::EventID id() const
Definition: EventBase.h:58
unsigned int size() const
Definition: SeedingHitSet.h:46
void store(edm::Event &ev, const pixeltrackfitting::TracksWithTTRHs &selectedTracks, const TrackerTopology &ttopo)
static void fillDescriptions(edm::ParameterSetDescription &desc)
def move(src, dest)
Definition: eostools.py:510
PixelTrackProducer(const edm::ParameterSet &conf)