testROOTEventIO.cc
Go to the documentation of this file.
1 
9 #include <iostream>
10 
11 #include <TROOT.h>
12 
13 #include <FEvent/testFEventImpl.h>
14 #include <SEvent/testSEventImpl.h>
15 #include <Shower/testShowerImpl.h>
16 
17 #include <io/OfflineROOTFile.h>
18 #include <evt/Event.h>
19 #include <evt/DefaultShowerGeometryProducer.h>
20 #include <fevt/FEvent.h>
21 #include <utl/ErrorLogger.h>
22 
23 #include <cppunit/extensions/HelperMacros.h>
24 
25 using namespace std;
26 using namespace io;
27 using evt::Event;
28 using fevt::FEvent;
29 
30 
31 class testOfflineEvent : public CppUnit::TestFixture {
32 
33  CPPUNIT_TEST_SUITE(testOfflineEvent);
34  CPPUNIT_TEST(testWriteEvent);
35  CPPUNIT_TEST(testReadBack);
36  CPPUNIT_TEST(testReadConfig);
37  CPPUNIT_TEST(testEventTriggerValues);
38  CPPUNIT_TEST(testHeaderValues);
39  CPPUNIT_TEST(testPMTValues);
40  CPPUNIT_TEST(testPMTSimDataValues);
41  CPPUNIT_TEST(testPMTRecDataValues);
42  CPPUNIT_TEST(testPMTCalibDataValues);
43  CPPUNIT_TEST(testStationValues);
44  CPPUNIT_TEST(testStationSimDataValues);
45  CPPUNIT_TEST(testStationRecDataValues);
46  CPPUNIT_TEST(testStationCalibDataValues);
47  CPPUNIT_TEST(testStationGPSDataValues);
48  CPPUNIT_TEST_SUITE_END();
49 
50 public:
52 
54 
55  void
57  {
58  fTestSEventImpl = new testSEventImpl();
59  fTestFEventImpl = new testFEventImpl();
60  fTestShowerImpl = new testShowerImpl();
61 
62  fTestFEventImpl->setUp(fEvent);
63  fTestSEventImpl->setUp(fEvent);
64  fTestShowerImpl->setUp(fEvent);
65 
66  fTestFEventImpl->setAll(fEvent.GetFEvent());
67  fTestSEventImpl->setAll(fEvent.GetSEvent());
68  fTestShowerImpl->SetShowerRecDataValues(fEvent.GetRecShower());
69  fEvent.MakeSimShower(evt::DefaultShowerGeometryProducer());
70  fTestShowerImpl->SetShowerSimDataValues(fEvent.GetSimShower());
71  }
72 
73  void
75  {
76  fTestFEventImpl->tearDown();
77  fTestSEventImpl->tearDown();
78  fTestShowerImpl->tearDown();
79 
80  delete fTestSEventImpl;
81  fTestSEventImpl = 0;
82  delete fTestFEventImpl;
83  fTestFEventImpl = 0;
84  delete fTestShowerImpl;
85  fTestShowerImpl = 0;
86  }
87 
88  void
90  {
91  OfflineROOTFile file("test.root",io::eNew);
92  file.Write(fEvent);
93  file.Close();
94  }
95 
96  void
98  {
99  OfflineROOTFile another_file("test.root", io::eRead);
100  Event event;
101  another_file.Read(event);
102  fTestSEventImpl->checkHeaderValues(event.GetSEvent());
103  another_file.Close();
104  }
105 
106  void
108  {
109  OfflineROOTFile another_file("test.root", io::eRead);
110  Event event;
111  another_file.Read(event);
112  fTestSEventImpl->checkEventTriggerValues(event.GetSEvent());
113  another_file.Close();
114  }
115 
116  void
118  {
119  OfflineROOTFile another_file("test.root", io::eRead);
120  Event event;
121  another_file.Read(event);
122  fTestSEventImpl->checkStationTriggerValues(event.GetSEvent());
123  another_file.Close();
124  }
125 
126  void
128  {
129  OfflineROOTFile another_file("test.root", io::eRead);
130  Event event;
131  another_file.Read(event);
132  fTestSEventImpl->checkPMTValues(event.GetSEvent());
133  another_file.Close();
134  }
135 
136  void
138  {
139  OfflineROOTFile another_file("test.root", io::eRead);
140  Event event;
141  another_file.Read(event);
142  fTestSEventImpl->checkPMTSimDataValues(event.GetSEvent());
143  another_file.Close();
144  }
145 
146  void
148  {
149  OfflineROOTFile another_file("test.root", io::eRead);
150  Event event;
151  another_file.Read(event);
152  fTestSEventImpl->checkPMTRecDataValues(event.GetSEvent());
153  another_file.Close();
154  }
155 
156  void
158  {
159  OfflineROOTFile another_file("test.root", io::eRead);
160  Event event;
161  another_file.Read(event);
162  fTestSEventImpl->checkPMTCalibDataValues(event.GetSEvent());
163  another_file.Close();
164  }
165 
166  void
168  {
169  OfflineROOTFile another_file("test.root", io::eRead);
170  Event event;
171  another_file.Read(event);
172  fTestSEventImpl->checkStationValues(event.GetSEvent());
173  another_file.Close();
174  }
175 
176  void
178  {
179  OfflineROOTFile another_file("test.root", io::eRead);
180  Event event;
181  another_file.Read(event);
182  fTestSEventImpl->checkStationSimDataValues(event.GetSEvent());
183  another_file.Close();
184  }
185 
186  void
188  {
189  OfflineROOTFile another_file("test.root", io::eRead);
190  Event event;
191  another_file.Read(event);
192  fTestSEventImpl->checkStationRecDataValues(event.GetSEvent());
193  another_file.Close();
194  }
195 
196  void
198  {
199  OfflineROOTFile another_file("test.root", io::eRead);
200  Event event;
201  another_file.Read(event);
202  fTestSEventImpl->checkStationCalibDataValues(event.GetSEvent());
203  another_file.Close();
204  }
205 
206  void
208  {
209  OfflineROOTFile another_file("test.root", io::eRead);
210  Event event;
211  another_file.Read(event);
212  fTestSEventImpl->checkStationGPSDataValues(event.GetSEvent());
213  another_file.Close();
214  }
215 
216  void
218  {
219  OfflineROOTFile another_file("test.root", io::eRead);
220  Event event;
221  cout << " ======================= testReadBack " << event.HasSimShower() << endl;
222  another_file.Read(event);
223 
224  cout << " ======================= " << event.HasSimShower() << endl;
225 
226  fTestFEventImpl->checkAll(event.GetFEvent());
227  fTestShowerImpl->CheckShowerSimDataValues(event.GetSimShower(), 0);
228  fTestShowerImpl->CheckShowerRecDataValues(event.GetRecShower());
229 
230  another_file.Close();
231  }
232 
233  void
235  {
236  OfflineROOTFile another_file("test.root", io::eRead);
237 
238  cout << "\nconfig\n"
239  << another_file.GetConfig() << endl;
240 
241  // put a proper check here
242  }
243 
244 private:
249 };
250 
251 
253 
254 // Configure (x)emacs for this file ...
255 // Local Variables:
256 // mode: c++
257 // compile-command: "make -C .. -k"
258 // En
std::string GetConfig()
Return a string with the configuration corresponding to the run.
ROOT streamer for top level offline format.
Open file for write, fail if exists.
Definition: IoCodes.h:19
ShowerRecData & GetRecShower()
bool HasSimShower() const
void testStationTriggerValues()
void testStationCalibDataValues()
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
void testStationGPSDataValues()
ShowerSimData & GetSimShower()
void Write(const evt::Event &event) override
void Close() override
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
const string file
fevt::FEvent & GetFEvent()
testShowerImpl * fTestShowerImpl
testFEventImpl * fTestFEventImpl
void testStationSimDataValues()
void testStationRecDataValues()
testSEventImpl * fTestSEventImpl
sevt::SEvent & GetSEvent()
Status Read(evt::Event &event) override
Returns -1 if End Of File.

, generated on Tue Sep 26 2023.