testRDetector.cc
Go to the documentation of this file.
1 // Test giving out infos on Stations
2 
3 #include <iostream>
4 #include <sstream>
5 #include <string>
6 #include <vector>
7 #include <det/Detector.h>
8 #include <rdet/RDetector.h>
9 #include <rdet/Station.h>
10 #include <rdet/Channel.h>
11 #include <sdet/SDetector.h>
12 #include <sdet/Station.h>
13 #include <fwk/CentralConfig.h>
14 #include <utl/TimeStamp.h>
15 #include <utl/UTCDateTime.h>
16 #include <cppunit/extensions/HelperMacros.h>
17 #include <tst/Verify.h>
18 #include <utl/Point.h>
19 #include <utl/ReferenceEllipsoid.h>
20 #include <fwk/CoordinateSystemRegistry.h>
21 #include <fwk/LocalCoordinateSystem.h>
22 #include <TROOT.h>
23 #include <TH2F.h>
24 #include <TFile.h>
25 #include <TCanvas.h>
26 #include <TPaveText.h>
27 #include <TAttText.h>
28 
29 using namespace det;
30 using namespace utl;
31 using namespace tst;
32 using namespace rdet;
33 using std::cout;
34 using std::endl;
35 
36 #define ASSERT_CLOSE(x, y, eps) CPPUNIT_ASSERT(Verify<CloseTo>(x, y, eps))
37 #define ASSERT_EQUAL(x, y) CPPUNIT_ASSERT(Verify<Equal>(x, y))
38 
39 class RDetectorTest : public CppUnit::TestFixture {
40 
41  CPPUNIT_TEST_SUITE(RDetectorTest);
42  CPPUNIT_TEST(testStationListManager);
43  CPPUNIT_TEST(testRModel);
44  CPPUNIT_TEST(testAntennaType);
45  CPPUNIT_TEST_SUITE_END();
46 
47 public:
48  void
50  {
51  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
52 
53  // CentralConfig must be created first.
54  //
55  /*CentralConfig* fCentralConfig =*/
56  fwk::CentralConfig::GetInstance(BOOTSTRAPFILE);
57 
58  // Create a detector
59  //
60  /*Detector& theDetector =*/
61  Detector::GetInstance();
62  }
63 
64  void tearDown() { }
65 
66  void
68  {
69  cout << "Test of the AntennaTypes of RDetector" << endl;
70 
71  Detector& detector = Detector::GetInstance();
72  const TimeStamp detTime = UTCDateTime(2008, 11, 10, 16, 45, 12).GetTimeStamp();
73  detector.Update(detTime);
74 
75  const rdet::RDetector& rDetector = det::Detector::GetInstance().GetRDetector();
76  const Station& rStation = rDetector.GetStation(102);
77  std::pair<std::complex<double>, std::complex<double>> cEffectiveAntennaHeight;
78 
79  cout << "test channel 1" << endl;
80  const Channel& rChannel1 = rStation.GetChannel(1);
81  for(unsigned int i = 0; i < 100; i+=5)
82  {
83  cEffectiveAntennaHeight =
84  rChannel1.GetElectricFieldResponse(0.2, 0.3, double(i) * megahertz, "LinearInterpolation");
85  cout << double(i) * megahertz / (giga * hertz) << " GHz \t-> e_theta_amp : "
86  << abs(cEffectiveAntennaHeight.first) / meter << " m, e_theta_phase : "
87  << arg(cEffectiveAntennaHeight.first) / degree << " degrees" << endl;
88  }
89  cEffectiveAntennaHeight =
90  rChannel1.GetElectricFieldResponse(0.2, 0.3, 50 * megahertz, "LinearInterpolation");
91  CPPUNIT_ASSERT(Verify<Equal>(abs(cEffectiveAntennaHeight.first) > 0, true));
92 
93  cout << "test channel 2" << endl;
94  const Channel& rChannel2 = rStation.GetChannel(2);
95  for(unsigned int i = 0; i < 100; i+=5)
96  {
97  cEffectiveAntennaHeight =
98  rChannel2.GetElectricFieldResponse(0.2, 0.3, double(i) * megahertz, "LinearInterpolation");
99  cout << double(i) * megahertz / (giga * hertz) << " GHz \t-> e_theta_amp : "
100  << abs(cEffectiveAntennaHeight.first) / meter << " m, e_theta_phase : "
101  << arg(cEffectiveAntennaHeight.first) / degree << " degrees" << endl;
102  }
103  cEffectiveAntennaHeight =
104  rChannel2.GetElectricFieldResponse(0.2, 0.3, 50 * megahertz, "LinearInterpolation");
105  CPPUNIT_ASSERT(Verify<Equal>(abs(cEffectiveAntennaHeight.first) > 0, true));
106 
107  };
108 
109  void
111  {
112  Detector& detector = Detector::GetInstance();
113  const TimeStamp detTime = UTCDateTime(2008, 11, 10, 16, 45, 12).GetTimeStamp();
114  detector.Update(detTime);
115 
116  // try to get the name of the RDetector.Station id=1
117  const RDetector& RDetector = detector.GetRDetector();
118  const Station& RStation = RDetector.GetStation(101);
119  cout << "Name of rdet::Station with Id 1: "
120  << RStation.GetName()
121  << endl;
122 
123  // get an SD detector (Olaia) as a reference
124  /*
125  const sdet::SDetector& SDetector = detector.GetSDetector();
126  const sdet::Station& OlaiaStation = SDetector.GetStation(1325); // get tank Olaia (infill tank close to BLS)
127  const utl::Point OlaiaLocation = OlaiaStation.GetPosition();
128  */
129 
130  /*Oliva: get antennas positions
131  (originset to Station with id=1)
132  then prepare the histo to be filled
133  */
134  utl::CoordinateSystemPtr localcoor = RDetector.GetStation(101).GetLocalCoordinateSystem();
135  // get reference coordinate system (usually PampaAmarilla)
137  TH2F *histo = new TH2F("histo","Antennas Position", 1000, -27100., -25600., 1000, -6000., -4600.);
138  TFile antennasposition("antennasposition.root","recreate");
139  TCanvas* RSPlot = new TCanvas("RSPlot","RSPlot");
140  RSPlot->cd();
141  histo->Draw();
142 
143  /*
144  // print out coordinates of Olaia relative to radio station 1
145  std::cout << " Olaia coordinates relative to first radio station: " << OlaiaLocation.GetX(localcoor) << " " << OlaiaLocation.GetY(localcoor) << " " << OlaiaLocation.GetZ(localcoor) << "\n" << endl;
146  */
147 
148  //Oliva @brief: iterator over radio stations to get infos on them
149  for (rdet::RDetector::StationIterator rdIt = RDetector.StationsBegin(); rdIt != RDetector.StationsEnd(); ++rdIt) {
150  std::string StationName = rdIt->GetName();
151  utl::Point Position = rdIt->GetPosition();
152  histo->Fill(Position.GetX(localcoor), Position.GetY(localcoor));
153 
154  cout << " Station Name: " << StationName << endl;
155  cout << " Position (x,y,z) meters: "
156  << Position.GetX(localcoor) << ", " << Position.GetY(localcoor) << ", " << Position.GetZ(localcoor) << endl;
157  cout << " Station Spher. coo. (theta, phi): "
158  << Position.GetTheta(localcoor) << ", " << Position.GetPhi(localcoor) <<endl;
159  cout << " Radius r (cylind. coo.) from origin (m): " << Position.GetRho(localcoor) << endl;
160  cout << " Radius R (spheri. coo.) from origin (m): " << Position.GetR(localcoor) << endl;
161  /*Oliva: the cylindric. coor. radius r
162  must b equal to "dist" defined right down here.
163  For a check UNCOMMENT next lines!
164  */
165  // double dist =
166  // sqrt(Position.GetX(localcoor)*Position.GetX(localcoor)+Position.GetY(localcoor)*Position.GetY(localcoor));
167  // cout <<" Dist. from origin sqrt(x^2+y^2) -CHECK- (m): " << dist <<endl;
168 
169  /*Oliva: Creates the RSPlot.png file
170  which displays the Radio Station positions
171  and their funny names.
172  */
173  std::stringstream StationText("");
174  StationText << " " << rdIt->GetId() << " " << StationName;
175  TText* RStext = new TText(Position.GetX(referenceCS), Position.GetY(referenceCS), StationText.str().c_str());
176  RStext->SetTextAlign(20);
177  RStext->SetTextAngle(35);
178  RStext->SetTextSize(.04);
179  RStext->Draw();
180  }
181 
182  histo->SetStats(false);
183  histo->SetMarkerStyle(2);
184  histo->SetFillColor(kWhite);
185  histo->SetMarkerSize(1.);
186  histo->Draw("same");
187  histo->Write();
188  RSPlot->SaveAs("RSPlot.png");
189  }
190 
191 
192  void
194  {
195  Detector& detector = Detector::GetInstance();
196  const TimeStamp detTime = UTCDateTime(2008,11,10,16,45,12).GetTimeStamp();
197  detector.Update(detTime);
198 
199  // try to get RDetector.GetStation
200  const RDetector& RDetector = detector.GetRDetector();
201  const Station& RStation = RDetector.GetStation(103);
202  const Channel& RChannel = RStation.GetChannel(1);
203  cout << "Lower Design Freq. of rdet::Channel of Station id=" << RStation.GetId()
204  << " and Channel=" << RChannel.GetId()
205  << ": " << RChannel.GetDesignLowerFreq() / utl::megahertz << " MHz"
206  << " GetOrientationAzimuth: " << RChannel.GetOrientationAzimuth() / utl::degree
207  << endl;
208 
209  const Channel& RChannel2 = RStation.GetChannel(2);
210  cout << "Lower Design Freq. of rdet::Channel of Station id=" << RStation.GetId()
211  << " and Channel=" << RChannel2.GetId()
212  << ": " << RChannel2.GetDesignLowerFreq() / utl::megahertz << " MHz"
213  << " GetOrientationAzimuth/degree: "
214  << RChannel2.GetOrientationAzimuth() / utl::degree
215  << " GetOrientationZeta/degree: "
216  << RChannel2.GetOrientationZeta() / utl::degree
217  << " GetPosition/m: "
218  << ReferenceEllipsoid::Get(ReferenceEllipsoid::eWGS84).PointToLatitudeLongitudeHeight(RChannel2.GetPosition()).get<2>()/utl::meter
219  << endl;
220 
221  ResponseMap rMap = RChannel2.GetResponseMap();
222 
223  std::string RHRME("");
224  cout << "Got ResponseMap for Station id=" << RStation.GetId()
225  << " and Channel=" << RChannel2.GetId()
226  << endl;
227  for (ResponseMap::const_iterator rMapIter=rMap.Begin(); rMapIter!=rMap.End(); ++rMapIter)
228  {
229  cout << "\n ResponseID: " << rMapIter->first
230  << "\n ResponseWeight: " << rMapIter->second
231  << "\n Nr of Points in Profile: " << RDetector.GetHardwareResponseProfile(rMapIter->first).GetNPoints()
232  << endl;
233  RHRME = rMapIter->first;
234  };
235 
236  cout << "Testiing HardwareProfile: " << RHRME << endl;
237  TabulatedFunctionComplexLgAmpPhase tComplexLgAmpPhase = RDetector.GetHardwareResponseProfile(RHRME);
238  cout << "\nNumber of Points: "
239  << tComplexLgAmpPhase.GetNPoints()
240  << "\n3rd x-value in MHz: "
241  << tComplexLgAmpPhase.GetX(2)
242  << " Log of Amplitude: "
243  << tComplexLgAmpPhase.GetY(2).GetLgAmplitude()
244  << ", Phase: "
245  << tComplexLgAmpPhase.GetY(2).GetPhase()
246  << "\nLog of Amplitude at 25 MHz: "
247  << tComplexLgAmpPhase.Y(25*utl::megahertz).GetLgAmplitude()
248  << ", Phase/degree: "
249  << tComplexLgAmpPhase.Y(25*utl::megahertz).GetPhase() / utl::degree
250  << "\nLog of Amplitude at 30 MHz: "
251  << tComplexLgAmpPhase.Y(30*utl::megahertz).GetLgAmplitude()
252  << ", Phase/degree: "
253  << tComplexLgAmpPhase.Y(30*utl::megahertz).GetPhase() / utl::degree
254  << endl;
255 
256  }
257 };
258 
boost::transform_iterator< InternalStationFunctor, InternalStationIterator, const Station & > StationIterator
StationIterator returns a pointer to a station.
Definition: RDetector.h:61
const_iterator End() const
Get an iterator to the end of the ResponseMap.
Definition: ResponseMap.h:48
void Update(const utl::TimeStamp &time, const bool invData=true, const bool invComp=true, const bool forceRadio=false)
Update detector: deletes currently constructed stations and sets new time.
Definition: Detector.cc:179
utl::CoordinateSystemPtr GetLocalCoordinateSystem() const
Get the Auger reference system centered on the station.
double GetOrientationZeta() const
Get zeta-tilt of Antenna for this Channel.
const double degree
Point object.
Definition: Point.h:32
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
Detector description interface for Station-related data.
int GetId() const
return ID of the Channel
double GetR(const CoordinateSystemPtr &coordinateSystem) const
radius r in spherical coordinates coordinates (distance to origin)
Definition: BasicVector.h:257
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
double GetPhase() const
Get the phase in radians, can be bigger than 2*pi.
StationIterator StationsEnd() const
End of the collection of pointers to commissioned stations.
Definition: RDetector.h:68
StationIterator StationsBegin() const
Beginning of the collection of pointers to commissioned stations.
Definition: RDetector.h:64
double GetDesignLowerFreq() const
Get design value of the freq-band.
const utl::Point & GetPosition() const
Get Position of this Antenna-Channel.
const double meter
Definition: GalacticUnits.h:29
Traditional name.
Definition: Verbosity.h:17
const utl::ComplexLgAmpPhase & GetY(const unsigned int idx) const
Interpolate the Y value with a polyDegree polynomial.
Detector description interface for Channel-related data.
constexpr double giga
Definition: AugerUnits.h:73
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
std::map< std::string, double >::const_iterator const_iterator
Definition: ResponseMap.h:34
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
const utl::TabulatedFunctionComplexLgAmpPhase & GetHardwareResponseProfile(const std::string &identifier) const
Get the response (TabulatedFunctionComplexLgAmpPhase) which corresponds to a hardware profile identif...
Definition: RDetector.cc:164
double GetX(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:206
Class to hold collection (x,y) points and provide interpolation between them, where y are complex num...
const utl::ResponseMap & GetResponseMap() const
Get the ResponseMap of the Channel.
double abs(const SVector< n, T > &v)
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
constexpr double meter
Definition: AugerUnits.h:81
void testStationListManager()
constexpr double degree
constexpr double megahertz
Definition: AugerUnits.h:155
int GetId() const
Station ID.
A helper class which manages a list of system response identifiers (std::strings) and their correspon...
Definition: ResponseMap.h:28
constexpr double hertz
Definition: AugerUnits.h:153
utl::ComplexLgAmpPhase Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
double GetLgAmplitude() const
Get log10(amplitude)
double GetRho(const CoordinateSystemPtr &coordinateSystem) const
radius r in cylindrical coordinates (distance to z axis)
Definition: BasicVector.h:263
const Channel & GetChannel(const int id) const
Get specified Channel by id.
double GetY(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:209
void testAntennaType()
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
const double & GetX(const unsigned int idx) const
utl::CoordinateSystemPtr GetReferenceCoordinateSystem() const
Get the reference coordinate system used for analysis (usually PampaAmarilla for Auger) ...
Definition: Detector.h:141
const_iterator Begin() const
Get an iterator to the first element of the ResponseMap.
Definition: ResponseMap.h:45
const rdet::RDetector & GetRDetector() const
Definition: Detector.cc:143
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
Definition: BasicVector.h:212
std::pair< std::complex< double >, std::complex< double > > GetElectricFieldResponse(const double theta, const double phi, const double freq, std::string interpolationMode) const
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141
TimeStamp GetTimeStamp() const
Definition: UTCDateTime.cc:115
double GetOrientationAzimuth() const
Get azimuth-direction of Antenna for this Channel.
std::string GetName() const
Station name.

, generated on Tue Sep 26 2023.