EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHTpcVertexFinder.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHTpcVertexFinder.cc
1 
7 #include "PHTpcVertexFinder.h"
8 
9 #include "Track.h" // for Track
10 
11 #include <phool/PHLog.h>
12 
13 #include <GenFit/GFRaveVertexFactory.h> // for GFRaveVertexFactory
14 
15 #include <TMatrixDSymfwd.h> // for TMatrixDSym
16 #include <TMatrixTSym.h> // for TMatrixTSym
17 #include <TVector3.h> // for TVector3
18 
19 #include <log4cpp/CategoryStream.hh> // for CategoryStream
20 
21 namespace genfit
22 {
23  class GFRaveVertex;
24 }
25 namespace genfit
26 {
27  class Track;
28 }
29 
31  : _vertex_finder(nullptr)
32 {
33 }
34 
36 {
37  delete _vertex_finder;
38 }
39 
40 std::vector<genfit::GFRaveVertex*> PHTpcVertexFinder::findVertices(std::vector<PHGenFit2::Track*>& gtracks)
41 {
42  std::vector<genfit::GFRaveVertex*> rave_vertices;
43 
44  if (!_vertex_finder)
45  {
46  _vertex_finder = new genfit::GFRaveVertexFactory(1 /* verbosity? */);
47  _vertex_finder->setMethod("avr-minweight:0.5-primcut:5-seccut:10");
48  // _vertex_finder->setMethod("avf-Tini:256-ratio:0.25-sigmacut:3");
49  TMatrixDSym beam_spot_cov(3);
50  beam_spot_cov(0, 0) = 0.2 * 0.2; // dx * dx
51  beam_spot_cov(1, 1) = 0.2 * 0.2; // dy * dy
52  beam_spot_cov(2, 2) = 100.0 * 100.0; // dz * dz
53  _vertex_finder->setBeamspot(TVector3(0, 0, 0), beam_spot_cov);
54  }
55 
56  std::vector<genfit::Track*> gftracks;
57  gftracks.reserve(gtracks.size());
58  for (auto it = gtracks.begin(); it != gtracks.end(); ++it)
59  {
60  gftracks.push_back((*it)->getGenFitTrack());
61  }
62 
63  LOG_DEBUG("tracking.PHTpcVertexFinder.findVertices") << "feeding " << gftracks.size() << " GenFit tracks into vertex finder";
64 
65  if (gftracks.size() < 2)
66  {
67  LOG_DEBUG("tracking.PHTpcVertexFinder.findVertices") << "less than two tracks, skipping vertexing";
68  return rave_vertices;
69  }
70 
71  try
72  {
73  _vertex_finder->findVertices(&rave_vertices, gftracks, true /* useBeamSpot */);
74  }
75  catch (...)
76  {
77  LOG_DEBUG("tracking.PHTpcVertexFinder.findVertices") << "Rave threw an exception, vertex finding failed";
78  rave_vertices.clear();
79  }
80 
81  /*
82  for ( unsigned int i = 0, ilen = rave_vtx->getNTracks(); i++ ) {
83  const genfit::Track* gftrack = rave_vtx->getParameters(i)->getTrack();
84  }
85  */
86 
87  return rave_vertices;
88 }