CMS 3D CMS Logo

TransientInitialStateEstimator.cc
Go to the documentation of this file.
2 
7 
9 
13 
16 
18 
19 using namespace std;
20 
22  : thePropagatorAlongName(conf.getParameter<std::string>("propagatorAlongTISE")),
23  thePropagatorOppositeName(conf.getParameter<std::string>("propagatorOppositeTISE")),
24  thePropagatorAlong(nullptr),
25  thePropagatorOpposite(nullptr),
26  theNumberMeasurementsForFit(conf.getParameter<int>("numberMeasurementsForFit")) {}
27 
29  theHitCloner = hc;
30 
32  edm::ESHandle<Propagator> hopposite;
33 
36  thePropagatorAlong = halong.product();
37  thePropagatorOpposite = hopposite.product();
38 }
39 
40 std::pair<TrajectoryStateOnSurface, const GeomDet*> TransientInitialStateEstimator::innerState(const Trajectory& traj,
41  bool doBackFit) const {
42  if (!doBackFit && traj.firstMeasurement().forwardPredictedState().isValid()) {
43  LogDebug("TransientInitialStateEstimator")
44  << "a backward fit will not be done. assuming that the state on first measurement is OK";
45  TSOS firstStateFromForward = traj.firstMeasurement().forwardPredictedState();
46  firstStateFromForward.rescaleError(100.);
47  return std::pair<TrajectoryStateOnSurface, const GeomDet*>(std::move(firstStateFromForward),
48  traj.firstMeasurement().recHit()->det());
49  }
50  if (!doBackFit) {
51  LogDebug("TransientInitialStateEstimator")
52  << "told to not do a back fit, but the forward state of the first measurement is not valid. doing a back fit.";
53  }
54 
55  int nMeas = traj.measurements().size();
56  int lastFitted = theNumberMeasurementsForFit >= 0 ? theNumberMeasurementsForFit : nMeas;
57  if (nMeas - 1 < lastFitted)
58  lastFitted = nMeas - 1;
59 
60  auto const& measvec = traj.measurements();
62 
63  bool foundLast = false;
64  int actualLast = -99;
65 
66  for (int i = lastFitted; i >= 0; i--) {
67  if (measvec[i].recHit()->det()) {
68  if (!foundLast) {
69  actualLast = i;
70  foundLast = true;
71  }
72  firstHits.push_back(measvec[i].recHit());
73  }
74  }
75  TSOS startingState = measvec[actualLast].updatedState();
76  startingState.rescaleError(100.);
77 
78  // avoid cloning...
79  KFUpdator const aKFUpdator;
80  Chi2MeasurementEstimator const aChi2MeasurementEstimator(100., 3);
81  KFTrajectoryFitter backFitter(
82  thePropagatorAlong, &aKFUpdator, &aChi2MeasurementEstimator, firstHits.size(), nullptr, &theHitCloner);
83 
85 
86  // only direction matters in this contest
88 
89  Trajectory&& fitres = backFitter.fitOne(
90  fakeSeed, firstHits, startingState, traj.nLoops() > 0 ? TrajectoryFitter::looper : TrajectoryFitter::standard);
91 
92  LogDebug("TransientInitialStateEstimator")
93  << "using a backward fit of :" << firstHits.size() << " hits, starting from:\n"
94  << startingState << " to get the estimate of the initial state of the track.";
95 
96  if (!fitres.isValid()) {
97  LogDebug("TransientInitialStateEstimator") << "FitTester: first hits fit failed!";
98  return std::pair<TrajectoryStateOnSurface, const GeomDet*>();
99  }
100 
101  TrajectoryMeasurement const& firstMeas = fitres.lastMeasurement();
102 
103  // magnetic field can be different!
104  TSOS firstState(firstMeas.updatedState().localParameters(),
105  firstMeas.updatedState().localError(),
106  firstMeas.updatedState().surface(),
108 
109  // TSOS & firstState = const_cast<TSOS&>(firstMeas.updatedState());
110 
111  // this fails in case of zero field? (for sure for beamhalo reconstruction)
112  // assert(thePropagatorAlong->magneticField()==firstState.magneticField());
113 
114  firstState.rescaleError(100.);
115 
116  LogDebug("TransientInitialStateEstimator")
117  << "the initial state is found to be:\n:" << firstState
118  << "\n it's field pointer is: " << firstState.magneticField()
119  << "\n the pointer from the state of the back fit was: " << firstMeas.updatedState().magneticField();
120 
121  return std::pair<TrajectoryStateOnSurface, const GeomDet*>(std::move(firstState), firstMeas.recHit()->det());
122 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
Chi2MeasurementEstimator.h
Handle.h
TransientInitialStateEstimator::theNumberMeasurementsForFit
const int theNumberMeasurementsForFit
Definition: TransientInitialStateEstimator.h:38
mps_fire.i
i
Definition: mps_fire.py:428
Trajectory::nLoops
signed char nLoops() const
Definition: Trajectory.h:329
MessageLogger.h
TrajectoryFitter::looper
Definition: TrajectoryFitter.h:21
ESHandle.h
TransientInitialStateEstimator::thePropagatorOppositeName
const std::string thePropagatorOppositeName
Definition: TransientInitialStateEstimator.h:34
Trajectory::direction
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
oppositeToMomentum
Definition: PropagationDirection.h:4
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
Propagator::magneticField
virtual const MagneticField * magneticField() const =0
TransientInitialStateEstimator.h
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
TransientInitialStateEstimator::setEventSetup
void setEventSetup(const edm::EventSetup &es, const TkClonerImpl &hc)
Definition: TransientInitialStateEstimator.cc:28
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
TransientInitialStateEstimator::innerState
std::pair< TrajectoryStateOnSurface, const GeomDet * > innerState(const Trajectory &traj, bool doBackFit=true) const
Definition: TransientInitialStateEstimator.cc:40
TransientInitialStateEstimator::thePropagatorAlong
const Propagator * thePropagatorAlong
Definition: TransientInitialStateEstimator.h:35
TrajectoryMeasurement::forwardPredictedState
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
Definition: TrajectoryMeasurement.h:177
Chi2MeasurementEstimator_cfi.Chi2MeasurementEstimator
Chi2MeasurementEstimator
Definition: Chi2MeasurementEstimator_cfi.py:5
edm::ESHandle< Propagator >
TrajectorySeed.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrajectoryStateOnSurface::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: TrajectoryStateOnSurface.h:73
KFUpdator.h
TrajectoryFitter::standard
Definition: TrajectoryFitter.h:21
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
TrackingRecHit::ConstRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: TrackingRecHit.h:32
PropagatorWithMaterial.h
Trajectory::lastMeasurement
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
TransientInitialStateEstimator::theHitCloner
TkClonerImpl theHitCloner
Definition: TransientInitialStateEstimator.h:37
TransientInitialStateEstimator::TransientInitialStateEstimator
TransientInitialStateEstimator(const edm::ParameterSet &conf)
Definition: TransientInitialStateEstimator.cc:21
createfilelist.int
int
Definition: createfilelist.py:10
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
Trajectory::measurements
DataContainer const & measurements() const
Definition: Trajectory.h:178
TrajectoryStateOnSurface::rescaleError
void rescaleError(double factor)
Definition: TrajectoryStateOnSurface.h:82
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TkClonerImpl
Definition: TkClonerImpl.h:12
Trajectory::firstMeasurement
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:166
Trajectory
Definition: Trajectory.h:38
TransientInitialStateEstimator::thePropagatorAlongName
const std::string thePropagatorAlongName
Definition: TransientInitialStateEstimator.h:33
TrackingComponentsRecord.h
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
TrajectorySeed
Definition: TrajectorySeed.h:18
EventSetup.h
TrajectoryStateOnSurface::surface
const SurfaceType & surface() const
Definition: TrajectoryStateOnSurface.h:78
KFTrajectoryFitter.h
TransientInitialStateEstimator::thePropagatorOpposite
const Propagator * thePropagatorOpposite
Definition: TransientInitialStateEstimator.h:36
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
TrajectoryStateOnSurface::magneticField
const MagneticField * magneticField() const
Definition: TrajectoryStateOnSurface.h:62
alongMomentum
Definition: PropagationDirection.h:4
KFUpdator
Definition: KFUpdator.h:32
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
Trajectory::isValid
bool isValid() const
Definition: Trajectory.h:257
edm::OwnVector< TrackingRecHit >
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12