StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTrgWriter.cxx
1 // $Id: StjTrgWriter.cxx,v 1.3 2008/09/21 19:11:40 tai Exp $
2 #include "StjTrgWriter.h"
3 
4 #include "StjTrg.h"
5 
6 #include <TDirectory.h>
7 #include <TTree.h>
8 
9 ClassImp(StjTrgWriter)
10 
11 void StjTrgWriter::Init()
12 {
13  _tree = createTree();
14  createBranch_general(_tree);
15  createBranch_trgSpecific(_tree);
16 }
17 
18 void StjTrgWriter::Make()
19 {
20  if( !(*_fillCondition)(_trg) ) return;
21  fillBranch_general();
22  fillBranch_trgSpecific();
23  _tree->Fill();
24 }
25 
26 void StjTrgWriter::Finish()
27 {
28  _tree->BuildIndex("runNumber", "eventId");
29 }
30 
31 TTree* StjTrgWriter::createTree()
32 {
33  _file->cd();
34  return new TTree(_treeName.c_str(), _treeTitle.c_str());
35 }
36 
37 void StjTrgWriter::createBranch_general(TTree* tree)
38 {
39  tree->Branch("runNumber" , &_runNumber , "runNumber/I" );
40  tree->Branch("eventId" , &_eventId , "eventId/I" );
41  tree->Branch("vertexZ" , &_vertexZ , "vertexZ/D" );
42  tree->Branch("trigID" , &_trigID , "trigID/I" );
43  tree->Branch("prescale" , &_prescale , "prescale/D" );
44  tree->Branch("passed" , &_passed , "passed/I" );
45  tree->Branch("hard" , &_hard , "hard/I" );
46  tree->Branch("soft" , &_soft , "soft/I" );
47 }
48 
49 void StjTrgWriter::fillBranch_general()
50 {
51  _trigID = _trg->id();
52 
53  _hard = _trg->hard();
54 
55  _soft = _trg->soft();
56 
57  _passed = _trg->passed();
58 
59  _runNumber = _trg->runNumber();
60 
61  _eventId = _trg->eventId();
62 
63  _vertexZ = _trg->vertexZ();
64 
65  _prescale = _trg->prescale();
66 }
67