AliRoot Core  edcc906 (edcc906)
TestsAliEMCALTriggerSTUDCSConfig.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include <cstdlib>
28 #include <bitset>
29 #include <iostream>
30 #include <sstream>
31 #include <string>
32 
34 
35 namespace EMCAL {
36  namespace Base {
37  namespace Tests {
38  namespace TestAliEMCALTriggerSTUDCSConfig {
39 
48  testobject.SetG(0,0,0);
49  testobject.SetG(1,0,0);
50  testobject.SetG(2,0,115);
51  testobject.SetG(0,1,0);
52  testobject.SetG(1,1,0);
53  testobject.SetG(2,1,51);
54  testobject.SetJ(0,0,0);
55  testobject.SetJ(1,0,0);
56  testobject.SetJ(2,0,255);
57  testobject.SetJ(0,1,0);
58  testobject.SetJ(1,1,0);
59  testobject.SetJ(2,1,204);
60  testobject.SetPatchSize(2);
61  testobject.SetFw(0x2A012);
62  testobject.SetMedianMode(0);
63  testobject.SetRegion(0xffffffff);
64  for(int i = 0; i < 4; i++) testobject.SetPHOSScale(i, 0);
65  }
66 
76  bool TestEqualSelf(){
78  ConfigureReference(test);
79  return test == test;
80  }
81 
91  bool TestEqualTrue(){
93  ConfigureReference(test1);
94  ConfigureReference(test2);
95  return test1 == test2;
96  }
97 
111  ConfigureReference(ref);
112  std::bitset<16> testresults;
113 
114  // Variation Gamma
115  ConfigureReference(test);
116  test.SetG(2, 0, 77);
117  test.SetG(2, 1, 51);
118  testresults.set(0, ref == test);
119 
120  // Variation Jet
121  ConfigureReference(test);
122  test.SetJ(2, 0, 191);
123  test.SetJ(2, 1, 128);
124  testresults.set(1, ref == test);
125 
126  // Variation patch size
127  ConfigureReference(test);
128  test.SetPatchSize(0);
129  testresults.set(2, ref == test);
130 
131  // Variation region
132  ConfigureReference(test);
133  test.SetRegion(0xffffff7f);
134  testresults.set(3, ref == test);
135 
136  // Variation fw
137  ConfigureReference(test);
138  test.SetFw(0x1A012);
139  testresults.set(4, ref == test);
140 
141  // Variation median mode
142  ConfigureReference(test);
143  test.SetMedianMode(1);
144  testresults.set(5, ref == test);
145 
146  // Variation PHOS scale
147  ConfigureReference(test);
148  test.SetPHOSScale(0, 1);
149  test.SetPHOSScale(1, 2);
150  test.SetPHOSScale(2, 1);
151  test.SetPHOSScale(3, 0);
152  testresults.set(6, ref == test);
153 
154  return !testresults.any();
155  }
156 
167  bool TestStream() {
168  std::string reference = std::string("Gamma High: (0, 0, 115)\nGamma Low: (0, 0, 51)\nJet High: (0, 0, 255)\nJet Low: (0, 0, 204)\n")
169  + std::string("GetRawData: 1, Region: -1, Median: 0Firmware: 2a012, PHOS Scale: (0, 0, 0, 0)\n");
170 
172  ConfigureReference(test);
173  std::stringstream testmaker;
174  testmaker << test;
175  return testmaker.str() == reference;
176  }
177  }
178  }
179  }
180 }
181 
191 int main(int argc, char **argv) {
192  int npass(0);
194  npass++;
195  } else {
196  std::cerr << "Failure eq_self" << std::endl;
197  }
199  npass++;
200  } else {
201  std::cerr << "Failure_eq_true" << std::endl;
202  }
204  npass++;
205  } else {
206  std::cerr << "Failure_eq_false" << std::endl;
207  }
209  npass++;
210  } else {
211  std::cerr << "Failure_stream" << std::endl;
212  }
213  std::cout << "Passing " << npass << "/4" << std::endl;
214  if(npass == 4) return EXIT_SUCCESS;
215  return EXIT_FAILURE;
216 }
void SetPHOSScale(int iscale, int val)
bool TestEqualFalse()
Test for operator== on different objects.
void ConfigureReference(AliEMCALTriggerSTUDCSConfig &testobject)
Apply reference configuration.
void SetG(Int_t vzpar, Int_t ithresh, Int_t val)
EMCal trigger STU DCS Config.
void test1()
void test()
Definition: interpolTest.C:100
int main(int argc, char **argv)
Test runner for tests of class AliEMCALTriggerSTUDCSConfig.
void SetJ(Int_t vzpar, Int_t ithresh, Int_t val)
void test2()