CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TransientInitialStateEstimator.cc
Go to the documentation of this file.
2 
7 
9 
13 
16 
18 
19 using namespace std;
20 
22  const edm::ParameterSet& conf)
23 {
24  thePropagatorAlongName = conf.getParameter<std::string>("propagatorAlongTISE");
25  thePropagatorOppositeName = conf.getParameter<std::string>("propagatorOppositeTISE");
26  theNumberMeasurementsForFit = conf.getParameter<int32_t>("numberMeasurementsForFit");
27 
28 
29  // let's avoid breaking compatibility now
30  es.get<TrackingComponentsRecord>().get(thePropagatorAlongName,thePropagatorAlong);
31  es.get<TrackingComponentsRecord>().get(thePropagatorOppositeName,thePropagatorOpposite);
32 }
33 
35  es.get<TrackingComponentsRecord>().get(thePropagatorAlongName,thePropagatorAlong);
36  es.get<TrackingComponentsRecord>().get(thePropagatorOppositeName,thePropagatorOpposite);
37 }
38 
39 std::pair<TrajectoryStateOnSurface, const GeomDet*>
40 TransientInitialStateEstimator::innerState( const Trajectory& traj, bool doBackFit) const
41 {
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*>( 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) lastFitted = nMeas-1;
58 
59  std::vector<TrajectoryMeasurement> measvec = traj.measurements();
61 
62  bool foundLast = false;
63  int actualLast = -99;
64 
65  for (int i=lastFitted; i >= 0; i--) {
66  if(measvec[i].recHit()->det()){
67  if(!foundLast){
68  actualLast = i;
69  foundLast = true;
70  }
71  firstHits.push_back( measvec[i].recHit());
72  }
73  }
74  TSOS startingState = measvec[actualLast].updatedState();
75  startingState.rescaleError(100.);
76 
77  // avoid cloning...
78  KFUpdator const aKFUpdator;
79  Chi2MeasurementEstimator const aChi2MeasurementEstimator( 100., 3);
80  KFTrajectoryFitter backFitter( thePropagatorAlong.product(),
81  &aKFUpdator,
82  &aChi2MeasurementEstimator,
83  firstHits.size());
84 
86 
87  // only direction matters in this contest
90  backFitDirection);
91 
92  vector<Trajectory> fitres = backFitter.fit( fakeSeed, firstHits, startingState);
93 
94  LogDebug("TransientInitialStateEstimator")
95  <<"using a backward fit of :"<<firstHits.size()<<" hits, starting from:\n"<<startingState
96  <<" to get the estimate of the initial state of the track.";
97 
98  if (fitres.size() != 1) {
99  LogDebug("TransientInitialStateEstimator")
100  << "FitTester: first hits fit failed!";
101  return std::pair<TrajectoryStateOnSurface, const GeomDet*>();
102  }
103 
104  TrajectoryMeasurement firstMeas = fitres[0].lastMeasurement();
105  TSOS firstState(firstMeas.updatedState().localParameters(),
106  firstMeas.updatedState().localError(),
107  firstMeas.updatedState().surface(),
108  thePropagatorAlong->magneticField());
109  // I couldn't do:
110  //TSOS firstState = firstMeas.updatedState();
111  // why????
112 
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 
122  return std::pair<TrajectoryStateOnSurface, const GeomDet*>( firstState,
123  firstMeas.recHit()->det());
124 }
125 
#define LogDebug(id)
TransientInitialStateEstimator(const edm::EventSetup &es, const edm::ParameterSet &conf)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void setEventSetup(const edm::EventSetup &es)
Call this at each event until this object will come from the EventSetup as it should.
const LocalTrajectoryParameters & localParameters() const
TrajectoryStateOnSurface forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
ConstRecHitPointer recHit() const
PropagationDirection
const MagneticField * magneticField() const
PropagationDirection const & direction() const
Definition: Trajectory.cc:195
DataContainer const & measurements() const
Definition: Trajectory.h:203
TrajectoryStateOnSurface updatedState() const
const LocalTrajectoryError & localError() const
tuple conf
Definition: dbtoconf.py:185
std::vector< ConstRecHitPointer > ConstRecHitContainer
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:194
const T & get() const
Definition: EventSetup.h:55
const Surface & surface() const
std::pair< TrajectoryStateOnSurface, const GeomDet * > innerState(const Trajectory &traj, bool doBackFit=true) const