StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjTowerEnergyListVariationTest.C
1 // Copyright (C) 2008 Tai Sakuma <sakuma@bnl.gov>
2 
3 #include <StjTowerEnergyListVariation.h>
4 #include <StjTowerEnergyList.h>
5 #include "StjTowerEnergyVariation.h"
6 #include "StjTowerEnergyVariationEnergy.h"
7 
8 #include <iostream>
9 #include <set>
10 #include <cmath>
11 
12 #include "StjTowerEnergyListVariationTest.hh"
13 
14 using namespace std;
15 
16 // Registers the fixture into the 'registry'
17 CPPUNIT_TEST_SUITE_REGISTRATION( StjTowerEnergyListVariationTest );
18 
19 void StjTowerEnergyListVariationTest::setUp()
20 {
21 
22 }
23 
24 void StjTowerEnergyListVariationTest::tearDown()
25 {
26 
27 }
28 
29 
30 void StjTowerEnergyListVariationTest::testEnergyPlus5()
31 {
33 
34  variation->addVariation(new StjTowerEnergyVariationEnergy(0.05));
35 
36  StjTowerEnergyList listIn;
37 
38  StjTowerEnergy energy1;
39  energy1.energy = 3.0;
40  listIn.push_back(energy1);
41 
42  StjTowerEnergy energy2;
43  energy2.energy = 5.0;
44  listIn.push_back(energy2);
45 
46  StjTowerEnergyList listExpected;
47  energy1.energy *= (1.0 + 0.05);
48  energy2.energy *= (1.0 + 0.05);
49  listExpected.push_back(energy1);
50  listExpected.push_back(energy2);
51 
52  // excercise
53  StjTowerEnergyList listActual = (*variation)(listIn);
54 
55  // verify
56  //CPPUNIT_ASSERT_EQUAL( listExpected.size(), listActual.size() );
57  //for(size_t i = 0; i < listExpected.size(); ++i) {
58  // CPPUNIT_ASSERT_EQUAL( listExpected[i].runNumber , listActual[i].runNumber );
59  // CPPUNIT_ASSERT_EQUAL( listExpected[i].eventId , listActual[i].eventId );
60  // CPPUNIT_ASSERT_EQUAL( listExpected[i].detectorId, listActual[i].detectorId );
61  // CPPUNIT_ASSERT_EQUAL( listExpected[i].towerId , listActual[i].towerId );
62  // CPPUNIT_ASSERT_EQUAL( listExpected[i].towerR , listActual[i].towerR );
63  // CPPUNIT_ASSERT_EQUAL( listExpected[i].towerEta , listActual[i].towerEta );
64  // CPPUNIT_ASSERT_EQUAL( listExpected[i].towerPhi , listActual[i].towerPhi );
65  // CPPUNIT_ASSERT_EQUAL( listExpected[i].vertexX , listActual[i].vertexX );
66  // CPPUNIT_ASSERT_EQUAL( listExpected[i].vertexY , listActual[i].vertexY );
67  // CPPUNIT_ASSERT_EQUAL( listExpected[i].vertexZ , listActual[i].vertexZ );
68  // CPPUNIT_ASSERT_DOUBLES_EQUAL( listExpected[i].energy , listActual[i].energy , 0.000000000001 );
69  // CPPUNIT_ASSERT_EQUAL( listExpected[i].adc , listActual[i].adc );
70  // CPPUNIT_ASSERT_EQUAL( listExpected[i].pedestal , listActual[i].pedestal );
71  // CPPUNIT_ASSERT_EQUAL( listExpected[i].rms , listActual[i].rms );
72  // CPPUNIT_ASSERT_EQUAL( listExpected[i].status , listActual[i].status );
73  // CPPUNIT_ASSERT_EQUAL( listExpected[i], listActual[i] );
74  //};
75 
76  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
77 
78  delete variation;
79 }
80 
81 void StjTowerEnergyListVariationTest::testEnergyMinus5()
82 {
84 
85  variation->addVariation(new StjTowerEnergyVariationEnergy(-0.05));
86 
87  StjTowerEnergyList listIn;
88 
89  StjTowerEnergy energy1;
90  energy1.energy = 3.0;
91  listIn.push_back(energy1);
92 
93  StjTowerEnergy energy2;
94  energy2.energy = 5.0;
95  listIn.push_back(energy2);
96 
97  StjTowerEnergyList listExpected;
98  energy1.energy *= (1.0 - 0.05);
99  energy2.energy *= (1.0 - 0.05);
100  listExpected.push_back(energy1);
101  listExpected.push_back(energy2);
102 
103  // excercise
104  StjTowerEnergyList listActual = (*variation)(listIn);
105 
106  // verify
107  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
108 
109  delete variation;
110 }
111 
112 void StjTowerEnergyListVariationTest::testEnergyPlus10()
113 {
115 
116  variation->addVariation(new StjTowerEnergyVariationEnergy(0.1));
117 
118  StjTowerEnergyList listIn;
119 
120  StjTowerEnergy energy1;
121  energy1.energy = 3.0;
122  listIn.push_back(energy1);
123 
124  StjTowerEnergy energy2;
125  energy2.energy = 5.0;
126  listIn.push_back(energy2);
127 
128  StjTowerEnergyList listExpected;
129  energy1.energy *= (1.0 + 0.1);
130  energy2.energy *= (1.0 + 0.1);
131  listExpected.push_back(energy1);
132  listExpected.push_back(energy2);
133 
134  // excercise
135  StjTowerEnergyList listActual = (*variation)(listIn);
136 
137  // verify
138  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
139 
140  delete variation;
141 }
142 
143 void StjTowerEnergyListVariationTest::testEnergyMinus10()
144 {
146 
147  variation->addVariation(new StjTowerEnergyVariationEnergy(-0.1));
148 
149  StjTowerEnergyList listIn;
150 
151  StjTowerEnergy energy1;
152  energy1.energy = 3.0;
153  listIn.push_back(energy1);
154 
155  StjTowerEnergy energy2;
156  energy2.energy = 5.0;
157  listIn.push_back(energy2);
158 
159  StjTowerEnergyList listExpected;
160  energy1.energy *= (1.0 - 0.1);
161  energy2.energy *= (1.0 - 0.1);
162  listExpected.push_back(energy1);
163  listExpected.push_back(energy2);
164 
165  // excercise
166  StjTowerEnergyList listActual = (*variation)(listIn);
167 
168  // verify
169  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
170 
171  delete variation;
172 }
173 
174 
175 void StjTowerEnergyListVariationTest::testEnergyNull()
176 {
178 
179  StjTowerEnergyList listIn;
180 
181  StjTowerEnergy energy1;
182  energy1.energy = 3.0;
183  listIn.push_back(energy1);
184 
185  StjTowerEnergy energy2;
186  energy2.energy = 5.0;
187  listIn.push_back(energy2);
188 
189  StjTowerEnergyList listExpected;
190  listExpected.push_back(energy1);
191  listExpected.push_back(energy2);
192 
193  // excercise
194  StjTowerEnergyList listActual = (*variation)(listIn);
195 
196  // verify
197  CPPUNIT_ASSERT_EQUAL( listExpected, listActual );
198 
199  delete variation;
200 }