StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjMCKinWriter.cxx
1 // $Id: StjMCKinWriter.cxx,v 1.2 2008/10/14 17:16:22 tai Exp $
2 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
3 #include "StjMCKinWriter.h"
4 
5 #include <StjMCKin.h>
6 
7 #include <TDirectory.h>
8 #include <TTree.h>
9 
10 ClassImp(StjMCKinWriter)
11 
12 void StjMCKinWriter::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("s" , &_s , "s/D" );
19  _tree->Branch("t" , &_t , "t/D" );
20  _tree->Branch("u" , &_u , "u/D" );
21  _tree->Branch("pid" , &_pid , "pid/I" );
22  _tree->Branch("pt" , &_pt , "pt/D" );
23  _tree->Branch("costh" , &_costh , "costh/D" );
24  _tree->Branch("x1" , &_x1 , "x1/D" );
25  _tree->Branch("x2" , &_x2 , "x2/D" );
26  _tree->Branch("vertexZ" , &_vertexZ , "vertexZ/D" );
27 }
28 
29 void StjMCKinWriter::Make()
30 {
31  _runNumber = _mckin->runNumber();
32 
33  _eventId = _mckin->eventId();
34 
35  _vertexZ = _mckin->vertexZ();
36 
37  _s = _mckin->s();
38 
39  _t = _mckin->t();
40 
41  _u = _mckin->u();
42 
43  _pt = _mckin->pt();
44 
45  _costh = _mckin->costh();
46 
47  _x1 = _mckin->x1();
48 
49  _x2 = _mckin->x2();
50 
51  _pid = _mckin->pid();
52 
53  _tree->Fill();
54 }
55 
56 void StjMCKinWriter::Finish()
57 {
58  _tree->BuildIndex("runNumber", "eventId");
59 }
60