CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonSeedFromRecHits.cc
Go to the documentation of this file.
1 
10 
12 
14 
17 
20 
26 
27 #include "gsl/gsl_statistics.h"
28 
29 using namespace std;
30 
31 template <class T> T sqr(const T& t) {return t*t;}
32 
34 : theField(0)
35 {
36 }
37 
38 
40  float sptmean,
42 {
43 
44  const std::string metname = "Muon|RecoMuon|MuonSeedFromRecHits";
45 
47 
48  // FIXME: put it into a parameter set!
49  double theMinMomentum = 3.0;
50  int charge=std::copysign(1,ptmean);
51 
52  // Minimal pt
53  if ( fabs(ptmean) < theMinMomentum ) ptmean = theMinMomentum * charge ;
54 
55  AlgebraicVector t(4);
56  AlgebraicSymMatrix mat(5,0) ;
57 
58  // Fill the LocalTrajectoryParameters
59  LocalPoint segPos=last->localPosition();
60  GlobalVector mom=last->globalPosition()-GlobalPoint();
62  last->globalDirection().phi(),
63  1.));
64  polar *=fabs(ptmean)/polar.perp();
65  LocalVector segDirFromPos=last->det()->toLocal(polar);
66 
67  LocalTrajectoryParameters param(segPos,segDirFromPos, charge);
68 
69  // this perform H.T() * parErr * H, which is the projection of the
70  // the measurement error (rechit rf) to the state error (TSOS rf)
71  // Legenda:
72  // H => is the 4x5 projection matrix
73  // parError the 4x4 parameter error matrix of the RecHit
74 
75  // LogTrace(metname) << "Projection matrix:\n" << last->projectionMatrix();
76  // LogTrace(metname) << "Error matrix:\n" << last->parametersError();
77 
78  mat = last->parametersError().similarityT( last->projectionMatrix() );
79 
80 
81  float p_err = sqr(sptmean/(ptmean*ptmean));
82  mat[0][0]= p_err;
83 
84 
85  LocalTrajectoryError error(asSMatrix<5>(mat));
86 
87  // Create the TrajectoryStateOnSurface
88  TrajectoryStateOnSurface tsos(param, error, last->det()->surface(), theField);
89 
90  // The following LogTraces must be moved somewhere else (StandAloneTrajectoryBuilder)
91  // Here the TSOS does not have the magnetic field set, so dumpTSOS causes a crash
92  // (when LogTrace/LogDebug is activated)
93  //LogTrace(metname) << "Trajectory State on Surface before the extrapolation"<<endl;
94  //LogTrace(metname) << debug.dumpTSOS(tsos);
95 
96  // Take the DetLayer on which relies the rechit
97  DetId id = last->geographicalId();
98  // Segment layer
99  //LogTrace(metname) << "The RecSegment relies on: "<<endl;
100  //LogTrace(metname) << debug.dumpMuonId(id);
101  //LogTrace(metname) << debug.dumpTSOS(tsos);
102 
103  // Transform it in a TrajectoryStateOnSurface
104 
105 
106  PTrajectoryStateOnDet const & seedTSOS =
108 
110  for (unsigned l=0; l<theRhits.size(); l++) {
111  container.push_back( theRhits[l]->hit()->clone() );
112  }
113 
114  TrajectorySeed theSeed(seedTSOS,container,alongMomentum);
115 
116  return theSeed;
117 }
118 
119 
120 
121 
tuple t
Definition: tree.py:139
T perp() const
Definition: PV3DBase.h:72
const std::string metname
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
const MagneticField * theField
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
void push_back(D *&d)
Definition: OwnVector.h:280
Definition: DetId.h:18
CLHEP::HepVector AlgebraicVector
#define debug
Definition: HDRShower.cc:19
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
Square< F >::type sqr(const F &f)
Definition: Square.h:13
TrajectorySeed createSeed(float ptmean, float sptmean, MuonTransientTrackingRecHit::ConstMuonRecHitPointer last) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
long double T