CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PixelTracksProducer Class Reference

#include <PixelTracksProducer.h>

Inheritance diagram for PixelTracksProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 PixelTracksProducer (const edm::ParameterSet &conf)
 
virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 
 ~PixelTracksProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

edm::InputTag seedProducer
 
const PixelTrackFiltertheFilter
 
const PixelFittertheFitter
 
TrackingRegionProducertheRegionProducer
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 20 of file PixelTracksProducer.h.

Constructor & Destructor Documentation

PixelTracksProducer::PixelTracksProducer ( const edm::ParameterSet conf)
explicit

Definition at line 32 of file PixelTracksProducer.cc.

References reco_skim_cfg_mod::filterName, reco::get(), edm::ParameterSet::getParameter(), seedProducer, theFilter, theFitter, and theRegionProducer.

32  :
33  theFitter(0),
34  theFilter(0),
36 {
37 
38  produces<reco::TrackCollection>();
39  produces<TrackingRecHitCollection>();
40  produces<reco::TrackExtraCollection>();
41 
42  const edm::ParameterSet& regfactoryPSet = conf.getParameter<edm::ParameterSet>("RegionFactoryPSet");
43  std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
44  theRegionProducer = TrackingRegionProducerFactory::get()->create(regfactoryName,regfactoryPSet);
45 
46  const edm::ParameterSet& fitterPSet = conf.getParameter<edm::ParameterSet>("FitterPSet");
47  std::string fitterName = fitterPSet.getParameter<std::string>("ComponentName");
48  theFitter = PixelFitterFactory::get()->create( fitterName, fitterPSet);
49 
50  const edm::ParameterSet& filterPSet = conf.getParameter<edm::ParameterSet>("FilterPSet");
51  std::string filterName = filterPSet.getParameter<std::string>("ComponentName");
52  theFilter = PixelTrackFilterFactory::get()->create( filterName, filterPSet);
53 
54  // The name of the seed producer
55  seedProducer = conf.getParameter<edm::InputTag>("SeedProducer");
56 
57 }
T getParameter(std::string const &) const
edm::InputTag seedProducer
TrackingRegionProducer * theRegionProducer
const PixelTrackFilter * theFilter
const PixelFitter * theFitter
T get(const Candidate &c)
Definition: component.h:56
PixelTracksProducer::~PixelTracksProducer ( )

Definition at line 61 of file PixelTracksProducer.cc.

References theFilter, theFitter, and theRegionProducer.

61  {
62 
63  delete theFilter;
64  delete theFitter;
65  delete theRegionProducer;
66 
67 }
TrackingRegionProducer * theRegionProducer
const PixelTrackFilter * theFilter
const PixelFitter * theFitter

Member Function Documentation

void PixelTracksProducer::produce ( edm::Event ev,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 72 of file PixelTracksProducer.cc.

References reco::TrackExtraBase::add(), clone(), edm::Event::getByLabel(), i, gen::k, edm::Event::put(), TrackingRegionProducer::regions(), PixelFitter::run(), seedProducer, reco::TrackBase::setHitPattern(), theFilter, theFitter, theRegionProducer, and testEve_cfg::tracks.

Referenced by python.JSONExport.JsonExport::export(), and python.HTMLExport.HTMLExport::export().

72  {
73 
74  std::auto_ptr<reco::TrackCollection> tracks(new reco::TrackCollection);
75  std::auto_ptr<TrackingRecHitCollection> recHits(new TrackingRecHitCollection);
76  std::auto_ptr<reco::TrackExtraCollection> trackExtras(new reco::TrackExtraCollection);
77  typedef std::vector<const TrackingRecHit *> RecHits;
78 
79  TracksWithRecHits pixeltracks;
80  TracksWithRecHits cleanedTracks;
81 
83  e.getByLabel(seedProducer,theSeeds);
84 
85  // No seed -> output an empty track collection
86  if(theSeeds->size() == 0) {
87  e.put(tracks);
88  e.put(recHits);
89  e.put(trackExtras);
90  return;
91  }
92 
93  //only one region Global, but it is called at every event...
94  //maybe there is a smarter way to set it only once
95  //NEED TO FIX
96  typedef std::vector<TrackingRegion* > Regions;
97  typedef Regions::const_iterator IR;
98  Regions regions = theRegionProducer->regions(e,es);
99  for (IR ir=regions.begin(), irEnd=regions.end(); ir < irEnd; ++ir) {
100  const TrackingRegion & region = **ir;
101 
102  // Loop over the seeds
103  TrajectorySeedCollection::const_iterator aSeed = theSeeds->begin();
104  TrajectorySeedCollection::const_iterator lastSeed = theSeeds->end();
105  for ( ; aSeed!=lastSeed; ++aSeed ) {
106 
107  // Find the first hit and last hit of the Seed
108  TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits();
109  edm::OwnVector<TrackingRecHit>::const_iterator aSeedingRecHit = theSeedingRecHitRange.first;
110  edm::OwnVector<TrackingRecHit>::const_iterator theLastSeedingRecHit = theSeedingRecHitRange.second;
111 
112  // Loop over the rechits
113  std::vector<const TrackingRecHit*> TripletHits(3,static_cast<const TrackingRecHit*>(0));
114  for ( unsigned i=0; aSeedingRecHit!=theLastSeedingRecHit; ++i,++aSeedingRecHit )
115  TripletHits[i] = &(*aSeedingRecHit);
116 
117  // fitting the triplet
118  reco::Track* track = theFitter->run(es, TripletHits, region);
119 
120  // decide if track should be skipped according to filter
121  if ( ! (*theFilter)(track) ) {
122  delete track;
123  continue;
124  }
125 
126  // add tracks
127  pixeltracks.push_back(TrackWithRecHits(track, TripletHits));
128 
129  }
130  }
131 
132  int cc=0;
133  int nTracks = pixeltracks.size();
134  for (int i = 0; i < nTracks; ++i) {
135 
136  reco::Track* track = pixeltracks.at(i).first;
137  const RecHits & hits = pixeltracks.at(i).second;
138 
139  for (unsigned int k = 0; k < hits.size(); k++) {
140  TrackingRecHit *hit = (hits.at(k))->clone();
141  track->setHitPattern(*hit, k);
142  recHits->push_back(hit);
143  }
144 
145  tracks->push_back(*track);
146  delete track;
147 
148  }
149 
150  edm::OrphanHandle <TrackingRecHitCollection> ohRH = e.put( recHits );
151 
152  for (int k = 0; k < nTracks; ++k) {
153 
154  // reco::TrackExtra* theTrackExtra = new reco::TrackExtra();
155  reco::TrackExtra theTrackExtra;
156 
157  //fill the TrackExtra with TrackingRecHitRef
158  // unsigned int nHits = tracks->at(k).numberOfValidHits();
159  unsigned nHits = 3; // We are dealing with triplets!
160  for(unsigned int i = 0; i < nHits; ++i) {
161  theTrackExtra.add(TrackingRecHitRef(ohRH,cc++));
162  //theTrackExtra->add(TrackingRecHitRef(ohRH,cc));
163  //cc++;
164  }
165 
166  trackExtras->push_back(theTrackExtra);
167  //trackExtras->push_back(*theTrackExtra);
168  //delete theTrackExtra;
169  }
170 
171  edm::OrphanHandle<reco::TrackExtraCollection> ohTE = e.put(trackExtras);
172 
173  for (int k = 0; k < nTracks; k++) {
174 
175  const reco::TrackExtraRef theTrackExtraRef(ohTE,k);
176  (tracks->at(k)).setExtra(theTrackExtraRef);
177 
178  }
179 
180  e.put(tracks);
181 
182  // Avoid a memory leak !
183  unsigned nRegions = regions.size();
184  for ( unsigned iRegions=0; iRegions<nRegions; ++iRegions ) {
185  delete regions[iRegions];
186  }
187 
188 }
int i
Definition: DBlmapReader.cc:9
virtual reco::Track * run(const edm::EventSetup &es, const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region) const =0
edm::InputTag seedProducer
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
TrackingRegionProducer * theRegionProducer
edm::Ref< TrackingRecHitCollection > TrackingRecHitRef
persistent reference to a TrackingRecHit
const PixelTrackFilter * theFilter
std::pair< const_iterator, const_iterator > range
std::pair< reco::Track *, std::vector< const TrackingRecHit * > > TrackWithRecHits
int k[5][pyjets_maxn]
void setHitPattern(const C &c)
set hit patterns from vector of hit references
Definition: TrackBase.h:246
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:9
tuple tracks
Definition: testEve_cfg.py:39
T * clone(const T *tp)
Definition: Ptr.h:42
void add(const TrackingRecHitRef &r)
add a reference to a RecHit
const PixelFitter * theFitter
std::vector< TrackWithRecHits > TracksWithRecHits
virtual std::vector< TrackingRegion * > regions(const edm::Event &ev, const edm::EventSetup &es) const =0

Member Data Documentation

edm::InputTag PixelTracksProducer::seedProducer
private

Definition at line 35 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().

const PixelTrackFilter* PixelTracksProducer::theFilter
private

Definition at line 32 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), produce(), and ~PixelTracksProducer().

const PixelFitter* PixelTracksProducer::theFitter
private

Definition at line 31 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), produce(), and ~PixelTracksProducer().

TrackingRegionProducer* PixelTracksProducer::theRegionProducer
private

Definition at line 33 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), produce(), and ~PixelTracksProducer().