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::TrackCandidateProducer ( const edm::ParameterSet conf)
explicit

Definition at line 63 of file TrackCandidateProducer.cc.

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 }

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

Member Function Documentation

◆ produce()

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

Definition at line 83 of file TrackCandidateProducer.cc.

83  {
84  // get records
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 
96 
97  // get products
99  e.getByToken(seedToken, seeds);
100 
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(
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 }

References alongMomentum, clone(), TrackingLayer::createFromDetId(), MillePedeFileConverter_cfg::e, Exception, edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), get, fastTrackingUtilities::getRecHitCombinationIndex(), fastTrackingUtilities::hitIsMasked(), fastTrackingUtilities::hitLocalError(), DetachedQuadStep_cff::hitMasks, hitMasksToken, hitSplitter, TrackerGeometry::idToDet(), edm::EDGetTokenT< T >::isUninitialized(), TrajectoryStateOnSurface::isValid(), HLT_2018_cff::magneticField, SeedMatcher::matchRecHitCombinations(), maxSeedMatchEstimator, eostools::move(), convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), edm::ESHandle< T >::product(), TrackCandidateProducer_cfi::propagator, propagatorLabel, edm::OwnVector< T, P >::push_back(), DetId::rawId(), TrackCandidateProducer_cfi::recHitCombinations, recHitCombinationsToken, rejectOverlaps, FastTrackerRecHit::sameId(), SurveyInfoScenario_cff::seed, InitialStep_cff::seeds, seedToken, fastTrackingUtilities::setRecHitCombinationIndex(), TrackCandidateProducer_cfi::simTracks, simTrackToken, FastTrackerRecHitSplitter::split(), splitHits, TrajectoryStateOnSurface::surface(), and trajectoryStateTransform::transientState().

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 59 of file TrackCandidateProducer.cc.

Referenced by produce().

◆ maxSeedMatchEstimator

double TrackCandidateProducer::maxSeedMatchEstimator
private

Definition at line 60 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ propagatorLabel

std::string TrackCandidateProducer::propagatorLabel
private

Definition at line 54 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

◆ 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 57 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 58 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
fastTrackingUtilities::hitLocalError
double hitLocalError(const TrackingRecHit *hit)
Definition: FastTrackingUtilities.h:48
GeomDet
Definition: GeomDet.h:27
DetachedQuadStep_cff.hitMasks
hitMasks
Definition: DetachedQuadStep_cff.py:99
TrackingLayer::createFromDetId
static TrackingLayer createFromDetId(const DetId &detId, const TrackerTopology &trackerTopology)
Definition: TrackingLayer.cc:9
TrajectorySeed::range
std::pair< const_iterator, const_iterator > range
Definition: TrajectorySeed.h:21
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
fastTrackingUtilities::setRecHitCombinationIndex
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
Definition: FastTrackingUtilities.h:11
FastTrackerRecHit::sameId
bool sameId(const FastTrackerRecHit *other, size_t i=0, size_t j=0) const
Definition: FastTrackerRecHit.h:136
fastTrackingUtilities::hitIsMasked
bool hitIsMasked(const FastTrackerRecHit *hit, const std::vector< bool > &hitMasks)
Definition: FastTrackingUtilities.h:39
SeedMatcher::matchRecHitCombinations
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
TrajectorySeed::const_iterator
recHitContainer::const_iterator const_iterator
Definition: TrajectorySeed.h:20
TrackCandidateProducer_cfi.simTracks
simTracks
Definition: TrackCandidateProducer_cfi.py:15
FastTrackerRecHit
Definition: FastTrackerRecHit.h:40
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
TrackCandidateProducer::simTrackToken
edm::EDGetTokenT< edm::SimTrackContainer > simTrackToken
Definition: TrackCandidateProducer.cc:53
edm::Handle
Definition: AssociativeIterator.h:50
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
TrackCandidateProducer::seedToken
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
Definition: TrackCandidateProducer.cc:50
TrackCandidateProducer::splitHits
bool splitHits
Definition: TrackCandidateProducer.cc:58
TrackCandidateProducer::rejectOverlaps
bool rejectOverlaps
Definition: TrackCandidateProducer.cc:57
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
TrackCandidateProducer::hitSplitter
FastTrackerRecHitSplitter hitSplitter
Definition: TrackCandidateProducer.cc:59
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
fastTrackingUtilities::getRecHitCombinationIndex
int32_t getRecHitCombinationIndex(const T &object)
Definition: FastTrackingUtilities.h:22
edm::EDGetTokenT::isUninitialized
bool isUninitialized() const
Definition: EDGetToken.h:70
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< MagneticField >
TrackCandidateProducer::maxSeedMatchEstimator
double maxSeedMatchEstimator
Definition: TrackCandidateProducer.cc:60
FastTrackerRecHitSplitter::split
void split(const FastTrackerRecHit &hitIn, edm::OwnVector< TrackingRecHit > &hitsOut, bool alongMomentum) const
Definition: FastTrackerRecHitSplitter.h:17
edm::OwnVector::front
reference front()
Definition: OwnVector.h:459
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:232
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
TrackCandidateCollection
std::vector< TrackCandidate > TrackCandidateCollection
Definition: TrackCandidateCollection.h:7
TrackCandidate
Definition: TrackCandidate.h:23
TrackCandidateProducer::recHitCombinationsToken
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
Definition: TrackCandidateProducer.cc:51
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrackCandidateProducer_cfi.recHitCombinations
recHitCombinations
Definition: TrackCandidateProducer_cfi.py:5
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TrackCandidateProducer::hitMasksToken
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
Definition: TrackCandidateProducer.cc:52
FastTrackerRecHitCombination
std::vector< FastTrackerRecHitRef > FastTrackerRecHitCombination
Definition: FastTrackerRecHitCollection.h:11
Exception
Definition: hltDiff.cc:246
TrajectorySeed
Definition: TrajectorySeed.h:17
edm::RefToBase< TrajectorySeed >
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
TrackCandidateProducer::propagatorLabel
std::string propagatorLabel
Definition: TrackCandidateProducer.cc:54
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
edm::InputTag
Definition: InputTag.h:15
alongMomentum
Definition: PropagationDirection.h:4
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
edm::OwnVector< TrackingRecHit >
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12