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_TG
 
std::string theCategory
 
const edm::ParameterSet theConfig
 
std::unique_ptr< MuonErrorMatrixtheErrorMatrixAdjuster
 
std::unique_ptr< const Chi2MeasurementEstimatortheEstimator
 
double theFixedErrorRescaling
 
double theFlexErrorRescaling
 
const TrackerGeometrytheGeometry
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtheGeometryToken
 
double theMaxChi2
 
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::ESGetToken< GeometricSearchTracker, TrackerRecoGeometryRecordtheTrackerToken
 
edm::ESHandle< TransientTrackingRecHitBuildertheTTRHBuilder
 
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecordtheTTRHBuilderToken
 
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 51 of file FastTSGFromPropagation.h.

Constructor & Destructor Documentation

◆ FastTSGFromPropagation() [1/2]

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

constructor

Definition at line 48 of file FastTSGFromPropagation.cc.

49  : FastTSGFromPropagation(iConfig, nullptr, iC) {}
FastTSGFromPropagation(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
constructor

◆ FastTSGFromPropagation() [2/2]

FastTSGFromPropagation::FastTSGFromPropagation ( const edm::ParameterSet par,
const MuonServiceProxy service,
edm::ConsumesCollector iC 
)

Definition at line 51 of file FastTSGFromPropagation.cc.

54  : theCategory("FastSimulation|Muons|FastTSGFromPropagation"),
55  theNavigation(),
57  theUpdator(),
58  theEstimator(),
59  theSigmaZ(0.0),
60  theConfig(iConfig),
62  iC.consumes<edm::SimTrackContainer>(theConfig.getParameter<edm::InputTag>("SimTrackCollectionLabel"))),
65  beamSpot_(iC.consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
67  iC.consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent"))),
std::unique_ptr< const TrajectoryStateUpdator > theUpdator
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theGeometryToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::SimTrackContainer > theSimTrackCollectionToken_
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theTTRHBuilderToken
const MuonServiceProxy * theService
edm::EDGetTokenT< MeasurementTrackerEvent > theMeasurementTrackerEventToken_
const edm::ParameterSet theConfig
std::unique_ptr< const DirectTrackerNavigation > theNavigation
edm::ESGetToken< GeometricSearchTracker, TrackerRecoGeometryRecord > theTrackerToken
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::~FastTSGFromPropagation ( )
override

destructor

Definition at line 72 of file FastTSGFromPropagation.cc.

References LogTrace, and theCategory.

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

Member Function Documentation

◆ adjust() [1/2]

void FastTSGFromPropagation::adjust ( FreeTrajectoryState state) const
private

adjust the error matrix of the FTS

Definition at line 495 of file FastTSGFromPropagation.cc.

References MuonErrorMatrix::multiply(), theErrorMatrixAdjuster, theFixedErrorRescaling, theFlexErrorRescaling, and theResetMethod.

Referenced by innerState(), and outerTkState().

495  {
496  //rescale the error
497  if (theResetMethod == "discreate") {
498  state.rescaleError(theFlexErrorRescaling);
499  return;
500  }
501 
502  //rescale the error
503  if (theResetMethod == "fixed" || !theErrorMatrixAdjuster) {
504  state.rescaleError(theFixedErrorRescaling);
505  return;
506  }
507 
508  CurvilinearTrajectoryError oMat = state.curvilinearError();
509  CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.momentum()); //FIXME with position
510  MuonErrorMatrix::multiply(oMat, sfMat);
511 
512  state = FreeTrajectoryState(state.parameters(), oMat);
513 }
static void multiply(CurvilinearTrajectoryError &initial_error, const CurvilinearTrajectoryError &scale_error)
multiply term by term the two matrix
std::unique_ptr< MuonErrorMatrix > theErrorMatrixAdjuster

◆ adjust() [2/2]

void FastTSGFromPropagation::adjust ( TrajectoryStateOnSurface state) const
private

adjust the error matrix of the TSOS

Definition at line 515 of file FastTSGFromPropagation.cc.

References MuonErrorMatrix::multiply(), theErrorMatrixAdjuster, theFixedErrorRescaling, theFlexErrorRescaling, and theResetMethod.

515  {
516  //rescale the error
517  if (theResetMethod == "discreate") {
518  state.rescaleError(theFlexErrorRescaling);
519  return;
520  }
521 
522  if (theResetMethod == "fixed" || !theErrorMatrixAdjuster) {
523  state.rescaleError(theFixedErrorRescaling);
524  return;
525  }
526 
527  CurvilinearTrajectoryError oMat = state.curvilinearError();
528  CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.globalMomentum()); //FIXME with position
529  MuonErrorMatrix::multiply(oMat, sfMat);
530 
531  state =
532  TrajectoryStateOnSurface(state.weight(), state.globalParameters(), oMat, state.surface(), state.surfaceSide());
533 }
static void multiply(CurvilinearTrajectoryError &initial_error, const CurvilinearTrajectoryError &scale_error)
multiply term by term the two matrix
std::unique_ptr< MuonErrorMatrix > theErrorMatrixAdjuster

◆ createSeed() [1/2]

TrajectorySeed FastTSGFromPropagation::createSeed ( const TrajectoryStateOnSurface tsos,
const DetId id 
) const
private

create a hitless seed from a trajectory state

Definition at line 413 of file FastTSGFromPropagation.cc.

Referenced by trackerSeeds().

413  {
415  return createSeed(tsos, container, id);
416 }
TrajectorySeed createSeed(const TrajectoryStateOnSurface &, const DetId &) const
create a hitless seed from a trajectory state

◆ createSeed() [2/2]

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 418 of file FastTSGFromPropagation.cc.

References oppositeToMomentum, and trajectoryStateTransform::persistentState().

420  {
422  return TrajectorySeed(seedTSOS, container, oppositeToMomentum);
423 }
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)

◆ dxyDis()

double FastTSGFromPropagation::dxyDis ( const TrajectoryStateOnSurface tsos) const
private

◆ estimator()

const Chi2MeasurementEstimator* FastTSGFromPropagation::estimator ( void  ) const
inlineprivate

Definition at line 83 of file FastTSGFromPropagation.h.

References theEstimator.

Referenced by findMeasurements(), and trackerSeeds().

83 { return theEstimator.get(); }
std::unique_ptr< const Chi2MeasurementEstimator > theEstimator

◆ findMeasurements()

std::vector< TrajectoryMeasurement > FastTSGFromPropagation::findMeasurements ( const DetLayer nl,
const TrajectoryStateOnSurface staState 
) const
private

look for measurements on the first compatible layer

Definition at line 431 of file FastTSGFromPropagation.cc.

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

Referenced by trackerSeeds().

432  {
433  std::vector<TrajectoryMeasurement> result;
434 
435  std::vector<DetLayer::DetWithState> compatDets = nl->compatibleDets(staState, *propagator(), *estimator());
436  if (compatDets.empty())
437  return result;
438 
439  for (std::vector<DetLayer::DetWithState>::const_iterator idws = compatDets.begin(); idws != compatDets.end();
440  ++idws) {
441  if (idws->second.isValid() && (idws->first)) {
442  std::vector<TrajectoryMeasurement> tmptm =
443  theMeasTrackerEvent->idToDet(idws->first->geographicalId())
444  .fastMeasurements(idws->second, idws->second, *propagator(), *estimator());
445  //validMeasurements(tmptm);
446  // if ( tmptm.size() > 2 ) {
447  // std::stable_sort(tmptm.begin(),tmptm.end(),increasingEstimate());
448  // result.insert(result.end(),tmptm.begin(), tmptm.begin()+2);
449  // } else {
450  result.insert(result.end(), tmptm.begin(), tmptm.end());
451  // }
452  }
453  }
454 
455  return result;
456 }
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

◆ getRescalingFactor()

void FastTSGFromPropagation::getRescalingFactor ( const TrackCand staMuon)
private

Definition at line 484 of file FastTSGFromPropagation.cc.

References DiDispStaMuonMonitor_cfi::pt, and theFlexErrorRescaling.

Referenced by trackerSeeds().

484  {
485  float pt = (staMuon.second)->pt();
486  if (pt < 13.0)
488  else if (pt < 30.0)
490  else
492  return;
493 }

◆ init()

void FastTSGFromPropagation::init ( const MuonServiceProxy service)
overridevirtual

initialize

Reimplemented from TrackerSeedGenerator.

Definition at line 307 of file FastTSGFromPropagation.cc.

References HLT_2022v11_cff::errorMatrixPset, edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theAdjustAtIp, theCacheId_TG, theConfig, theErrorMatrixAdjuster, theEstimator, theFixedErrorRescaling, theFlexErrorRescaling, theGeometry, theGeometryToken, theMaxChi2, thePropagatorName, theResetMethod, theSelectStateFlag, theService, theSigmaZ, theTTRHBuilder, theTTRHBuilderToken, theUpdateStateFlag, theUpdator, and theUseVertexStateFlag.

307  {
308  theMaxChi2 = theConfig.getParameter<double>("MaxChi2");
309 
310  theFixedErrorRescaling = theConfig.getParameter<double>("ErrorRescaling");
311 
312  theFlexErrorRescaling = 1.0;
313 
315 
316  if (theResetMethod != "discrete" && theResetMethod != "fixed" && theResetMethod != "matrix") {
317  edm::LogError("FastTSGFromPropagation") << "Wrong error rescaling method: " << theResetMethod << "\n"
318  << "Possible choices are: discrete, fixed, matrix.\n"
319  << "Use discrete method" << std::endl;
320  theResetMethod = "discrete";
321  }
322 
323  theEstimator = std::make_unique<Chi2MeasurementEstimator>(theMaxChi2);
324 
325  theCacheId_TG = 0;
326 
328 
330 
331  theUseVertexStateFlag = theConfig.getParameter<bool>("UseVertexState");
332 
333  theUpdateStateFlag = theConfig.getParameter<bool>("UpdateState");
334 
335  theSelectStateFlag = theConfig.getParameter<bool>("SelectState");
336 
337  theUpdator = std::make_unique<KFUpdator>();
338 
339  theSigmaZ = theConfig.getParameter<double>("SigmaZ");
340 
342  if (theResetMethod == "matrix" && !errorMatrixPset.empty()) {
343  theAdjustAtIp = errorMatrixPset.getParameter<bool>("atIP");
344  theErrorMatrixAdjuster = std::make_unique<MuonErrorMatrix>(errorMatrixPset);
345  } else {
346  theAdjustAtIp = false;
347  theErrorMatrixAdjuster.reset();
348  }
349 
350  theGeometry = &theService->eventSetup().getData(theGeometryToken);
351 
352  theTTRHBuilder = theService->eventSetup().getHandle(theTTRHBuilderToken);
353 }
std::unique_ptr< const TrajectoryStateUpdator > theUpdator
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theGeometryToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theTTRHBuilderToken
const MuonServiceProxy * theService
Log< level::Error, false > LogError
const edm::ParameterSet theConfig
const TrackerGeometry * theGeometry
std::unique_ptr< const Chi2MeasurementEstimator > theEstimator
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder
unsigned long long theCacheId_TG
std::unique_ptr< MuonErrorMatrix > theErrorMatrixAdjuster

◆ innerState()

TrajectoryStateOnSurface FastTSGFromPropagation::innerState ( const TrackCand staMuon) const
private

Definition at line 376 of file FastTSGFromPropagation.cc.

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

Referenced by outerTkState().

376  {
377  TrajectoryStateOnSurface innerTS;
378 
379  if (staMuon.first && staMuon.first->isValid()) {
380  if (staMuon.first->direction() == alongMomentum) {
381  innerTS = staMuon.first->firstMeasurement().updatedState();
382  } else if (staMuon.first->direction() == oppositeToMomentum) {
383  innerTS = staMuon.first->lastMeasurement().updatedState();
384  }
385  } else {
387  *(staMuon.second), *theService->trackingGeometry(), &*theService->magneticField());
388  }
389  //rescale the error
390  adjust(innerTS);
391 
392  return innerTS;
393 }
const MuonServiceProxy * theService
void adjust(FreeTrajectoryState &) const
adjust the error matrix of the FTS
TrajectoryStateOnSurface innerStateOnSurface(const reco::Track &tk, const TrackingGeometry &geom, const MagneticField *field, bool withErr=true)

◆ outerTkState()

TrajectoryStateOnSurface FastTSGFromPropagation::outerTkState ( const TrackCand staMuon) const
private

Definition at line 395 of file FastTSGFromPropagation.cc.

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

Referenced by trackerSeeds().

395  {
397 
398  if (theUseVertexStateFlag && staMuon.second->pt() > 1.0) {
399  FreeTrajectoryState iniState =
400  trajectoryStateTransform::initialFreeState(*(staMuon.second), &*theService->magneticField());
401  //rescale the error at IP
402  adjust(iniState);
403 
404  StateOnTrackerBound fromInside(&*(theService->propagator("PropagatorWithMaterial")));
405  result = fromInside(iniState);
406  } else {
407  StateOnTrackerBound fromOutside(&*propagator());
408  result = fromOutside(innerState(staMuon));
409  }
410  return result;
411 }
const MuonServiceProxy * theService
void adjust(FreeTrajectoryState &) const
adjust the error matrix of the FTS
TrajectoryStateOnSurface innerState(const TrackCand &) const
edm::ESHandle< Propagator > propagator() const
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)

◆ passSelection()

bool FastTSGFromPropagation::passSelection ( const TrajectoryStateOnSurface tsos) const
private

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

Definition at line 458 of file FastTSGFromPropagation.cc.

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

Referenced by trackerSeeds().

458  {
459  if (!theSelectStateFlag)
460  return true;
461  else {
462  if (theBeamSpot.isValid()) {
463  return ((fabs(zDis(tsos) - theBeamSpot->z0()) < theSigmaZ));
464 
465  } else {
466  return ((fabs(zDis(tsos)) < theSigmaZ));
467  // double theDxyCut = 100;
468  // return ( (zDis(tsos) < theSigmaZ) && (dxyDis(tsos) < theDxyCut) );
469  }
470  }
471 }
edm::Handle< reco::BeamSpot > theBeamSpot
double zDis(const TrajectoryStateOnSurface &tsos) const
bool isValid() const
Definition: HandleBase.h:70
double z0() const
z coordinate
Definition: BeamSpot.h:65

◆ propagator()

edm::ESHandle<Propagator> FastTSGFromPropagation::propagator ( ) const
inlineprivate

Definition at line 85 of file FastTSGFromPropagation.h.

References MuonServiceProxy::propagator(), thePropagatorName, and theService.

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

const MuonServiceProxy * theService
edm::ESHandle< Propagator > propagator(std::string propagatorName) const
get the propagator

◆ setEvent()

void FastTSGFromPropagation::setEvent ( const edm::Event iEvent)
overridevirtual

set an event

Reimplemented from TrackerSeedGenerator.

Definition at line 355 of file FastTSGFromPropagation.cc.

References beamSpot_, iEvent, LogTrace, recHitCombinations, recHitCombinationsToken_, theBeamSpot, theCacheId_TG, theCategory, theMeasTrackerEvent, theMeasurementTrackerEventToken_, theNavigation, theService, theSimTrackCollectionToken_, theSimTracks, theTrackerToken, and theUpdateStateFlag.

355  {
356  iEvent.getByToken(beamSpot_, theBeamSpot);
357 
358  // retrieve the MC truth (SimTracks)
361 
362  if (theUpdateStateFlag) {
364  }
365 
366  unsigned long long newCacheId_TG = theService->eventSetup().get<TrackerRecoGeometryRecord>().cacheIdentifier();
367 
368  if (newCacheId_TG != theCacheId_TG) {
369  LogTrace(theCategory) << "Tracker Reco Geometry changed!";
370  theCacheId_TG = newCacheId_TG;
371  auto theTracker = theService->eventSetup().getHandle(theTrackerToken);
372  theNavigation = std::make_unique<DirectTrackerNavigation>(theTracker);
373  }
374 }
edm::Handle< MeasurementTrackerEvent > theMeasTrackerEvent
edm::Handle< reco::BeamSpot > theBeamSpot
edm::EDGetTokenT< edm::SimTrackContainer > theSimTrackCollectionToken_
edm::Handle< edm::SimTrackContainer > theSimTracks
const MuonServiceProxy * theService
#define LogTrace(id)
edm::EDGetTokenT< MeasurementTrackerEvent > theMeasurementTrackerEventToken_
int iEvent
Definition: GenABIO.cc:224
std::unique_ptr< const DirectTrackerNavigation > theNavigation
edm::Handle< FastTrackerRecHitCombinationCollection > recHitCombinations
edm::ESGetToken< GeometricSearchTracker, TrackerRecoGeometryRecord > theTrackerToken
edm::EDGetTokenT< reco::BeamSpot > beamSpot_
edm::EDGetTokenT< FastTrackerRecHitCombinationCollection > recHitCombinationsToken_
unsigned long long theCacheId_TG

◆ stateOnDet()

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 535 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(), RPCpg::pts, and TrajectoryStateOnSurface::surfaceSide().

537  {
538  const AlgebraicSymMatrix55& m = ts.localError().matrix();
539  int dim = 5;
540  float localErrors[15];
541  int k = 0;
542  for (int i = 0; i < dim; ++i) {
543  for (int j = 0; j <= i; ++j) {
544  localErrors[k++] = m(i, j);
545  }
546  }
547  int surfaceSide = static_cast<int>(ts.surfaceSide());
548  pts = PTrajectoryStateOnDet(ts.localParameters(), ts.globalMomentum().perp(), localErrors, detid, surfaceSide);
549 }
T perp() const
Definition: PV3DBase.h:69
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
const LocalTrajectoryError & localError() const
const LocalTrajectoryParameters & localParameters() const
static const double pts[33]
Definition: Constants.h:30
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
GlobalVector globalMomentum() const
const AlgebraicSymMatrix55 & matrix() const

◆ trackerSeeds()

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 74 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, mps_fire::result, fastTrackingUtilities::setRecHitCombinationIndex(), TrackCandidateProducer_cfi::simTracks, theCategory, theGeometry, theNavigation, theResetMethod, theService, theTTRHBuilder, theUpdateStateFlag, SimTrack::trackerSurfaceMomentum(), SimTrack::trackerSurfacePosition(), trajectoryStateTransform::transientState(), TrajectoryStateUpdator::update(), updator(), and PV3DBase< T, PVType, FrameType >::y().

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

◆ updator()

const TrajectoryStateUpdator* FastTSGFromPropagation::updator ( ) const
inlineprivate

Definition at line 81 of file FastTSGFromPropagation.h.

References theUpdator.

Referenced by trackerSeeds().

81 { return theUpdator.get(); }
std::unique_ptr< const TrajectoryStateUpdator > theUpdator

◆ validMeasurements()

void FastTSGFromPropagation::validMeasurements ( std::vector< TrajectoryMeasurement > &  tms) const
private

select valid measurements

Definition at line 425 of file FastTSGFromPropagation.cc.

425  {
426  std::vector<TrajectoryMeasurement>::iterator tmsend = std::remove_if(tms.begin(), tms.end(), isInvalid());
427  tms.erase(tmsend, tms.end());
428  return;
429 }

◆ zDis()

double FastTSGFromPropagation::zDis ( const TrajectoryStateOnSurface tsos) const
private

Member Data Documentation

◆ beamSpot_

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

Definition at line 168 of file FastTSGFromPropagation.h.

Referenced by setEvent().

◆ recHitCombinations

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

Definition at line 173 of file FastTSGFromPropagation.h.

Referenced by setEvent(), and trackerSeeds().

◆ recHitCombinationsToken_

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

Definition at line 167 of file FastTSGFromPropagation.h.

Referenced by setEvent().

◆ theAdjustAtIp

bool FastTSGFromPropagation::theAdjustAtIp
private

Definition at line 161 of file FastTSGFromPropagation.h.

Referenced by init().

◆ theBeamSpot

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

Definition at line 171 of file FastTSGFromPropagation.h.

Referenced by passSelection(), and setEvent().

◆ theCacheId_TG

unsigned long long FastTSGFromPropagation::theCacheId_TG
private

Definition at line 129 of file FastTSGFromPropagation.h.

Referenced by init(), and setEvent().

◆ theCategory

std::string FastTSGFromPropagation::theCategory
private

Definition at line 131 of file FastTSGFromPropagation.h.

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

◆ theConfig

const edm::ParameterSet FastTSGFromPropagation::theConfig
private

Definition at line 165 of file FastTSGFromPropagation.h.

Referenced by init().

◆ theErrorMatrixAdjuster

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

Definition at line 159 of file FastTSGFromPropagation.h.

Referenced by adjust(), and init().

◆ theEstimator

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

Definition at line 141 of file FastTSGFromPropagation.h.

Referenced by estimator(), and init().

◆ theFixedErrorRescaling

double FastTSGFromPropagation::theFixedErrorRescaling
private

Definition at line 147 of file FastTSGFromPropagation.h.

Referenced by adjust(), and init().

◆ theFlexErrorRescaling

double FastTSGFromPropagation::theFlexErrorRescaling
private

Definition at line 145 of file FastTSGFromPropagation.h.

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

◆ theGeometry

const TrackerGeometry* FastTSGFromPropagation::theGeometry
private

Definition at line 135 of file FastTSGFromPropagation.h.

Referenced by init(), and trackerSeeds().

◆ theGeometryToken

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> FastTSGFromPropagation::theGeometryToken
private

Definition at line 178 of file FastTSGFromPropagation.h.

Referenced by init().

◆ theMaxChi2

double FastTSGFromPropagation::theMaxChi2
private

Definition at line 143 of file FastTSGFromPropagation.h.

Referenced by init().

◆ theMeasTrackerEvent

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

Definition at line 174 of file FastTSGFromPropagation.h.

Referenced by findMeasurements(), and setEvent().

◆ theMeasurementTrackerEventToken_

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

Definition at line 169 of file FastTSGFromPropagation.h.

Referenced by setEvent().

◆ theNavigation

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

Definition at line 133 of file FastTSGFromPropagation.h.

Referenced by setEvent(), and trackerSeeds().

◆ thePropagatorName

std::string FastTSGFromPropagation::thePropagatorName
private

Definition at line 157 of file FastTSGFromPropagation.h.

Referenced by init(), and propagator().

◆ theResetMethod

std::string FastTSGFromPropagation::theResetMethod
private

Definition at line 153 of file FastTSGFromPropagation.h.

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

◆ theSelectStateFlag

bool FastTSGFromPropagation::theSelectStateFlag
private

Definition at line 155 of file FastTSGFromPropagation.h.

Referenced by init(), and passSelection().

◆ theService

const MuonServiceProxy* FastTSGFromPropagation::theService
private

◆ theSigmaZ

double FastTSGFromPropagation::theSigmaZ
private

Definition at line 163 of file FastTSGFromPropagation.h.

Referenced by init(), and passSelection().

◆ theSimTrackCollectionToken_

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

Definition at line 166 of file FastTSGFromPropagation.h.

Referenced by setEvent().

◆ theSimTracks

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

Definition at line 172 of file FastTSGFromPropagation.h.

Referenced by setEvent().

◆ theTrackerToken

edm::ESGetToken<GeometricSearchTracker, TrackerRecoGeometryRecord> FastTSGFromPropagation::theTrackerToken
private

Definition at line 182 of file FastTSGFromPropagation.h.

Referenced by setEvent().

◆ theTTRHBuilder

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

Definition at line 175 of file FastTSGFromPropagation.h.

Referenced by init(), and trackerSeeds().

◆ theTTRHBuilderToken

edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> FastTSGFromPropagation::theTTRHBuilderToken
private

Definition at line 179 of file FastTSGFromPropagation.h.

Referenced by init().

◆ theUpdateStateFlag

bool FastTSGFromPropagation::theUpdateStateFlag
private

Definition at line 151 of file FastTSGFromPropagation.h.

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

◆ theUpdator

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

Definition at line 139 of file FastTSGFromPropagation.h.

Referenced by init(), and updator().

◆ theUseVertexStateFlag

bool FastTSGFromPropagation::theUseVertexStateFlag
private

Definition at line 149 of file FastTSGFromPropagation.h.

Referenced by init(), and outerTkState().