StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiStarVertexFinder.cxx
1 #include <stdexcept>
2 #include "Sti/StiStarVertexFinder.h"
3 #include "Sti/StiHit.h"
4 #include "StThreeVectorF.hh"
5 #include "StMatrixF.hh"
6 #include "StEvent.h"
7 #include "StPrimaryVertex.h"
8 #include "Sti/Base/Factory.h"
9 #include "StGenericVertexMaker/StGenericVertexMaker.h"
10 #include "StGenericVertexMaker/StGenericVertexFinder.h"
11 #include "StMaker.h"
12 
13 
14 //______________________________________________________________________________
15 StiStarVertexFinder::StiStarVertexFinder(const string & name)
16  : StiVertexFinder(name)
17 {mGVF=0;}
18 
19 //______________________________________________________________________________
20 StiStarVertexFinder::~StiStarVertexFinder()
21 {}
22 //______________________________________________________________________________
23 void StiStarVertexFinder::clear()
24 {
25  if (mGVF) mGVF->Clear();
26 }
27 //______________________________________________________________________________
28 int StiStarVertexFinder::size() const
29 {
30  return (mGVF)? mGVF->size():0;
31 }
32 
33 //______________________________________________________________________________
37 //______________________________________________________________________________
39 {
40  cout <<"StiStarVertexFinder::fit(StEvent * event) -I- Started"<<endl;
41 
42  // call the actual vertex finder method here...
43  // assume the result is stored in StEvent...
44  if (!mGVF) {
45  StGenericVertexMaker* gvm = (StGenericVertexMaker*)StMaker::GetChain()->GetMaker("GenericVertex");
46  if ( gvm ){
47  mGVF = gvm->GetGenericFinder();
48  assert(mGVF);
49  } else {
50  LOG_WARN << "Could not find a GenericVertex instance" << endm;
51  }
52  }
53  //AAR - modified
54  // changed to fill primary vert only if fit returns true (okay)
55  int nVtx=0;
56  if ( mGVF ){
57  clear(); // this calls mGVF->Clear() requiring knowing about GenericVertex
58  nVtx = mGVF->fit(event);
59  if(nVtx){
60  //vertex fit returns okay, so save
61  mGVF->FillStEvent(event);
62  }
63  }
64  return nVtx;
65 
66 }
67 
68 //______________________________________________________________________________
72 //______________________________________________________________________________
74 {
75  if (!mGVF) return 0;
76  StPrimaryVertex *spv = mGVF->getVertex(idx);
77  if (!spv) return 0;
78 
79  // Get an instance of StHit from the factory
80  StiHit *vertex = getHitFactory()->getInstance();
81  const StThreeVectorF& vp = spv->position();
82  StMatrixF cov = spv->covariantMatrix();
83 
84  cout <<"StiStarVertexFinder::getVertex("<<idx<< ") -I- set hit parameters"<<endl;
85  cout << "x:"<< vp.x() << "+-" << sqrt(cov[0][0])<<endl;
86  cout << "y:"<< vp.y() << "+-" << sqrt(cov[1][1])<<endl;
87  cout << "z:"<< vp.z() << "+-" << sqrt(cov[2][2])<<endl;
88  vertex->set(0, spv,
89  0.,
90  vp.x(),vp.y(),vp.z(),
91  cov[0][0],
92  cov[0][1],
93  cov[0][2],
94  cov[1][1],
95  cov[1][2],
96  cov[2][2]);
97  return vertex;
98 }
Definition: StiHit.h:51
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
StiHit * getVertex(int index)