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 
12 
14 
16 
19 
22 
28 
29 #include "gsl/gsl_statistics.h"
30 
31 using namespace std;
32 
33 template <class T> T sqr(const T& t) {return t*t;}
34 
36 : theField(0)
37 {
38 }
39 
40 
42  float sptmean,
44 {
45 
46  const std::string metname = "Muon|RecoMuon|MuonSeedFromRecHits";
47 
49 
50  // FIXME: put it into a parameter set!
51  double theMinMomentum = 3.0;
52 
53  // Minimal pt
54  if ( fabs(ptmean) < theMinMomentum ) ptmean = theMinMomentum * ptmean/fabs(ptmean) ;
55 
56  AlgebraicVector t(4);
57  AlgebraicSymMatrix mat(5,0) ;
58 
59  // Fill the LocalTrajectoryParameters
60  LocalPoint segPos=last->localPosition();
61  GlobalVector mom=last->globalPosition()-GlobalPoint();
63  last->globalDirection().phi(),
64  1.));
65  polar *=fabs(ptmean)/polar.perp();
66  LocalVector segDirFromPos=last->det()->toLocal(polar);
67  int charge=(int)(ptmean/fabs(ptmean));
68 
69  LocalTrajectoryParameters param(segPos,segDirFromPos, charge);
70 
71  // this perform H.T() * parErr * H, which is the projection of the
72  // the measurement error (rechit rf) to the state error (TSOS rf)
73  // Legenda:
74  // H => is the 4x5 projection matrix
75  // parError the 4x4 parameter error matrix of the RecHit
76 
77  // LogTrace(metname) << "Projection matrix:\n" << last->projectionMatrix();
78  // LogTrace(metname) << "Error matrix:\n" << last->parametersError();
79 
80  mat = last->parametersError().similarityT( last->projectionMatrix() );
81 
82 
83  float p_err = sqr(sptmean/(ptmean*ptmean));
84  mat[0][0]= p_err;
85 
86 
88 
89  // Create the TrajectoryStateOnSurface
90  TrajectoryStateOnSurface tsos(param, error, last->det()->surface(), theField);
91 
92  LogTrace(metname) << "Trajectory State on Surface before the extrapolation"<<endl;
93  LogTrace(metname) << debug.dumpTSOS(tsos);
94 
95  // Take the DetLayer on which relies the rechit
96  DetId id = last->geographicalId();
97  // Segment layer
98  LogTrace(metname) << "The RecSegment relies on: "<<endl;
99  LogTrace(metname) << debug.dumpMuonId(id);
100  LogTrace(metname) << debug.dumpTSOS(tsos);
101 
102  // Transform it in a TrajectoryStateOnSurface
103  TrajectoryStateTransform tsTransform;
104 
105  PTrajectoryStateOnDet *seedTSOS =
106  tsTransform.persistentState( tsos ,id.rawId());
107 
109  for (unsigned l=0; l<theRhits.size(); l++) {
110  container.push_back( theRhits[l]->hit()->clone() );
111  }
112 
113  TrajectorySeed theSeed(*seedTSOS,container,alongMomentum);
114 
115  delete seedTSOS;
116 
117  return theSeed;
118 }
119 
120 
121 
122 
T perp() const
Definition: PV3DBase.h:66
const std::string metname
MuonTransientTrackingRecHit::MuonRecHitContainer theRhits
const MagneticField * theField
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
double charge(const std::vector< uint8_t > &Ampls)
std::string dumpMuonId(const DetId &id) const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
std::string dumpTSOS(const TrajectoryStateOnSurface &tsos) const
void push_back(D *&d)
Definition: OwnVector.h:290
PTrajectoryStateOnDet * persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid) const
#define LogTrace(id)
Definition: DetId.h:20
CLHEP::HepVector AlgebraicVector
T * clone(const T *tp)
Definition: Ptr.h:42
Square< F >::type sqr(const F &f)
Definition: Square.h:13
TrajectorySeed createSeed(float ptmean, float sptmean, MuonTransientTrackingRecHit::ConstMuonRecHitPointer last) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
#define debug
Definition: MEtoEDMFormat.h:34
long double T