Go to the documentation of this file.00001
00011 #include "RecoMuon/TrackingTools/interface/MuonSeedFromRecHits.h"
00012
00013 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
00014
00015 #include "RecoMuon/TrackingTools/interface/MuonPatternRecoDumper.h"
00016
00017 #include "MagneticField/Engine/interface/MagneticField.h"
00018 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00019
00020 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00021 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00022
00023 #include "DataFormats/TrajectoryState/interface/PTrajectoryStateOnDet.h"
00024 #include "DataFormats/Common/interface/OwnVector.h"
00025 #include "FWCore/Framework/interface/EventSetup.h"
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028
00029 #include "gsl/gsl_statistics.h"
00030
00031 using namespace std;
00032
00033 template <class T> T sqr(const T& t) {return t*t;}
00034
00035 MuonSeedFromRecHits::MuonSeedFromRecHits()
00036 : theField(0)
00037 {
00038 }
00039
00040
00041 TrajectorySeed MuonSeedFromRecHits::createSeed(float ptmean,
00042 float sptmean,
00043 ConstMuonRecHitPointer last) const
00044 {
00045
00046 const std::string metname = "Muon|RecoMuon|MuonSeedFromRecHits";
00047
00048 MuonPatternRecoDumper debug;
00049
00050
00051 double theMinMomentum = 3.0;
00052
00053
00054 if ( fabs(ptmean) < theMinMomentum ) ptmean = theMinMomentum * ptmean/fabs(ptmean) ;
00055
00056 AlgebraicVector t(4);
00057 AlgebraicSymMatrix mat(5,0) ;
00058
00059
00060 LocalPoint segPos=last->localPosition();
00061 GlobalVector mom=last->globalPosition()-GlobalPoint();
00062 GlobalVector polar(GlobalVector::Spherical(mom.theta(),
00063 last->globalDirection().phi(),
00064 1.));
00065 polar *=fabs(ptmean)/polar.perp();
00066 LocalVector segDirFromPos=last->det()->toLocal(polar);
00067 int charge=(int)(ptmean/fabs(ptmean));
00068
00069 LocalTrajectoryParameters param(segPos,segDirFromPos, charge);
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 mat = last->parametersError().similarityT( last->projectionMatrix() );
00081
00082
00083 float p_err = sqr(sptmean/(ptmean*ptmean));
00084 mat[0][0]= p_err;
00085
00086
00087 LocalTrajectoryError error(mat);
00088
00089
00090 TrajectoryStateOnSurface tsos(param, error, last->det()->surface(), theField);
00091
00092 LogTrace(metname) << "Trajectory State on Surface before the extrapolation"<<endl;
00093 LogTrace(metname) << debug.dumpTSOS(tsos);
00094
00095
00096 DetId id = last->geographicalId();
00097
00098 LogTrace(metname) << "The RecSegment relies on: "<<endl;
00099 LogTrace(metname) << debug.dumpMuonId(id);
00100 LogTrace(metname) << debug.dumpTSOS(tsos);
00101
00102
00103 TrajectoryStateTransform tsTransform;
00104
00105 PTrajectoryStateOnDet *seedTSOS =
00106 tsTransform.persistentState( tsos ,id.rawId());
00107
00108 edm::OwnVector<TrackingRecHit> container;
00109 for (unsigned l=0; l<theRhits.size(); l++) {
00110 container.push_back( theRhits[l]->hit()->clone() );
00111 }
00112
00113 TrajectorySeed theSeed(*seedTSOS,container,alongMomentum);
00114
00115 delete seedTSOS;
00116
00117 return theSeed;
00118 }
00119
00120
00121
00122