test
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 ()
 
ModuleDescription const & moduleDescription () const
 
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 ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::InputTag seedProducer
 
edm::EDGetTokenT
< TrajectorySeedCollection
seedProducerToken
 
const PixelTrackFiltertheFilter
 
const PixelFittertheFitter
 
TrackingRegionProducertheRegionProducer
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- 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::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 22 of file PixelTracksProducer.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file PixelTracksProducer.cc.

References edm::EDConsumerBase::consumesCollector(), reco_skim_cfg_mod::filterName, reco::get(), edm::ParameterSet::getParameter(), seedProducer, seedProducerToken, 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,
46  regfactoryPSet, consumesCollector());
47 
48  const edm::ParameterSet& fitterPSet = conf.getParameter<edm::ParameterSet>("FitterPSet");
49  std::string fitterName = fitterPSet.getParameter<std::string>("ComponentName");
50  theFitter = PixelFitterFactory::get()->create( fitterName, fitterPSet);
51 
53  const edm::ParameterSet& filterPSet = conf.getParameter<edm::ParameterSet>("FilterPSet");
54  std::string filterName = filterPSet.getParameter<std::string>("ComponentName");
55  theFilter = PixelTrackFilterFactory::get()->create( filterName, filterPSet, iC);
56 
57  // The name of the seed producer
58  seedProducer = conf.getParameter<edm::InputTag>("SeedProducer");
59  seedProducerToken = consumes<TrajectorySeedCollection>(seedProducer);
60 
61 }
T getParameter(std::string const &) const
edm::InputTag seedProducer
TrackingRegionProducer * theRegionProducer
edm::EDGetTokenT< TrajectorySeedCollection > seedProducerToken
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const PixelTrackFilter * theFilter
const PixelFitter * theFitter
T get(const Candidate &c)
Definition: component.h:55
PixelTracksProducer::~PixelTracksProducer ( )

Definition at line 65 of file PixelTracksProducer.cc.

References theFilter, theFitter, and theRegionProducer.

65  {
66 
67  delete theFilter;
68  delete theFitter;
69  delete theRegionProducer;
70 
71 }
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 76 of file PixelTracksProducer.cc.

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

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

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

Referenced by PixelTracksProducer().

edm::EDGetTokenT<TrajectorySeedCollection> PixelTracksProducer::seedProducerToken
private

Definition at line 38 of file PixelTracksProducer.h.

Referenced by PixelTracksProducer(), and produce().

const PixelTrackFilter* PixelTracksProducer::theFilter
private

Definition at line 34 of file PixelTracksProducer.h.

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

const PixelFitter* PixelTracksProducer::theFitter
private

Definition at line 33 of file PixelTracksProducer.h.

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

TrackingRegionProducer* PixelTracksProducer::theRegionProducer
private

Definition at line 35 of file PixelTracksProducer.h.

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