FEvent.cc
Go to the documentation of this file.
1 #include <fevt/FEvent.h>
2 #include <fevt/Eye.h>
3 
4 #include <det/Detector.h>
5 #include <fdet/FDetector.h>
6 #include <fdet/Eye.h>
7 
8 #include <utl/ErrorLogger.h>
9 #include <utl/AugerException.h>
10 #include <utl/IteratorDeprecator.h>
11 
12 #include <sstream>
13 
14 #include <utl/LameShadowPtr_imp.h>
16 
17 using namespace std;
18 using namespace fevt;
19 
20 
21 FEvent::FEvent(const FEvent& theFEvent)
22 {
23  *this = theFEvent;
24 }
25 
26 
27 FEvent::~FEvent()
28 {
29  for (InternalEyeIterator eyeIt = fEyes.begin();
30  eyeIt != fEyes.end(); ++eyeIt)
31  delete *eyeIt;
32 }
33 
34 
35 FEvent&
36 FEvent::operator=(const FEvent& theFEvent)
37 {
38  if (this != &theFEvent) {
39 
40  for (InternalEyeIterator eyeIt = fEyes.begin();
41  eyeIt != fEyes.end(); ++eyeIt)
42  delete *eyeIt;
43  fEyes.clear();
44  for (InternalConstEyeIterator eyeIt = theFEvent.fEyes.begin();
45  eyeIt != theFEvent.fEyes.end(); ++eyeIt)
46  fEyes.push_back(new Eye(**eyeIt));
47 
48  fHeader = theFEvent.fHeader;
49 
50  }
51 
52  return *this;
53 }
54 
55 
56 bool
57 FEvent::HasEye(const unsigned int eyeId, const ComponentSelector::Status status)
58  const
59 {
60  for (ConstEyeIterator it = EyesBegin(status);
61  it != EyesEnd(status); ++it)
62  if (it->GetId() == eyeId)
63  return true;
64 
65  return false;
66 }
67 
68 
69 Eye&
70 FEvent::GetEye(const unsigned int eyeId, const ComponentSelector::Status status)
71 {
72  for (EyeIterator it = EyesBegin(status);
73  it != EyesEnd(status); ++it)
74  if (it->GetId() == eyeId)
75  return *it;
76 
77  ostringstream err;
78  err << "Eye with id=" << eyeId << " not present at status=" << status << ".";
79 
80  if (HasEye(eyeId, ComponentSelector::eUnknown)) {
81  err << " Eye has status: " << GetEye(eyeId, ComponentSelector::eUnknown).GetStatus() << "! ";
82  } else {
83  err << " Eye not defined! ";
84  }
85 
86  ERROR(err);
87  throw utl::NonExistentComponentException(err.str());
88 }
89 
90 
91 const Eye&
92 FEvent::GetEye(const unsigned int eyeId, const ComponentSelector::Status status)
93  const
94 {
95  for (ConstEyeIterator it = EyesBegin(status);
96  it != EyesEnd(status); ++it)
97  if (it->GetId() == eyeId)
98  return *it;
99 
100  ostringstream err;
101  err << "Eye with id=" << eyeId << " not present at status=" << status << ".";
102 
103  if (HasEye(eyeId, ComponentSelector::eUnknown)) {
104  err << " Eye has status: " << GetEye(eyeId, ComponentSelector::eUnknown).GetStatus() << "! ";
105  } else {
106  err << " Eye not defined! ";
107  }
108 
109  ERROR(err);
110  throw utl::NonExistentComponentException(err.str());
111 }
112 
113 
114 void
115 FEvent::MakeEye(const unsigned int eyeId, const ComponentSelector::Status status)
116 {
117  if (HasEye(eyeId, ComponentSelector::eExists)) {
118  ostringstream err;
119  err << "Eye with id " << eyeId << " already present, not replacing";
120  WARNING(err);
121  return;
122  }
123 
124  fEyes.push_back(new Eye(eyeId, status));
125 }
126 
127 
128 bool
129 FEvent::HasEye(const std::string& eyeName, const ComponentSelector::Status status)
130  const
131 {
132  unsigned int id;
133  try {
134  id = GetIdFromName(eyeName);
135  } catch (utl::IOFailureException& ex) {
136  ostringstream err;
137  err << "Unable to respond to request. Detector information seems to be unavailable.";
138  ERROR(err);
139  throw;
140  } catch (...) {
141  return false;
142  }
143  return HasEye(id, status);
144 }
145 
146 
147 void
148 FEvent::MakeEye(const string& eyeName, const ComponentSelector::Status status)
149 {
150  unsigned int id;
151  try {
152  id = GetIdFromName(eyeName);
153  } catch (utl::IOFailureException& ex) {
154  ostringstream err;
155  err << "Unable to respond to request. Detector information seems to be unavailable.";
156  ERROR(err);
157  throw;
158  } catch (utl::NonExistentComponentException& ex) {
159  ostringstream err;
160  err << "Cannot invoke MakeEye for an eye '" << eyeName
161  << "' which does not exist, according to the detector description";
162  ERROR(err);
163  throw;
164  }
165 
166  try {
167  MakeEye(id, status);
168  } catch (...) {
169  throw;
170  }
171 }
172 
173 
174 Eye&
175 FEvent::GetEye(const string& eyeName, const ComponentSelector::Status status)
176 {
177  unsigned int id;
178  try {
179  id = GetIdFromName(eyeName);
180  } catch (utl::IOFailureException& ex) {
181  ostringstream err;
182  err << "Unable to respond to request. Detector information seems to be unavailable.";
183  ERROR(err);
184  throw;
185  } catch (utl::NonExistentComponentException& ex) {
186  ostringstream err;
187  err << "Cannot get eye '" << eyeName
188  << "' which does not exist, according to the detector description";
189  ERROR(err);
190  throw;
191  }
192 
193  try {
194  return GetEye(id, status);
195  } catch (...) {
196  throw;
197  }
198 }
199 
200 
201 const Eye&
202 FEvent::GetEye(const string& eyeName, const ComponentSelector::Status status)
203  const
204 {
205  unsigned int id;
206  try {
207  id = GetIdFromName(eyeName);
208  } catch (utl::IOFailureException& ex) {
209  ostringstream err;
210  err << "Unable to respond to request. Detector information seems to be unavailable.";
211  ERROR(err);
212  throw;
213  } catch (utl::NonExistentComponentException& ex) {
214  ostringstream err;
215  err << "Cannot get eye '" << eyeName
216  << "' which does not exist, according to the detector description";
217  ERROR(err);
218  throw;
219  }
220 
221  try {
222  return GetEye(id, status);
223  } catch (...) {
224  throw;
225  }
226 }
227 
228 
229 // Look up the Id from the given name (uses the Detector Description
230 unsigned int
231 FEvent::GetIdFromName(const string& eyeName)
232  const
233 {
234  // Find the id corresponding to the requested name
235  try {
236  return det::Detector::GetInstance().GetFDetector().GetEye(eyeName).GetId();
237  } catch (utl::IOFailureException& ex) {
238  ostringstream err;
239  err << "Could not access the Detector description";
240  ERROR(err);
241  throw;
242  } catch (utl::NonExistentComponentException& ex) {
243  ostringstream err;
244  err << "Could not find requested eye '" << eyeName << "' in Detector description";
245  ERROR(err);
246  throw;
247  }
248 }
249 
250 
251 // This is deprecated!
253 FEvent::EyesBegin()
254 {
255  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::FEvent::EyesBegin");
256 
257  return EyeIterator(ComponentSelector(ComponentSelector::eHasData),
258  AllEyesBegin(), AllEyesEnd());
259 }
260 
261 
262 // This is deprecated!
264 FEvent::EyesBegin()
265  const
266 {
267  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::FEvent::EyesBegin");
268 
269  return ConstEyeIterator(ComponentSelector(ComponentSelector::eHasData),
270  AllEyesBegin(), AllEyesEnd());
271 }
272 
273 
274 // This is deprecated!
276 FEvent::EyesEnd()
277 {
278  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::FEvent::EyesEnd");
279 
280  return EyeIterator(ComponentSelector(ComponentSelector::eHasData),
281  AllEyesEnd(), AllEyesEnd());
282 }
283 
284 
285 // This is deprecated!
287 FEvent::EyesEnd()
288  const
289 {
290  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::FEvent::EyesEnd");
291 
292  return ConstEyeIterator(ComponentSelector(ComponentSelector::eHasData),
293  AllEyesEnd(), AllEyesEnd());
294 }
295 
296 
297 // Configure (x)emacs for this file ...
298 // Local Variables:
299 // mode: c++
300 // compile-command: "make -C .. FEvent/FEvent.o -k"
301 // End:
Predicate specifying whether telescope is selected or not.
#define LAMESHADOWPTR_INST(_T_...)
InternalEyeContainer::const_iterator InternalConstEyeIterator
Definition: FEvent.h:38
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
boost::filter_iterator< ComponentSelector, ConstAllEyeIterator > ConstEyeIterator
Definition: FEvent.h:56
InternalEyeContainer fEyes
Definition: FEvent.h:103
Base class for exceptions trying to access non-existing components.
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Definition: FEvent.h:55
fevt::Header fHeader
Definition: FEvent.h:104
Base class to report exceptions in IO.
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
Status
Possible component status.
InternalEyeContainer::iterator InternalEyeIterator
Definition: FEvent.h:37
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
ComponentSelector::Status GetStatus() const
Definition: FEvent/Eye.h:118

, generated on Tue Sep 26 2023.