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::stream::EDProducer<> edm::stream::EDProducerBase 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::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 37 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.

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

References theFilter, theFitter, and theRegionProducer.

69  {
70 
71  delete theFilter;
72  delete theFitter;
73  delete theRegionProducer;
74 
75 }
TrackingRegionProducer * theRegionProducer
const PixelTrackFilter * theFilter
const PixelFitter * theFitter

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 80 of file PixelTracksProducer.cc.

References reco::TrackBase::appendHitPattern(), clone(), edm::EventSetup::get(), edm::Event::getByToken(), i, relval_2017::k, nTracks(), edm::Event::put(), HLT_25ns10e33_v2_cff::recHits, HLT_25ns10e33_v2_cff::region, TrackingRegionProducer::regions(), HLT_25ns10e33_v2_cff::Regions, PixelFitter::run(), seedProducerToken, reco::TrackExtraBase::setHits(), theFilter, theFitter, theRegionProducer, and testEve_cfg::tracks.

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

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

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().