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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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  for (auto const& recHit : seed.recHits()) {
144  selectedRecHits.push_back(static_cast<const FastTrackerRecHit*>(&recHit));
145  }
146 
147  // prepare to skip seed hits
148  const FastTrackerRecHit* lastHitToSkip = nullptr;
149  if (!selectedRecHits.empty()) {
150  lastHitToSkip = selectedRecHits.back();
151  }
152 
153  // inOut or outIn tracking ?
154  bool hitsAlongMomentum = (seed.direction() == alongMomentum);
155 
156  // add hits from combination to hit selection
157  for (unsigned hitIndex = hitsAlongMomentum ? 0 : recHitCombination.size() - 1;
158  hitIndex < recHitCombination.size();
159  hitsAlongMomentum ? ++hitIndex : --hitIndex) {
160  const FastTrackerRecHit* selectedRecHit = recHitCombination[hitIndex].get();
161 
162  // skip seed hits
163  if (lastHitToSkip) {
164  if (lastHitToSkip->sameId(selectedRecHit)) {
165  lastHitToSkip = nullptr;
166  }
167  continue;
168  }
169 
170  // apply hit masking
171  if (hitMasks.isValid() && fastTrackingUtilities::hitIsMasked(selectedRecHit, *hitMasks)) {
172  continue;
173  }
174 
175  // if overlap rejection is not switched on, accept all hits
176  // always accept the first hit
177  // also accept a hit if it is not on the layer of the previous hit
178  if (!rejectOverlaps || selectedRecHits.empty() ||
179  (TrackingLayer::createFromDetId(selectedRecHits.back()->geographicalId(), *trackerTopology.product()) !=
180  TrackingLayer::createFromDetId(selectedRecHit->geographicalId(), *trackerTopology.product()))) {
181  selectedRecHits.push_back(selectedRecHit);
182  }
183  // else:
184  // overlap rejection is switched on
185  // the hit is on the same layer as the previous hit
186  // accept the one with smallest error
187  else if (fastTrackingUtilities::hitLocalError(selectedRecHit) <
188  fastTrackingUtilities::hitLocalError(selectedRecHits.back())) {
189  selectedRecHits.back() = selectedRecHit;
190  }
191  }
192 
193  // split hits / store copies for the track candidate
194  edm::OwnVector<TrackingRecHit> hitsForTrackCandidate;
195  for (unsigned index = 0; index < selectedRecHits.size(); ++index) {
196  if (splitHits) {
197  // add split hits to splitSelectedRecHits
198  hitSplitter.split(*selectedRecHits[index], hitsForTrackCandidate, hitsAlongMomentum);
199  } else {
200  hitsForTrackCandidate.push_back(selectedRecHits[index]->clone());
201  }
202  }
203 
204  // set the recHitCombinationIndex
205  fastTrackingUtilities::setRecHitCombinationIndex(hitsForTrackCandidate, icomb);
206 
207  // create track candidate state
208  // 1. get seed state (defined on the surface of the most outer hit)
209  DetId seedDetId(seed.startingState().detId());
210  const GeomDet* gdet = trackerGeometry->idToDet(seedDetId);
211  TrajectoryStateOnSurface seedTSOS =
212  trajectoryStateTransform::transientState(seed.startingState(), &(gdet->surface()), magneticField.product());
213  // 2. backPropagate the seedState to the surfuce of the most inner hit
214  const GeomDet* initialLayer = trackerGeometry->idToDet(hitsForTrackCandidate.front().geographicalId());
215  const TrajectoryStateOnSurface initialTSOS = propagator->propagate(seedTSOS, initialLayer->surface());
216  // 3. check validity and transform
217  if (!initialTSOS.isValid())
218  continue;
220  initialTSOS, hitsForTrackCandidate.front().geographicalId().rawId());
221 
222  // add track candidate to output collection
223  output->push_back(
224  TrackCandidate(hitsForTrackCandidate, seed, PTSOD, edm::RefToBase<TrajectorySeed>(seeds, seedIndex)));
225  }
226  }
227 
228  // Save the track candidates
229  e.put(std::move(output));
230 }

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_FULL_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(), rpcPointValidation_cfi::recHit, TrackCandidateProducer_cfi::recHitCombinations, recHitCombinationsToken, rejectOverlaps, FastTrackerRecHit::sameId(), fileCollector::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:100
TrackingLayer::createFromDetId
static TrackingLayer createFromDetId(const DetId &detId, const TrackerTopology &trackerTopology)
Definition: TrackingLayer.cc:9
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
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
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
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
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
edm::Handle
Definition: AssociativeIterator.h:50
TrackingRecHit::geographicalId
DetId geographicalId() const
Definition: TrackingRecHit.h:120
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
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
fileCollector.seed
seed
Definition: fileCollector.py:127
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
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
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:231
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
TrackCandidateCollection
std::vector< TrackCandidate > TrackCandidateCollection
Definition: TrackCandidateCollection.h:7
TrackCandidate
Definition: TrackCandidate.h:24
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
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:245
TrajectorySeed
Definition: TrajectorySeed.h:18
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
edm::OwnVector< TrackingRecHit >
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12