15 #include "StEvent/StEvent.h"
16 #include "StGenericVertexMaker/Minuit/StMinuitVertexFinder.h"
17 #include "StGenericVertexMaker/StFixedVertexFinder.h"
18 #include "StGenericVertexMaker/StGenericVertexFinder.h"
19 #include "StGenericVertexMaker/StGenericVertexMaker.h"
20 #include "StGenericVertexMaker/StiPPVertex/StPPVertexFinder.h"
21 #include "StGenericVertexMaker/StppLMVVertexFinder.h"
22 #include "StGenericVertexMaker/StvPPVertex/StPPVertexFinder.h"
23 #include "St_base/StMessMgr.h"
24 #include "St_db_Maker/St_db_Maker.h"
25 #include "tables/St_g2t_vertex_Table.h"
38 StGenericVertexMaker::StGenericVertexMaker(
const char *name):
StMaker(name),
45 externalFindUse(true),
57 StGenericVertexMaker::~StGenericVertexMaker()
59 SafeDelete(theFinder);
81 useITTF = IAttr(
"ITTF");
82 useBeamline = IAttr(
"beamLine");
83 useCTB = IAttr(
"CTB");
84 usePCT = IAttr(
"PCT");
85 useBTOF = IAttr(
"BTOF");
87 minTracks = IAttr(
"minTracks");
89 bool isMinuit = ( IAttr(
"VFMinuit") || IAttr(
"VFMinuit2") || IAttr(
"VFMinuit3") );
90 bool isPPV = ( IAttr(
"VFPPV") || IAttr(
"VFPPVnoCTB") || IAttr(
"VFPPVEv") || IAttr(
"VFPPVEvNoBTof") );
93 StGenericVertexFinder::VertexFit_t vertexFitMode;
95 if ( IAttr(
"beamline") && isPPV)
96 vertexFitMode = StGenericVertexFinder::VertexFit_t::BeamlineNoFit;
97 else if ( IAttr(
"beamline") && isMinuit )
98 vertexFitMode = StGenericVertexFinder::VertexFit_t::Beamline1D;
99 else if ( IAttr(
"beamline1D") )
100 vertexFitMode = StGenericVertexFinder::VertexFit_t::Beamline1D;
101 else if ( IAttr(
"beamline3D") )
102 vertexFitMode = StGenericVertexFinder::VertexFit_t::Beamline3D;
104 vertexFitMode = StGenericVertexFinder::VertexFit_t::NoBeamline;
109 LOG_INFO <<
"StMinuitVertexFinder::StMinuitVertexFinder is in use." << endm;
118 }
else if ( IAttr(
"VFppLMV")){
120 theFinder->SetMode(0);
122 }
else if ( IAttr(
"VFppLMV5")){
124 theFinder->SetMode(1);
126 }
else if ( (IAttr(
"VFPPV") || IAttr(
"VFPPVnoCTB")) && !IAttr(
"VFPPVev")) {
128 LOG_INFO <<
"StGenericVertexMaker::Init: uses PPVertex finder"<< endm;
129 LOG_INFO <<
"StPPVertexFinder::StPPVertexFinder is in use" << endm;
133 if ( IAttr(
"VFPPVnoCTB")) theFinder->UseCTB(kFALSE);
136 int vfstore = IAttr(
"VFstore");
141 LOG_INFO <<
"StGenericVertexMaker::Init: Using VFStore depth = " << vfstore << endm;
144 if ( IAttr(
"useBTOFmatchOnly") ){
145 LOG_INFO <<
"StGenericVertexMaker::Init: UseBTOFmatchOnly option enabled" << endm;
150 }
else if ( IAttr(
"VFPPVEv") || IAttr(
"VFPPVEvNoBTof") ) {
151 LOG_INFO <<
"StGenericVertexMaker::Init: uses StvPPVertex finder(StEvent based)"<< endm;
152 LOG_INFO <<
"StPPVertexFinder::StPPVertexFinder is in use" << endm;
155 useBTOF = (IAttr(
"VFPPVEvNoBTof"))? 0:1;
157 }
else if ( IAttr(
"VFFV") || IAttr(
"VFMCE")) {
160 LOG_INFO <<
"StGenericVertexMaker::Init: fixed vertex using MC vertex" << endm;
161 theFinder->SetMode(1);
163 theFinder->SetVertexPosition(0.,0.,0);
164 LOG_INFO <<
"StGenericVertexMaker::Init: fixed vertex 'finder' selected" << endm;
168 LOG_INFO <<
"StMinuitVertexFinder::StMinuitVertexFinder is in use." << endm;
177 theFinder->UsePCT(usePCT);
178 theFinder->UseBTOF(useBTOF);
188 mEvalNtuple =
new TNtuple(
"results",
"results",
"thX:thY:thZ:thStat:goodGlob:evX:evY:evZ:evStat:nPrim:nCTB:geantX:geantY:geantZ");
191 return StMaker::Init();
195 void StGenericVertexMaker::Clear(
const char* opt){
196 LOG_INFO <<
" StGenericVertexMaker::Clear()"<<endm;
214 theFinder->InitRun(runnumber, st_db_maker);
216 return StMaker::InitRun(runnumber);
224 LOG_INFO <<
"StGenericVertexMaker::Finish " <<
GetName() <<endm;
225 LOG_INFO <<
" Total events: " << nEvTotal << endm;
226 LOG_INFO <<
" Good events: " << nEvGood << endm;
231 TFile out(
"MinuitVertexEval.root",
"RECREATE");
232 mEvalNtuple->Write();
236 if(theFinder) theFinder->Finish();
243 Bool_t StGenericVertexMaker::DoFit(){
245 if (theFinder->fit(mEvent)) {
246 theFinder->printInfo();
248 LOG_ERROR <<
"StGenericVertexMaker::DoFit: vertex fit failed, no vertex." << endm;
266 if (IAttr(
"useMuDst")) {
268 TClonesArray* vtxArray = 0;
269 WhiteBoard(
"muDst",&muDst);
270 WhiteBoard(
"vtxArray",&vtxArray);
271 if (!(vtxArray && muDst)) {
272 LOG_ERROR <<
"problems for refitting MuDst" << endm;
275 theFinder->fit(*muDst);
276 theFinder->result(*vtxArray);
280 mEvent = (
StEvent*) GetInputDS(
"StEvent");
281 LOG_DEBUG <<
"StGenericVertexMaker::Make: StEvent pointer " << mEvent << endm;
282 LOG_DEBUG <<
"StGenericVertexMaker::Make: external find use " << externalFindUse << endm;
284 if(!externalFindUse){
288 if (eval)MakeEvalNtuple();
290 if(!externalFindUse){
292 if (theFinder->size()>0){
302 void StGenericVertexMaker::MakeEvalNtuple(){
306 St_g2t_vertex *g2t_ver=0;
307 g2t_vertex_st *gver=0;
308 if(gds) g2t_ver=( St_g2t_vertex *)gds->
Find(
"g2t_vertex");
309 if(g2t_ver)gver=g2t_ver->GetTable();
323 primV=mEvent->primaryVertex();
328 LOG_INFO <<
"primaryVertex()=NULL"<<endm;
330 float x=999,y=999,z=999;
331 mEvalNtuple->Fill(x,y,z,stat,mEvent->summary()->numberOfGoodTracks(),-999.,-999.,-999.,-999.,-999.,nCtb,gx,gy,gz);
334 LOG_INFO << Form(
"primaryVertex()= %f, %f %f, nTracks=%d\n",
335 primV->position().x(), primV->position().y(), primV->position().z(),
336 primV->numberOfDaughters()) << endm;
338 mEvalNtuple->Fill(primV->position().x(), primV->position().y(), primV->position().z(),
339 stat, mEvent->summary()->numberOfGoodTracks(),
340 primV->position().x(), primV->position().y(), primV->position().z(), primV->flag(),
341 primV->numberOfDaughters(), nCtb, gx, gy, gz);
virtual Int_t InitRun(Int_t runumber)
StGenericVertexFinder implementation for fixing vertex.
void FillStEvent(StEvent *)
virtual const char * GetName() const
special overload
virtual TDataSet * Find(const char *path) const