Detector.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <sstream>
3 #include <map>
4 
5 #include <det/Detector.h>
6 #include <det/ManagerRegister.h>
7 #include <fwk/CentralConfig.h>
8 #include <utl/Reader.h>
9 #include <utl/ErrorLogger.h>
10 #include <utl/TimeStamp.h>
11 
12 #include <fwk/CoordinateSystemRegistry.h>
13 #include <utl/CoordinateSystem.h>
14 
15 #include <sdet/SManagerRegister.h>
16 #include <sdet/SDetector.h>
17 #include <fdet/FManagerRegister.h>
18 #include <fdet/FDetector.h>
19 #include <atm/AManagerRegister.h>
20 
21 #include <rdet/RManagerRegister.h>
22 #include <rdet/RDetector.h>
23 
24 #include <mdet/MManagerRegister.h>
25 #include <mdet/MDetector.h>
26 
27 #include <cdet/CManagerRegister.h>
28 #include <cdet/CDetector.h>
29 
30 #warning RU: magnetic field model fwk->det
31 #include <fwk/MagneticFieldModel.h>
32 #include <fwk/ParametricGeoMagneticField.h>
33 
34 using namespace std;
35 using namespace det;
36 using namespace sdet;
37 using namespace fdet;
38 using namespace rdet;
39 using namespace mdet;
40 using namespace cdet;
41 using namespace atm;
42 using namespace utl;
43 using namespace fwk;
44 
45 
46 Detector::Detector()
47 {
48  const auto cc = CentralConfig::GetInstance();
49 
50  // Configure the SManagerRegister from an external XML file.
51  auto sManagerConfigBranch = cc->GetTopBranch("SManagerRegister");
52  if (sManagerConfigBranch)
53  SManagerRegister::GetInstance().Configure(sManagerConfigBranch);
54  else {
55  INFO("Could not access a configuration file for the SManagerRegister. "
56  "The Detector interface will not be able to get information about the SD "
57  "(This is not an error, unless you are planning to use the surface detector information).");
58  }
59 
60  // Configure the FManagerRegister from an external XML file
61  auto fManagerConfigBranch = cc->GetTopBranch("FManagerRegister");
62  if (fManagerConfigBranch)
63  FManagerRegister::GetInstance().Configure(fManagerConfigBranch);
64  else {
65  INFO("Could not access a configuration file for the FManagerRegister. "
66  "The Detector interface will not be able to get information about the FD "
67  "(this is not an error, unless you are planning to use fluorescence detector information).");
68  }
69 
70  // Configure the RManagerRegister from an external XML file
71  auto rManagerConfigBranch = cc->GetTopBranch("RManagerRegister");
72  if (rManagerConfigBranch)
73  RManagerRegister::GetInstance().Configure(rManagerConfigBranch);
74  else {
75  INFO("Could not access a configuration file for the RManagerRegister. "
76  "The Detector interface will not be able to get information about Radio "
77  "(this is not an error, unless you are planning to use radio detector information).");
78  }
79 
80  // Configure the MManagerRegister from an external XML file.
81  auto mManagerConfigBranch = cc->GetTopBranch("MManagerRegister");
82  if (mManagerConfigBranch)
83  MManagerRegister::GetInstance().Configure(mManagerConfigBranch);
84  else {
85  INFO("Could not access a configuration file for the MManagerRegister. "
86  "The Detector interface will not be able to get information about the MD "
87  "(this is not an error, unless you are planning to use muon detector information).");
88  }
89 
90  // Configure the CManagerRegister from an external XML file
91  auto cManagerConfigBranch = cc->GetTopBranch("CManagerRegister");
92  if (cManagerConfigBranch)
93  CManagerRegister::GetInstance().Configure(cManagerConfigBranch);
94  else {
95  INFO("Could not access a configuration file for the CManagerRegister. "
96  "The Detector interface will not be able to get information about MARTA "
97  "(this is not an error, unless you are planning to use MARTA detector information).");
98  }
99 
100  // Configure the AManagerRegister from an external XML file
101  auto aManagerConfigBranch = cc->GetTopBranch("AManagerRegister");
102  if (aManagerConfigBranch) {
103  AManagerRegister::GetInstance().Configure(aManagerConfigBranch);
104  } else {
105  INFO("Could not access a configuration file for the AManagerRegister. "
106  "The Detector interface will not be able to get information about the Atmosphere "
107  "(this is not an error, unless you are planning to use the Atmosphere information).");
108  }
109 
110  fAtmosphere.Init();
111 
112  fSiteReferenceSystem = fwk::CoordinateSystemRegistry::Get("Malargue");
113 
114  fReferenceCoordinateSystem = fwk::CoordinateSystemRegistry::Get("PampaAmarilla");
115 }
116 
117 
118 const sdet::SDetector&
119 Detector::GetSDetector()
120  const
121 {
122  if (!fSDetector) {
123  fSDetector = new SDetector();
124  fSDetector->Update();
125  }
126  return *fSDetector;
127 }
128 
129 
130 const fdet::FDetector&
131 Detector::GetFDetector()
132  const
133 {
134  if (!fFDetector) {
135  fFDetector = new FDetector();
136  fFDetector->Update();
137  }
138  return *fFDetector;
139 }
140 
141 
142 const rdet::RDetector&
143 Detector::GetRDetector()
144  const
145 {
146  if (!fRDetector) {
147  fRDetector = new RDetector();
148  fRDetector->Update();
149  }
150  return *fRDetector;
151 }
152 
153 
154 const mdet::MDetector&
155 Detector::GetMDetector()
156  const
157 {
158  if (!fMDetector) {
159  fMDetector = new MDetector();
160  fMDetector->Update();
161  }
162  return *fMDetector;
163 }
164 
165 
166 const cdet::CDetector&
167 Detector::GetCDetector()
168  const
169 {
170  if (!fCDetector) {
171  fCDetector = new CDetector();
172  fCDetector->Update();
173  }
174  return *fCDetector;
175 }
176 
177 
178 void
179 Detector::Update(const TimeStamp& time, const bool invData, const bool invComp, const bool forceRadio)
180 {
181 
182  if (fTime == time) {
183  WARNING("Already at the requested time.");
184  } else {
185  ostringstream info;
186  info << "to time " << time;
187  INFO(info);
188 
189  fTime = time;
190 
191  // Update time in Detector. This method also
192  // deletes currently constructed surface stations and fluorescence
193  // stations (actual deletion is handled by Update() methods of SDetector
194  // and FDetector, respectively).
195 
196  if (fSDetector)
197  fSDetector->Update();
198  if (fFDetector)
199  fFDetector->Update();
200  if (fRDetector)
201  fRDetector->Update();
202  if (fMDetector)
203  fMDetector->Update(invData, invComp);
204  if (fCDetector)
205  fCDetector->Update();
206 
207  fAtmosphere.Update();
208 
209  delete fGeoMagneticField;
210  fGeoMagneticField = nullptr;
211  }
212  // update the dense array, even if the time stamp has not changed.
213  if (fSDetector)
214  fSDetector->UpdateDense();
215  if (fCDetector)
216  fCDetector->UpdateDense();
217 
218  // Update to add virtual stations to RDetector which in the mean time have
219  // been added to the RStationListManager.
220  // TODO: Replace buy a better logic (e.g., UpdateStar(), similar to UpdateDense)
221  if (forceRadio && fRDetector)
222  fRDetector->Update();
223 }
224 
225 
227 Detector::GetGeoMagneticField()
228 {
229 #warning RU: Magnetic field should be handled same way as all other components. No global singleton.
230  if (!fGeoMagneticField)
231  fGeoMagneticField =
233  return *fGeoMagneticField;
234 }
235 
236 
238 Detector::GetGeoMagneticFieldAt(const utl::Point& location)
239 {
240  return GetGeoMagneticField().Get(location);
241 }
242 
243 
244 Detector::~Detector()
245 {
246  delete fGeoMagneticField;
247  delete fRDetector;
248  delete fFDetector;
249  delete fSDetector;
250  delete fMDetector;
251  delete fCDetector;
252 }
Point object.
Definition: Point.h:32
Detector description interface for CDetector-related data.
Definition: CDetector.h:40
void Update(std::vector< double > &init, const std::vector< double > &res)
Definition: Util.h:100
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
Detector associated to muon detector hierarchy.
Definition: MDetector.h:32
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
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
static MagneticFieldModel & instance()
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
Spherical harmonics parametrisation of geomagnetic field.
Vector object.
Definition: Vector.h:30
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.

, generated on Tue Sep 26 2023.