00001 #include <stdexcept>
00002 #include "Sti/StiStarVertexFinder.h"
00003 #include "Sti/StiHit.h"
00004 #include "StThreeVectorF.hh"
00005 #include "StMatrixF.hh"
00006 #include "StEvent.h"
00007 #include "StPrimaryVertex.h"
00008 #include "Sti/Base/Factory.h"
00009 #include "StGenericVertexMaker/StGenericVertexMaker.h"
00010 #include "StGenericVertexMaker/StGenericVertexFinder.h"
00011 #include "StMaker.h"
00012
00013
00014
00015 StiStarVertexFinder::StiStarVertexFinder(const string & name)
00016 : StiVertexFinder(name)
00017 {mGVF=0;}
00018
00019
00020 StiStarVertexFinder::~StiStarVertexFinder()
00021 {}
00022
00023 void StiStarVertexFinder::clear()
00024 {
00025 if (mGVF) mGVF->Clear();
00026 }
00027
00028 int StiStarVertexFinder::size() const
00029 {
00030 return (mGVF)? mGVF->size():0;
00031 }
00032
00033
00037
00038 int StiStarVertexFinder::fit(StEvent * event)
00039 {
00040 cout <<"StiStarVertexFinder::fit(StEvent * event) -I- Started"<<endl;
00041
00042
00043
00044 if (!mGVF) {
00045 StGenericVertexMaker* gvm = (StGenericVertexMaker*)StMaker::GetChain()->GetMaker("GenericVertex");
00046 if ( gvm ){
00047 mGVF = gvm->GetGenericFinder();
00048 assert(mGVF);
00049 } else {
00050 LOG_WARN << "Could not find a GenericVertex instance" << endm;
00051 }
00052 }
00053
00054
00055 int nVtx=0;
00056 if ( mGVF ){
00057 clear();
00058 nVtx = mGVF->fit(event);
00059 if(nVtx){
00060
00061 mGVF->FillStEvent(event);
00062 }
00063 }
00064 return nVtx;
00065
00066 }
00067
00068
00072
00073 StiHit * StiStarVertexFinder::getVertex(int idx)
00074 {
00075 if (!mGVF) return 0;
00076 StPrimaryVertex *spv = mGVF->getVertex(idx);
00077 if (!spv) return 0;
00078
00079
00080 StiHit *vertex = getHitFactory()->getInstance();
00081 const StThreeVectorF& vp = spv->position();
00082 StMatrixF cov = spv->covariantMatrix();
00083
00084 cout <<"StiStarVertexFinder::getVertex("<<idx<< ") -I- set hit parameters"<<endl;
00085 cout << "x:"<< vp.x() << "+-" << sqrt(cov[0][0])<<endl;
00086 cout << "y:"<< vp.y() << "+-" << sqrt(cov[1][1])<<endl;
00087 cout << "z:"<< vp.z() << "+-" << sqrt(cov[2][2])<<endl;
00088 vertex->set(0, spv,
00089 0.,
00090 vp.x(),vp.y(),vp.z(),
00091 cov[0][0],
00092 cov[0][1],
00093 cov[0][2],
00094 cov[1][1],
00095 cov[1][2],
00096 cov[2][2]);
00097 return vertex;
00098 }