CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
MkFitOutputConverter Class Reference
Inheritance diagram for MkFitOutputConverter:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MkFitOutputConverter (edm::ParameterSet const &iConfig)
 
 ~MkFitOutputConverter () override=default
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

std::pair< TrajectoryStateOnSurface, const GeomDet * > backwardFit (const FreeTrajectoryState &fts, const edm::OwnVector< TrackingRecHit > &hits, const Propagator &propagatorAlong, const Propagator &propagatorOpposite, const TkClonerImpl &hitCloner, bool lastHitWasInvalid, bool lastHitWasChanged) const
 
TrackCandidateCollection convertCandidates (const MkFitOutputWrapper &mkFitOutput, const mkfit::EventOfHits &eventOfHits, const MkFitClusterIndexToHit &pixelClusterIndexToHit, const MkFitClusterIndexToHit &stripClusterIndexToHit, const edm::View< TrajectorySeed > &seeds, const MagneticField &mf, const Propagator &propagatorAlong, const Propagator &propagatorOpposite, const TkClonerImpl &hitCloner, const std::vector< const DetLayer * > &detLayers, const mkfit::TrackVec &mkFitSeeds) const
 
std::pair< TrajectoryStateOnSurface, const GeomDet * > convertInnermostState (const FreeTrajectoryState &fts, const edm::OwnVector< TrackingRecHit > &hits, const Propagator &propagatorAlong, const Propagator &propagatorOpposite) const
 
void produce (edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 

Private Attributes

const edm::EDGetTokenT< MkFitEventOfHitseventOfHitsToken_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmfToken_
 
const edm::ESGetToken< MkFitGeometry, TrackerRecoGeometryRecordmkFitGeomToken_
 
const edm::EDGetTokenT< MkFitSeedWrappermkfitSeedToken_
 
const edm::EDGetTokenT< MkFitClusterIndexToHitpixelClusterIndexToHitToken_
 
const std::string propagatorAlongName_
 
const edm::ESGetToken< Propagator, TrackingComponentsRecordpropagatorAlongToken_
 
const std::string propagatorOppositeName_
 
const edm::ESGetToken< Propagator, TrackingComponentsRecordpropagatorOppositeToken_
 
const edm::EDPutTokenT< std::vector< SeedStopInfo > > putSeedStopInfoToken_
 
const edm::EDPutTokenT< TrackCandidateCollectionputTrackCandidateToken_
 
const edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken_
 
const edm::EDGetTokenT< MkFitClusterIndexToHitstripClusterIndexToHitToken_
 
const edm::EDGetTokenT< MkFitOutputWrappertracksToken_
 
const std::string ttrhBuilderName_
 
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecordttrhBuilderToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 58 of file MkFitOutputConverter.cc.

Constructor & Destructor Documentation

◆ MkFitOutputConverter()

MkFitOutputConverter::MkFitOutputConverter ( edm::ParameterSet const &  iConfig)
explicit

Definition at line 111 of file MkFitOutputConverter.cc.

112  : eventOfHitsToken_{consumes<MkFitEventOfHits>(iConfig.getParameter<edm::InputTag>("mkFitEventOfHits"))},
113  pixelClusterIndexToHitToken_{consumes(iConfig.getParameter<edm::InputTag>("mkFitPixelHits"))},
114  stripClusterIndexToHitToken_{consumes(iConfig.getParameter<edm::InputTag>("mkFitStripHits"))},
115  mkfitSeedToken_{consumes<MkFitSeedWrapper>(iConfig.getParameter<edm::InputTag>("mkFitSeeds"))},
116  tracksToken_{consumes<MkFitOutputWrapper>(iConfig.getParameter<edm::InputTag>("tracks"))},
117  seedToken_{consumes<edm::View<TrajectorySeed>>(iConfig.getParameter<edm::InputTag>("seeds"))},
119  esConsumes<Propagator, TrackingComponentsRecord>(iConfig.getParameter<edm::ESInputTag>("propagatorAlong"))},
120  propagatorOppositeToken_{esConsumes<Propagator, TrackingComponentsRecord>(
121  iConfig.getParameter<edm::ESInputTag>("propagatorOpposite"))},
122  mfToken_{esConsumes<MagneticField, IdealMagneticFieldRecord>()},
123  ttrhBuilderToken_{esConsumes<TransientTrackingRecHitBuilder, TransientRecHitRecord>(
124  iConfig.getParameter<edm::ESInputTag>("ttrhBuilder"))},
125  mkFitGeomToken_{esConsumes<MkFitGeometry, TrackerRecoGeometryRecord>()},
126  putTrackCandidateToken_{produces<TrackCandidateCollection>()},
127  putSeedStopInfoToken_{produces<std::vector<SeedStopInfo>>()} {}

References edm::ParameterSet::getParameter().

◆ ~MkFitOutputConverter()

MkFitOutputConverter::~MkFitOutputConverter ( )
overridedefault

Member Function Documentation

◆ backwardFit()

std::pair< TrajectoryStateOnSurface, const GeomDet * > MkFitOutputConverter::backwardFit ( const FreeTrajectoryState fts,
const edm::OwnVector< TrackingRecHit > &  hits,
const Propagator propagatorAlong,
const Propagator propagatorOpposite,
const TkClonerImpl hitCloner,
bool  lastHitWasInvalid,
bool  lastHitWasChanged 
) const
private

Definition at line 323 of file MkFitOutputConverter.cc.

330  {
331  // First filter valid hits as in TransientInitialStateEstimator
333 
334  for (int i = hits.size() - 1; i >= 0; --i) {
335  if (hits[i].det()) {
336  // TransientTrackingRecHit::ConstRecHitContainer has shared_ptr,
337  // and it is passed to backFitter below so it is really needed
338  // to keep the interface. Since we keep the ownership in hits,
339  // let's disable the deleter.
340  firstHits.emplace_back(&(hits[i]), edm::do_nothing_deleter{});
341  }
342  }
343 
344  // Then propagate along to the surface of the last hit to get a TSOS
345  const auto& lastHitSurface = firstHits.front()->det()->surface();
346 
347  const Propagator* tryFirst = &propagatorAlong;
348  const Propagator* trySecond = &propagatorOpposite;
349  if (lastHitWasInvalid || lastHitWasChanged) {
350  LogTrace("MkFitOutputConverter") << "Propagating first opposite, then along, because lastHitWasInvalid? "
351  << lastHitWasInvalid << " or lastHitWasChanged? " << lastHitWasChanged;
352  std::swap(tryFirst, trySecond);
353  } else {
354  const auto lastHitSubdet = firstHits.front()->geographicalId().subdetId();
355  const auto& surfacePos = lastHitSurface.position();
356  const auto& lastHitPos = firstHits.front()->globalPosition();
357  bool doSwitch = false;
358  if (isBarrel(lastHitSubdet)) {
359  doSwitch = (surfacePos.perp2() < lastHitPos.perp2());
360  } else {
361  doSwitch = (surfacePos.z() < lastHitPos.z());
362  }
363  if (doSwitch) {
364  LogTrace("MkFitOutputConverter")
365  << "Propagating first opposite, then along, because surface is inner than the hit; surface perp2 "
366  << surfacePos.perp() << " hit " << lastHitPos.perp2() << " surface z " << surfacePos.z() << " hit "
367  << lastHitPos.z();
368 
369  std::swap(tryFirst, trySecond);
370  }
371  }
372 
373  auto tsosDouble = tryFirst->propagateWithPath(fts, lastHitSurface);
374  if (!tsosDouble.first.isValid()) {
375  LogDebug("MkFitOutputConverter") << "Propagating to startingState failed, trying in another direction next";
376  tsosDouble = trySecond->propagateWithPath(fts, lastHitSurface);
377  }
378  auto& startingState = tsosDouble.first;
379 
380  if (!startingState.isValid()) {
381  edm::LogWarning("MkFitOutputConverter")
382  << "startingState is not valid, FTS was\n"
383  << fts << " last hit surface surface:"
384  << "\n position " << lastHitSurface.position() << "\n phiSpan " << lastHitSurface.phiSpan().first << ","
385  << lastHitSurface.phiSpan().first << "\n rSpan " << lastHitSurface.rSpan().first << ","
386  << lastHitSurface.rSpan().first << "\n zSpan " << lastHitSurface.zSpan().first << ","
387  << lastHitSurface.zSpan().first;
388  return std::pair<TrajectoryStateOnSurface, const GeomDet*>();
389  }
390 
391  // Then return back to the logic from TransientInitialStateEstimator
392  startingState.rescaleError(100.);
393 
394  // avoid cloning
395  KFUpdator const aKFUpdator;
396  Chi2MeasurementEstimator const aChi2MeasurementEstimator(100., 3);
397  KFTrajectoryFitter backFitter(
398  &propagatorAlong, &aKFUpdator, &aChi2MeasurementEstimator, firstHits.size(), nullptr, &hitCloner);
399 
400  // assume for now that the propagation in mkfit always alongMomentum
401  PropagationDirection backFitDirection = oppositeToMomentum;
402 
403  // only direction matters in this context
405 
406  // ignore loopers for now
407  Trajectory fitres = backFitter.fitOne(fakeSeed, firstHits, startingState, TrajectoryFitter::standard);
408 
409  LogDebug("MkFitOutputConverter") << "using a backward fit of :" << firstHits.size() << " hits, starting from:\n"
410  << startingState << " to get the estimate of the initial state of the track.";
411 
412  if (!fitres.isValid()) {
413  edm::LogWarning("MkFitOutputConverter") << "FitTester: first hits fit failed";
414  return std::pair<TrajectoryStateOnSurface, const GeomDet*>();
415  }
416 
417  TrajectoryMeasurement const& firstMeas = fitres.lastMeasurement();
418 
419  // magnetic field can be different!
420  TrajectoryStateOnSurface firstState(firstMeas.updatedState().localParameters(),
421  firstMeas.updatedState().localError(),
422  firstMeas.updatedState().surface(),
423  propagatorAlong.magneticField());
424 
425  firstState.rescaleError(100.);
426 
427  LogDebug("MkFitOutputConverter") << "the initial state is found to be:\n:" << firstState
428  << "\n it's field pointer is: " << firstState.magneticField()
429  << "\n the pointer from the state of the back fit was: "
430  << firstMeas.updatedState().magneticField();
431 
432  return std::make_pair(firstState, firstMeas.recHit()->det());
433 }

References hfClusterShapes_cfi::hits, mps_fire::i, PixelPluginsPhase0_cfi::isBarrel, Trajectory::isValid(), Trajectory::lastMeasurement(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LogDebug, LogTrace, TrajectoryStateOnSurface::magneticField(), oppositeToMomentum, FreeTrajectoryState::position(), Propagator::propagateWithPath(), HLT_FULL_cff::propagatorAlong, HLT_FULL_cff::propagatorOpposite, TrajectoryMeasurement::recHit(), TrajectoryStateOnSurface::rescaleError(), TrajectoryFitter::standard, TrajectoryStateOnSurface::surface(), std::swap(), and TrajectoryMeasurement::updatedState().

Referenced by convertCandidates().

◆ convertCandidates()

TrackCandidateCollection MkFitOutputConverter::convertCandidates ( const MkFitOutputWrapper mkFitOutput,
const mkfit::EventOfHits &  eventOfHits,
const MkFitClusterIndexToHit pixelClusterIndexToHit,
const MkFitClusterIndexToHit stripClusterIndexToHit,
const edm::View< TrajectorySeed > &  seeds,
const MagneticField mf,
const Propagator propagatorAlong,
const Propagator propagatorOpposite,
const TkClonerImpl hitCloner,
const std::vector< const DetLayer * > &  detLayers,
const mkfit::TrackVec mkFitSeeds 
) const
private

Definition at line 174 of file MkFitOutputConverter.cc.

184  {
186  const auto& candidates = mkFitOutput.tracks();
187  output.reserve(candidates.size());
188 
189  LogTrace("MkFitOutputConverter") << "Number of candidates " << candidates.size();
190 
191  int candIndex = -1;
192  for (const auto& cand : candidates) {
193  ++candIndex;
194  LogTrace("MkFitOutputConverter") << "Candidate " << candIndex << " pT " << cand.pT() << " eta " << cand.momEta()
195  << " phi " << cand.momPhi() << " chi2 " << cand.chi2();
196 
197  // hits
199  // nTotalHits() gives sum of valid hits (nFoundHits()) and
200  // invalid/missing hits (up to a maximum of 32 inside mkFit,
201  // restriction to be lifted in the future)
202  const int nhits = cand.nTotalHits();
203  bool lastHitInvalid = false;
204  for (int i = 0; i < nhits; ++i) {
205  const auto& hitOnTrack = cand.getHitOnTrack(i);
206  LogTrace("MkFitOutputConverter") << " hit on layer " << hitOnTrack.layer << " index " << hitOnTrack.index;
207  if (hitOnTrack.index < 0) {
208  // See index-desc.txt file in mkFit for description of negative values
209  //
210  // In order to use the regular InvalidTrackingRecHit I'd need
211  // a GeomDet (and "unfortunately" that is needed in
212  // TrackProducer).
213  //
214  // I guess we could take the track state and propagate it to
215  // each layer to find the actual module the track crosses, and
216  // check whether it is active or not to be able to mark
217  // inactive hits
218  const auto* detLayer = detLayers.at(hitOnTrack.layer);
219  if (detLayer == nullptr) {
220  throw cms::Exception("LogicError") << "DetLayer for layer index " << hitOnTrack.layer << " is null!";
221  }
222  // In principle an InvalidTrackingRecHitNoDet could be
223  // inserted here, but it seems that it is best to deal with
224  // them in the TrackProducer.
225  lastHitInvalid = true;
226  } else {
227  auto const isPixel = eventOfHits[hitOnTrack.layer].is_pix_lyr();
228  auto const& hits = isPixel ? pixelClusterIndexToHit.hits() : stripClusterIndexToHit.hits();
229 
230  auto const& thit = static_cast<BaseTrackerRecHit const&>(*hits[hitOnTrack.index]);
231  if (thit.firstClusterRef().isPixel() || thit.detUnit()->type().isEndcap()) {
232  recHits.push_back(hits[hitOnTrack.index]->clone());
233  } else {
234  recHits.push_back(std::make_unique<SiStripRecHit1D>(
235  thit.localPosition(),
236  LocalError(thit.localPositionError().xx(), 0.f, std::numeric_limits<float>::max()),
237  *thit.det(),
238  thit.firstClusterRef()));
239  }
240  LogTrace("MkFitOutputConverter") << " pos " << recHits.back().globalPosition().x() << " "
241  << recHits.back().globalPosition().y() << " "
242  << recHits.back().globalPosition().z() << " mag2 "
243  << recHits.back().globalPosition().mag2() << " detid "
244  << recHits.back().geographicalId().rawId() << " cluster " << hitOnTrack.index;
245  lastHitInvalid = false;
246  }
247  }
248 
249  const auto lastHitId = recHits.back().geographicalId();
250 
251  // MkFit hits are *not* in the order of propagation, sort by 3D radius for now (as we don't have loopers)
252  // TODO: Improve the sorting (extract keys? maybe even bubble sort would work well as the hits are almost in the correct order)
253  recHits.sort([](const auto& a, const auto& b) {
254  const auto asub = a.geographicalId().subdetId();
255  const auto bsub = b.geographicalId().subdetId();
256  if (asub != bsub) {
257  // Subdetector order (BPix, FPix, TIB, TID, TOB, TEC) corresponds also the navigation
258  return asub < bsub;
259  }
260 
261  const auto& apos = a.globalPosition();
262  const auto& bpos = b.globalPosition();
263 
264  if (isBarrel(asub)) {
265  return apos.perp2() < bpos.perp2();
266  }
267  return std::abs(apos.z()) < std::abs(bpos.z());
268  });
269 
270  const bool lastHitChanged = (recHits.back().geographicalId() != lastHitId); // TODO: make use of the bools
271 
272  // seed
273  const auto seedIndex = cand.label();
274  LogTrace("MkFitOutputConverter") << " from seed " << seedIndex << " seed hits";
275 
276  // state
277  auto state = cand.state(); // copy because have to modify
278  state.convertFromCCSToGlbCurvilinear();
279  const auto& param = state.parameters;
280  const auto& err = state.errors;
282  for (int i = 0; i < 5; ++i) {
283  for (int j = i; j < 5; ++j) {
284  cov[i][j] = err.At(i, j);
285  }
286  }
287 
288  auto fts = FreeTrajectoryState(
290  GlobalPoint(param[0], param[1], param[2]), GlobalVector(param[3], param[4], param[5]), state.charge, &mf),
292  if (!fts.curvilinearError().posDef()) {
293  edm::LogWarning("MkFitOutputConverter") << "Curvilinear error not pos-def\n"
294  << fts.curvilinearError().matrix() << "\ncandidate ignored";
295  continue;
296  }
297 
298  auto tsosDet =
299  mkFitOutput.propagatedToFirstLayer()
301  : backwardFit(fts, recHits, propagatorAlong, propagatorOpposite, hitCloner, lastHitInvalid, lastHitChanged);
302  if (!tsosDet.first.isValid()) {
303  edm::LogWarning("MkFitOutputConverter")
304  << "Backward fit of candidate " << candIndex << " failed, ignoring the candidate";
305  continue;
306  }
307 
308  // convert to persistent, from CkfTrackCandidateMakerBase
309  auto pstate = trajectoryStateTransform::persistentState(tsosDet.first, tsosDet.second->geographicalId().rawId());
310 
311  output.emplace_back(
312  recHits,
313  seeds.at(seedIndex),
314  pstate,
315  seeds.refAt(seedIndex),
316  0, // mkFit does not produce loopers, so set nLoops=0
317  static_cast<uint8_t>(StopReason::UNINITIALIZED) // TODO: ignore details of stopping reason as well for now
318  );
319  }
320  return output;
321 }

References a, funct::abs(), b, backwardFit(), HLT_FULL_cff::candidates, convertInnermostState(), submitPVResolutionJobs::err, InitialStepPreSplitting_cff::eventOfHits, Exception, hfClusterShapes_cfi::hits, MkFitClusterIndexToHit::hits(), mps_fire::i, PixelPluginsPhase0_cfi::isBarrel, fastTrackerRecHitType::isPixel(), dqmiolumiharvest::j, LogTrace, SiStripPI::max, nhits, convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), MkFitOutputWrapper::propagatedToFirstLayer(), HLT_FULL_cff::propagatorAlong, HLT_FULL_cff::propagatorOpposite, FastTrackerRecHitMaskProducer_cfi::recHits, DetachedQuadStep_cff::seeds, MkFitOutputWrapper::tracks(), and UNINITIALIZED.

Referenced by produce().

◆ convertInnermostState()

std::pair< TrajectoryStateOnSurface, const GeomDet * > MkFitOutputConverter::convertInnermostState ( const FreeTrajectoryState fts,
const edm::OwnVector< TrackingRecHit > &  hits,
const Propagator propagatorAlong,
const Propagator propagatorOpposite 
) const
private

Definition at line 435 of file MkFitOutputConverter.cc.

439  {
440  auto det = hits[0].det();
441  if (det == nullptr) {
442  throw cms::Exception("LogicError") << "Got nullptr from the first hit det()";
443  }
444 
445  const auto& firstHitSurface = det->surface();
446 
447  auto tsosDouble = propagatorAlong.propagateWithPath(fts, firstHitSurface);
448  if (!tsosDouble.first.isValid()) {
449  LogDebug("MkFitOutputConverter") << "Propagating to startingState along momentum failed, trying opposite next";
450  tsosDouble = propagatorOpposite.propagateWithPath(fts, firstHitSurface);
451  }
452 
453  return std::make_pair(tsosDouble.first, det);
454 }

References Exception, hfClusterShapes_cfi::hits, LogDebug, HLT_FULL_cff::propagatorAlong, and HLT_FULL_cff::propagatorOpposite.

Referenced by convertCandidates().

◆ fillDescriptions()

void MkFitOutputConverter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 129 of file MkFitOutputConverter.cc.

129  {
131 
132  desc.add("mkFitEventOfHits", edm::InputTag{"mkFitEventOfHits"});
133  desc.add("mkFitPixelHits", edm::InputTag{"mkFitSiPixelHits"});
134  desc.add("mkFitStripHits", edm::InputTag{"mkFitSiStripHits"});
135  desc.add("mkFitSeeds", edm::InputTag{"mkFitSeedConverter"});
136  desc.add("tracks", edm::InputTag{"mkFitProducer"});
137  desc.add("seeds", edm::InputTag{"initialStepSeeds"});
138  desc.add("ttrhBuilder", edm::ESInputTag{"", "WithTrackAngle"});
139  desc.add("propagatorAlong", edm::ESInputTag{"", "PropagatorWithMaterial"});
140  desc.add("propagatorOpposite", edm::ESInputTag{"", "PropagatorWithMaterialOpposite"});
141 
142  descriptions.addWithDefaultLabel(desc);
143 }

References edm::ConfigurationDescriptions::addWithDefaultLabel(), and submitPVResolutionJobs::desc.

◆ produce()

void MkFitOutputConverter::produce ( edm::StreamID  iID,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 145 of file MkFitOutputConverter.cc.

145  {
146  const auto& seeds = iEvent.get(seedToken_);
147  const auto& mkfitSeeds = iEvent.get(mkfitSeedToken_);
148 
149  const auto& ttrhBuilder = iSetup.getData(ttrhBuilderToken_);
150  const auto* tkBuilder = dynamic_cast<TkTransientTrackingRecHitBuilder const*>(&ttrhBuilder);
151  if (!tkBuilder) {
152  throw cms::Exception("LogicError") << "TTRHBuilder must be of type TkTransientTrackingRecHitBuilder";
153  }
154  const auto& mkFitGeom = iSetup.getData(mkFitGeomToken_);
155 
156  // Convert mkfit presentation back to CMSSW
159  iEvent.get(eventOfHitsToken_).get(),
162  seeds,
163  iSetup.getData(mfToken_),
166  tkBuilder->cloner(),
167  mkFitGeom.detLayers(),
168  mkfitSeeds.seeds()));
169 
170  // TODO: SeedStopInfo is currently unfilled
171  iEvent.emplace(putSeedStopInfoToken_, seeds.size());
172 }

References convertCandidates(), eventOfHitsToken_, Exception, edm::EventSetup::getData(), iEvent, mfToken_, mkFitGeomToken_, mkfitSeedToken_, pixelClusterIndexToHitToken_, propagatorAlongToken_, propagatorOppositeToken_, putSeedStopInfoToken_, putTrackCandidateToken_, DetachedQuadStep_cff::seeds, seedToken_, stripClusterIndexToHitToken_, tracksToken_, and ttrhBuilderToken_.

Member Data Documentation

◆ eventOfHitsToken_

const edm::EDGetTokenT<MkFitEventOfHits> MkFitOutputConverter::eventOfHitsToken_
private

Definition at line 93 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ mfToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> MkFitOutputConverter::mfToken_
private

Definition at line 101 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ mkFitGeomToken_

const edm::ESGetToken<MkFitGeometry, TrackerRecoGeometryRecord> MkFitOutputConverter::mkFitGeomToken_
private

Definition at line 103 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ mkfitSeedToken_

const edm::EDGetTokenT<MkFitSeedWrapper> MkFitOutputConverter::mkfitSeedToken_
private

Definition at line 96 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ pixelClusterIndexToHitToken_

const edm::EDGetTokenT<MkFitClusterIndexToHit> MkFitOutputConverter::pixelClusterIndexToHitToken_
private

Definition at line 94 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ propagatorAlongName_

const std::string MkFitOutputConverter::propagatorAlongName_
private

Definition at line 107 of file MkFitOutputConverter.cc.

◆ propagatorAlongToken_

const edm::ESGetToken<Propagator, TrackingComponentsRecord> MkFitOutputConverter::propagatorAlongToken_
private

Definition at line 99 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ propagatorOppositeName_

const std::string MkFitOutputConverter::propagatorOppositeName_
private

Definition at line 108 of file MkFitOutputConverter.cc.

◆ propagatorOppositeToken_

const edm::ESGetToken<Propagator, TrackingComponentsRecord> MkFitOutputConverter::propagatorOppositeToken_
private

Definition at line 100 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ putSeedStopInfoToken_

const edm::EDPutTokenT<std::vector<SeedStopInfo> > MkFitOutputConverter::putSeedStopInfoToken_
private

Definition at line 105 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ putTrackCandidateToken_

const edm::EDPutTokenT<TrackCandidateCollection> MkFitOutputConverter::putTrackCandidateToken_
private

Definition at line 104 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ seedToken_

const edm::EDGetTokenT<edm::View<TrajectorySeed> > MkFitOutputConverter::seedToken_
private

Definition at line 98 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ stripClusterIndexToHitToken_

const edm::EDGetTokenT<MkFitClusterIndexToHit> MkFitOutputConverter::stripClusterIndexToHitToken_
private

Definition at line 95 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ tracksToken_

const edm::EDGetTokenT<MkFitOutputWrapper> MkFitOutputConverter::tracksToken_
private

Definition at line 97 of file MkFitOutputConverter.cc.

Referenced by produce().

◆ ttrhBuilderName_

const std::string MkFitOutputConverter::ttrhBuilderName_
private

Definition at line 106 of file MkFitOutputConverter.cc.

◆ ttrhBuilderToken_

const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> MkFitOutputConverter::ttrhBuilderToken_
private

Definition at line 102 of file MkFitOutputConverter.cc.

Referenced by produce().

mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
Chi2MeasurementEstimator
Definition: Chi2MeasurementEstimator.h:15
MkFitOutputConverter::stripClusterIndexToHitToken_
const edm::EDGetTokenT< MkFitClusterIndexToHit > stripClusterIndexToHitToken_
Definition: MkFitOutputConverter.cc:95
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
MkFitOutputConverter::mkfitSeedToken_
const edm::EDGetTokenT< MkFitSeedWrapper > mkfitSeedToken_
Definition: MkFitOutputConverter.cc:96
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::do_nothing_deleter
Definition: do_nothing_deleter.h:34
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MkFitOutputConverter::propagatorOppositeToken_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorOppositeToken_
Definition: MkFitOutputConverter.cc:100
oppositeToMomentum
Definition: PropagationDirection.h:4
KFTrajectoryFitter
Definition: KFTrajectoryFitter.h:22
MkFitOutputWrapper::tracks
mkfit::TrackVec const & tracks() const
Definition: MkFitOutputWrapper.h:22
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
FreeTrajectoryState::position
GlobalPoint position() const
Definition: FreeTrajectoryState.h:67
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
MkFitOutputConverter::backwardFit
std::pair< TrajectoryStateOnSurface, const GeomDet * > backwardFit(const FreeTrajectoryState &fts, const edm::OwnVector< TrackingRecHit > &hits, const Propagator &propagatorAlong, const Propagator &propagatorOpposite, const TkClonerImpl &hitCloner, bool lastHitWasInvalid, bool lastHitWasChanged) const
Definition: MkFitOutputConverter.cc:323
MkFitOutputConverter::mfToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > mfToken_
Definition: MkFitOutputConverter.cc:101
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MkFitOutputConverter::convertInnermostState
std::pair< TrajectoryStateOnSurface, const GeomDet * > convertInnermostState(const FreeTrajectoryState &fts, const edm::OwnVector< TrackingRecHit > &hits, const Propagator &propagatorAlong, const Propagator &propagatorOpposite) const
Definition: MkFitOutputConverter.cc:435
Propagator
Definition: Propagator.h:44
MkFitOutputConverter::putSeedStopInfoToken_
const edm::EDPutTokenT< std::vector< SeedStopInfo > > putSeedStopInfoToken_
Definition: MkFitOutputConverter.cc:105
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
MkFitOutputConverter::pixelClusterIndexToHitToken_
const edm::EDGetTokenT< MkFitClusterIndexToHit > pixelClusterIndexToHitToken_
Definition: MkFitOutputConverter.cc:94
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
MkFitOutputConverter::propagatorAlongToken_
const edm::ESGetToken< Propagator, TrackingComponentsRecord > propagatorAlongToken_
Definition: MkFitOutputConverter.cc:99
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
nhits
Definition: HIMultiTrackSelector.h:42
b
double b
Definition: hdecay.h:118
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
TrajectoryStateOnSurface::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: TrajectoryStateOnSurface.h:73
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
MkFitOutputConverter::ttrhBuilderToken_
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > ttrhBuilderToken_
Definition: MkFitOutputConverter.cc:102
TrajectoryFitter::standard
Definition: TrajectoryFitter.h:21
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
TrackCandidateCollection
std::vector< TrackCandidate > TrackCandidateCollection
Definition: TrackCandidateCollection.h:7
a
double a
Definition: hdecay.h:119
MkFitOutputConverter::mkFitGeomToken_
const edm::ESGetToken< MkFitGeometry, TrackerRecoGeometryRecord > mkFitGeomToken_
Definition: MkFitOutputConverter.cc:103
HLT_FULL_cff.propagatorOpposite
propagatorOpposite
Definition: HLT_FULL_cff.py:116
fastTrackerRecHitType::isPixel
bool isPixel(HitType hitType)
Definition: FastTrackerRecHit.h:37
TrackingRecHit::ConstRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: TrackingRecHit.h:32
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LocalError
Definition: LocalError.h:12
Trajectory::lastMeasurement
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
cand
Definition: decayParser.h:32
MkFitClusterIndexToHit::hits
std::vector< TrackingRecHit const * > & hits()
Definition: MkFitClusterIndexToHit.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
InitialStepPreSplitting_cff.eventOfHits
eventOfHits
Definition: InitialStepPreSplitting_cff.py:154
TrajectoryStateOnSurface::rescaleError
void rescaleError(double factor)
Definition: TrajectoryStateOnSurface.h:82
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
MkFitOutputConverter::putTrackCandidateToken_
const edm::EDPutTokenT< TrackCandidateCollection > putTrackCandidateToken_
Definition: MkFitOutputConverter.cc:104
HLT_FULL_cff.propagatorAlong
propagatorAlong
Definition: HLT_FULL_cff.py:118
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
DetachedQuadStep_cff.seeds
seeds
Definition: DetachedQuadStep_cff.py:195
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
MkFitOutputWrapper::propagatedToFirstLayer
bool propagatedToFirstLayer() const
Definition: MkFitOutputWrapper.h:23
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
Trajectory
Definition: Trajectory.h:38
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:55017
StopReason::UNINITIALIZED
Exception
Definition: hltDiff.cc:245
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
TrajectorySeed
Definition: TrajectorySeed.h:18
Propagator::propagateWithPath
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Surface &) const final
Definition: Propagator.cc:10
MkFitOutputConverter::convertCandidates
TrackCandidateCollection convertCandidates(const MkFitOutputWrapper &mkFitOutput, const mkfit::EventOfHits &eventOfHits, const MkFitClusterIndexToHit &pixelClusterIndexToHit, const MkFitClusterIndexToHit &stripClusterIndexToHit, const edm::View< TrajectorySeed > &seeds, const MagneticField &mf, const Propagator &propagatorAlong, const Propagator &propagatorOpposite, const TkClonerImpl &hitCloner, const std::vector< const DetLayer * > &detLayers, const mkfit::TrackVec &mkFitSeeds) const
Definition: MkFitOutputConverter.cc:174
MkFitOutputConverter::eventOfHitsToken_
const edm::EDGetTokenT< MkFitEventOfHits > eventOfHitsToken_
Definition: MkFitOutputConverter.cc:93
TrajectoryStateOnSurface::surface
const SurfaceType & surface() const
Definition: TrajectoryStateOnSurface.h:78
MkFitOutputConverter::tracksToken_
const edm::EDGetTokenT< MkFitOutputWrapper > tracksToken_
Definition: MkFitOutputConverter.cc:97
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
TrajectoryStateOnSurface::magneticField
const MagneticField * magneticField() const
Definition: TrajectoryStateOnSurface.h:62
edm::InputTag
Definition: InputTag.h:15
KFUpdator
Definition: KFUpdator.h:32
Trajectory::isValid
bool isValid() const
Definition: Trajectory.h:257
MkFitOutputConverter::seedToken_
const edm::EDGetTokenT< edm::View< TrajectorySeed > > seedToken_
Definition: MkFitOutputConverter.cc:98
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
edm::OwnVector< TrackingRecHit >