testMuonArrivalTime.cc
Go to the documentation of this file.
1 
11 #include <iostream>
12 #include "MuonArrivalTime.h"
13 
14 #include <tst/Verify.h>
15 #include <cppunit/extensions/HelperMacros.h>
16 
17 using namespace std;
18 using namespace utl;
19 using namespace tst;
20 
24 class MuonArrivalTimeTest : public CppUnit::TestFixture {
25 
26  CPPUNIT_TEST_SUITE(MuonArrivalTimeTest);
27  CPPUNIT_TEST(testTimeCDF);
28  CPPUNIT_TEST(testApproximateTimeCDF);
29  CPPUNIT_TEST(testFirstTimePDF);
30  CPPUNIT_TEST(testApproximateFirstTimePDF);
31  CPPUNIT_TEST_SUITE_END();
32 
34 
35 public:
36 
37  void
39  {
40  fTM.SetTheta(60*degree);
41  fTM.SetCoordinates(1000*meter, 0);
42  }
43 
44  void tearDown() { }
45 
46  void
48  {
49  const double res = fTM.TimeCDF(1e9*ns);
50  CPPUNIT_ASSERT(Verify<CloseTo>(res, 1.0));
51  }
52 
53  void
55  {
56  const double res = fTM.ApproximateTimeCDF(1e9*ns);
57  CPPUNIT_ASSERT(Verify<CloseTo>(res, 1.0));
58  }
59 
60  void
62  {
63  const unsigned int nmuon = 10;
64  const double lntmin = std::log(1e1*ns);
65  const double lntmax = std::log(1e3*ns);
66  const double n = 100;
67 
68  double tsum = 0;
69  double ttsum = 0;
70  for (int i = 0; i < n; ++i)
71  {
72  const double z = double(i)/(n-1);
73  const double t = std::exp((1.0-z)*lntmin + z*lntmax);
74  const double dp = fTM.FirstTimePDF(t,nmuon)*t;
75  tsum += dp*t;
76  ttsum += dp*t*t;
77  }
78 
79  const double dlnt = (lntmax-lntmin)/n;
80  const double tmean = tsum*dlnt;
81  const double tsigma = std::sqrt(ttsum*dlnt-tmean*tmean);
82 
83  CPPUNIT_ASSERT(Verify<CloseTo>(tmean, 76.*ns, 1e-1));
84  CPPUNIT_ASSERT(Verify<CloseTo>(tsigma, 15.*ns, 1e-1));
85  }
86 
87  void
89  {
90  const unsigned int nmuon = 10;
91  const double lntmin = std::log(1e1*ns);
92  const double lntmax = std::log(1e3*ns);
93  const double n = 100;
94 
95  double tsum = 0;
96  double ttsum = 0;
97  for (int i = 0; i < n; ++i)
98  {
99  const double z = double(i)/(n-1);
100  const double t = std::exp((1.0-z)*lntmin + z*lntmax);
101  const double dp = fTM.ApproximateFirstTimePDF(t,nmuon)*t;
102  tsum += dp*t;
103  ttsum += dp*t*t;
104  }
105 
106  const double dlnt = (lntmax-lntmin)/n;
107  const double tmean = tsum*dlnt;
108  const double tsigma = std::sqrt(ttsum*dlnt-tmean*tmean);
109 
110  CPPUNIT_ASSERT(Verify<CloseTo>(tmean, 76.*ns, 1e-1));
111  CPPUNIT_ASSERT(Verify<CloseTo>(tsigma, 19.*ns, 1e-1));
112  }
113 
114 };
115 
116 
118 
119 
120 // Configure (x)emacs for this file ...
121 // Local Variables:
122 // mode: c++
123 // End:
const double degree
const double meter
Definition: GalacticUnits.h:29
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
const double ns
all time delays are relative to arrival time of shower front plane

, generated on Tue Sep 26 2023.