CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PixelTrackProducer.cc
Go to the documentation of this file.
1 #include "PixelTrackProducer.h"
2 
7 
12 
13 #include <vector>
14 
15 using namespace pixeltrackfitting;
16 using edm::ParameterSet;
17 
19  : theReconstruction(cfg, consumesCollector())
20 {
21  edm::LogInfo("PixelTrackProducer")<<" construction...";
22  produces<reco::TrackCollection>();
23  produces<TrackingRecHitCollection>();
24  produces<reco::TrackExtraCollection>();
25 }
26 
28 
30 {
32 }
33 
35 {
37 }
38 
40 {
41  LogDebug("PixelTrackProducer, produce")<<"event# :"<<ev.id();
42 
44  theReconstruction.run(tracks,ev,es);
45 
46  // store tracks
47  store(ev, tracks);
48 }
49 
51 {
52  std::auto_ptr<reco::TrackCollection> tracks(new reco::TrackCollection());
53  std::auto_ptr<TrackingRecHitCollection> recHits(new TrackingRecHitCollection());
54  std::auto_ptr<reco::TrackExtraCollection> trackExtras(new reco::TrackExtraCollection());
55 
56  int cc = 0, nTracks = tracksWithHits.size();
57 
58  for (int i = 0; i < nTracks; i++)
59  {
60  reco::Track* track = tracksWithHits.at(i).first;
61  const SeedingHitSet& hits = tracksWithHits.at(i).second;
62 
63  for (unsigned int k = 0; k < hits.size(); k++)
64  {
65  TrackingRecHit *hit = hits[k]->hit()->clone();
66 
67  track->appendHitPattern(*hit);
68  recHits->push_back(hit);
69  }
70  tracks->push_back(*track);
71  delete track;
72 
73  }
74 
75  LogDebug("TrackProducer") << "put the collection of TrackingRecHit in the event" << "\n";
77 
79  for (int k = 0; k < nTracks; k++)
80  {
81  reco::TrackExtra theTrackExtra{};
82 
83  //fill the TrackExtra with TrackingRecHitRef
84  unsigned int nHits = tracks->at(k).numberOfValidHits();
85  theTrackExtra.setHits(hitCollProd, cc, nHits);
86  cc +=nHits;
87  trackExtras->push_back(theTrackExtra);
88  }
89 
90  LogDebug("TrackProducer") << "put the collection of TrackExtra in the event" << "\n";
92 
93  for (int k = 0; k < nTracks; k++)
94  {
95  const reco::TrackExtraRef theTrackExtraRef(ohTE,k);
96  (tracks->at(k)).setExtra(theTrackExtraRef);
97  }
98 
99  ev.put(tracks);
100 
101 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
void init(const edm::EventSetup &es)
tuple cfg
Definition: looper.py:259
void setHits(TrackingRecHitRefProd const &prod, unsigned firstH, unsigned int nH)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
bool ev
virtual void endRun(const edm::Run &run, const edm::EventSetup &es) override
std::vector< TrackWithTTRHs > TracksWithTTRHs
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual void beginRun(const edm::Run &run, const edm::EventSetup &es) override
bool appendHitPattern(const TrackingRecHit &hit)
append a single hit to the HitPattern
Definition: TrackBase.h:394
virtual void produce(edm::Event &ev, const edm::EventSetup &es) override
void run(pixeltrackfitting::TracksWithTTRHs &tah, edm::Event &ev, const edm::EventSetup &es)
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
tuple tracks
Definition: testEve_cfg.py:39
PixelTrackReconstruction theReconstruction
edm::EventID id() const
Definition: EventBase.h:60
unsigned int size() const
Definition: SeedingHitSet.h:44
void store(edm::Event &ev, const pixeltrackfitting::TracksWithTTRHs &selectedTracks)
PixelTrackProducer(const edm::ParameterSet &conf)
Definition: Run.h:41