CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TrackCandidateProducer Class Reference
Inheritance diagram for TrackCandidateProducer:
edm::stream::EDProducer<>

Public Member Functions

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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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
 

Detailed Description

Definition at line 42 of file TrackCandidateProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 63 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.

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

Definition at line 83 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(), DetachedQuadStep_cff::hitMasks, hitMasksToken, hitSplitter, TrackerGeometry::idToDet(), edm::EDGetTokenT< T >::isUninitialized(), TrajectoryStateOnSurface::isValid(), edm::HandleBase::isValid(), HLT_2018_cff::magneticField, SeedMatcher::matchRecHitCombinations(), maxSeedMatchEstimator, eostools::move(), TrajectorySeed::nHits(), convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), edm::ESHandle< T >::product(), Propagator::propagate(), TrackCandidateProducer_cfi::propagator, propagatorLabel, edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), TrackCandidateProducer_cfi::recHitCombinations, recHitCombinationsToken, TrajectorySeed::recHits(), rejectOverlaps, FastTrackerRecHit::sameId(), SurveyInfoScenario_cff::seed, seedToken, fastTrackingUtilities::setRecHitCombinationIndex(), TrackCandidateProducer_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().

83  {
84  // get records
86  es.get<IdealMagneticFieldRecord>().get(magneticField);
87 
88  edm::ESHandle<TrackerGeometry> trackerGeometry;
89  es.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
90 
91  edm::ESHandle<TrackerTopology> trackerTopology;
92  es.get<TrackerTopologyRcd>().get(trackerTopology);
93 
95  es.get<TrackingComponentsRecord>().get(propagatorLabel, propagator);
96 
97  // get products
99  e.getByToken(seedToken, seeds);
100 
102  e.getByToken(recHitCombinationsToken, recHitCombinations);
103 
105  e.getByToken(simTrackToken, simTracks);
106 
109  e.getByToken(hitMasksToken, hitMasks);
110  }
111 
112  // output collection
113  std::unique_ptr<TrackCandidateCollection> output(new TrackCandidateCollection);
114 
115  // loop over the seeds
116  for (unsigned seedIndex = 0; seedIndex < seeds->size(); ++seedIndex) {
117  const TrajectorySeed seed = (*seeds)[seedIndex];
118  std::vector<int32_t> recHitCombinationIndices;
119 
120  // match hitless seeds to simTracks and find corresponding recHitCombination
121  if (seed.nHits() == 0) {
122  recHitCombinationIndices = SeedMatcher::matchRecHitCombinations(
123  seed, *recHitCombinations, *simTracks, maxSeedMatchEstimator, *propagator, *magneticField, *trackerGeometry);
124  }
125  // for normal seeds, retrieve the corresponding recHitCombination from the seed hits
126  else {
128  recHitCombinationIndices.push_back(icomb);
129  }
130 
131  // loop over the matched recHitCombinations
132  for (auto icomb : recHitCombinationIndices) {
133  if (icomb < 0 || unsigned(icomb) >= recHitCombinations->size()) {
134  throw cms::Exception("TrackCandidateProducer")
135  << " found seed with recHitCombination out or range: " << icomb << std::endl;
136  }
137  const FastTrackerRecHitCombination& recHitCombination = (*recHitCombinations)[icomb];
138 
139  // container for select hits
140  std::vector<const FastTrackerRecHit*> selectedRecHits;
141 
142  // add the seed hits
143  TrajectorySeed::range seedHitRange = seed.recHits(); //Hits in a seed
144  for (TrajectorySeed::const_iterator ihit = seedHitRange.first; ihit != seedHitRange.second; ++ihit) {
145  selectedRecHits.push_back(static_cast<const FastTrackerRecHit*>(&*ihit));
146  }
147 
148  // prepare to skip seed hits
149  const FastTrackerRecHit* lastHitToSkip = nullptr;
150  if (!selectedRecHits.empty()) {
151  lastHitToSkip = selectedRecHits.back();
152  }
153 
154  // inOut or outIn tracking ?
155  bool hitsAlongMomentum = (seed.direction() == alongMomentum);
156 
157  // add hits from combination to hit selection
158  for (unsigned hitIndex = hitsAlongMomentum ? 0 : recHitCombination.size() - 1;
159  hitIndex < recHitCombination.size();
160  hitsAlongMomentum ? ++hitIndex : --hitIndex) {
161  const FastTrackerRecHit* selectedRecHit = recHitCombination[hitIndex].get();
162 
163  // skip seed hits
164  if (lastHitToSkip) {
165  if (lastHitToSkip->sameId(selectedRecHit)) {
166  lastHitToSkip = nullptr;
167  }
168  continue;
169  }
170 
171  // apply hit masking
172  if (hitMasks.isValid() && fastTrackingUtilities::hitIsMasked(selectedRecHit, *hitMasks)) {
173  continue;
174  }
175 
176  // if overlap rejection is not switched on, accept all hits
177  // always accept the first hit
178  // also accept a hit if it is not on the layer of the previous hit
179  if (!rejectOverlaps || selectedRecHits.empty() ||
180  (TrackingLayer::createFromDetId(selectedRecHits.back()->geographicalId(), *trackerTopology.product()) !=
181  TrackingLayer::createFromDetId(selectedRecHit->geographicalId(), *trackerTopology.product()))) {
182  selectedRecHits.push_back(selectedRecHit);
183  }
184  // else:
185  // overlap rejection is switched on
186  // the hit is on the same layer as the previous hit
187  // accept the one with smallest error
188  else if (fastTrackingUtilities::hitLocalError(selectedRecHit) <
189  fastTrackingUtilities::hitLocalError(selectedRecHits.back())) {
190  selectedRecHits.back() = selectedRecHit;
191  }
192  }
193 
194  // split hits / store copies for the track candidate
195  edm::OwnVector<TrackingRecHit> hitsForTrackCandidate;
196  for (unsigned index = 0; index < selectedRecHits.size(); ++index) {
197  if (splitHits) {
198  // add split hits to splitSelectedRecHits
199  hitSplitter.split(*selectedRecHits[index], hitsForTrackCandidate, hitsAlongMomentum);
200  } else {
201  hitsForTrackCandidate.push_back(selectedRecHits[index]->clone());
202  }
203  }
204 
205  // set the recHitCombinationIndex
206  fastTrackingUtilities::setRecHitCombinationIndex(hitsForTrackCandidate, icomb);
207 
208  // create track candidate state
209  // 1. get seed state (defined on the surface of the most outer hit)
210  DetId seedDetId(seed.startingState().detId());
211  const GeomDet* gdet = trackerGeometry->idToDet(seedDetId);
212  TrajectoryStateOnSurface seedTSOS =
213  trajectoryStateTransform::transientState(seed.startingState(), &(gdet->surface()), magneticField.product());
214  // 2. backPropagate the seedState to the surfuce of the most inner hit
215  const GeomDet* initialLayer = trackerGeometry->idToDet(hitsForTrackCandidate.front().geographicalId());
216  const TrajectoryStateOnSurface initialTSOS = propagator->propagate(seedTSOS, initialLayer->surface());
217  // 3. check validity and transform
218  if (!initialTSOS.isValid())
219  continue;
221  initialTSOS, hitsForTrackCandidate.front().geographicalId().rawId());
222 
223  // add track candidate to output collection
224  output->push_back(
225  TrackCandidate(hitsForTrackCandidate, seed, PTSOD, edm::RefToBase<TrajectorySeed>(seeds, seedIndex)));
226  }
227  }
228 
229  // Save the track candidates
230  e.put(std::move(output));
231 }
PropagationDirection direction() const
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
std::pair< const_iterator, const_iterator > range
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:131
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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)
Definition: TrackingLayer.cc:9
std::vector< TrackCandidate > TrackCandidateCollection
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
FastTrackerRecHitSplitter hitSplitter
void push_back(D *&d)
Definition: OwnVector.h:326
const SurfaceType & surface() const
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
recHitContainer::const_iterator const_iterator
unsigned int detId() const
bool isValid() const
Definition: HandleBase.h:70
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:17
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)
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:50
unsigned int nHits() const
double hitLocalError(const TrackingRecHit *hit)
T get() const
Definition: EventSetup.h:73
const TrackerGeomDet * idToDet(DetId) const override
bool isUninitialized() const
Definition: EDGetToken.h:70
DetId geographicalId() const
T const * product() const
Definition: ESHandle.h:86
reference front()
Definition: OwnVector.h:459
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 52 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

FastTrackerRecHitSplitter TrackCandidateProducer::hitSplitter
private

Definition at line 59 of file TrackCandidateProducer.cc.

Referenced by produce().

double TrackCandidateProducer::maxSeedMatchEstimator
private

Definition at line 60 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

std::string TrackCandidateProducer::propagatorLabel
private

Definition at line 54 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 51 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::rejectOverlaps
private

Definition at line 57 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 50 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 53 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

bool TrackCandidateProducer::splitHits
private

Definition at line 58 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().