CMS 3D CMS Logo

KinematicParticleVertexFitter.cc
Go to the documentation of this file.
2 // #include "Vertex/LinearizationPointFinders/interface/LMSLinearizationPointFinder.h"
14 
17  setup(pSet);
18 }
19 
21 
25 
29  SequentialVertexSmoother<6> smoother(vtu, vse, covCalc);
32 }
33 
35  delete vFactory;
36  delete pointFinder;
37  delete fitter;
38 }
39 
41  edm::ParameterSet pSet;
42  pSet.addParameter<double>("maxDistance", 0.01);
43  pSet.addParameter<int>("maxNbrOfIterations", 100); //10
44  return pSet;
45 }
46 
48  const std::vector<RefCountedKinematicParticle> &particles) const {
49  typedef ReferenceCountingPointer<VertexTrack<6> > RefCountedVertexTrack;
50  //sorting the input
51  if (particles.size() < 2)
52  throw VertexException("KinematicParticleVertexFitter::input states are less than 2");
53  InputSort iSort;
54  std::pair<std::vector<RefCountedKinematicParticle>, std::vector<FreeTrajectoryState> > input = iSort.sort(particles);
55  std::vector<RefCountedKinematicParticle> &newPart = input.first;
56  std::vector<FreeTrajectoryState> &freeStates = input.second;
57 
58  GlobalPoint linPoint = pointFinder->getLinearizationPoint(freeStates);
59 
60  // cout<<"Linearization point found"<<endl;
61 
62  //making initial veretx seed with lin point as position and a fake error
64  we(0, 0) = we(1, 1) = we(2, 2) = 10000.;
65  GlobalError error(we);
66  VertexState state(linPoint, error);
67 
68  //vector of Vertex Tracks to fit
69  std::vector<RefCountedVertexTrack> ttf;
71  for (auto const &i : newPart) {
72  if (!(i)->currentState().isValid() || !propagator_.willPropagateToTheTransversePCA((i)->currentState(), linPoint)) {
73  // std::cout << "Here's the bad state." << std::endl;
74  return ReferenceCountingPointer<KinematicTree>(new KinematicTree()); // return invalid vertex
75  }
76  ttf.push_back(vFactory->vertexTrack((i)->particleLinearizedTrackState(linPoint), state, 1.));
77  }
78 
79  // //debugging code to check neutrals:
80  // for(std::vector<RefCountedVertexTrack>::const_iterator i = ttf.begin(); i!=ttf.end(); i++)
81  // {
82  // // cout<<"predicted state momentum error"<<(*i)->linearizedTrack()->predictedStateMomentumError()<<endl;
83  // // cout<<"Momentum jacobian"<<(*i)->linearizedTrack()->momentumJacobian() <<endl;
84  // // cout<<"predicted state momentum "<<(*i)->linearizedTrack()->predictedStateMomentum()<<endl;
85  // // cout<<"constant term"<<(*i)->linearizedTrack()->constantTerm()<<endl;
86  //
87  // }
88 
90  if (!vtx.isValid()) {
91  LogDebug("RecoVertex/KinematicParticleVertexFitter") << "Fitted position is invalid. Returned Tree is invalid\n";
92  return ReferenceCountingPointer<KinematicTree>(new KinematicTree()); // return invalid vertex
93  }
94  FinalTreeBuilder tBuilder;
95  return tBuilder.buildTree(vtx, newPart);
96 }
std::pair< std::vector< RefCountedKinematicParticle >, std::vector< FreeTrajectoryState > > sort(const std::vector< RefCountedKinematicParticle > &particles) const
Definition: InputSort.cc:5
bool willPropagateToTheTransversePCA(const KinematicState &state, const GlobalPoint &point) const override
void setup(const edm::ParameterSet &pSet)
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
RefCountedKinematicTree fit(const std::vector< RefCountedKinematicParticle > &particles) const
Common base class.
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
static std::string const input
Definition: EdmProvDump.cc:50
virtual CachingVertex< N > vertex(const std::vector< reco::TransientTrack > &tracks) const =0
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
RefCountedKinematicTree buildTree(const CachingVertex< 6 > &vtx, const std::vector< RefCountedKinematicParticle > &input) const
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
#define LogDebug(id)