CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
KinematicParticleVertexFitter.cc
Go to the documentation of this file.
2 // #include "Vertex/LinearizationPointFinders/interface/LMSLinearizationPointFinder.h"
14 
16 {
18  setup(pSet);
19 }
20 
22 {
23  setup(pSet);
24 }
25 
26 void
28 {
29 
32 
36  SequentialVertexSmoother<6> smoother(vtu, vse, covCalc);
37  fitter
40 }
41 
43 {
44  delete vFactory;
45  delete pointFinder;
46  delete fitter;
47 }
48 
50 {
51  edm::ParameterSet pSet;
52  pSet.addParameter<double>("maxDistance", 0.01);
53  pSet.addParameter<int>("maxNbrOfIterations", 100); //10
54  return pSet;
55 }
56 
57 RefCountedKinematicTree KinematicParticleVertexFitter::fit(std::vector<RefCountedKinematicParticle> particles) const
58 {
59  typedef ReferenceCountingPointer<VertexTrack<6> > RefCountedVertexTrack;
60 //sorting the input
61  if(particles.size()<2) throw VertexException("KinematicParticleVertexFitter::input states are less than 2");
62  InputSort iSort;
63  std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> > input = iSort.sort(particles);
64  std::vector<RefCountedKinematicParticle> & newPart = input.first;
65  std::vector<FreeTrajectoryState> & freeStates = input.second;
66 
67  GlobalPoint linPoint = pointFinder->getLinearizationPoint(freeStates);
68 
69 // cout<<"Linearization point found"<<endl;
70 
71 //making initial veretx seed with lin point as position and a fake error
73  we(0,0)=we(1,1)=we(2,2) = 10000.;
74  GlobalError error(we);
75  VertexState state(linPoint, error);
76 
77 //vector of Vertex Tracks to fit
78  std::vector<RefCountedVertexTrack> ttf;
79  for(std::vector<RefCountedKinematicParticle>::const_iterator i = newPart.begin();i != newPart.end();i++)
80  {ttf.push_back(vFactory->vertexTrack((*i)->particleLinearizedTrackState(linPoint),state,1.));}
81 
82 // //debugging code to check neutrals:
83 // for(std::vector<RefCountedVertexTrack>::const_iterator i = ttf.begin(); i!=ttf.end(); i++)
84 // {
85 // // cout<<"predicted state momentum error"<<(*i)->linearizedTrack()->predictedStateMomentumError()<<endl;
86 // // cout<<"Momentum jacobian"<<(*i)->linearizedTrack()->momentumJacobian() <<endl;
87 // // cout<<"predicted state momentum "<<(*i)->linearizedTrack()->predictedStateMomentum()<<endl;
88 // // cout<<"constant term"<<(*i)->linearizedTrack()->constantTerm()<<endl;
89 //
90 // }
91 
92  CachingVertex<6> vtx = fitter->vertex(ttf);
93  if (!vtx.isValid()) {
94  LogDebug("RecoVertex/KinematicParticleVertexFitter")
95  << "Fitted position is invalid. Returned Tree is invalid\n";
96  return ReferenceCountingPointer<KinematicTree>(new KinematicTree()); // return invalid vertex
97  }
98  FinalTreeBuilder tBuilder;
99  return tBuilder.buildTree(vtx, newPart);
100 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::pair< std::vector< RefCountedKinematicParticle >, std::vector< FreeTrajectoryState > > sort(std::vector< RefCountedKinematicParticle > particles) const
Definition: InputSort.cc:6
edm::ParameterSet defaultParameters() const
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
Common base class.
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
virtual CachingVertex< N > vertex(const std::vector< reco::TransientTrack > &tracks) const =0
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
RefCountedKinematicTree fit(std::vector< RefCountedKinematicParticle > particles) const
void setup(const edm::ParameterSet pSet)
RefCountedKinematicTree buildTree(const CachingVertex< 6 > &vtx, std::vector< RefCountedKinematicParticle > input) const
char state
Definition: procUtils.cc:75
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
bool isValid() const
Definition: CachingVertex.h:95