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::EDConsumerBase 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 &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 20 of file PixelTracksProducer.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file PixelTracksProducer.cc.

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

33  :
34  theFitter(0),
35  theFilter(0),
37 {
38 
39  produces<reco::TrackCollection>();
40  produces<TrackingRecHitCollection>();
41  produces<reco::TrackExtraCollection>();
42 
43  const edm::ParameterSet& regfactoryPSet = conf.getParameter<edm::ParameterSet>("RegionFactoryPSet");
44  std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
45  theRegionProducer = TrackingRegionProducerFactory::get()->create(regfactoryName,regfactoryPSet);
46 
47  const edm::ParameterSet& fitterPSet = conf.getParameter<edm::ParameterSet>("FitterPSet");
48  std::string fitterName = fitterPSet.getParameter<std::string>("ComponentName");
49  theFitter = PixelFitterFactory::get()->create( fitterName, fitterPSet);
50 
51  const edm::ParameterSet& filterPSet = conf.getParameter<edm::ParameterSet>("FilterPSet");
52  std::string filterName = filterPSet.getParameter<std::string>("ComponentName");
53  theFilter = PixelTrackFilterFactory::get()->create( filterName, filterPSet);
54 
55  // The name of the seed producer
56  seedProducer = conf.getParameter<edm::InputTag>("SeedProducer");
57 
58 }
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 62 of file PixelTracksProducer.cc.

References theFilter, theFitter, and theRegionProducer.

62  {
63 
64  delete theFilter;
65  delete theFitter;
66  delete theRegionProducer;
67 
68 }
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 73 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 JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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