9 #include <tst/Verify.h>
10 #include <cppunit/extensions/HelperMacros.h>
12 #include <io/TimeDistribution_ROOT.h>
13 #include <utl/TimeDistribution.h>
15 #include <io/Trace_ROOT.h>
16 #include <io/MultiTrace_ROOT.h>
17 #include <utl/Trace.h>
18 #include <utl/MultiTrace.h>
19 #include <utl/System.h>
21 #include <utl/TabulatedFunctionErrors.h>
22 #include <utl/TabulatedFunction.h>
23 #include <io/TabulatedFunctionErrors_ROOT.h>
24 #include <io/TabulatedFunction_ROOT.h>
26 #include <io/MultiTabulatedFunction_ROOT.h>
27 #include <io/MultiTabulatedFunctionErrors_ROOT.h>
28 #include <utl/MultiTabulatedFunction.h>
29 #include <utl/MultiTabulatedFunctionErrors.h>
31 #include <utl/Ignore.h>
38 #include <boost/tuple/tuple_io.hpp>
49 CPPUNIT_TEST(testTimeDistributionD);
50 CPPUNIT_TEST(testTimeDistributionI);
51 CPPUNIT_TEST(testTraceD);
52 CPPUNIT_TEST(testTraceI);
55 CPPUNIT_TEST(testTabulatedFunction);
56 CPPUNIT_TEST(testPhoton);
57 CPPUNIT_TEST(testMultiTabulatedFunction);
58 CPPUNIT_TEST(testMultiTrace);
59 CPPUNIT_TEST_SUITE_END();
86 fFilename =
"basura.root";
100 fFile1 =
new TFile(fFilename.c_str(),
"RECREATE");
101 CPPUNIT_ASSERT(fFile1);
104 double array[bins] = { 10, 5.1, 3, 2, 1 };
106 double array2[bins] = { 10, 5.1, 3, 2, 1 };
120 fFile1->WriteObject(&stream, stream.Class_Name());
124 fFile2 =
new TFile(fFilename.c_str());
125 CPPUNIT_ASSERT(fFile2);
129 CPPUNIT_ASSERT(stream2);
132 *stream2 >> multiTrace2;
134 CPPUNIT_ASSERT(IsEqual(multiTrace, multiTrace2));
144 msg.append(fFilename);
151 fFile1 =
new TFile(fFilename.c_str(),
"RECREATE");
152 CPPUNIT_ASSERT(fFile1);
155 for (
int i = 0; i < 10; ++i)
156 tabulatedFunction.
PushBack(i*0.5, 10.0-i);
159 fFile1->WriteObject(&tabulatedFunction_ROOT, tabulatedFunction_ROOT.Class_Name());
162 for (
int i = 0; i < 10; ++i)
163 tabulatedFunctionErrors.
PushBack(i*0.5, 10.0-i, 0.01*i, 0.05*i);
166 fFile1->WriteObject(&tabulatedFunctionErrors_ROOT, tabulatedFunctionErrors_ROOT.Class_Name());
170 fFile2 =
new TFile(fFilename.c_str());
171 CPPUNIT_ASSERT(fFile2);
175 CPPUNIT_ASSERT(tabulatedFunctionErrors_ROOT2);
177 *tabulatedFunctionErrors_ROOT2 >> tabulatedFunctionErrors2;
178 CPPUNIT_ASSERT(IsEqual(tabulatedFunctionErrors, tabulatedFunctionErrors2));
182 CPPUNIT_ASSERT(tabulatedFunction_ROOT2);
184 *tabulatedFunction_ROOT2 >> tabulatedFunction2;
185 CPPUNIT_ASSERT(IsEqual(tabulatedFunction, tabulatedFunction2));
195 msg.append(fFilename);
202 fFile1 =
new TFile(fFilename.c_str(),
"RECREATE");
203 CPPUNIT_ASSERT(fFile1);
205 for (
int i = 0; i < 10; ++i)
206 tabulatedFunction1.
PushBack(i*0.5, 10.0-i);
209 for (
int i = 10; i < 20; ++i)
210 tabulatedFunction2.
PushBack(i*0.5, 10.0-i);
213 for (
int i = 20; i < 30; ++i)
214 tabulatedFunction3.
PushBack(i*0.5, 10.0-i);
222 fFile1->WriteObject(&multiTabulatedFunction_ROOT, multiTabulatedFunction_ROOT.Class_Name());
226 fFile2 =
new TFile(fFilename.c_str());
227 CPPUNIT_ASSERT(fFile2);
231 CPPUNIT_ASSERT(multiTabulatedFunction_ROOT2);
234 *multiTabulatedFunction_ROOT2 >> multiTabulatedFunction2;
236 CPPUNIT_ASSERT(IsEqual(multiTabulatedFunction2, multiTabulatedFunction));
246 msg.append(fFilename);
253 fFile1 =
new TFile(fFilename.c_str(),
"RECREATE");
254 CPPUNIT_ASSERT(fFile1);
257 const double array[bins] = { 10.0, 5.1, 3, 2, 1 };
260 TraceD trace(bins, array, binsize);
264 fFile1->WriteObject(&stream, stream.Class_Name());
268 fFile2 =
new TFile(fFilename.c_str());
269 CPPUNIT_ASSERT(fFile2);
272 (
TraceD_ROOT*)gROOT->FindObject(
"io::Trace_ROOT<double>");
273 CPPUNIT_ASSERT(stream2);
278 CPPUNIT_ASSERT(IsEqual(trace, trace2));
288 msg.append(fFilename);
295 fFile1 =
new TFile(fFilename.c_str(),
"RECREATE");
296 CPPUNIT_ASSERT(fFile1);
299 const int array[bins] = { 10, 5, 3, 2, 1 };
302 TraceI trace(bins, array, binsize);
306 fFile1->WriteObject(&stream, stream.Class_Name());
310 fFile2 =
new TFile(fFilename.c_str());
311 CPPUNIT_ASSERT(fFile2);
314 (
TraceI_ROOT*)gROOT->FindObject(
"io::Trace_ROOT<int>");
315 CPPUNIT_ASSERT(stream2);
320 CPPUNIT_ASSERT(IsEqual(trace, trace2));
330 msg.append(fFilename);
337 fFile1 =
new TFile(fFilename.c_str(),
"RECREATE");
338 CPPUNIT_ASSERT(fFile1);
342 fFile2 =
new TFile(fFilename.c_str());
343 CPPUNIT_ASSERT(fFile2);
353 msg.append(fFilename);
360 const double binning = 2;
363 timeDistribution->
AddTime(11, 5);
364 timeDistribution->
AddTime(5, 3);
366 TFile*
const eventFile =
new TFile(
"basura.root",
"RECREATE");
367 CPPUNIT_ASSERT(eventFile);
369 CPPUNIT_ASSERT(streamed);
371 eventFile->WriteObject(streamed, streamed->Class_Name());
375 TFile*
const eventFile2 =
new TFile(
"basura.root");
376 CPPUNIT_ASSERT(eventFile2);
379 CPPUNIT_ASSERT(streamed2);
383 *streamed2 >> *timeDistribution2;
385 CPPUNIT_ASSERT(IsEqual(*timeDistribution, *timeDistribution2));
403 it != function2.
End(); ++it)
404 if (function1.
FindX(it->X())->Y() != it->
Y())
415 it != function2.
End(); ++it)
416 if (function1.
FindX(it->X())->Y() != it->
Y())
443 it != timeDistribution2.
SparseEnd(); ++it)
444 if (timeDistribution1.
At(it->template get<0>()) != it->template get<1>())
448 it != timeDistribution1.
SparseEnd(); ++it)
449 if (timeDistribution2[it->template get<0>()] != it->template get<1>())
467 for (
int i = 0; i < int(trace1.
GetSize()); ++i)
468 if (trace1[i] != trace2[i])
483 it != traces1.
End(); ++it)
484 if (!IsEqual(it->GetTrace(), traces2.
GetTrace(it->GetLabel())))
T At(const double time) const
void SetStop(const SizeType stop)
Set valid data stop bin.
ROOT streamer implementation for utl::MultiTabulatedFunction.
void testTabulatedFunction()
TimeDistribution< double > TimeDistributionD
void AddTrace(const int size, const double binSize, const int label)
void System(const char *const command, const bool throwOnError, const bool notify)
SizeType GetStop() const
Get valid data stop bin.
Iterator TabulatedFunctionsBegin()
Class to hold collection (x,y) points and provide interpolation between them.
Iterator TabulatedFunctionsEnd()
ConstIterator FindX(const double x) const
ROOT streamer for TimeDistributionD.
double GetBinning() const
size of one slot
Histogram class for time distributions with suppressed empty bins.
void AddTabulatedFunction(const int label)
void PushBack(const double x, const double y)
bool IsEqual(const MultiTrace< T > &traces1, const MultiTrace< T > &traces2)
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
ROOT streamer implementation for class TabulatedFunction.
TabulatedFunction & GetTabulatedFunction(const int label=0)
Returns the TabulatedFunction for /par source, throws an exception if na.
void SetStart(const SizeType start)
Set valid data start bin.
void testMultiTabulatedFunction()
void testTimeDistributionI()
void PushBack(const double x, const double xErr, const double y, const double yErr)
SparseIterator SparseEnd() const
ROOT streamer implementation for class TabulatedFunctionErrors.
void testTimeDistributionD()
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
SizeType GetStart() const
Get valid data start bin.
Trace< T > & GetTrace(const int label=0)
Returns the trace for /par source.
A collection of TabulatedFunction.
ConstIteratorErr FindX(const double x) const
unsigned int GetNLabels() const
A collection of Trace<T>,which provides methods to access different sources.
SparseIterator SparseBegin() const
Iterator over time slots with data in them (skips empty slots).
TimeDistribution_ROOT< double > TimeDistributionD_ROOT
void AddTime(const double time, const T weight=T(1))
Add an entry (optionally weighted) for the given time. Slot will be computed.
boost::transform_iterator< InternalMapFunctor, InternalConstIterator, Tuple > SparseIterator