CMS 3D CMS Logo

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

#include <SeedTransformer.h>

Public Member Functions

std::vector< TrajectoryseedTransform (const TrajectorySeed &) const
 Performs the fit. More...
 
 SeedTransformer (const edm::ParameterSet &, edm::ConsumesCollector)
 Constructor. More...
 
TrajectoryStateOnSurface seedTransientState (const TrajectorySeed &) const
 
void setServices (const edm::EventSetup &)
 Set the services needed by the SeedTransformer. More...
 
virtual ~SeedTransformer ()
 Destructor. More...
 

Private Attributes

double errorRescale
 Error rescale factor. More...
 
unsigned int nMinRecHits
 Minimum number of RecHits required to perform the fit. More...
 
const TrajectoryFittertheFitter
 
edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::RecordtheFitterToken
 
const MagneticFieldtheMagneticField
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordtheMagneticFieldToken
 
const TransientTrackingRecHitBuildertheMuonRecHitBuilder
 
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecordtheMuonRecHitBuilderToken
 
const PropagatorthePropagator
 
edm::ESGetToken< Propagator, TrackingComponentsRecordthePropagatorToken
 
const GlobalTrackingGeometrytheTrackingGeometry
 
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordtheTrackingGeometryToken
 
bool useSubRecHits
 

Detailed Description

Description: this class takes a TrajectorySeed, fits its RecHits and returns a vector of Trajectories. If the fit fails, the returned vector is empty.

Author
D. Trocino - University and INFN Torino

Definition at line 35 of file SeedTransformer.h.

Constructor & Destructor Documentation

◆ SeedTransformer()

SeedTransformer::SeedTransformer ( const edm::ParameterSet iConfig,
edm::ConsumesCollector  iC 
)

Constructor.

Definition at line 47 of file SeedTransformer.cc.

References edm::ConsumesCollector::esConsumes(), edm::ParameterSet::getParameter(), LogTrace, and HLT_2022v14_cff::propagatorName.

47  {
48  LogTrace("Reco|TrackingTools|SeedTransformer") << "SeedTransformer constructor called." << endl << endl;
49 
52  auto fitterName = iConfig.getParameter<string>("Fitter");
53  theFitterToken = iC.esConsumes(edm::ESInputTag("", fitterName));
54  auto muonRecHitBuilderName = iConfig.getParameter<string>("MuonRecHitBuilder");
55  theMuonRecHitBuilderToken = iC.esConsumes(edm::ESInputTag("", muonRecHitBuilderName));
56  auto propagatorName = iConfig.getParameter<string>("Propagator");
58 
59  nMinRecHits = iConfig.getParameter<unsigned int>("NMinRecHits");
60  errorRescale = iConfig.getParameter<double>("RescaleError");
61  useSubRecHits = iConfig.getParameter<bool>("UseSubRecHits");
62 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMagneticFieldToken
double errorRescale
Error rescale factor.
#define LogTrace(id)
edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theFitterToken
unsigned int nMinRecHits
Minimum number of RecHits required to perform the fit.
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > theTrackingGeometryToken
edm::ESGetToken< Propagator, TrackingComponentsRecord > thePropagatorToken
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theMuonRecHitBuilderToken

◆ ~SeedTransformer()

SeedTransformer::~SeedTransformer ( )
virtual

Destructor.

Definition at line 64 of file SeedTransformer.cc.

References LogTrace.

64  {
65  LogTrace("Reco|TrackingTools|SeedTransformer") << "SeedTransformer destructor called." << endl << endl;
66 }
#define LogTrace(id)

Member Function Documentation

◆ seedTransform()

vector< Trajectory > SeedTransformer::seedTransform ( const TrajectorySeed aSeed) const

Performs the fit.

Definition at line 76 of file SeedTransformer.cc.

References MuonTransientTrackingRecHitBreaker::breakInSubRecHits(), filterCSVwithJSON::copy, TrajectoryStateOnSurface::isValid(), LogTrace, metname, TrajectorySeed::nHits(), rpcPointValidation_cfi::recHit, FastTrackerRecHitMaskProducer_cfi::recHits, TrajectorySeed::recHits(), and TrajectoryStateOnSurface::rescaleError().

Referenced by DirectMuonTrajectoryBuilder::trajectories().

76  {
77  const string metname = "Reco|TrackingTools|SeedTransformer";
78 
79  LogTrace(metname) << " Number of valid RecHits: " << aSeed.nHits() << endl;
80 
81  if (aSeed.nHits() < nMinRecHits) {
82  LogTrace(metname) << " --- Too few RecHits, no refit performed! ---" << endl;
83  return vector<Trajectory>();
84  }
85 
87 
88  // Rescale errors before refit, not to bias the result
89  aTSOS.rescaleError(errorRescale);
90 
91  vector<TransientTrackingRecHit::ConstRecHitPointer> recHits;
92 
93  for (auto const& recHit : aSeed.recHits()) {
94  if (recHit.isValid()) {
96 
97  if (useSubRecHits) {
100  copy(subHits.begin(), subHits.end(), back_inserter(recHits));
101  } else {
102  recHits.push_back(ttrh);
103  }
104  }
105  }
106 
107  TrajectoryStateOnSurface aInitTSOS = thePropagator->propagate(aTSOS, recHits.front()->det()->surface());
108 
109  if (!aInitTSOS.isValid()) {
110  LogTrace(metname) << " --- Initial state for refit not valid! ---" << endl;
111  return vector<Trajectory>();
112  }
113 
114  vector<Trajectory> refittedSeed = theFitter->fit(aSeed, recHits, aInitTSOS);
115 
116  if (refittedSeed.empty()) {
117  LogTrace(metname) << " --- Seed fit failed! ---" << endl;
118  return vector<Trajectory>();
119  }
120 
121  else if (!refittedSeed.front().isValid()) {
122  LogTrace(metname) << " --- Seed fitted, but trajectory not valid! ---" << endl;
123  return vector<Trajectory>();
124  }
125 
126  else
127  LogTrace(metname) << " +++ Seed fit succeded! +++" << endl;
128 
129  return refittedSeed;
130 }
const std::string metname
RecHitRange recHits() const
double errorRescale
Error rescale factor.
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
#define LogTrace(id)
static TransientTrackingRecHit::ConstRecHitContainer breakInSubRecHits(TransientTrackingRecHit::ConstRecHitPointer, int granularity)
takes a muon rechit and returns its sub-rechits given a certain granularity
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
unsigned int nHits() const
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
const TransientTrackingRecHitBuilder * theMuonRecHitBuilder
const Propagator * thePropagator
std::vector< ConstRecHitPointer > ConstRecHitContainer
const TrajectoryFitter * theFitter
unsigned int nMinRecHits
Minimum number of RecHits required to perform the fit.
TrajectoryStateOnSurface seedTransientState(const TrajectorySeed &) const
std::vector< Trajectory > fit(const Trajectory &traj, fitType type=standard) const

◆ seedTransientState()

TrajectoryStateOnSurface SeedTransformer::seedTransientState ( const TrajectorySeed tmpSeed) const

Definition at line 132 of file SeedTransformer.cc.

References PTrajectoryStateOnDet::detId(), TrajectorySeed::startingState(), and trajectoryStateTransform::transientState().

132  {
133  PTrajectoryStateOnDet tmpTSOD = tmpSeed.startingState();
134  DetId tmpDetId(tmpTSOD.detId());
135  const GeomDet* tmpGeomDet = theTrackingGeometry->idToDet(tmpDetId);
136 
137  TrajectoryStateOnSurface tmpTSOS =
138  trajectoryStateTransform::transientState(tmpTSOD, &(tmpGeomDet->surface()), &(*theMagneticField));
139 
140  return tmpTSOS;
141 }
const GlobalTrackingGeometry * theTrackingGeometry
const MagneticField * theMagneticField
const GeomDet * idToDet(DetId) const override
unsigned int detId() const
PTrajectoryStateOnDet const & startingState() const
Definition: DetId.h:17
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)

◆ setServices()

void SeedTransformer::setServices ( const edm::EventSetup iSetup)

Set the services needed by the SeedTransformer.

Definition at line 68 of file SeedTransformer.cc.

References edm::EventSetup::getData().

Referenced by DirectMuonTrajectoryBuilder::trajectories().

68  {
71  theFitter = &iSetup.getData(theFitterToken);
74 }
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMagneticFieldToken
const GlobalTrackingGeometry * theTrackingGeometry
const MagneticField * theMagneticField
edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > theFitterToken
const TransientTrackingRecHitBuilder * theMuonRecHitBuilder
const Propagator * thePropagator
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const TrajectoryFitter * theFitter
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > theTrackingGeometryToken
edm::ESGetToken< Propagator, TrackingComponentsRecord > thePropagatorToken
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theMuonRecHitBuilderToken

Member Data Documentation

◆ errorRescale

double SeedTransformer::errorRescale
private

Error rescale factor.

Definition at line 69 of file SeedTransformer.h.

◆ nMinRecHits

unsigned int SeedTransformer::nMinRecHits
private

Minimum number of RecHits required to perform the fit.

Definition at line 66 of file SeedTransformer.h.

◆ theFitter

const TrajectoryFitter* SeedTransformer::theFitter
private

Definition at line 55 of file SeedTransformer.h.

◆ theFitterToken

edm::ESGetToken<TrajectoryFitter, TrajectoryFitter::Record> SeedTransformer::theFitterToken
private

Definition at line 61 of file SeedTransformer.h.

◆ theMagneticField

const MagneticField* SeedTransformer::theMagneticField
private

Definition at line 54 of file SeedTransformer.h.

◆ theMagneticFieldToken

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> SeedTransformer::theMagneticFieldToken
private

Definition at line 60 of file SeedTransformer.h.

◆ theMuonRecHitBuilder

const TransientTrackingRecHitBuilder* SeedTransformer::theMuonRecHitBuilder
private

Definition at line 56 of file SeedTransformer.h.

◆ theMuonRecHitBuilderToken

edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> SeedTransformer::theMuonRecHitBuilderToken
private

Definition at line 62 of file SeedTransformer.h.

◆ thePropagator

const Propagator* SeedTransformer::thePropagator
private

Definition at line 57 of file SeedTransformer.h.

◆ thePropagatorToken

edm::ESGetToken<Propagator, TrackingComponentsRecord> SeedTransformer::thePropagatorToken
private

Definition at line 63 of file SeedTransformer.h.

◆ theTrackingGeometry

const GlobalTrackingGeometry* SeedTransformer::theTrackingGeometry
private

Definition at line 53 of file SeedTransformer.h.

◆ theTrackingGeometryToken

edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> SeedTransformer::theTrackingGeometryToken
private

Definition at line 59 of file SeedTransformer.h.

◆ useSubRecHits

bool SeedTransformer::useSubRecHits
private

Definition at line 71 of file SeedTransformer.h.