StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTrgTreeTest.C
1 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
2 
3 #include <StjTrgReader.h>
4 #include <StjTrgTree.h>
5 
6 #include <TFile.h>
7 #include <TTree.h>
8 
9 #include "StjTrgTreeTest.hh"
10 
11 // Registers the fixture into the 'registry'
12 CPPUNIT_TEST_SUITE_REGISTRATION( StjTrgTreeTest );
13 
14 void StjTrgTreeTest::setUp()
15 {
16 
17 }
18 
19 void StjTrgTreeTest::tearDown()
20 {
21 
22 }
23 
24 void StjTrgTreeTest::testOne()
25 {
26  TFile* file = new TFile("./part_run6143024.root");
27 
28  TTree *tree = dynamic_cast<TTree*>(file->Get("trgBJP2"));
29 
30  StjTrgReader *reader = new StjTrgReader(tree);
31 
32  tree->BuildIndex("runNumber", "eventId");
33 
34  reader->Init();
35 
36  StjTrgTree* trg = new StjTrgTree(reader);
37 
38  reader->GetEntryWithIndex(6143024, 1095);
39  CPPUNIT_ASSERT_EQUAL( 96233, trg->id() );
40  CPPUNIT_ASSERT_EQUAL( 6143024, trg->runNumber() );
41  CPPUNIT_ASSERT_EQUAL( 1095, trg->eventId() );
42  CPPUNIT_ASSERT_EQUAL( true, trg->hard() );
43  CPPUNIT_ASSERT_EQUAL( true, trg->soft() );
44  CPPUNIT_ASSERT_EQUAL( true, trg->passed() );
45  CPPUNIT_ASSERT_EQUAL( 1.0, trg->prescale() );
46  CPPUNIT_ASSERT_EQUAL( (size_t)0, trg->towers().size() );
47  CPPUNIT_ASSERT_EQUAL( (size_t)1, trg->jetPatches().size() );
48  CPPUNIT_ASSERT_EQUAL( 3, trg->jetPatches()[0] );
49 
50  reader->GetEntryWithIndex(6143024, 2000);
51  CPPUNIT_ASSERT_EQUAL( false, trg->hard() );
52  CPPUNIT_ASSERT_EQUAL( false, trg->soft() );
53  CPPUNIT_ASSERT_EQUAL( false, trg->passed() );
54  CPPUNIT_ASSERT_EQUAL( (size_t)0, trg->towers().size() );
55  CPPUNIT_ASSERT_EQUAL( (size_t)0, trg->jetPatches().size() );
56 
57  reader->GetEntryWithIndex(6143024, 24897);
58  CPPUNIT_ASSERT_EQUAL( 96233, trg->id() );
59  CPPUNIT_ASSERT_EQUAL( 6143024, trg->runNumber() );
60  CPPUNIT_ASSERT_EQUAL( 24897, trg->eventId() );
61  CPPUNIT_ASSERT_EQUAL( true, trg->hard() );
62  CPPUNIT_ASSERT_EQUAL( true, trg->soft() );
63  CPPUNIT_ASSERT_EQUAL( true, trg->passed() );
64  CPPUNIT_ASSERT_EQUAL( 1.0, trg->prescale() );
65  CPPUNIT_ASSERT_EQUAL( (size_t)0, trg->towers().size() );
66  CPPUNIT_ASSERT_EQUAL( (size_t)1, trg->jetPatches().size() );
67  CPPUNIT_ASSERT_EQUAL( 4, trg->jetPatches()[0] );
68 
69  reader->GetEntryWithIndex(6143024, 28661);
70  CPPUNIT_ASSERT_EQUAL( 96233, trg->id() );
71  CPPUNIT_ASSERT_EQUAL( 6143024, trg->runNumber() );
72  CPPUNIT_ASSERT_EQUAL( 28661, trg->eventId() );
73  CPPUNIT_ASSERT_EQUAL( true, trg->hard() );
74  CPPUNIT_ASSERT_EQUAL( true, trg->soft() );
75  CPPUNIT_ASSERT_EQUAL( true, trg->passed() );
76  CPPUNIT_ASSERT_EQUAL( 1.0, trg->prescale() );
77  CPPUNIT_ASSERT_EQUAL( (size_t)0, trg->towers().size() );
78  CPPUNIT_ASSERT_EQUAL( (size_t)1, trg->jetPatches().size() );
79  CPPUNIT_ASSERT_EQUAL( 2, trg->jetPatches()[0] );
80 
81 }