CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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,
IdealMagneticFieldRecord
magneticFieldESToken_
 
double maxSeedMatchEstimator
 
const edm::ESGetToken
< Propagator,
TrackingComponentsRecord
propagatorESToken_
 
std::string propagatorLabel
 
edm::EDGetTokenT
< FastTrackerRecHitCombinationCollection
recHitCombinationsToken
 
bool rejectOverlaps
 
edm::EDGetTokenT< edm::View
< TrajectorySeed > > 
seedToken
 
edm::EDGetTokenT
< edm::SimTrackContainer
simTrackToken
 
bool splitHits
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
trackerGeometryESToken_
 
const edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
trackerTopologyESToken_
 

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 ( 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 }
T getUntrackedParameter(std::string const &, T const &) const
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_
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
edm::EDGetTokenT< std::vector< bool > > hitMasksToken
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorESToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyESToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283

Member Function Documentation

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

Definition at line 92 of file TrackCandidateProducer.cc.

References alongMomentum, clone(), TrackingLayer::createFromDetId(), PTrajectoryStateOnDet::detId(), TrajectorySeed::direction(), Exception, edm::OwnVector< T, P >::front(), TrackingRecHit::geographicalId(), edm::Event::getByToken(), edm::EventSetup::getData(), fastTrackingUtilities::getRecHitCombinationIndex(), fastTrackingUtilities::hitIsMasked(), fastTrackingUtilities::hitLocalError(), LowPtTripletStep_cff::hitMasks, hitMasksToken, hitSplitter, edm::EDGetTokenT< T >::isUninitialized(), TrajectoryStateOnSurface::isValid(), edm::HandleBase::isValid(), HLT_FULL_cff::magneticField, magneticFieldESToken_, SeedMatcher::matchRecHitCombinations(), maxSeedMatchEstimator, eostools::move(), TrajectorySeed::nHits(), convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), HLT_FULL_cff::propagator, propagatorESToken_, edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), recHitCombinationsToken, TrajectorySeed::recHits(), rejectOverlaps, FastTrackerRecHit::sameId(), fileCollector::seed, DetachedQuadStep_cff::seeds, seedToken, fastTrackingUtilities::setRecHitCombinationIndex(), simTrackToken, FastTrackerRecHitSplitter::split(), splitHits, TrajectorySeed::startingState(), 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 
104  e.getByToken(recHitCombinationsToken, recHitCombinations);
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(
125  seed, *recHitCombinations, *simTracks, maxSeedMatchEstimator, propagator, magneticField, trackerGeometry);
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 =
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 }
PropagationDirection direction() const
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
tuple propagator
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:133
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryESToken_
edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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 bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
tuple magneticField
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
FastTrackerRecHitSplitter hitSplitter
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldESToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void push_back(D *&d)
Definition: OwnVector.h:326
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken
def move
Definition: eostools.py:511
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)
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorESToken_
RecHitRange recHits() const
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)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
unsigned int nHits() const
double hitLocalError(const TrackingRecHit *hit)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopologyESToken_
DetId geographicalId() const
reference front()
Definition: OwnVector.h:459

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

Referenced by produce().

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

Definition at line 55 of file TrackCandidateProducer.cc.

Referenced by produce().

double TrackCandidateProducer::maxSeedMatchEstimator
private

Definition at line 64 of file TrackCandidateProducer.cc.

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 58 of file TrackCandidateProducer.cc.

Referenced by produce().

std::string TrackCandidateProducer::propagatorLabel
private

Definition at line 54 of file TrackCandidateProducer.cc.

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

Referenced by produce(), and TrackCandidateProducer().

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

Definition at line 56 of file TrackCandidateProducer.cc.

Referenced by produce().

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

Definition at line 57 of file TrackCandidateProducer.cc.

Referenced by produce().