00001 #include "RecoTracker/CkfPattern/interface/TransientInitialStateEstimator.h"
00002
00003 #include "DataFormats/Common/interface/Handle.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007
00008 #include "MagneticField/Engine/interface/MagneticField.h"
00009
00010 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00011 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
00012 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
00013
00014 #include "TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h"
00015 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00016
00017 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00018
00019 using namespace std;
00020
00021 TransientInitialStateEstimator::TransientInitialStateEstimator( const edm::EventSetup& es,
00022 const edm::ParameterSet& conf)
00023 {
00024 thePropagatorAlongName = conf.getParameter<std::string>("propagatorAlongTISE");
00025 thePropagatorOppositeName = conf.getParameter<std::string>("propagatorOppositeTISE");
00026
00027
00028 es.get<TrackingComponentsRecord>().get(thePropagatorAlongName,thePropagatorAlong);
00029 es.get<TrackingComponentsRecord>().get(thePropagatorOppositeName,thePropagatorOpposite);
00030 }
00031
00032 void TransientInitialStateEstimator::setEventSetup( const edm::EventSetup& es ) {
00033 es.get<TrackingComponentsRecord>().get(thePropagatorAlongName,thePropagatorAlong);
00034 es.get<TrackingComponentsRecord>().get(thePropagatorOppositeName,thePropagatorOpposite);
00035 }
00036
00037 std::pair<TrajectoryStateOnSurface, const GeomDet*>
00038 TransientInitialStateEstimator::innerState( const Trajectory& traj) const
00039 {
00040 int lastFitted = 4;
00041 int nhits = traj.foundHits();
00042 if (nhits-1 < lastFitted) lastFitted = nhits-1;
00043
00044 std::vector<TrajectoryMeasurement> measvec = traj.measurements();
00045 TransientTrackingRecHit::ConstRecHitContainer firstHits;
00046
00047 bool foundLast = false;
00048 int actualLast = -99;
00049
00050
00051
00052 for (int i=nhits-1; i >= 0; i--) {
00053 if(measvec[i].recHit()->det()){
00054
00055
00056
00057
00058
00059 }
00060 }
00061
00062 for (int i=lastFitted; i >= 0; i--) {
00063 if(measvec[i].recHit()->det()){
00064
00065
00066
00067
00068
00069 }
00070
00071 if(measvec[i].recHit()->det()){
00072 if(!foundLast){
00073 actualLast = i;
00074 foundLast = true;
00075 }
00076 firstHits.push_back( measvec[i].recHit());
00077 }
00078 }
00079 TSOS unscaledState = measvec[actualLast].updatedState();
00080
00081 AlgebraicSymMatrix55 C = AlgebraicMatrixID();
00082
00083
00084 TSOS startingState( unscaledState.localParameters(), LocalTrajectoryError(C),
00085 unscaledState.surface(),
00086 thePropagatorAlong->magneticField());
00087
00088
00089
00090 KFTrajectoryFitter backFitter( *thePropagatorAlong,
00091 KFUpdator(),
00092 Chi2MeasurementEstimator( 100., 3),
00093 firstHits.size());
00094
00095 PropagationDirection backFitDirection = traj.direction() == alongMomentum ? oppositeToMomentum: alongMomentum;
00096
00097
00098 TrajectorySeed fakeSeed = TrajectorySeed(PTrajectoryStateOnDet() ,
00099 edm::OwnVector<TrackingRecHit>(),
00100 backFitDirection);
00101
00102 vector<Trajectory> fitres = backFitter.fit( fakeSeed, firstHits, startingState);
00103
00104 if (fitres.size() != 1) {
00105
00106 return std::pair<TrajectoryStateOnSurface, const GeomDet*>();
00107 }
00108
00109 TrajectoryMeasurement firstMeas = fitres[0].lastMeasurement();
00110 TSOS firstState = firstMeas.updatedState();
00111
00112
00113
00114
00115
00116
00117
00118 TSOS initialState( firstState.localParameters(), LocalTrajectoryError(C),
00119 firstState.surface(),
00120 thePropagatorAlong->magneticField());
00121
00122 return std::pair<TrajectoryStateOnSurface, const GeomDet*>( initialState,
00123 firstMeas.recHit()->det());
00124 }
00125