StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjVertexWriter.cxx
1 // $Id: StjVertexWriter.cxx,v 1.1 2008/08/13 19:37:30 tai Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjVertexWriter.h"
4 
5 #include <StjVertex.h>
6 
7 #include <TDirectory.h>
8 #include <TTree.h>
9 
10 ClassImp(StjVertexWriter)
11 
12 void StjVertexWriter::Init()
13 {
14  _file->cd();
15  _tree = new TTree(_treeName.c_str(), _treeTitle.c_str());
16  _tree->Branch("runNumber" , &_runNumber , "runNumber/I" );
17  _tree->Branch("eventId" , &_eventId , "eventId/I" );
18  _tree->Branch("vertexZ" , &_vertexZ , "vertexZ/D" );
19  _tree->Branch("vertexY" , &_vertexY , "vertexY/D" );
20  _tree->Branch("vertexX" , &_vertexX , "vertexX/D" );
21 }
22 
23 void StjVertexWriter::Make()
24 {
25  _runNumber = _vertex->runNumber();
26 
27  _eventId = _vertex->eventId();
28 
29  _vertexZ = _vertex->vertexZ();
30 
31  _vertexY = _vertex->vertexY();
32 
33  _vertexX = _vertex->vertexX();
34 
35  _tree->Fill();
36 }
37 
38 void StjVertexWriter::Finish()
39 {
40  _tree->BuildIndex("runNumber", "eventId");
41 }
42