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 &, const edm::EventSetup &) override
 
 TrackCandidateProducer (const edm::ParameterSet &conf)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

edm::EDGetTokenT< std::vector< bool > > hitMasksToken
 
FastTrackerRecHitSplitter hitSplitter
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldESToken_
 
double maxSeedMatchEstimator
 
const edm::ESGetToken< Propagator, TrackingComponentsRecordpropagatorESToken_
 
std::string propagatorLabel
 
edm::EDGetTokenT< FastTrackerRecHitCombinationCollectionrecHitCombinationsToken
 
bool rejectOverlaps
 
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
 
edm::EDGetTokenT< edm::SimTrackContainersimTrackToken
 
bool splitHits
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeometryESToken_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtrackerTopologyESToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 42 of file TrackCandidateProducer.cc.

Constructor & Destructor Documentation

◆ TrackCandidateProducer()

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

Definition at line 67 of file TrackCandidateProducer.cc.

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

68  : propagatorLabel(conf.getParameter<std::string>("propagator")),
73  hitSplitter() {
74  // produces
75  produces<TrackCandidateCollection>();
76 
77  // consumes
78  if (conf.exists("hitMasks")) {
79  hitMasksToken = consumes<std::vector<bool> >(conf.getParameter<edm::InputTag>("hitMasks"));
80  }
81  seedToken = consumes<edm::View<TrajectorySeed> >(conf.getParameter<edm::InputTag>("src"));
83  consumes<FastTrackerRecHitCombinationCollection>(conf.getParameter<edm::InputTag>("recHitCombinations"));
84  simTrackToken = consumes<edm::SimTrackContainer>(conf.getParameter<edm::InputTag>("simTracks"));
85 
86  // other parameters
87  maxSeedMatchEstimator = conf.getUntrackedParameter<double>("maxSeedMatchEstimator", 0);
88  rejectOverlaps = conf.getParameter<bool>("OverlapCleaning");
89  splitHits = conf.getParameter<bool>("SplitHits");
90 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryESToken_
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
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldESToken_
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorESToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyESToken_

Member Function Documentation

◆ produce()

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

Definition at line 92 of file TrackCandidateProducer.cc.

References alongMomentum, clone(), TrackingLayer::createFromDetId(), MillePedeFileConverter_cfg::e, Exception, edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::EventSetup::getData(), fastTrackingUtilities::getRecHitCombinationIndex(), fastTrackingUtilities::hitIsMasked(), fastTrackingUtilities::hitLocalError(), DetachedQuadStep_cff::hitMasks, hitMasksToken, hitSplitter, edm::EDGetTokenT< T >::isUninitialized(), TrajectoryStateOnSurface::isValid(), HLT_2024v14_cff::magneticField, magneticFieldESToken_, SeedMatcher::matchRecHitCombinations(), maxSeedMatchEstimator, eostools::move(), convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), TrackCandidateProducer_cfi::propagator, propagatorESToken_, edm::OwnVector< T, P >::push_back(), DetId::rawId(), rpcPointValidation_cfi::recHit, TrackCandidateProducer_cfi::recHitCombinations, recHitCombinationsToken, rejectOverlaps, FastTrackerRecHit::sameId(), fileCollector::seed, HLT_2024v14_cff::seeds, seedToken, fastTrackingUtilities::setRecHitCombinationIndex(), TrackCandidateProducer_cfi::simTracks, simTrackToken, FastTrackerRecHitSplitter::split(), splitHits, GeomDet::surface(), trackerGeometryESToken_, trackerTopologyESToken_, and trajectoryStateTransform::transientState().

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

Member Data Documentation

◆ hitMasksToken

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

Definition at line 52 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ hitSplitter

FastTrackerRecHitSplitter TrackCandidateProducer::hitSplitter
private

Definition at line 63 of file TrackCandidateProducer.cc.

Referenced by produce().

◆ magneticFieldESToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> TrackCandidateProducer::magneticFieldESToken_
private

Definition at line 55 of file TrackCandidateProducer.cc.

Referenced by produce().

◆ maxSeedMatchEstimator

double TrackCandidateProducer::maxSeedMatchEstimator
private

Definition at line 64 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ propagatorESToken_

const edm::ESGetToken<Propagator, TrackingComponentsRecord> TrackCandidateProducer::propagatorESToken_
private

Definition at line 58 of file TrackCandidateProducer.cc.

Referenced by produce().

◆ propagatorLabel

std::string TrackCandidateProducer::propagatorLabel
private

Definition at line 54 of file TrackCandidateProducer.cc.

◆ recHitCombinationsToken

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

Definition at line 51 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ rejectOverlaps

bool TrackCandidateProducer::rejectOverlaps
private

Definition at line 61 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ seedToken

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

Definition at line 50 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ simTrackToken

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

Definition at line 53 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ splitHits

bool TrackCandidateProducer::splitHits
private

Definition at line 62 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ trackerGeometryESToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> TrackCandidateProducer::trackerGeometryESToken_
private

Definition at line 56 of file TrackCandidateProducer.cc.

Referenced by produce().

◆ trackerTopologyESToken_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> TrackCandidateProducer::trackerTopologyESToken_
private

Definition at line 57 of file TrackCandidateProducer.cc.

Referenced by produce().