CMS 3D CMS Logo

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