StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjSpinWriter.cxx
1 // $Id: StjSpinWriter.cxx,v 1.1 2008/11/05 05:48:30 tai Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjSpinWriter.h"
4 
5 #include <StjSpin.h>
6 
7 #include <TDirectory.h>
8 #include <TTree.h>
9 
10 ClassImp(StjSpinWriter)
11 
12 void StjSpinWriter::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("bx7" , &_bx7 , "bx7/I" );
19  _tree->Branch("bx48" , &_bx48 , "bx48/I" );
20  _tree->Branch("spin4" , &_spin4 , "spin4/I" );
21  _tree->Branch("bbcTimebin" , &_bbcTimebin , "bbcTimebin/I" );
22  _tree->Branch("vertexZ" , &_vertexZ , "vertexZ/D" );
23 }
24 
25 void StjSpinWriter::Make()
26 {
27  _runNumber = _spin->runNumber();
28  _eventId = _spin->eventId();
29  _bx7 = _spin->bx7();
30  _bx48 = _spin->bx48();
31  _spin4 = _spin->spin4();
32  _bbcTimebin = _spin->bbcTimebin();
33  _vertexZ = _spin->vertexZ();
34  _tree->Fill();
35 }
36 
37 void StjSpinWriter::Finish()
38 {
39  _tree->BuildIndex("runNumber", "eventId");
40 }
41