CMS 3D CMS Logo

MuonSeedFromRecHits.cc

Go to the documentation of this file.
00001 
00011 #include "RecoMuon/MuonSeedGenerator/src/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   // FIXME: put it into a parameter set!
00051   double theMinMomentum = 3.0;
00052  
00053   // Minimal pt
00054   if ( fabs(ptmean) < theMinMomentum ) ptmean = theMinMomentum * ptmean/fabs(ptmean) ;
00055 
00056   AlgebraicVector t(4);
00057   AlgebraicSymMatrix mat(5,0) ;
00058 
00059   // Fill the LocalTrajectoryParameters
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   // this perform H.T() * parErr * H, which is the projection of the 
00072   // the measurement error (rechit rf) to the state error (TSOS rf)
00073   // Legenda:
00074   // H => is the 4x5 projection matrix
00075   // parError the 4x4 parameter error matrix of the RecHit
00076 
00077   // LogTrace(metname) << "Projection matrix:\n" << last->projectionMatrix();
00078   // LogTrace(metname) << "Error matrix:\n" << last->parametersError();
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   // Create the TrajectoryStateOnSurface
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   // Take the DetLayer on which relies the rechit
00096   DetId id = last->geographicalId();
00097   // Segment layer
00098   LogTrace(metname) << "The RecSegment relies on: "<<endl;
00099   LogTrace(metname) << debug.dumpMuonId(id);
00100   LogTrace(metname) << debug.dumpTSOS(tsos);
00101 
00102   // Transform it in a TrajectoryStateOnSurface
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,oppositeToMomentum);
00114 
00115   delete seedTSOS;
00116     
00117   return theSeed;
00118 }
00119 
00120 
00121 
00122 

Generated on Tue Jun 9 17:44:26 2009 for CMSSW by  doxygen 1.5.4