CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
FastTSGFromPropagation Class Reference

#include <FastTSGFromPropagation.h>

Inheritance diagram for FastTSGFromPropagation:
TrackerSeedGenerator

Classes

struct  increasingEstimate
 
struct  isInvalid
 

Public Member Functions

 FastTSGFromPropagation (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 constructor More...
 
 FastTSGFromPropagation (const edm::ParameterSet &par, const MuonServiceProxy *, edm::ConsumesCollector &iC)
 
void init (const MuonServiceProxy *) override
 initialize More...
 
void setEvent (const edm::Event &) override
 set an event More...
 
void trackerSeeds (const TrackCand &, const TrackingRegion &, const TrackerTopology *tTopo, std::vector< TrajectorySeed > &) override
 generate seed(s) for a track More...
 
 ~FastTSGFromPropagation () override
 destructor More...
 
- Public Member Functions inherited from TrackerSeedGenerator
const edm::EventgetEvent () const
 
 TrackerSeedGenerator ()
 
virtual void trackerSeeds (const TrackCand &, const TrackingRegion &, const TrackerTopology *, BTSeedCollection &)
 
virtual ~TrackerSeedGenerator ()
 destructor More...
 

Private Member Functions

void adjust (FreeTrajectoryState &) const
 adjust the error matrix of the FTS More...
 
void adjust (TrajectoryStateOnSurface &) const
 adjust the error matrix of the TSOS More...
 
TrajectorySeed createSeed (const TrajectoryStateOnSurface &, const DetId &) const
 create a hitless seed from a trajectory state More...
 
TrajectorySeed createSeed (const TrajectoryStateOnSurface &tsos, const edm::OwnVector< TrackingRecHit > &container, const DetId &id) const
 create a seed from a trajectory state More...
 
double dxyDis (const TrajectoryStateOnSurface &tsos) const
 
const Chi2MeasurementEstimatorestimator () const
 
std::vector< TrajectoryMeasurementfindMeasurements (const DetLayer *, const TrajectoryStateOnSurface &) const
 look for measurements on the first compatible layer More...
 
void getRescalingFactor (const TrackCand &staMuon)
 
TrajectoryStateOnSurface innerState (const TrackCand &) const
 
TrajectoryStateOnSurface outerTkState (const TrackCand &) const
 
bool passSelection (const TrajectoryStateOnSurface &) const
 check some quantity and beam-spot compatibility and decide to continue More...
 
edm::ESHandle< Propagatorpropagator () const
 
void stateOnDet (const TrajectoryStateOnSurface &ts, unsigned int detid, PTrajectoryStateOnDet &pts) const
 A mere copy (without memory leak) of an existing tracking method. More...
 
const TrajectoryStateUpdatorupdator () const
 
void validMeasurements (std::vector< TrajectoryMeasurement > &) const
 select valid measurements More...
 
double zDis (const TrajectoryStateOnSurface &tsos) const
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpot_
 
edm::Handle< FastTrackerRecHitCombinationCollectionrecHitCombinations
 
edm::EDGetTokenT< FastTrackerRecHitCombinationCollectionrecHitCombinationsToken_
 
bool theAdjustAtIp
 
edm::Handle< reco::BeamSpottheBeamSpot
 
unsigned long long theCacheId_MT
 
unsigned long long theCacheId_TG
 
std::string theCategory
 
const edm::ParameterSet theConfig
 
std::unique_ptr< MuonErrorMatrixtheErrorMatrixAdjuster
 
std::unique_ptr< const Chi2MeasurementEstimatortheEstimator
 
double theFixedErrorRescaling
 
double theFlexErrorRescaling
 
const TrackerGeometrytheGeometry
 
double theMaxChi2
 
edm::ESHandle< MeasurementTrackertheMeasTracker
 
edm::Handle< MeasurementTrackerEventtheMeasTrackerEvent
 
edm::EDGetTokenT< MeasurementTrackerEventtheMeasurementTrackerEventToken_
 
std::unique_ptr< const DirectTrackerNavigationtheNavigation
 
std::string thePropagatorName
 
std::string theResetMethod
 
bool theSelectStateFlag
 
const MuonServiceProxytheService
 
double theSigmaZ
 
edm::EDGetTokenT< edm::SimTrackContainertheSimTrackCollectionToken_
 
edm::Handle< edm::SimTrackContainertheSimTracks
 
edm::ESHandle< GeometricSearchTrackertheTracker
 
edm::ESHandle< TransientTrackingRecHitBuildertheTTRHBuilder
 
bool theUpdateStateFlag
 
std::unique_ptr< const TrajectoryStateUpdatortheUpdator
 
bool theUseVertexStateFlag
 

Additional Inherited Members

- Public Types inherited from TrackerSeedGenerator
typedef std::vector< TrajectorySeedBTSeedCollection
 
typedef std::pair< const Trajectory *, reco::TrackRefTrackCand
 
- Protected Attributes inherited from TrackerSeedGenerator
const edm::EventtheEvent
 
const MuonServiceProxytheProxyService
 

Detailed Description

Emulate TSGFromPropagation in RecoMuon

Author
Hwidong Yoo - Purdue University

Tracker Seed Generator by propagating and updating a standAlone muon to the first 2 (or 1) rechits it meets in tracker system

Emulate TSGFromPropagation in RecoMuon

Author
Hwidong Yoo - Purdue University

Definition at line 48 of file FastTSGFromPropagation.h.

Constructor & Destructor Documentation

FastTSGFromPropagation::FastTSGFromPropagation ( const edm::ParameterSet pset,
edm::ConsumesCollector iC 
)

constructor

Definition at line 46 of file FastTSGFromPropagation.cc.

47  : FastTSGFromPropagation(iConfig, nullptr, iC) {}
FastTSGFromPropagation(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
constructor
FastTSGFromPropagation::FastTSGFromPropagation ( const edm::ParameterSet par,
const MuonServiceProxy service,
edm::ConsumesCollector iC 
)

Definition at line 49 of file FastTSGFromPropagation.cc.

52  : theCategory("FastSimulation|Muons|FastTSGFromPropagation"),
53  theTracker(),
54  theNavigation(),
56  theUpdator(),
57  theEstimator(),
58  theSigmaZ(0.0),
59  theConfig(iConfig),
61  iC.consumes<edm::SimTrackContainer>(theConfig.getParameter<edm::InputTag>("SimTrackCollectionLabel"))),
64  beamSpot_(iC.consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
66  iC.consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent"))) {}
std::unique_ptr< const TrajectoryStateUpdator > theUpdator
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::SimTrackContainer > theSimTrackCollectionToken_
edm::ESHandle< GeometricSearchTracker > theTracker
const MuonServiceProxy * theService
edm::EDGetTokenT< MeasurementTrackerEvent > theMeasurementTrackerEventToken_
const edm::ParameterSet theConfig
std::unique_ptr< const DirectTrackerNavigation > theNavigation
edm::EDGetTokenT< reco::BeamSpot > beamSpot_
std::vector< FastTrackerRecHitCombination > FastTrackerRecHitCombinationCollection
std::unique_ptr< const Chi2MeasurementEstimator > theEstimator
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken_
std::vector< SimTrack > SimTrackContainer
FastTSGFromPropagation::~FastTSGFromPropagation ( )
override

destructor

Definition at line 68 of file FastTSGFromPropagation.cc.

References LogTrace, and theCategory.

68 { LogTrace(theCategory) << " FastTSGFromPropagation dtor called "; }
#define LogTrace(id)

Member Function Documentation

void FastTSGFromPropagation::adjust ( FreeTrajectoryState state) const
private

adjust the error matrix of the FTS

Definition at line 512 of file FastTSGFromPropagation.cc.

References FreeTrajectoryState::curvilinearError(), FreeTrajectoryState::momentum(), MuonErrorMatrix::multiply(), FreeTrajectoryState::parameters(), FreeTrajectoryState::rescaleError(), theErrorMatrixAdjuster, theFixedErrorRescaling, theFlexErrorRescaling, and theResetMethod.

Referenced by innerState(), outerTkState(), and propagator().

512  {
513  //rescale the error
514  if (theResetMethod == "discreate") {
516  return;
517  }
518 
519  //rescale the error
520  if (theResetMethod == "fixed" || !theErrorMatrixAdjuster) {
522  return;
523  }
524 
526  CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.momentum()); //FIXME with position
527  MuonErrorMatrix::multiply(oMat, sfMat);
528 
529  state = FreeTrajectoryState(state.parameters(), oMat);
530 }
const GlobalTrajectoryParameters & parameters() const
const CurvilinearTrajectoryError & curvilinearError() const
static void multiply(CurvilinearTrajectoryError &initial_error, const CurvilinearTrajectoryError &scale_error)
multiply term by term the two matrix
GlobalVector momentum() const
void rescaleError(double factor)
std::unique_ptr< MuonErrorMatrix > theErrorMatrixAdjuster
void FastTSGFromPropagation::adjust ( TrajectoryStateOnSurface state) const
private

adjust the error matrix of the TSOS

Definition at line 532 of file FastTSGFromPropagation.cc.

References TrajectoryStateOnSurface::curvilinearError(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalParameters(), MuonErrorMatrix::multiply(), TrajectoryStateOnSurface::rescaleError(), TrajectoryStateOnSurface::surface(), TrajectoryStateOnSurface::surfaceSide(), theErrorMatrixAdjuster, theFixedErrorRescaling, theFlexErrorRescaling, theResetMethod, and TrajectoryStateOnSurface::weight().

532  {
533  //rescale the error
534  if (theResetMethod == "discreate") {
536  return;
537  }
538 
539  if (theResetMethod == "fixed" || !theErrorMatrixAdjuster) {
541  return;
542  }
543 
545  CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.globalMomentum()); //FIXME with position
546  MuonErrorMatrix::multiply(oMat, sfMat);
547 
548  state =
549  TrajectoryStateOnSurface(state.weight(), state.globalParameters(), oMat, state.surface(), state.surfaceSide());
550 }
const CurvilinearTrajectoryError & curvilinearError() const
const SurfaceType & surface() const
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
static void multiply(CurvilinearTrajectoryError &initial_error, const CurvilinearTrajectoryError &scale_error)
multiply term by term the two matrix
const GlobalTrajectoryParameters & globalParameters() const
GlobalVector globalMomentum() const
std::unique_ptr< MuonErrorMatrix > theErrorMatrixAdjuster
TrajectorySeed FastTSGFromPropagation::createSeed ( const TrajectoryStateOnSurface tsos,
const DetId id 
) const
private

create a hitless seed from a trajectory state

Definition at line 430 of file FastTSGFromPropagation.cc.

Referenced by propagator(), and trackerSeeds().

430  {
432  return createSeed(tsos, container, id);
433 }
TrajectorySeed createSeed(const TrajectoryStateOnSurface &, const DetId &) const
create a hitless seed from a trajectory state
TrajectorySeed FastTSGFromPropagation::createSeed ( const TrajectoryStateOnSurface tsos,
const edm::OwnVector< TrackingRecHit > &  container,
const DetId id 
) const
private

create a seed from a trajectory state

Definition at line 435 of file FastTSGFromPropagation.cc.

References oppositeToMomentum, and trajectoryStateTransform::persistentState().

437  {
439  return TrajectorySeed(seedTSOS, container, oppositeToMomentum);
440 }
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
double FastTSGFromPropagation::dxyDis ( const TrajectoryStateOnSurface tsos) const
private

Definition at line 490 of file FastTSGFromPropagation.cc.

References TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by propagator().

490  {
491  return fabs(
492  (-tsos.globalPosition().x() * tsos.globalMomentum().y() + tsos.globalPosition().y() * tsos.globalMomentum().x()) /
493  tsos.globalMomentum().perp());
494 }
T perp() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
GlobalVector globalMomentum() const
T x() const
Definition: PV3DBase.h:59
const Chi2MeasurementEstimator* FastTSGFromPropagation::estimator ( void  ) const
inlineprivate

Definition at line 80 of file FastTSGFromPropagation.h.

References theEstimator.

Referenced by findMeasurements(), and trackerSeeds().

80 { return theEstimator.get(); }
std::unique_ptr< const Chi2MeasurementEstimator > theEstimator
std::vector< TrajectoryMeasurement > FastTSGFromPropagation::findMeasurements ( const DetLayer nl,
const TrajectoryStateOnSurface staState 
) const
private

look for measurements on the first compatible layer

Definition at line 448 of file FastTSGFromPropagation.cc.

References GeometricSearchDet::compatibleDets(), estimator(), propagator(), mps_fire::result, and theMeasTrackerEvent.

Referenced by propagator(), and trackerSeeds().

449  {
450  std::vector<TrajectoryMeasurement> result;
451 
452  std::vector<DetLayer::DetWithState> compatDets = nl->compatibleDets(staState, *propagator(), *estimator());
453  if (compatDets.empty())
454  return result;
455 
456  for (std::vector<DetLayer::DetWithState>::const_iterator idws = compatDets.begin(); idws != compatDets.end();
457  ++idws) {
458  if (idws->second.isValid() && (idws->first)) {
459  std::vector<TrajectoryMeasurement> tmptm =
460  theMeasTrackerEvent->idToDet(idws->first->geographicalId())
461  .fastMeasurements(idws->second, idws->second, *propagator(), *estimator());
462  //validMeasurements(tmptm);
463  // if ( tmptm.size() > 2 ) {
464  // std::stable_sort(tmptm.begin(),tmptm.end(),increasingEstimate());
465  // result.insert(result.end(),tmptm.begin(), tmptm.begin()+2);
466  // } else {
467  result.insert(result.end(), tmptm.begin(), tmptm.end());
468  // }
469  }
470  }
471 
472  return result;
473 }
edm::Handle< MeasurementTrackerEvent > theMeasTrackerEvent
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
const Chi2MeasurementEstimator * estimator() const
edm::ESHandle< Propagator > propagator() const
void FastTSGFromPropagation::getRescalingFactor ( const TrackCand staMuon)
private

Definition at line 501 of file FastTSGFromPropagation.cc.

References DiDispStaMuonMonitor_cfi::pt, and theFlexErrorRescaling.

Referenced by propagator(), and trackerSeeds().

501  {
502  float pt = (staMuon.second)->pt();
503  if (pt < 13.0)
505  else if (pt < 30.0)
507  else
509  return;
510 }
void FastTSGFromPropagation::init ( const MuonServiceProxy service)
overridevirtual

initialize

Reimplemented from TrackerSeedGenerator.

Definition at line 303 of file FastTSGFromPropagation.cc.

References Chi2MeasurementEstimator_cfi::Chi2MeasurementEstimator, HLT_2018_cff::errorMatrixPset, geometry, edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theAdjustAtIp, theCacheId_MT, theCacheId_TG, theConfig, theErrorMatrixAdjuster, theEstimator, theFixedErrorRescaling, theFlexErrorRescaling, theGeometry, theMaxChi2, theNavigation, thePropagatorName, theResetMethod, theSelectStateFlag, theService, theSigmaZ, theTracker, theTTRHBuilder, theUpdateStateFlag, theUpdator, and theUseVertexStateFlag.

303  {
304  theMaxChi2 = theConfig.getParameter<double>("MaxChi2");
305 
306  theFixedErrorRescaling = theConfig.getParameter<double>("ErrorRescaling");
307 
308  theFlexErrorRescaling = 1.0;
309 
311 
312  if (theResetMethod != "discrete" && theResetMethod != "fixed" && theResetMethod != "matrix") {
313  edm::LogError("FastTSGFromPropagation") << "Wrong error rescaling method: " << theResetMethod << "\n"
314  << "Possible choices are: discrete, fixed, matrix.\n"
315  << "Use discrete method" << std::endl;
316  theResetMethod = "discrete";
317  }
318 
320 
321  theCacheId_MT = 0;
322 
323  theCacheId_TG = 0;
324 
326 
328 
329  theUseVertexStateFlag = theConfig.getParameter<bool>("UseVertexState");
330 
331  theUpdateStateFlag = theConfig.getParameter<bool>("UpdateState");
332 
333  theSelectStateFlag = theConfig.getParameter<bool>("SelectState");
334 
335  theUpdator.reset(new KFUpdator());
336 
337  theSigmaZ = theConfig.getParameter<double>("SigmaZ");
338 
340  if (theResetMethod == "matrix" && !errorMatrixPset.empty()) {
341  theAdjustAtIp = errorMatrixPset.getParameter<bool>("atIP");
342  theErrorMatrixAdjuster.reset(new MuonErrorMatrix(errorMatrixPset));
343  } else {
344  theAdjustAtIp = false;
345  theErrorMatrixAdjuster.reset();
346  }
347 
348  theService->eventSetup().get<TrackerRecoGeometryRecord>().get(theTracker);
350 
352  theService->eventSetup().get<TrackerDigiGeometryRecord>().get(geometry);
353  theGeometry = &(*geometry);
354 
355  theService->eventSetup().get<TransientRecHitRecord>().get("WithTrackAngle", theTTRHBuilder);
356 }
std::unique_ptr< const TrajectoryStateUpdator > theUpdator
T getParameter(std::string const &) const
unsigned long long theCacheId_MT
edm::ESHandle< GeometricSearchTracker > theTracker
const MuonServiceProxy * theService
const edm::ParameterSet theConfig
const TrackerGeometry * theGeometry
std::unique_ptr< const DirectTrackerNavigation > theNavigation
ESHandle< TrackerGeometry > geometry
std::unique_ptr< const Chi2MeasurementEstimator > theEstimator
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
unsigned long long theCacheId_TG
std::unique_ptr< MuonErrorMatrix > theErrorMatrixAdjuster
TrajectoryStateOnSurface FastTSGFromPropagation::innerState ( const TrackCand staMuon) const
private

Definition at line 393 of file FastTSGFromPropagation.cc.

References adjust(), alongMomentum, trajectoryStateTransform::innerStateOnSurface(), oppositeToMomentum, and theService.

Referenced by outerTkState().

393  {
394  TrajectoryStateOnSurface innerTS;
395 
396  if (staMuon.first && staMuon.first->isValid()) {
397  if (staMuon.first->direction() == alongMomentum) {
398  innerTS = staMuon.first->firstMeasurement().updatedState();
399  } else if (staMuon.first->direction() == oppositeToMomentum) {
400  innerTS = staMuon.first->lastMeasurement().updatedState();
401  }
402  } else {
404  *(staMuon.second), *theService->trackingGeometry(), &*theService->magneticField());
405  }
406  //rescale the error
407  adjust(innerTS);
408 
409  return innerTS;
410 }
void adjust(FreeTrajectoryState &) const
adjust the error matrix of the FTS
const MuonServiceProxy * theService
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)
TrajectoryStateOnSurface FastTSGFromPropagation::outerTkState ( const TrackCand staMuon) const
private

Definition at line 412 of file FastTSGFromPropagation.cc.

References adjust(), trajectoryStateTransform::initialFreeState(), innerState(), propagator(), mps_fire::result, theService, and theUseVertexStateFlag.

Referenced by trackerSeeds().

412  {
414 
415  if (theUseVertexStateFlag && staMuon.second->pt() > 1.0) {
416  FreeTrajectoryState iniState =
417  trajectoryStateTransform::initialFreeState(*(staMuon.second), &*theService->magneticField());
418  //rescale the error at IP
419  adjust(iniState);
420 
421  StateOnTrackerBound fromInside(&*(theService->propagator("PropagatorWithMaterial")));
422  result = fromInside(iniState);
423  } else {
424  StateOnTrackerBound fromOutside(&*propagator());
425  result = fromOutside(innerState(staMuon));
426  }
427  return result;
428 }
void adjust(FreeTrajectoryState &) const
adjust the error matrix of the FTS
const MuonServiceProxy * theService
TrajectoryStateOnSurface innerState(const TrackCand &) const
edm::ESHandle< Propagator > propagator() const
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
bool FastTSGFromPropagation::passSelection ( const TrajectoryStateOnSurface tsos) const
private

check some quantity and beam-spot compatibility and decide to continue

Definition at line 475 of file FastTSGFromPropagation.cc.

References edm::HandleBase::isValid(), theBeamSpot, theSelectStateFlag, theSigmaZ, reco::BeamSpot::z0(), and zDis().

Referenced by propagator(), and trackerSeeds().

475  {
476  if (!theSelectStateFlag)
477  return true;
478  else {
479  if (theBeamSpot.isValid()) {
480  return ((fabs(zDis(tsos) - theBeamSpot->z0()) < theSigmaZ));
481 
482  } else {
483  return ((fabs(zDis(tsos)) < theSigmaZ));
484  // double theDxyCut = 100;
485  // return ( (zDis(tsos) < theSigmaZ) && (dxyDis(tsos) < theDxyCut) );
486  }
487  }
488 }
double z0() const
z coordinate
Definition: BeamSpot.h:65
edm::Handle< reco::BeamSpot > theBeamSpot
bool isValid() const
Definition: HandleBase.h:70
double zDis(const TrajectoryStateOnSurface &tsos) const
edm::ESHandle<Propagator> FastTSGFromPropagation::propagator ( ) const
inlineprivate

Definition at line 82 of file FastTSGFromPropagation.h.

References adjust(), createSeed(), dxyDis(), findMeasurements(), getRescalingFactor(), passSelection(), MuonServiceProxy::propagator(), thePropagatorName, theService, validMeasurements(), and zDis().

Referenced by findMeasurements(), outerTkState(), and trackerSeeds().

const MuonServiceProxy * theService
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator
void FastTSGFromPropagation::setEvent ( const edm::Event iEvent)
overridevirtual

set an event

Reimplemented from TrackerSeedGenerator.

Definition at line 358 of file FastTSGFromPropagation.cc.

References beamSpot_, edm::Event::getByToken(), LogTrace, edm::ESHandle< T >::product(), recHitCombinations, recHitCombinationsToken_, theBeamSpot, theCacheId_MT, theCacheId_TG, theCategory, theMeasTracker, theMeasTrackerEvent, theMeasurementTrackerEventToken_, theNavigation, theService, theSimTrackCollectionToken_, theSimTracks, theTracker, and theUpdateStateFlag.

358  {
360 
361  // retrieve the MC truth (SimTracks)
364 
365  unsigned long long newCacheId_MT = theService->eventSetup().get<CkfComponentsRecord>().cacheIdentifier();
366 
367  if (theUpdateStateFlag && newCacheId_MT != theCacheId_MT) {
368  LogTrace(theCategory) << "Measurment Tracker Geometry changed!";
369  theCacheId_MT = newCacheId_MT;
370  theService->eventSetup().get<CkfComponentsRecord>().get(theMeasTracker);
371  }
372 
373  if (theUpdateStateFlag) {
375  }
376 
377  bool trackerGeomChanged = false;
378 
379  unsigned long long newCacheId_TG = theService->eventSetup().get<TrackerRecoGeometryRecord>().cacheIdentifier();
380 
381  if (newCacheId_TG != theCacheId_TG) {
382  LogTrace(theCategory) << "Tracker Reco Geometry changed!";
383  theCacheId_TG = newCacheId_TG;
384  theService->eventSetup().get<TrackerRecoGeometryRecord>().get(theTracker);
385  trackerGeomChanged = true;
386  }
387 
388  if (trackerGeomChanged && theTracker.product()) {
390  }
391 }
edm::Handle< MeasurementTrackerEvent > theMeasTrackerEvent
edm::ESHandle< MeasurementTracker > theMeasTracker
edm::Handle< reco::BeamSpot > theBeamSpot
unsigned long long theCacheId_MT
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< edm::SimTrackContainer > theSimTrackCollectionToken_
edm::Handle< edm::SimTrackContainer > theSimTracks
edm::ESHandle< GeometricSearchTracker > theTracker
const MuonServiceProxy * theService
edm::EDGetTokenT< MeasurementTrackerEvent > theMeasurementTrackerEventToken_
#define LogTrace(id)
std::unique_ptr< const DirectTrackerNavigation > theNavigation
edm::Handle< FastTrackerRecHitCombinationCollection > recHitCombinations
edm::EDGetTokenT< reco::BeamSpot > beamSpot_
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken_
T const * product() const
Definition: ESHandle.h:86
unsigned long long theCacheId_TG
void FastTSGFromPropagation::stateOnDet ( const TrajectoryStateOnSurface ts,
unsigned int  detid,
PTrajectoryStateOnDet pts 
) const
private

A mere copy (without memory leak) of an existing tracking method.

should check if corresponds to m

Definition at line 552 of file FastTSGFromPropagation.cc.

References TrajectoryStateOnSurface::globalMomentum(), mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), visualization-live-secondInstance_cfg::m, LocalTrajectoryError::matrix(), PV3DBase< T, PVType, FrameType >::perp(), and TrajectoryStateOnSurface::surfaceSide().

554  {
555  const AlgebraicSymMatrix55& m = ts.localError().matrix();
556  int dim = 5;
557  float localErrors[15];
558  int k = 0;
559  for (int i = 0; i < dim; ++i) {
560  for (int j = 0; j <= i; ++j) {
561  localErrors[k++] = m(i, j);
562  }
563  }
564  int surfaceSide = static_cast<int>(ts.surfaceSide());
565  pts = PTrajectoryStateOnDet(ts.localParameters(), ts.globalMomentum().perp(), localErrors, detid, surfaceSide);
566 }
T perp() const
Definition: PV3DBase.h:69
const LocalTrajectoryParameters & localParameters() const
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
GlobalVector globalMomentum() const
void FastTSGFromPropagation::trackerSeeds ( const TrackCand staMuon,
const TrackingRegion region,
const TrackerTopology tTopo,
std::vector< TrajectorySeed > &  result 
)
override

generate seed(s) for a track

Definition at line 70 of file FastTSGFromPropagation.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), TransientTrackingRecHitBuilder::build(), CoreSimTrack::charge(), ALCARECOTkAlJpsiMuMu_cff::charge, FastTrackerRecHit::clone(), createSeed(), PTrajectoryStateOnDet::detId(), estimator(), PV3DBase< T, PVType, FrameType >::eta(), findMeasurements(), TrajectoryStateOnSurface::freeState(), g, TrackingRecHit::geographicalId(), getRescalingFactor(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrajectorySeedHitCandidate::hit(), triggerObjects_cff::id, TrackerGeometry::idToDet(), createfilelist::int, TrajectoryStateOnSurface::isValid(), LogTrace, oppositeToMomentum, outerTkState(), passSelection(), PV3DBase< T, PVType, FrameType >::perp(), position, propagator(), edm::OwnVector< T, P >::push_back(), DetId::rawId(), rpcPointValidation_cfi::recHit, recHitCombinations, fastTrackingUtilities::setRecHitCombinationIndex(), TrackCandidateProducer_cfi::simTracks, GeomDet::surface(), theCategory, theGeometry, theNavigation, theResetMethod, theService, theTTRHBuilder, theUpdateStateFlag, SimTrack::trackerSurfaceMomentum(), SimTrack::trackerSurfacePosition(), trajectoryStateTransform::transientState(), TrajectoryStateUpdator::update(), updator(), and PV3DBase< T, PVType, FrameType >::y().

73  {
74  if (theResetMethod == "discrete")
75  getRescalingFactor(staMuon);
76 
77  TrajectoryStateOnSurface staState = outerTkState(staMuon);
78 
79  if (!staState.isValid()) {
80  LogTrace(theCategory) << "Error: initial state from L2 muon is invalid.";
81  return;
82  }
83 
84  LogTrace(theCategory) << "begin of trackerSeed:\n staState pos: " << staState.globalPosition()
85  << " mom: " << staState.globalMomentum() << "pos eta: " << staState.globalPosition().eta()
86  << "mom eta: " << staState.globalMomentum().eta();
87 
88  std::vector<const DetLayer*> nls = theNavigation->compatibleLayers(*(staState.freeState()), oppositeToMomentum);
89 
90  LogTrace(theCategory) << " compatible layers: " << nls.size();
91 
92  if (nls.empty())
93  return;
94 
95  int ndesLayer = 0;
96 
97  bool usePredictedState = false;
98 
99  if (theUpdateStateFlag) { //use updated states
100  std::vector<TrajectoryMeasurement> alltm;
101 
102  for (std::vector<const DetLayer*>::const_iterator inl = nls.begin(); inl != nls.end(); inl++, ndesLayer++) {
103  if ((*inl == nullptr))
104  break;
105  // if ( (inl != nls.end()-1 ) && ( (*inl)->subDetector() == GeomDetEnumerators::TEC ) && ( (*(inl+1))->subDetector() == GeomDetEnumerators::TOB ) ) continue;
106  alltm = findMeasurements(*inl, staState);
107  if ((!alltm.empty())) {
108  LogTrace(theCategory) << "final compatible layer: " << ndesLayer;
109  break;
110  }
111  }
112 
113  if (alltm.empty()) {
114  LogTrace(theCategory) << " NO Measurements Found: eta: " << staState.globalPosition().eta() << "pt "
115  << staState.globalMomentum().perp();
116  usePredictedState = true;
117  } else {
118  LogTrace(theCategory) << " Measurements for seeds: " << alltm.size();
119  std::stable_sort(alltm.begin(), alltm.end(), increasingEstimate());
120  if (alltm.size() > 5)
121  alltm.erase(alltm.begin() + 5, alltm.end());
122 
123  const edm::SimTrackContainer* simTracks = &(*theSimTracks);
124  TrajectorySeedHitCandidate theSeedHits;
125  std::vector<TrajectorySeedHitCandidate> outerHits;
126 
127  //std::vector<TrajectorySeed> tmpTS;
128  bool isMatch = false;
129  for (std::vector<TrajectoryMeasurement>::const_iterator itm = alltm.begin(); itm != alltm.end(); itm++) {
130  const TrajectoryStateOnSurface seedState = itm->predictedState();
131  double preY = seedState.globalPosition().y();
132 
133  // Check SimTrack
134  FreeTrajectoryState simtrack_trackerstate;
135  for (unsigned icomb = 0; icomb < recHitCombinations->size(); ++icomb) {
136  const auto& recHitCombination = (*recHitCombinations)[icomb];
137  if (recHitCombination.empty())
138  continue;
139  int32_t simTrackId = recHitCombination.back()->simTrackId(0);
140  const SimTrack& simtrack = (*simTracks)[simTrackId];
141 
143  simtrack.trackerSurfacePosition().y(),
144  simtrack.trackerSurfacePosition().z());
145  GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(),
146  simtrack.trackerSurfaceMomentum().y(),
147  simtrack.trackerSurfaceMomentum().z());
148  int charge = (int)simtrack.charge();
149  GlobalTrajectoryParameters glb_parameters(
150  position, momentum, charge, &*theService->magneticField().product());
151  simtrack_trackerstate = FreeTrajectoryState(glb_parameters);
152 
153  unsigned int outerId = 0;
154  for (const auto& recHitRef : recHitCombination) {
155  theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo);
156  unsigned int id = theSeedHits.hit()->geographicalId().rawId();
157  if (preY < 0) {
158  if (id > outerId)
159  outerId = id;
160  } else {
161  if (id > outerId)
162  outerId = id;
163  }
164  }
165  for (const auto& recHitRef : recHitCombination) {
166  theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo);
167  if (itm->recHit()->hit()->geographicalId().rawId() == theSeedHits.hit()->geographicalId().rawId()) {
168  auto aTrackingRecHit = std::unique_ptr<TrackingRecHit>(theSeedHits.hit()->clone());
170  if (!recHit)
171  continue;
172  TrajectoryStateOnSurface updatedTSOS = updator()->update(seedState, *(recHit));
173  if (updatedTSOS.isValid() && passSelection(updatedTSOS)) {
175  container.push_back(recHit->hit()->clone());
177  TrajectorySeed ts = createSeed(updatedTSOS, container, recHit->geographicalId());
178  // check direction
179  const TrajectorySeed* aSeed = &ts;
180  PTrajectoryStateOnDet PTSOD = aSeed->startingState();
181 
182  const GeomDet* g = theGeometry->idToDet(PTSOD.detId());
184  PTSOD, &(g->surface()), &*theService->magneticField().product());
185  if (tsos.globalMomentum().basicVector() * seedState.globalMomentum().basicVector() < 0.)
186  continue;
187  result.push_back(ts);
188  isMatch = true;
189  }
190  }
191  }
192  }
193  }
194  if (!isMatch) {
195  // if there is no hits w.r.t. TM, find outermost hit
196  for (std::vector<TrajectoryMeasurement>::const_iterator itm = alltm.begin(); itm != alltm.end(); itm++) {
197  const TrajectoryStateOnSurface seedState = itm->predictedState();
198  double preY = seedState.globalPosition().y();
199 
200  // Check SimTrack
201  TrackingRecHit* aTrackingRecHit;
202  FreeTrajectoryState simtrack_trackerstate;
203 
204  for (unsigned icomb = 0; icomb < recHitCombinations->size(); ++icomb) {
205  const auto& recHitCombination = (*recHitCombinations)[icomb];
206  if (recHitCombination.empty())
207  continue;
208  int32_t simTrackId = recHitCombination.back()->simTrackId(0);
209  const SimTrack& simtrack = (*simTracks)[simTrackId];
210 
212  simtrack.trackerSurfacePosition().y(),
213  simtrack.trackerSurfacePosition().z());
214  GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(),
215  simtrack.trackerSurfaceMomentum().y(),
216  simtrack.trackerSurfaceMomentum().z());
217  int charge = (int)simtrack.charge();
218  GlobalTrajectoryParameters glb_parameters(
219  position, momentum, charge, &*theService->magneticField().product());
220  simtrack_trackerstate = FreeTrajectoryState(glb_parameters);
221 
222  unsigned int outerId = 0;
223  for (const auto& recHitRef : recHitCombination) {
224  theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo);
225  unsigned int id = theSeedHits.hit()->geographicalId().rawId();
226  if (preY < 0) {
227  if (id > outerId)
228  outerId = id;
229  } else {
230  if (id > outerId)
231  outerId = id;
232  }
233  }
234  for (const auto& recHitRef : recHitCombination) {
235  theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo);
236  if (outerId == theSeedHits.hit()->geographicalId().rawId()) {
237  aTrackingRecHit = theSeedHits.hit()->clone();
239  if (!recHit)
240  continue;
241  TrajectoryStateOnSurface updatedTSOS = updator()->update(seedState, *(recHit));
242  if (updatedTSOS.isValid() && passSelection(updatedTSOS)) {
244  container.push_back(recHit->hit()->clone());
246  TrajectorySeed ts = createSeed(updatedTSOS, container, recHit->geographicalId());
247  // check direction
248  const TrajectorySeed* aSeed = &ts;
249  PTrajectoryStateOnDet PTSOD = aSeed->startingState();
250 
251  const GeomDet* g = theGeometry->idToDet(PTSOD.detId());
253  PTSOD, &(g->surface()), &*theService->magneticField().product());
254  if (tsos.globalMomentum().basicVector() * seedState.globalMomentum().basicVector() < 0.)
255  continue;
256  result.push_back(ts);
257  }
258  }
259  }
260  }
261  }
262  }
263 
264  /*
265  for( unsigned ir = 0; ir < tmpTS.size(); ir++ ) {
266  const BasicTrajectorySeed* aSeed = &((tmpTS)[ir]);
267  PTrajectoryStateOnDet PTSOD = aSeed->startingState();
268 
269  DetId seedDetId(PTSOD.detId());
270  const GeomDet * g = theGeometry->idToDet(seedDetId);
271  TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(PTSOD, &(g->surface()), &*theService->magneticField().product());
272  cout << "tsos3 = " << tsos.globalMomentum() << endl;
273  if( _index == ir ) {
274  cout << "tsos4 = " << tsos.globalMomentum() << endl;
275  result.push_back(tmpTS[ir]);
276  }
277  }
278  */
279  LogTrace(theCategory) << "result: " << result.size();
280  return;
281  }
282  }
283 
284  if (!theUpdateStateFlag || usePredictedState) { //use predicted states
285  LogTrace(theCategory) << "use predicted state: ";
286  for (std::vector<const DetLayer*>::const_iterator inl = nls.begin(); inl != nls.end(); inl++) {
287  if (!result.empty() || *inl == nullptr) {
288  break;
289  }
290  std::vector<DetLayer::DetWithState> compatDets = (*inl)->compatibleDets(staState, *propagator(), *estimator());
291  LogTrace(theCategory) << " compatDets " << compatDets.size();
292  if (compatDets.empty())
293  continue;
294  TrajectorySeed ts = createSeed(compatDets.front().second, compatDets.front().first->geographicalId());
295  result.push_back(ts);
296  }
297  LogTrace(theCategory) << "result: " << result.size();
298  return;
299  }
300  return;
301 }
std::vector< TrajectoryMeasurement > findMeasurements(const DetLayer *, const TrajectoryStateOnSurface &) const
look for measurements on the first compatible layer
void setRecHitCombinationIndex(edm::OwnVector< T > &recHits, int32_t icomb)
const math::XYZVectorD & trackerSurfacePosition() const
Definition: SimTrack.h:37
T perp() const
Definition: PV3DBase.h:69
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
const MuonServiceProxy * theService
float charge() const
charge
Definition: CoreSimTrack.cc:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
const Chi2MeasurementEstimator * estimator() const
FastTrackerRecHit * clone() const override
void getRescalingFactor(const TrackCand &staMuon)
void push_back(D *&d)
Definition: OwnVector.h:326
bool passSelection(const TrajectoryStateOnSurface &) const
check some quantity and beam-spot compatibility and decide to continue
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
FreeTrajectoryState const * freeState(bool withErrors=true) const
unsigned int detId() const
TrajectoryStateOnSurface outerTkState(const TrackCand &) const
#define LogTrace(id)
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
const TrackerGeometry * theGeometry
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
const TrajectoryStateUpdator * updator() const
std::unique_ptr< const DirectTrackerNavigation > theNavigation
const math::XYZTLorentzVectorD & trackerSurfaceMomentum() const
Definition: SimTrack.h:39
edm::ESHandle< Propagator > propagator() const
TrajectorySeed createSeed(const TrajectoryStateOnSurface &, const DetId &) const
create a hitless seed from a trajectory state
edm::Handle< FastTrackerRecHitCombinationCollection > recHitCombinations
T eta() const
Definition: PV3DBase.h:73
GlobalVector globalMomentum() const
static int position[264][3]
Definition: ReadPGInfo.cc:289
const TrackerGeomDet * idToDet(DetId) const override
const FastTrackerRecHit * hit() const
The Hit itself.
DetId geographicalId() const
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
std::vector< SimTrack > SimTrackContainer
const TrajectoryStateUpdator* FastTSGFromPropagation::updator ( ) const
inlineprivate

Definition at line 78 of file FastTSGFromPropagation.h.

References theUpdator.

Referenced by trackerSeeds().

78 { return theUpdator.get(); }
std::unique_ptr< const TrajectoryStateUpdator > theUpdator
void FastTSGFromPropagation::validMeasurements ( std::vector< TrajectoryMeasurement > &  tms) const
private

select valid measurements

Definition at line 442 of file FastTSGFromPropagation.cc.

Referenced by propagator().

442  {
443  std::vector<TrajectoryMeasurement>::iterator tmsend = std::remove_if(tms.begin(), tms.end(), isInvalid());
444  tms.erase(tmsend, tms.end());
445  return;
446 }
double FastTSGFromPropagation::zDis ( const TrajectoryStateOnSurface tsos) const
private

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> FastTSGFromPropagation::beamSpot_
private

Definition at line 170 of file FastTSGFromPropagation.h.

Referenced by setEvent().

edm::Handle<FastTrackerRecHitCombinationCollection> FastTSGFromPropagation::recHitCombinations
private

Definition at line 175 of file FastTSGFromPropagation.h.

Referenced by setEvent(), and trackerSeeds().

edm::EDGetTokenT<FastTrackerRecHitCombinationCollection> FastTSGFromPropagation::recHitCombinationsToken_
private

Definition at line 169 of file FastTSGFromPropagation.h.

Referenced by setEvent().

bool FastTSGFromPropagation::theAdjustAtIp
private

Definition at line 163 of file FastTSGFromPropagation.h.

Referenced by init().

edm::Handle<reco::BeamSpot> FastTSGFromPropagation::theBeamSpot
private

Definition at line 173 of file FastTSGFromPropagation.h.

Referenced by passSelection(), and setEvent().

unsigned long long FastTSGFromPropagation::theCacheId_MT
private

Definition at line 126 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

unsigned long long FastTSGFromPropagation::theCacheId_TG
private

Definition at line 127 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

std::string FastTSGFromPropagation::theCategory
private

Definition at line 129 of file FastTSGFromPropagation.h.

Referenced by setEvent(), trackerSeeds(), and ~FastTSGFromPropagation().

const edm::ParameterSet FastTSGFromPropagation::theConfig
private

Definition at line 167 of file FastTSGFromPropagation.h.

Referenced by init().

std::unique_ptr<MuonErrorMatrix> FastTSGFromPropagation::theErrorMatrixAdjuster
private

Definition at line 161 of file FastTSGFromPropagation.h.

Referenced by adjust(), and init().

std::unique_ptr<const Chi2MeasurementEstimator> FastTSGFromPropagation::theEstimator
private

Definition at line 143 of file FastTSGFromPropagation.h.

Referenced by estimator(), and init().

double FastTSGFromPropagation::theFixedErrorRescaling
private

Definition at line 149 of file FastTSGFromPropagation.h.

Referenced by adjust(), and init().

double FastTSGFromPropagation::theFlexErrorRescaling
private

Definition at line 147 of file FastTSGFromPropagation.h.

Referenced by adjust(), getRescalingFactor(), and init().

const TrackerGeometry* FastTSGFromPropagation::theGeometry
private

Definition at line 137 of file FastTSGFromPropagation.h.

Referenced by init(), and trackerSeeds().

double FastTSGFromPropagation::theMaxChi2
private

Definition at line 145 of file FastTSGFromPropagation.h.

Referenced by init().

edm::ESHandle<MeasurementTracker> FastTSGFromPropagation::theMeasTracker
private

Definition at line 133 of file FastTSGFromPropagation.h.

Referenced by setEvent().

edm::Handle<MeasurementTrackerEvent> FastTSGFromPropagation::theMeasTrackerEvent
private

Definition at line 176 of file FastTSGFromPropagation.h.

Referenced by findMeasurements(), and setEvent().

edm::EDGetTokenT<MeasurementTrackerEvent> FastTSGFromPropagation::theMeasurementTrackerEventToken_
private

Definition at line 171 of file FastTSGFromPropagation.h.

Referenced by setEvent().

std::unique_ptr<const DirectTrackerNavigation> FastTSGFromPropagation::theNavigation
private

Definition at line 135 of file FastTSGFromPropagation.h.

Referenced by init(), setEvent(), and trackerSeeds().

std::string FastTSGFromPropagation::thePropagatorName
private

Definition at line 159 of file FastTSGFromPropagation.h.

Referenced by init(), and propagator().

std::string FastTSGFromPropagation::theResetMethod
private

Definition at line 155 of file FastTSGFromPropagation.h.

Referenced by adjust(), init(), and trackerSeeds().

bool FastTSGFromPropagation::theSelectStateFlag
private

Definition at line 157 of file FastTSGFromPropagation.h.

Referenced by init(), and passSelection().

const MuonServiceProxy* FastTSGFromPropagation::theService
private
double FastTSGFromPropagation::theSigmaZ
private

Definition at line 165 of file FastTSGFromPropagation.h.

Referenced by init(), and passSelection().

edm::EDGetTokenT<edm::SimTrackContainer> FastTSGFromPropagation::theSimTrackCollectionToken_
private

Definition at line 168 of file FastTSGFromPropagation.h.

Referenced by setEvent().

edm::Handle<edm::SimTrackContainer> FastTSGFromPropagation::theSimTracks
private

Definition at line 174 of file FastTSGFromPropagation.h.

Referenced by setEvent().

edm::ESHandle<GeometricSearchTracker> FastTSGFromPropagation::theTracker
private

Definition at line 131 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

edm::ESHandle<TransientTrackingRecHitBuilder> FastTSGFromPropagation::theTTRHBuilder
private

Definition at line 177 of file FastTSGFromPropagation.h.

Referenced by init(), and trackerSeeds().

bool FastTSGFromPropagation::theUpdateStateFlag
private

Definition at line 153 of file FastTSGFromPropagation.h.

Referenced by init(), setEvent(), and trackerSeeds().

std::unique_ptr<const TrajectoryStateUpdator> FastTSGFromPropagation::theUpdator
private

Definition at line 141 of file FastTSGFromPropagation.h.

Referenced by init(), and updator().

bool FastTSGFromPropagation::theUseVertexStateFlag
private

Definition at line 151 of file FastTSGFromPropagation.h.

Referenced by init(), and outerTkState().