testInclinedProfileModel.cc
Go to the documentation of this file.
1 #include <det/Detector.h>
2 
3 #include <atm/Atmosphere.h>
4 #include <atm/ProfileResult.h>
5 #include <atm/InclinedAtmosphericProfile.h>
6 
7 #include <fwk/CentralConfig.h>
8 #include <fwk/LocalCoordinateSystem.h>
9 #include <fwk/CoordinateSystemRegistry.h>
10 
11 #include <utl/TimeStamp.h>
12 #include <utl/UTCDateTime.h>
13 #include <utl/Point.h>
14 #include <utl/Vector.h>
15 #include <utl/TabulatedFunction.h>
16 #include <utl/AugerUnits.h>
17 #include <utl/AugerException.h>
18 #include <utl/ErrorLogger.h>
19 
20 #include <cppunit/extensions/HelperMacros.h>
21 #include <tst/Verify.h>
22 
23 #include <iostream>
24 
25 using namespace std;
26 using namespace det;
27 using namespace atm;
28 using namespace fwk;
29 using namespace utl;
30 using namespace tst;
31 
32 
42 class TestInclinedProfileModel : public CppUnit::TestFixture {
43 
44  CPPUNIT_TEST_SUITE(TestInclinedProfileModel);
45  CPPUNIT_TEST_EXCEPTION(TestAccessHeightException,
47  CPPUNIT_TEST(TestAccessHeight);
48  CPPUNIT_TEST(TestAccessDepth);
49  CPPUNIT_TEST(TestVerticalGeometry);
50  //CPPUNIT_TEST(TestAntiVerticalGeometry);
51  //CPPUNIT_TEST(TestHorizontalGeometry);
52  CPPUNIT_TEST_SUITE_END();
53 
54 private:
55  void InitTestProfile() { }
56 
57 public:
58  void
59  setUp()
60  override
61  {
62  CentralConfig::GetInstance(BOOTSTRAPFILE);
63  Detector::GetInstance().Update(UTCDateTime(2005, 1, 1, 0, 0, 0).GetTimeStamp());
64  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
65  }
66 
67  void tearDown() override { }
68 
69  void
71  {
72  Detector::GetInstance().GetAtmosphere().EvaluateHeightVsSlantDepth();
73  }
74 
75  void
77  {
78  const auto& cs = det::Detector::GetInstance().GetReferenceCoordinateSystem();
79  const auto& atm = Detector::GetInstance().GetAtmosphere();
80  const Point origin(0,0,0, cs);
81  const Vector dir(0,0,-1, cs); // oposite of axis
82  const double xStep = 20*g/cm2;
83  atm.InitSlantProfileModel(origin, -dir, xStep);
84  atm.EvaluateHeightVsSlantDepth();
85  }
86 
87  void
88  TestAccessHeight() // DV: ??? this looks exactly the same as TestAccessDepth() ???
89  {
90  const auto& cs = det::Detector::GetInstance().GetReferenceCoordinateSystem();
91  const auto& atm = Detector::GetInstance().GetAtmosphere();
92  const Point origin(0,0,0, cs);
93  const Vector dir(0,0,-1, cs); // oposite of axis
94  const double xStep = 20*g/cm2;
95  atm.InitSlantProfileModel(origin, -dir, xStep);
96  atm.EvaluateHeightVsSlantDepth();
97  }
98 
99  void
101  {
102  const auto& cs = det::Detector::GetInstance().GetReferenceCoordinateSystem();
103  InitTestProfile();
104  // vetical geometry
105  const Point core(0,0,0, cs);
106  const Vector dir(0,0,-1, cs);
107  const double xStep = 20*g/cm2;
108  const auto& atm = Detector::GetInstance().GetAtmosphere();
109  atm.InitSlantProfileModel(core, -dir, xStep);
110  }
111 
112  void
114  {
115  InitTestProfile();
116  const auto& det = det::Detector::GetInstance();
117  const auto& atm = det.GetAtmosphere();
118  const auto& depthProfile = atm.EvaluateDepthVsHeight();
119  //const auto& heightProfile = atm.EvaluateHeightVsDepth();
120 
121  // vetical geometry
122  const auto& cs = det.GetReferenceCoordinateSystem();
123  const Point core(0,0,0, cs);
124  const Vector dir(0,0,-1, cs);
125  const double xStep = 20*g/cm2;
126 
127  atm.InitSlantProfileModel(core, -dir, xStep);
128 
129  const auto& heightVsSlant = atm.EvaluateDistanceVsSlantDepth();
130 
131  const unsigned int nBins = 10; //fProfDepth.size()/4;
132  const double minSlantDepth = heightVsSlant.MinX();
133  const double maxSlantDepth = heightVsSlant.MaxX();
134  const double dSlant = (maxSlantDepth - minSlantDepth) / (nBins - 1);
135  cout << " -- " << minSlantDepth << ' '
136  << maxSlantDepth << ' ' << nBins << '\n';
137  // loop along shower and check mapping
138  for (unsigned int i = 0; i < nBins; ++i) {
139  const double atmSlantDepth = minSlantDepth + i * dSlant;
140  const double height = heightVsSlant.Y(atmSlantDepth);
141  const double atmDepth = depthProfile.Y(height);
142  cout << i << ' '
143  << atmSlantDepth/g*cm2 << ' '
144  << atmDepth/g*cm2 << ' '
145  << abs(atmSlantDepth - atmDepth)/g*cm2
146  << endl;
147  CPPUNIT_ASSERT(Verify<CloseTo>(atmDepth, atmSlantDepth, 1e-1*g/cm2));
148  }
149  }
150 
151 /*
152  NOT CLEAR HOW TO HANDLE THAT
153  WHERE SHOULD THE SHOWER HAVE ITS FIRST INTERACTION ???
154 
155  void testAntiVerticalGeometry() {
156 
157  cout << " testAntiVerticalGeometry " << endl;
158 
159  initTestProfile();
160 
161  CoordinateSystemPtr referenceCS =
162  det::Detector::GetInstance().GetReferenceCoordinateSystem();
163 
164  const atm::ProfileResult depthProfile
165  = Detector::GetInstance().GetAtmosphere().
166  EvaluateDepthVsHeight();
167 
168  const atm::ProfileResult heightProfile
169  = Detector::GetInstance().GetAtmosphere().
170  EvaluateHeightVsDepth();
171 
172 
173  // vetical geometry
174  Point core (0,0,0,referenceCS);
175  Vector dir (0,0,1,referenceCS);
176 
177  const Atmosphere& theAtm = Detector::GetInstance().GetAtmosphere();
178  theAtm.InitSlantProfileModel (core, dir, fProfDepth);
179 
180 
181  cout << " ok " << endl;
182 
183  const ProfileResult& slantVsHeight =
184  theAtm.EvaluateSlantDepthVsHeight();
185 
186  unsigned int nBins = fProfDepth.size();
187  double minHeight = slantVsHeight.MinX();
188  double maxHeight = slantVsHeight.MaxX();
189  cout << " -- " << minHeight
190  << " " << maxHeight
191  << " " << nBins
192  << endl;
193 
194 
195  // loop along shower and check mapping
196  for (unsigned int i=0; i<nBins; i++) {
197 
198  double atmHeight = minHeight + (maxHeight-minHeight)*i/(nBins-1);
199  //cout << atmHeight/m << " " << endl;
200  //cout << " 1 " << endl;
201  double atmDepth = depthProfile.Y (atmHeight);
202  //cout << " 2 " << endl;
203  double depth = slantVsHeight.Y (atmHeight);
204  //cout << " 3 " << endl;
205 
206  cout << depth/g*cm*cm << " " << atmDepth/g*cm*cm
207  << " " << (depth/g*cm*cm == atmDepth/g*cm*cm)
208  << endl;
209  CPPUNIT_ASSERT (Test<CloseTo>(depth/g*cm*cm,
210  atmDepth/g*cm*cm,
211  1.e-3));
212 
213 
214  }
215 
216  }
217 */
218 
219  void
221  {
222  InitTestProfile();
223  auto& det = det::Detector::GetInstance();
224  [[maybe_unused]] const auto& cs = det.GetReferenceCoordinateSystem();
225  auto& atm = det.GetAtmosphere();
226 
227  const auto& depthProfile = atm.EvaluateDepthVsHeight();
228  cout << "depth profile: X " << depthProfile.MinX()/meter << ' ' << depthProfile.MaxX()/meter << "\n"
229  " Y " << depthProfile.Y(depthProfile.MinX())/(g/cm2) << ' ' << depthProfile.Y(depthProfile.MaxX())/(g/cm2)
230  << endl;
231 
232  const auto& heightProfile = atm.EvaluateHeightVsDepth();
233  cout << "height profile: X " << heightProfile.MinX()/(g/cm2) << ' ' << heightProfile.MaxX()/(g/cm2) << "\n"
234  " Y " << heightProfile.Y(heightProfile.MinX())/meter << ' ' << heightProfile.Y(heightProfile.MaxX())/meter
235  << endl;
236 
237  //Commented for the time being
238  /*// horizontal geometry
239  const Point core(0,0,0, referenceCS);
240  const Vector dir(0,1,0, referenceCS);
241 
242  const Atmosphere& atm = Detector::GetInstance().GetAtmosphere();
243  theAtm.InitSlantProfileModel(core, dir, 20*g/cm2);
244 
245  cout << " ok " << endl;
246 
247  const ProfileResult& slantVsHeight = atm.EvaluateSlantDepthVsHeight();
248 
249  const unsigned int nBins = 10; //fProfDepth.size();
250  const double minHeight = slantVsHeight.MinX();
251  const double maxHeight = slantVsHeight.MaxX();
252  cout << " -- " << minHeight << ' '
253  << maxHeight << ' ' << nBins << endl;
254 
255  // loop along shower and check mapping
256  for (unsigned int i = 0; i < nBins; ++i) {
257 
258  const double atmHeight = minHeight + (maxHeight - minHeight) * i / (nBins - 1);
259  const double atmDepth = depthProfile.Y(atmHeight);
260  const double depth = slantVsHeight.Y(atmHeight);
261 
262  cout << depth/g*cm2 << ' ' << atmDepth/g*cm2 << ' '
263  << (depth/g*cm2 == atmDepth/g*cm2) << endl;
264 
265  CPPUNIT_ASSERT(Verify<CloseTo>(depth/g*cm2, atmDepth/g*cm2, 1e-1));
266 
267  }*/
268  }
269 
270 };
271 
272 
Point object.
Definition: Point.h:32
const double meter
Definition: GalacticUnits.h:29
Traditional name.
Definition: Verbosity.h:17
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
double abs(const SVector< n, T > &v)
constexpr double g
Definition: AugerUnits.h:200
execption handling for calculation/access for inclined atmosphere model
Vector object.
Definition: Vector.h:30
constexpr double cm2
Definition: AugerUnits.h:118

, generated on Tue Sep 26 2023.