TestEventVector Class Reference

#include <TestNuEventVector.h>

List of all members.

Public Member Functions

void testInitialisation (void)
void testPushback (void)
void testSize (void)
void testNoPot (void)
void testSetPot (void)
void testEventRw (void)
void testFCEvent2 (void)
void testMaxRwNoPOT (void)
void testMaxRwPOT (void)
void testScaleNoPOT (void)
void testScalePOT (void)
void testScaleMax (void)
void testScaleMaxPOT (void)

Detailed Description

Definition at line 18 of file TestNuEventVector.h.


Member Function Documentation

void TestEventVector::testEventRw ( void   )  [inline]

Definition at line 115 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, and NuEventVector< T >::push_back().

00116   {
00117     NuEventVector<event> a;
00118     event b(1.0);
00119     a.push_back(b, 1);
00120     
00121     // Now check an event with different POT is weighted correctly
00122     a.push_back(b, 0.5);
00123     TS_ASSERT_DELTA(a[1].rw, 2.0, 1e-9);
00124   }

void TestEventVector::testFCEvent2 ( void   )  [inline]

Definition at line 127 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::push_back(), NuFCEvent2::Rw(), and NuEvent::rw.

00128   {
00129     NuEventVector<NuFCEvent2> a;
00130     // Build a NuFCEvent2 from a NuEvent
00131     NuEvent bsrc;
00132     bsrc.rw = 1.0;
00133     NuFCEvent2 b(bsrc);
00134     
00135     TS_ASSERT_DELTA(b.Rw(), 1.0, 1e-9);
00136     
00137     a.push_back(b, 1);
00138     TS_ASSERT_DELTA(a[0].Rw(), b.Rw(), 1e-9);
00139     
00140     a.push_back(b, 0.5);
00141     TS_ASSERT_DELTA(a[1].Rw(), b.Rw()*2, 1e-9);
00142     
00143   }

void TestEventVector::testInitialisation ( void   )  [inline]

Definition at line 30 of file TestNuEventVector.h.

References MuELoss::a.

00031   {
00032     NuEventVector<event> a;
00033   }

void TestEventVector::testMaxRwNoPOT ( void   )  [inline]

Definition at line 146 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::maxrw(), and NuEventVector< T >::push_back().

00147   {
00148     NuEventVector<event> a;
00149     event b(1.0);
00150     event c(2.0);
00151     a.push_back(b);
00152     TS_ASSERT_DELTA(a.maxrw(), 1.0, 1e-9);
00153     
00154     a.push_back(c);
00155     TS_ASSERT_DELTA(a.maxrw(), 2.0, 1e-9);
00156 
00157     a.push_back(b);
00158     TS_ASSERT_DELTA(a.maxrw(), 2.0, 1e-9);
00159   }

void TestEventVector::testMaxRwPOT ( void   )  [inline]

Definition at line 162 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::maxrw(), and NuEventVector< T >::push_back().

00163   {
00164     NuEventVector<event> a;
00165     event b(1.0);
00166     event c(2.0);
00167     a.push_back(b, 1E20);
00168     TS_ASSERT_DELTA(a.maxrw(), 1.0, 1e-9);
00169     
00170     a.push_back(c, 1E20);
00171     TS_ASSERT_DELTA(a.maxrw(), 2.0, 1e-9);
00172 
00173     a.push_back(b, 4E20);
00174     TS_ASSERT_DELTA(a.maxrw(), 2.0, 1e-9);
00175     
00176     a.push_back(b, 0.25E20);
00177     TS_ASSERT_DELTA(a.maxrw(), 4.0, 1e-9);
00178   }

void TestEventVector::testNoPot ( void   )  [inline]

Definition at line 65 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::pot(), and NuEventVector< T >::push_back().

00066   {
00067     NuEventVector<event> a;
00068     event b;
00069     b.rw = 1.0;
00070     
00071     TS_ASSERT_DELTA(a.pot(), 0.0, 1e-9);
00072     
00073     a.push_back(b);
00074     
00075     TS_ASSERT_DELTA(a.pot(), 0.0, 1e-9);
00076     
00077     // This should fail to add
00078     TS_ASSERT_THROWS( a.push_back(b, 3.2E20), std::logic_error );
00079     a.push_back(b);
00080     
00081     TS_ASSERT_DELTA(a.pot(), 0.0, 1e-9);
00082   }

void TestEventVector::testPushback ( void   )  [inline]

Definition at line 35 of file TestNuEventVector.h.

References MuELoss::a, and NuEventVector< T >::push_back().

00036   {
00037     NuEventVector<event> a;
00038     event b;
00039     b.rw = 0xDEAFBEEF;
00040     
00041     a.push_back(b);
00042     
00043     // Check we got an identical copy in the push
00044     TS_ASSERT_SAME_DATA(&b, &a[0], sizeof(event));
00045   }

void TestEventVector::testScaleMax ( void   )  [inline]

Definition at line 202 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::maxrw(), NuEventVector< T >::push_back(), and NuEventVector< T >::scale().

00203   {
00204     NuEventVector<event> a;
00205 
00206     // Generate a sequence of events with weights
00207     for (int i = 0; i < 10; ++i) {
00208       a.push_back(event(i));
00209     }
00210     // Double check this worked
00211     TS_ASSERT_LESS_THAN(1.0, a.maxrw());
00212     
00213     // Now, reweight everything to 1.0
00214     a.scale(1./a.maxrw());
00215     TS_ASSERT_DELTA(a.maxrw(), 1.0, 1e-9);
00216   }

void TestEventVector::testScaleMaxPOT ( void   )  [inline]

Definition at line 219 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::maxrw(), NuEventVector< T >::pot(), NuEventVector< T >::push_back(), and NuEventVector< T >::scale().

00220   {
00221     NuEventVector<event> a;
00222 
00223     // Generate a sequence of events with weights
00224     for (int i = 0; i < 10; ++i) {
00225       a.push_back(event(i), 1E20);
00226     }
00227     // Double check this worked (maxrw will be greater than 1.0)
00228     TS_ASSERT_LESS_THAN(1.0, a.maxrw());
00229     
00230     // Now, reweight everything to 1.0
00231     a.scale(1./a.maxrw());
00232     TS_ASSERT_DELTA(a.maxrw(), 1.0, 1e-9);
00233     TS_ASSERT_DELTA(a.pot(), 1E20/9, 1e-29);
00234   }

void TestEventVector::testScaleNoPOT ( void   )  [inline]

Definition at line 181 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::maxrw(), NuEventVector< T >::push_back(), and NuEventVector< T >::scale().

00182   {
00183     NuEventVector<event> a;
00184     event b(1.0);
00185     a.push_back(b);
00186     a.scale(2.0);
00187     TS_ASSERT_DELTA(a.maxrw(), 2.0, 1e-9);
00188   }

void TestEventVector::testScalePOT ( void   )  [inline]

Definition at line 191 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::pot(), NuEventVector< T >::push_back(), and NuEventVector< T >::scale().

00192   {
00193     NuEventVector<event> a;
00194     event b(1.0);
00195     a.push_back(b, 1E20);
00196     a.scale(2.0);
00197     TS_ASSERT_DELTA(a.pot(), 2E20, 1e-9);
00198     
00199   }

void TestEventVector::testSetPot ( void   )  [inline]

Definition at line 85 of file TestNuEventVector.h.

References MuELoss::a, MuELoss::e, NuEventVector< T >::pot(), and NuEventVector< T >::push_back().

00086   {
00087     NuEventVector<event> a;
00088     event b;
00089     b.rw = 1.0;
00090     
00091     a.push_back(b, 1);
00092     // check the POT was set
00093     TS_ASSERT_DELTA(a.pot(), 1.0, 1e-9);
00094     
00095     // Check this left the rw of the event unchanged
00096     TS_ASSERT_DELTA(a[0].rw, 1.0, 1e-9);
00097     
00098     // Check the POT does not change if pushing a different POT event
00099     a.push_back(b, 2);
00100     TS_ASSERT_DELTA(a.pot(), 1.0, 1e-9);
00101     
00102   }

void TestEventVector::testSize ( void   )  [inline]

Definition at line 47 of file TestNuEventVector.h.

References MuELoss::a, and NuEventVector< T >::push_back().

00048   {
00049     // Push back lots of events, making sure the size is okay
00050     NuEventVector<event> a;
00051     event b;
00052     
00053     for (int i = 0; i < 1000; ++i)
00054     {
00055       for (int j = 0; j < i; ++j)
00056       {
00057         a.push_back(b);
00058       }
00059       TS_ASSERT_EQUALS(a.size(), i);
00060       a.clear();
00061     }
00062   }


The documentation for this class was generated from the following file:

Generated on 15 Jul 2018 for loon by  doxygen 1.6.1