CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TrackCandidateProducer Class Reference
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)
 
- 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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::EDGetTokenT< std::vector< bool > > hitMasksToken
 
FastTrackerRecHitSplitter hitSplitter
 
double maxSeedMatchEstimator
 
std::string propagatorLabel
 
edm::EDGetTokenT< FastTrackerRecHitCombinationCollectionrecHitCombinationsToken
 
bool rejectOverlaps
 
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
 
edm::EDGetTokenT< edm::SimTrackContainersimTrackToken
 
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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
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 42 of file TrackCandidateProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 66 of file TrackCandidateProducer.cc.

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

67  : hitSplitter()
68 {
69  // produces
70  produces<TrackCandidateCollection>();
71 
72  // consumes
73  if (conf.exists("hitMasks")){
74  hitMasksToken = consumes<std::vector<bool> >(conf.getParameter<edm::InputTag>("hitMasks"));
75  }
76  seedToken = consumes<edm::View<TrajectorySeed> >(conf.getParameter<edm::InputTag>("src"));
77  recHitCombinationsToken = consumes<FastTrackerRecHitCombinationCollection>(conf.getParameter<edm::InputTag>("recHitCombinations"));
78  simTrackToken = consumes<edm::SimTrackContainer>(conf.getParameter<edm::InputTag>("simTracks"));
79 
80  // other parameters
81  maxSeedMatchEstimator = conf.getUntrackedParameter<double>("maxSeedMatchEstimator",0);
82  rejectOverlaps = conf.getParameter<bool>("OverlapCleaning");
83  splitHits = conf.getParameter<bool>("SplitHits");
84  propagatorLabel = conf.getParameter<std::string>("propagator");
85 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
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

Member Function Documentation

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

Definition at line 88 of file TrackCandidateProducer.cc.

References alongMomentum, clone(), TrackingLayer::createFromDetId(), DEFINE_FWK_MODULE, PTrajectoryStateOnDet::detId(), TrajectorySeed::direction(), Exception, edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByToken(), fastTrackingUtilities::getRecHitCombinationIndex(), fastTrackingUtilities::hitIsMasked(), fastTrackingUtilities::hitLocalError(), hitMasksToken, hitSplitter, TrackerGeometry::idToDet(), diffTreeTool::index, edm::EDGetTokenT< T >::isUninitialized(), TrajectoryStateOnSurface::isValid(), edm::HandleBase::isValid(), seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, SeedMatcher::matchRecHitCombinations(), maxSeedMatchEstimator, eostools::move(), TrajectorySeed::nHits(), convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), edm::ESHandle< T >::product(), Propagator::propagate(), PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::propagator, propagatorLabel, edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), recHitCombinationsToken, TrajectorySeed::recHits(), rejectOverlaps, FastTrackerRecHit::sameId(), SurveyInfoScenario_cff::seed, seedToken, fastTrackingUtilities::setRecHitCombinationIndex(), tkConvValidator_cfi::simTracks, simTrackToken, FastTrackerRecHitSplitter::split(), splitHits, TrajectorySeed::startingState(), TrajectoryStateOnSurface::surface(), and trajectoryStateTransform::transientState().

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

88  {
89 
90  // get records
92  es.get<IdealMagneticFieldRecord>().get(magneticField);
93 
94  edm::ESHandle<TrackerGeometry> trackerGeometry;
95  es.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
96 
97  edm::ESHandle<TrackerTopology> trackerTopology;
98  es.get<TrackerTopologyRcd>().get(trackerTopology);
99 
101  es.get<TrackingComponentsRecord>().get(propagatorLabel,propagator);
102 
103  // get products
105  e.getByToken(seedToken,seeds);
106 
108  e.getByToken(recHitCombinationsToken, recHitCombinations);
109 
111  e.getByToken(simTrackToken,simTracks);
112 
115  {
116  e.getByToken(hitMasksToken,hitMasks);
117  }
118 
119  // output collection
120  std::unique_ptr<TrackCandidateCollection> output(new TrackCandidateCollection);
121 
122  // loop over the seeds
123  for (unsigned seedIndex = 0; seedIndex < seeds->size(); ++seedIndex){
124 
125  const TrajectorySeed seed = (*seeds)[seedIndex];
126  std::vector<int32_t> recHitCombinationIndices;
127 
128  // match hitless seeds to simTracks and find corresponding recHitCombination
129  if(seed.nHits()==0){
130  recHitCombinationIndices = SeedMatcher::matchRecHitCombinations(
131  seed,
132  *recHitCombinations,
133  *simTracks,
135  *propagator,
136  *magneticField,
137  *trackerGeometry);
138  }
139  // for normal seeds, retrieve the corresponding recHitCombination from the seed hits
140  else
141  {
143  recHitCombinationIndices.push_back(icomb);
144  }
145 
146  // loop over the matched recHitCombinations
147  for(auto icomb : recHitCombinationIndices)
148  {
149  if(icomb < 0 || unsigned(icomb) >= recHitCombinations->size())
150  {
151  throw cms::Exception("TrackCandidateProducer") << " found seed with recHitCombination out or range: " << icomb << std::endl;
152  }
153  const FastTrackerRecHitCombination & recHitCombination = (*recHitCombinations)[icomb];
154 
155  // container for select hits
156  std::vector<const FastTrackerRecHit *> selectedRecHits;
157 
158  // add the seed hits
159  TrajectorySeed::range seedHitRange = seed.recHits();//Hits in a seed
160  for (TrajectorySeed::const_iterator ihit = seedHitRange.first; ihit != seedHitRange.second; ++ihit)
161  {
162  selectedRecHits.push_back(static_cast<const FastTrackerRecHit*>(&*ihit));
163  }
164 
165  // prepare to skip seed hits
166  const FastTrackerRecHit * lastHitToSkip = 0;
167  if(selectedRecHits.size() > 0)
168  {
169  lastHitToSkip = selectedRecHits.back();
170  }
171 
172  // inOut or outIn tracking ?
173  bool hitsAlongMomentum = (seed.direction()== alongMomentum);
174 
175  // add hits from combination to hit selection
176  for (unsigned hitIndex = hitsAlongMomentum ? 0 : recHitCombination.size() - 1;
177  hitIndex < recHitCombination.size();
178  hitsAlongMomentum ? ++hitIndex : --hitIndex)
179  {
180 
181  const FastTrackerRecHit * selectedRecHit = recHitCombination[hitIndex].get();
182 
183  // skip seed hits
184  if(lastHitToSkip)
185  {
186  if(lastHitToSkip->sameId(selectedRecHit))
187  {
188  lastHitToSkip=0;
189  }
190  continue;
191  }
192 
193  // apply hit masking
194  if(hitMasks.isValid() && fastTrackingUtilities::hitIsMasked(selectedRecHit,*hitMasks))
195  {
196  continue;
197  }
198 
199 
200  // if overlap rejection is not switched on, accept all hits
201  // always accept the first hit
202  // also accept a hit if it is not on the layer of the previous hit
203  if( ! rejectOverlaps
204  || selectedRecHits.size() == 0
205  || ( TrackingLayer::createFromDetId(selectedRecHits.back()->geographicalId(),*trackerTopology.product())
206  != TrackingLayer::createFromDetId(selectedRecHit->geographicalId(),*trackerTopology.product())))
207  {
208  selectedRecHits.push_back(selectedRecHit);
209  }
210  // else:
211  // overlap rejection is switched on
212  // the hit is on the same layer as the previous hit
213  // accept the one with smallest error
214  else if ( fastTrackingUtilities::hitLocalError(selectedRecHit)
215  < fastTrackingUtilities::hitLocalError(selectedRecHits.back()) )
216  {
217  selectedRecHits.back() = selectedRecHit;
218  }
219  }
220 
221  // split hits / store copies for the track candidate
222  edm::OwnVector<TrackingRecHit> hitsForTrackCandidate;
223  for ( unsigned index = 0; index<selectedRecHits.size(); ++index )
224  {
225  if(splitHits)
226  {
227  // add split hits to splitSelectedRecHits
228  hitSplitter.split(*selectedRecHits[index],hitsForTrackCandidate,hitsAlongMomentum);
229  }
230  else
231  {
232  hitsForTrackCandidate.push_back(selectedRecHits[index]->clone());
233  }
234  }
235 
236  // set the recHitCombinationIndex
237  fastTrackingUtilities::setRecHitCombinationIndex(hitsForTrackCandidate,icomb);
238 
239  // create track candidate state
240  // 1. get seed state (defined on the surface of the most outer hit)
241  DetId seedDetId(seed.startingState().detId());
242  const GeomDet* gdet = trackerGeometry->idToDet(seedDetId);
243  TrajectoryStateOnSurface seedTSOS = trajectoryStateTransform::transientState(seed.startingState(), &(gdet->surface()),magneticField.product());
244  // 2. backPropagate the seedState to the surfuce of the most inner hit
245  const GeomDet* initialLayer = trackerGeometry->idToDet(hitsForTrackCandidate.front().geographicalId());
246  const TrajectoryStateOnSurface initialTSOS = propagator->propagate(seedTSOS,initialLayer->surface()) ;
247  // 3. check validity and transform
248  if (!initialTSOS.isValid()) continue;
249  PTrajectoryStateOnDet PTSOD = trajectoryStateTransform::persistentState(initialTSOS,hitsForTrackCandidate.front().geographicalId().rawId());
250 
251  // add track candidate to output collection
252  output->push_back(TrackCandidate(hitsForTrackCandidate,seed,PTSOD,edm::RefToBase<TrajectorySeed>(seeds,seedIndex)));
253  }
254  }
255 
256  // Save the track candidates
257  e.put(std::move(output));
258 
259 }
PropagationDirection direction() const
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
bool sameId(const FastTrackerRecHit *other, size_t i=0, size_t j=0) const
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
static TrackingLayer createFromDetId(const DetId &detId, const TrackerTopology &trackerTopology)
std::vector< TrackCandidate > TrackCandidateCollection
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
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
recHitContainer::const_iterator const_iterator
std::pair< const_iterator, const_iterator > range
unsigned int detId() const
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
bool hitIsMasked(const FastTrackerRecHit *hit, const std::vector< bool > &hitMasks)
int32_t getRecHitCombinationIndex(const T &object)
Definition: DetId.h:18
std::vector< FastTrackerRecHitRef > FastTrackerRecHitCombination
PTrajectoryStateOnDet const & startingState() const
void split(const FastTrackerRecHit &hitIn, edm::OwnVector< TrackingRecHit > &hitsOut, bool alongMomentum) const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
const T & get() const
Definition: EventSetup.h:56
range recHits() const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
unsigned int nHits() const
double hitLocalError(const TrackingRecHit *hit)
bool isUninitialized() const
Definition: EDGetToken.h:73
DetId geographicalId() const
T const * product() const
Definition: ESHandle.h:86
reference front()
Definition: OwnVector.h:423
def move(src, dest)
Definition: eostools.py:510
const TrackerGeomDet * idToDet(DetId) const

Member Data Documentation

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

Definition at line 55 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

FastTrackerRecHitSplitter TrackCandidateProducer::hitSplitter
private

Definition at line 62 of file TrackCandidateProducer.cc.

Referenced by produce().

double TrackCandidateProducer::maxSeedMatchEstimator
private

Definition at line 63 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

std::string TrackCandidateProducer::propagatorLabel
private

Definition at line 57 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 54 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::rejectOverlaps
private

Definition at line 60 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 53 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 56 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::splitHits
private

Definition at line 61 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().