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
TrackCandidateProducer Class Reference

#include <TrackCandidateProducer.h>

Inheritance diagram for TrackCandidateProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &e, const edm::EventSetup &es) override
 
 TrackCandidateProducer (const edm::ParameterSet &conf)
 
virtual ~TrackCandidateProducer ()
 
- 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

bool hitMasks_exists
 
edm::EDGetTokenT< std::vector
< bool > > 
hitMasksToken
 
FastTrackerRecHitSplitter hitSplitter
 
unsigned int maxNumberOfCrossedLayers
 
double maxSeedMatchEstimator
 
unsigned int minNumberOfCrossedLayers
 
std::string propagatorLabel
 
edm::EDGetTokenT
< FastTrackerRecHitCombinationCollection
recHitCombinationsToken
 
bool rejectOverlaps
 
edm::EDGetTokenT< edm::View
< TrajectorySeed > > 
seedToken
 
edm::EDGetTokenT
< edm::SimTrackContainer
simTrackToken
 
edm::EDGetTokenT
< edm::SimVertexContainer
simVertexToken
 
bool splitHits
 

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 18 of file TrackCandidateProducer.h.

Constructor & Destructor Documentation

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

Definition at line 44 of file TrackCandidateProducer.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hitMasks_exists, hitMasksToken, maxSeedMatchEstimator, minNumberOfCrossedLayers, propagatorLabel, recHitCombinationsToken, rejectOverlaps, seedToken, simTrackToken, simVertexToken, splitHits, and AlCaHLTBitMon_QueryRunRegistry::string.

45  : hitSplitter()
46 {
47  // products
48  produces<TrackCandidateCollection>();
49 
50  // general parameters
51  minNumberOfCrossedLayers = conf.getParameter<unsigned int>("MinNumberOfCrossedLayers");
52  rejectOverlaps = conf.getParameter<bool>("OverlapCleaning");
53  splitHits = conf.getParameter<bool>("SplitHits");
54 
55  // input tags, labels, tokens
56  hitMasks_exists = conf.exists("hitMasks");
57  if (hitMasks_exists){
58  hitMasksToken = consumes<std::vector<bool> >(conf.getParameter<edm::InputTag>("hitMasks"));
59  }
60 
61  edm::InputTag simTrackLabel = conf.getParameter<edm::InputTag>("simTracks");
62  simVertexToken = consumes<edm::SimVertexContainer>(simTrackLabel);
63  simTrackToken = consumes<edm::SimTrackContainer>(simTrackLabel);
64 
65  edm::InputTag seedLabel = conf.getParameter<edm::InputTag>("src");
66  seedToken = consumes<edm::View<TrajectorySeed> >(seedLabel);
67 
68  edm::InputTag recHitCombinationsLabel = conf.getParameter<edm::InputTag>("recHitCombinations");
69  recHitCombinationsToken = consumes<FastTrackerRecHitCombinationCollection>(recHitCombinationsLabel);
70 
71  propagatorLabel = conf.getParameter<std::string>("propagator");
72 
73  maxSeedMatchEstimator = conf.getUntrackedParameter<double>("maxSeedMatchEstimator",0);
74 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
edm::EDGetTokenT< edm::SimVertexContainer > simVertexToken
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
bool exists(std::string const &parameterName) const
checks if a parameter exists
FastTrackerRecHitSplitter hitSplitter
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
virtual TrackCandidateProducer::~TrackCandidateProducer ( )
inlinevirtual

Definition at line 24 of file TrackCandidateProducer.h.

24 {;}

Member Function Documentation

void TrackCandidateProducer::produce ( edm::Event e,
const edm::EventSetup es 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 77 of file TrackCandidateProducer.cc.

References clone(), PTrajectoryStateOnDet::detId(), TrajectorySeed::direction(), Exception, edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByToken(), fastTrackingHelper::getRecHitCombinationIndex(), BaseTrackerRecHit::hit(), TrajectorySeedHitCandidate::hit(), hitMasks_exists, hitMasksToken, hitSplitter, cmsHarvester::index, TrajectoryStateOnSurface::isValid(), TrajectorySeedHitCandidate::layerNumber(), TrajectorySeedHitCandidate::localError(), HLT_FULL_cff::magneticField, SeedMatcher::matchRecHitCombinations(), maxSeedMatchEstimator, TrajectorySeed::nHits(), oppositeToMomentum, convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), HLT_FULL_cff::propagator, propagatorLabel, edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), recHitCombinationsToken, TrajectorySeed::recHits(), rejectOverlaps, FastTrackerRecHit::sameId(), fileCollector::seed, seedToken, fastTrackingHelper::setRecHitCombinationIndex(), simTrackToken, simVertexToken, FastTrackerRecHitSplitter::split(), splitHits, TrajectorySeed::startingState(), TrajectorySeedHitCandidate::subDetId(), TrajectoryStateOnSurface::surface(), and trajectoryStateTransform::transientState().

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

77  {
78 
79  // get services
81  es.get<IdealMagneticFieldRecord>().get(magneticField);
82 
83  edm::ESHandle<TrackerGeometry> trackerGeometry;
84  es.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
85 
86  edm::ESHandle<TrackerTopology> trackerTopology;
87  es.get<TrackerTopologyRcd>().get(trackerTopology);
88 
90  es.get<TrackingComponentsRecord>().get(propagatorLabel,propagator);
91  // Propagator* thePropagator = propagator.product()->clone();
92 
93  // get products
95  e.getByToken(seedToken,seeds);
96 
98  e.getByToken(recHitCombinationsToken, recHitCombinations);
99 
101  e.getByToken(simVertexToken,simVertices);
102 
104  e.getByToken(simTrackToken,simTracks);
105 
106  // the hits to be skipped
107  std::unique_ptr<HitMaskHelper> hitMaskHelper;
108  if (hitMasks_exists == true){
110  e.getByToken(hitMasksToken,hitMasks);
111  hitMaskHelper.reset(new HitMaskHelper(hitMasks.product()));
112  }
113 
114  // output collection
115  std::auto_ptr<TrackCandidateCollection> output(new TrackCandidateCollection);
116 
117  // loop over the seeds
118  for (unsigned seednr = 0; seednr < seeds->size(); ++seednr){
119 
120 
121  const TrajectorySeed seed = (*seeds)[seednr];
122  std::vector<int32_t> recHitCombinationIndices;
123  if(seed.nHits()==0){
124  recHitCombinationIndices = SeedMatcher::matchRecHitCombinations(
125  seed,
126  *recHitCombinations,
127  *simTracks,
129  *propagator,
130  *magneticField,
131  *trackerGeometry);
132  }
133  else
134  {
135 
136  // Get the combination of hits that produced the seed
137  int32_t icomb = fastTrackingHelper::getRecHitCombinationIndex(seed);
138  recHitCombinationIndices.push_back(icomb);
139  }
140  for(auto icomb : recHitCombinationIndices)
141  {
142  if(icomb < 0 || unsigned(icomb) >= recHitCombinations->size()){
143  throw cms::Exception("TrackCandidateProducer") << " found seed with recHitCombination out or range: " << icomb << std::endl;
144  }
145  const FastTrackerRecHitCombination & recHitCombination = (*recHitCombinations)[icomb];
146 
147  // select hits, temporarily store as TrajectorySeedHitCandidates
148  std::vector<TrajectorySeedHitCandidate> recHitCandidates;
149  TrajectorySeedHitCandidate recHitCandidate;
150  TrajectorySeed::range seedHitRange = seed.recHits();//Hits in a seed
151  for (TrajectorySeed::const_iterator ihit = seedHitRange.first; ihit != seedHitRange.second; ++ihit) {
153  trackerGeometry.product(),trackerTopology.product());
154  recHitCandidates.push_back(seedHit);
155  }
156  bool passedLastSeedHit = false;
157 
158  for (const auto & _hit : recHitCombination) {
159  TrajectorySeedHitCandidate currentTrackerHit=TrajectorySeedHitCandidate(_hit.get(),trackerGeometry.product(),trackerTopology.product());
160  if(seed.nHits()==0)passedLastSeedHit=true;
161 
162  if(!passedLastSeedHit)
163  {
164  const FastTrackerRecHit * lastSeedHit = recHitCandidates.back().hit();
165  if(seed.nHits()==0||lastSeedHit->sameId(currentTrackerHit.hit()))
166  {
167  passedLastSeedHit=true;
168  }
169  continue;
170  }
171 
172  // apply hit masking
173  if(hitMaskHelper
174  && hitMaskHelper->mask(_hit.get())){
175  continue;
176  }
177 
178  recHitCandidate = TrajectorySeedHitCandidate(_hit.get(),trackerGeometry.product(),trackerTopology.product());
179  // hit selection
180  // - always select first hit
181  if( recHitCandidates.size() == 0 ) {
182  recHitCandidates.push_back(recHitCandidate);
183  }
184  // - in case of *no* verlap rejection: select all hits
185  else if( !rejectOverlaps) {
186  recHitCandidates.push_back(recHitCandidate);
187  }
188  // - in case of overlap rejection:
189  // - select hit if it is not on same layer as previous hit
190  else if( recHitCandidate.subDetId() != recHitCandidates.back().subDetId() ||
191  recHitCandidate.layerNumber() != recHitCandidates.back().layerNumber() ) {
192  recHitCandidates.push_back(recHitCandidate);
193  }
194  // - in case of overlap rejection and hit is on same layer as previous hit
195  // - replace previous hit with current hit if it has better precision
196  else if ( recHitCandidate.localError() < recHitCandidates.back().localError() ){
197  recHitCandidates.back() = recHitCandidate;
198 
199  }
200  }
201 
202  // order hits along the seed direction
203  bool oiSeed = seed.direction()==oppositeToMomentum;
204  if (oiSeed)
205  {
206  std::reverse(recHitCandidates.begin(),recHitCandidates.end());
207  }
208 
209  // Convert TrajectorySeedHitCandidate to TrackingRecHit and split hits
210  edm::OwnVector<TrackingRecHit> trackRecHits;
211  for ( unsigned index = 0; index<recHitCandidates.size(); ++index ) {
212  if(splitHits){
213  hitSplitter.split(*recHitCandidates[index].hit(),trackRecHits,oiSeed);
214  }
215  else {
216  trackRecHits.push_back(recHitCandidates[index].hit()->clone());
217  }
218  }
219 
220 
221  // set the recHitCombinationIndex
223 
224  // create track candidate state
225  // - get seed state
226  DetId seedDetId(seed.startingState().detId());
227  const GeomDet* gdet = trackerGeometry->idToDet(seedDetId);
228  TrajectoryStateOnSurface seedTSOS = trajectoryStateTransform::transientState(seed.startingState(), &(gdet->surface()),magneticField.product());
229  // - backPropagate seedState to first recHit
230  const GeomDet* initialLayer = trackerGeometry->idToDet(trackRecHits.front().geographicalId());
231  const TrajectoryStateOnSurface initialTSOS = propagator->propagate(seedTSOS,initialLayer->surface()) ;
232  // - check validity and transform
233  if (!initialTSOS.isValid()) continue;
235  // add track candidate to output collection
236  output->push_back(TrackCandidate(trackRecHits,seed,PTSOD,edm::RefToBase<TrajectorySeed>(seeds,seednr)));
237 
238  }
239  }
240 
241  // Save the track candidates
242  e.put(output);
243 
244 }
PropagationDirection direction() const
tuple propagator
static std::vector< int > matchRecHitCombinations(const TrajectorySeed &seed, const FastTrackerRecHitCombinationCollection &recHitCombinationCollection, const std::vector< SimTrack > &simTrackCollection, double maxMatchEstimator, const Propagator &propagator, const MagneticField &magneticField, const TrackerGeometry &trackerGeometry)
Definition: SeedMatcher.cc:14
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< edm::SimVertexContainer > simVertexToken
bool sameId(const FastTrackerRecHit *other, size_t i=0, size_t j=0) const
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
std::vector< TrackCandidate > TrackCandidateCollection
void split(const FastTrackerRecHit &hitIn, edm::OwnVector< TrackingRecHit > &hitsOut, bool reverseHits) const
BaseTrackerRecHit const * hit() const final
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
tuple magneticField
FastTrackerRecHitSplitter hitSplitter
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void push_back(D *&d)
Definition: OwnVector.h:290
const SurfaceType & surface() const
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
recHitContainer::const_iterator const_iterator
std::pair< const_iterator, const_iterator > range
unsigned int detId() const
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
Definition: DetId.h:18
std::vector< FastTrackerRecHitRef > FastTrackerRecHitCombination
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
range recHits() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
unsigned int nHits() const
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
const FastTrackerRecHit * hit() const
The Hit itself.
unsigned int layerNumber() const
The Layer Number.
DetId geographicalId() const
int32_t getRecHitCombinationIndex(const T &object)
unsigned int subDetId() const
The subdet Id.
reference front()
Definition: OwnVector.h:429

Member Data Documentation

bool TrackCandidateProducer::hitMasks_exists
private

Definition at line 35 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<std::vector<bool> > TrackCandidateProducer::hitMasksToken
private

Definition at line 44 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

FastTrackerRecHitSplitter TrackCandidateProducer::hitSplitter
private

Definition at line 37 of file TrackCandidateProducer.h.

Referenced by produce().

unsigned int TrackCandidateProducer::maxNumberOfCrossedLayers
private

Definition at line 31 of file TrackCandidateProducer.h.

double TrackCandidateProducer::maxSeedMatchEstimator
private

Definition at line 46 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

unsigned int TrackCandidateProducer::minNumberOfCrossedLayers
private

Definition at line 30 of file TrackCandidateProducer.h.

Referenced by TrackCandidateProducer().

std::string TrackCandidateProducer::propagatorLabel
private

Definition at line 45 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<FastTrackerRecHitCombinationCollection> TrackCandidateProducer::recHitCombinationsToken
private

Definition at line 41 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::rejectOverlaps
private

Definition at line 33 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<edm::View<TrajectorySeed> > TrackCandidateProducer::seedToken
private

Definition at line 40 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<edm::SimTrackContainer> TrackCandidateProducer::simTrackToken
private

Definition at line 43 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

edm::EDGetTokenT<edm::SimVertexContainer> TrackCandidateProducer::simVertexToken
private

Definition at line 42 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::splitHits
private

Definition at line 34 of file TrackCandidateProducer.h.

Referenced by produce(), and TrackCandidateProducer().