StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTrackListCutTest.C
1 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
2 
3 #include <StjTrackList.h>
4 
5 #include <StjTrackListCut.h>
6 
7 #include <StjTrackCutDca.h>
8 #include <StjTrackCutDcaPtDependent.h>
9 #include <StjTrackCutEta.h>
10 #include <StjTrackCutPossibleHitRatio.h>
11 #include <StjTrackCutNHits.h>
12 #include <StjTrackCutFlag.h>
13 
14 #include <iostream>
15 #include <set>
16 #include <cmath>
17 
18 #include "StjTrackListCutTest.hh"
19 
20 using namespace std;
21 
22 // Registers the fixture into the 'registry'
23 CPPUNIT_TEST_SUITE_REGISTRATION( StjTrackListCutTest );
24 
25 void StjTrackListCutTest::setUp()
26 {
27 
28 }
29 
30 void StjTrackListCutTest::tearDown()
31 {
32 
33 }
34 
35 
36 void StjTrackListCutTest::testFlag()
37 {
38  StjTrackListCut *cut = new StjTrackListCut();
39  cut->addCut(new StjTrackCutNHits());
40 
41  StjTrackList listIn;
42 
43  StjTrack track1;
44  track1.flag = 30;
45  listIn.push_back(track1);
46 
47  StjTrack track2;
48  track2.flag = -3;
49  listIn.push_back(track2);
50 
51  StjTrackList listExpected;
52  listExpected.push_back(track1);
53 
54  // excercise
55  StjTrackList listActual = (*cut)(listIn);
56 
57  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
58 
59  delete cut;
60 }
61 
62 void StjTrackListCutTest::testNHits()
63 {
64  StjTrackListCut *cut = new StjTrackListCut();
65  cut->addCut(new StjTrackCutNHits());
66 
67  StjTrackList listIn;
68 
69  StjTrack track1;
70  track1.nHits = 13;
71  listIn.push_back(track1);
72 
73  StjTrack track2;
74  track2.nHits = 11;
75  listIn.push_back(track2);
76 
77  StjTrack track3;
78  track3.nHits = 12;
79  listIn.push_back(track3);
80 
81  StjTrackList listExpected;
82  listExpected.push_back(track1);
83 
84  // excercise
85  StjTrackList listActual = (*cut)(listIn);
86 
87  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
88 
89  delete cut;
90 }
91 
92 void StjTrackListCutTest::test2005()
93 {
94  StjTrackListCut *cut = new StjTrackListCut();
95  cut->addCut(new StjTrackCutDca());
96  cut->addCut(new StjTrackCutEta());
97  // cut->addCut(new StjTrackCutPossibleHitRatio());
98 
99  StjTrackList listIn;
100 
101  StjTrack track1;
102  track1.Tdca = 2.9;
103  track1.eta = 0.2;
104  listIn.push_back(track1);
105 
106  StjTrack track2;
107  track2.Tdca = 3.1;
108  track2.eta = 0.2;
109  listIn.push_back(track2);
110 
111  StjTrack track3;
112  track3.Tdca = 2.9;
113  track3.eta = 2.1;
114  listIn.push_back(track3);
115 
116  StjTrack track4;
117  track4.Tdca = 2.9;
118  track4.eta = -2.1;
119  listIn.push_back(track4);
120 
121  StjTrackList listExpected;
122  listExpected.push_back(track1);
123 
124  // excercise
125  StjTrackList listActual = (*cut)(listIn);
126 
127  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
128 
129  delete cut;
130 }
131 
132 
133 void StjTrackListCutTest::test2006()
134 {
135  StjTrackListCut *cut = new StjTrackListCut();
136  cut->addCut(new StjTrackCutDca());
137  cut->addCut(new StjTrackCutDcaPtDependent());
138  cut->addCut(new StjTrackCutEta());
139  // cut->addCut(new StjTrackCutPossibleHitRatio());
140 
141  StjTrackList listIn;
142 
143  StjTrack track1;
144  track1.pt = 0.8;
145  track1.Tdca = 2.9;
146  track1.dcaD = 2.9;
147  track1.eta = 0.2;
148  listIn.push_back(track1);
149 
150  StjTrack track2;
151  track2.pt = 0.8;
152  track2.Tdca = 2.9;
153  track2.dcaD = 3.1;
154  track2.eta = 0.2;
155  listIn.push_back(track2);
156 
157  StjTrack track3;
158  track3.pt = 0.8;
159  track3.Tdca = 2.9;
160  track3.dcaD = 2.9;
161  track3.eta = 2.1;
162  listIn.push_back(track3);
163 
164  StjTrack track4;
165  track4.pt = 0.8;
166  track4.Tdca = 2.9;
167  track4.dcaD = 2.9;
168  track4.eta = -2.1;
169  listIn.push_back(track4);
170 
171  StjTrack track5;
172  track5.pt = 0.4;
173  track5.Tdca = 2.9;
174  track5.dcaD = 1.9;
175  track5.eta = 1.1;
176  listIn.push_back(track5);
177 
178  StjTrack track6;
179  track6.pt = 0.4;
180  track6.Tdca = 2.9;
181  track6.dcaD = 2.1;
182  track6.eta = 1.1;
183  listIn.push_back(track6);
184 
185  StjTrack track7;
186  track7.pt = 0.8;
187  track7.Tdca = 2.9;
188  track7.dcaD = 1.1;
189  track7.eta = 1.1;
190  listIn.push_back(track7);
191 
192  StjTrack track8;
193  track8.pt = 0.8;
194  track8.Tdca = 2.9;
195  track8.dcaD = 1.5;
196  track8.eta = 1.1;
197  listIn.push_back(track8);
198 
199  StjTrack track9;
200  track9.pt = 1.1;
201  track9.Tdca = 2.9;
202  track9.dcaD = 0.9;
203  track9.eta = 1.1;
204  track9.nHits = 10;
205  track9.nHitsPoss = 11;
206  listIn.push_back(track9);
207 
208  StjTrack track10;
209  track10.pt = 1.1;
210  track10.Tdca = 2.9;
211  track10.dcaD = 1.1;
212  track10.eta = 1.1;
213  listIn.push_back(track10);
214 
215  StjTrackList listExpected;
216  listExpected.push_back(track5);
217  listExpected.push_back(track7);
218  listExpected.push_back(track9);
219 
220  // excercise
221  StjTrackList listActual = (*cut)(listIn);
222 
223  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
224 
225  delete cut;
226 }