FEvent/Telescope.cc
Go to the documentation of this file.
1 #include <det/Detector.h>
2 #include <fdet/FDetector.h>
3 #include <fdet/Eye.h>
4 #include <fdet/Telescope.h>
5 #include <fdet/Pixel.h>
6 #include <fevt/Telescope.h>
7 #include <fevt/EyeRecData.h>
8 #include <fevt/Channel.h>
9 #include <fevt/Pixel.h>
10 #include <fevt/TelescopeSimData.h>
11 #include <fevt/TelescopeRecData.h>
12 #include <fevt/TelescopeTriggerData.h>
13 #include <utl/ErrorLogger.h>
14 #include <utl/AugerException.h>
15 #include <utl/IteratorDeprecator.h>
16 #include <utl/PointerContainer.h>
17 #include <sstream>
18 
19 using namespace std;
20 using namespace utl;
21 using namespace fevt;
22 
23 
24 Telescope::Telescope(const unsigned int eyeId, const unsigned int telescopeId,
25  const ComponentSelector::Status status) :
26  fTelescopeId(telescopeId),
27  fEyeId(eyeId),
28  fRawTelPointing("unknown"),
29  fStatus(status)
30 { }
31 
32 
34 {
35  for (const auto cp : fChannels)
36  delete cp;
37  for (const auto pp : fPixels)
38  delete pp;
39 }
40 
41 
42 Telescope&
44 {
45  if (this != &telescope) {
46  fTelescopeId = telescope.fTelescopeId;
47  fEyeId = telescope.fEyeId;
48  fSimData = telescope.fSimData;
49  fRecData = telescope.fRecData;
50  fTriggerData = telescope.fTriggerData;
52 
53  for (const auto cp : fChannels)
54  delete cp;
55  fChannels.clear();
56  for (const auto cp : telescope.fChannels)
57  fChannels.push_back(new Channel(*cp));
58 
59  for (const auto pp : fPixels)
60  delete pp;
61  fPixels.clear();
62  for (const auto pp : telescope.fPixels)
63  fPixels.push_back(new Pixel(*pp));
64 
65  fTimeOffset = telescope.fTimeOffset;
66  fRawTelPointing = telescope.fRawTelPointing;
67  fStatus = telescope.fStatus;
69  }
70  return *this;
71 }
72 
73 
74 void
76 {
77  const auto tId = fTelescopeId;
78  const auto eId = fEyeId;
79  *this = t;
80  CorrectIds(eId, tId);
81 }
82 
83 
84 Channel&
85 Telescope::GetChannel(const unsigned int channelId)
86 {
87  for (auto& c : ChannelsRange())
88  if (c.GetId() == channelId)
89  return c;
90 
91  ostringstream err;
92  err << "Non existent channel requested, Eye: " << fEyeId
93  << " Tel: "<< fTelescopeId << " pix: " << channelId;
94  ERROR(err);
95 
96  throw utl::NonExistentComponentException(err.str());
97 }
98 
99 
100 const Channel&
101 Telescope::GetChannel(const unsigned int channelId)
102  const
103 {
104  for (const auto& c : ChannelsRange())
105  if (c.GetId() == channelId)
106  return c;
107 
108  ostringstream err;
109  err << "Non existent channel requested, Eye: " << fEyeId
110  << " Tel: "<< fTelescopeId << " pix: " << channelId;
111  ERROR(err);
112 
113  throw utl::NonExistentComponentException(err.str());
114 }
115 
116 
117 void
118 Telescope::MakeChannel(const unsigned int channelId)
119 {
120  for (const auto& c : ChannelsRange())
121  if (c.GetId() == channelId) {
122  ostringstream err;
123  err << "Channel already exists, Eye: " << fEyeId
124  << " Tel: " << fTelescopeId << " pix: " << channelId
125  << " - Not replacing";
126  ERROR(err);
127  return;
128  }
129 
130  fChannels.push_back(new Channel(fEyeId, fTelescopeId, channelId));
131 }
132 
133 
134 bool
135 Telescope::HasChannel(const unsigned int channelId)
136  const
137 {
138  for (const auto& c : ChannelsRange())
139  if (c.GetId() == channelId)
140  return true;
141 
142  return false;
143 }
144 
145 
146 Pixel&
147 Telescope::GetPixel(const unsigned int pixelId,
148  const ComponentSelector::Status status)
149 {
150  for (auto& p : PixelsRange(status))
151  if (p.GetId() == pixelId)
152  return p;
153 
154  ostringstream err;
155  err << "Non existent pixel (status: " << int(status) << ") requested, Eye: " << fEyeId
156  << " Tel: " << fTelescopeId << " pix: " << pixelId << ".";
157 
159  err << " Pixel has status: " << GetPixel(pixelId, ComponentSelector::eUnknown).GetStatus() << "! ";
160  else
161  err << " Pixel not defined! ";
162 
163  ERROR(err);
164  throw utl::NonExistentComponentException(err.str());
165 }
166 
167 
168 const Pixel&
169 Telescope::GetPixel(const unsigned int pixelId,
170  const ComponentSelector::Status status)
171  const
172 {
173  for (const auto& p : PixelsRange(status))
174  if (p.GetId() == pixelId)
175  return p;
176 
177  ostringstream err;
178  err << "Non existent pixel (status: " << int(status) << ") requested, Eye: " << fEyeId
179  << " Tel: " << fTelescopeId << " pix: " << pixelId << ".";
180 
182  err << " Pixel has status: " << GetPixel(pixelId, ComponentSelector::eUnknown).GetStatus() << "! ";
183  else
184  err << " Pixel not defined! ";
185 
186  ERROR(err);
187  throw utl::NonExistentComponentException(err.str());
188 }
189 
190 
191 void
192 Telescope::MakePixel(const unsigned int pixelId, const ComponentSelector::Status status)
193 {
194  for (const auto& p : PixelsRange(status))
195  if (p.GetId() == pixelId) {
196  ostringstream err;
197  err << "pixel " << pixelId << " already exists for eye " << fEyeId
198  << " tel " << fTelescopeId << "; not replacing";
199  ERROR(err);
200  return;
201  }
202 
203  fPixels.push_back(new Pixel(fEyeId, fTelescopeId, pixelId, status));
204 }
205 
206 
207 bool
208 Telescope::HasPixel(const unsigned int pixelId, const ComponentSelector::Status status)
209  const
210 {
211  for (const auto& p : PixelsRange(status))
212  if (p.GetId() == pixelId)
213  return true;
214 
215  return false;
216 }
217 
218 
221 {
222  return *fSimData;
223 }
224 
225 
226 const TelescopeSimData&
228  const
229 {
230  return *fSimData;
231 }
232 
233 
234 void
236 {
237  if (fSimData)
238  ERROR("TelescopeSimData already exists - Not Replacing");
239  else
241 }
242 
243 
246 {
247  return *fRecData;
248 }
249 
250 
253  const
254 {
255  return *fRecData;
256 }
257 
258 
259 void
261 {
262  if (fRecData)
263  ERROR("TelescopeRecData already exists - Not Replacing");
264  else
265  fRecData = new TelescopeRecData( GetEyeId(), GetId() );
266 }
267 
268 
271 {
272  return *fTriggerData;
273 }
274 
275 
278  const
279 {
280  return *fTriggerData;
281 }
282 
283 
284 void
286 {
287  if (fTriggerData)
288  ERROR("TelescopeTriggerData already exists - Not Replacing");
289  else
291 }
292 
293 
294 void
296  const
297 {
298  const fdet::FDetector& fDet = det::Detector::GetInstance().GetFDetector();
299  const fdet::Telescope& dTel = fDet.GetTelescope(*this);
300 
301  // 1.05 is just an arbitrary extra margin against floating point issues
302  const double cosNeighbourPixelAngle = cos((4./3*1.05)*dTel.GetCamera().GetEta());
303 
304  // Generate list of candidate pixel directions from detector + out of border pixels
305  vector<Vector> candidatePixelDirections;
306 
307  // First, add the out of border pixels to the candidates
308  for (const auto& pv : dTel.OutOfBorderPixelsRange())
309  candidatePixelDirections.push_back(pv);
310 
311  for (unsigned int i = dTel.GetFirstPixelId(); i <= dTel.GetLastPixelId(); ++i) {
312  // Skip event pixels
314  continue;
315  // Add the remaining det Pixels to the list of candidates
316  candidatePixelDirections.push_back(dTel.GetCameraPixelDirection(i));
317  }
318 
319  // Iterate over all candidate pixel directions
320  for (const auto& cd : candidatePixelDirections) {
321  // Iterate over all event pixel directions
322  for (const auto& p : PixelsRange(ComponentSelector::eHasData)) {
323  // If the candidate direction is within one pixel row of an event pixel direction,
324  // it is an event border pixel
325  if (!p.HasRecData())
326  continue;
327  const unsigned int id = p.GetId();
328  if (CosAngle(cd, dTel.GetCameraPixelDirection(id)) > cosNeighbourPixelAngle) {
329  fMirrorEventBorderPixelsDir.push_back(cd);
330  break;
331  }
332  }
333  }
334 }
335 
336 
339  const
340 {
341  if (fMirrorEventBorderPixelsDir.empty())
343  return fMirrorEventBorderPixelsDir.begin();
344 }
345 
346 
349  const
350 {
351  if (fMirrorEventBorderPixelsDir.empty())
353  return fMirrorEventBorderPixelsDir.end();
354 }
355 
356 
357 // This is deprecated!
360 {
361  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::Telescope::PixelsBegin");
362 
365 }
366 
367 
368 // This is deprecated!
371  const
372 {
373  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::Telescope::PixelsBegin");
374 
377 }
378 
379 
380 // This is deprecated!
383 {
384  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::Telescope::PixelsEnd");
385 
388 }
389 
390 
391 // This is deprecated!
394  const
395 {
396  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::Telescope::PixelsEnd");
397 
400 }
401 
402 
403 void
404 Telescope::CorrectIds(const unsigned int eyeId, const unsigned int telescopeId)
405 {
406  fTelescopeId = telescopeId;
407  fEyeId = eyeId;
408  if (fRecData)
409  fRecData->CorrectIds(eyeId, telescopeId);
410  for (auto& c : ChannelsRange())
411  c.CorrectIds(eyeId, telescopeId);
412  for (auto& p : AllPixelsRange())
413  p.CorrectIds(eyeId, telescopeId);
414 }
Predicate specifying whether telescope is selected or not.
utl::Vector GetCameraPixelDirection(const unsigned int pixelId) const
ComponentSelector::Status GetStatus() const
Definition: FEvent/Pixel.h:54
void GenerateMirrorEventBorderPixels() const
unsigned int fTimeOffset
AllPixelIterator AllPixelsEnd()
utl::TimeStamp fTracesStartTime
unsigned int GetFirstPixelId() const
double GetEta() const
Camera angular pixel spacing.
bool HasRecData() const
Definition: FEvent/Pixel.h:43
unsigned int GetEyeId() const
Base class for exceptions trying to access non-existing components.
Telescope & operator=(const Telescope &t)
fevt::TelescopeRecData & GetRecData()
Reconstructed data for this telescope.
InternalChannelContainer fChannels
AllPixelIterator AllPixelsBegin()
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
PixelIterator PixelsEnd()
iterator pointing to end of available pixels of status eHasData (DEPRECATED)
std::vector< utl::Vector >::const_iterator ConstMirrorEventBorderPixelsIterator
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
InternalPixelContainer fPixels
void MakePixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Make Pixel telescopeId.
bool HasPixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Check if the pixel is in the event.
fevt::TelescopeSimData & GetSimData()
Description of simulated data for one Telescope.
ConstMirrorEventBorderPixelsIterator MirrorEventBorderPixelsEnd() const
End of list of pixels just outside the mirror event.
unsigned int GetLastPixelId() const
Channel & GetChannel(const unsigned int channelId)
InternalPixelDirCollection fMirrorEventBorderPixelsDir
Fluorescence Detector Pixel event.
Definition: FEvent/Pixel.h:28
unsigned int fTelescopeId
void CorrectIds(const unsigned int eyeId, const unsigned int telescopeId)
boost::filter_iterator< ComponentSelector, ConstAllPixelIterator > ConstPixelIterator
Telescope-specific shower reconstruction data.
Fluorescence Detector Channel Event.
utl::ShadowPtr< TelescopeRecData > fRecData
Status
Possible component status.
void MakeChannel(const unsigned int channelId)
fTelescopeId(t.GetTelescopeId())
ConstMirrorEventBorderPixelsIterator MirrorEventBorderPixelsBegin() const
Begin of list of pixels just outside the mirror event.
utl::ShadowPtr< TelescopeTriggerData > fTriggerData
Pixel & GetPixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Pixel by Id, throw exception if not existent.
boost::filter_iterator< ComponentSelector, AllPixelIterator > PixelIterator
selective Pixel iterators
Detector description interface for Telescope-related data.
bool HasChannel(const unsigned int channelId) const
const Telescope & GetTelescope(const fevt::Telescope &eventTel) const
Get fdet::Telescope from fevt::Telescope.
Definition: FDetector.cc:150
ComponentSelector::Status fStatus
This is for HEAT to determine pointing.
unsigned int GetId() const
utl::ShadowPtr< TelescopeSimData > fSimData
unsigned int fEyeId
double CosAngle(const Vector &l, const Vector &r)
Definition: OperationsVV.h:71
std::string fRawTelPointing
Fluorescence Detector Telescope Event.
PixelIterator PixelsBegin()
iterator pointing to first available pixel of status eHasData (DEPRECATED)
Description of trigger data for one Telescope.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
fevt::TelescopeTriggerData & GetTriggerData()
void Assign(const Telescope &t)
copy all but keep original telescope and eye id

, generated on Tue Sep 26 2023.