FEvent/Eye.cc
Go to the documentation of this file.
1 #include <sstream>
2 #include <utl/ErrorLogger.h>
3 
4 #include <fevt/EyeRecData.h>
5 #include <fevt/EyeTriggerData.h>
6 #include <fevt/Telescope.h>
7 #include <fevt/EyeHeader.h>
8 #include <fevt/Eye.h>
9 
10 #include <utl/AugerException.h>
11 #include <utl/IteratorDeprecator.h>
12 
13 using namespace std;
14 using namespace utl;
15 using namespace fevt;
16 
17 
18 Eye::Eye(const unsigned int eyeId, const ComponentSelector::Status status) :
19  fId(eyeId),
20  fStatus(status)
21 { }
22 
23 
24 Eye::Eye(const Eye& eyeData)
25 {
26  *this = eyeData;
27 }
28 
29 
31 {
32  for (const auto p : fTelescopes)
33  delete p;
34 }
35 
36 
37 Eye&
38 Eye::operator=(const Eye& eyeData)
39 {
40  if (this != &eyeData) {
41  fId = eyeData.fId;
42  fRecData = eyeData.fRecData;
43  fTriggerData = eyeData.fTriggerData;
44  fHeader = eyeData.fHeader;
45  for (const auto p : fTelescopes)
46  delete p;
47  fTelescopes.clear();
48  for (const auto p : eyeData.fTelescopes)
49  fTelescopes.push_back(new Telescope(*p));
50  fStatus = eyeData.fStatus;
51  }
52  return *this;
53 }
54 
55 
56 Telescope&
57 Eye::GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status)
58 {
59  for (TelescopeIterator tIt = TelescopesBegin(status);
60  tIt != TelescopesEnd(status); ++tIt)
61  if (tIt->GetId() == telescopeId)
62  return *tIt;
63 
64  ostringstream err;
65  err << "Non existent telescope requested, Eye=" << fId
66  << " Tel=" << telescopeId << " at status=" << status << ".";
67 
68  if (HasTelescope(telescopeId, ComponentSelector::eUnknown))
69  err << " Telescope has status: " << GetTelescope(telescopeId, ComponentSelector::eUnknown).GetStatus() << "! ";
70  else
71  err << " Telescope not defined! ";
72 
73  ERROR(err);
74  throw utl::NonExistentComponentException(err.str());
75 }
76 
77 
78 const Telescope&
79 Eye::GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status)
80  const
81 {
82  for (ConstTelescopeIterator tIt = TelescopesBegin(status);
83  tIt != TelescopesEnd(status); ++tIt)
84  if (tIt->GetId() == telescopeId)
85  return *tIt;
86 
87  ostringstream err;
88  err << "Non existent telescope requested, Eye=" << fId
89  << " Tel=" << telescopeId << " at status=" << status << ".";
90 
91  if (HasTelescope(telescopeId, ComponentSelector::eUnknown))
92  err << " Telescope has status: " << GetTelescope(telescopeId, ComponentSelector::eUnknown).GetStatus() << "! ";
93  else
94  err << " Telescope not defined! ";
95 
96  ERROR(err);
97  throw utl::NonExistentComponentException(err.str());
98 }
99 
100 
101 void
102 Eye::MakeTelescope(const unsigned int telescopeId, const ComponentSelector::Status status)
103 {
104  if (HasTelescope(telescopeId, ComponentSelector::eExists)) {
105  ostringstream err;
106  err << "Telescope already exists, Eye: " << fId
107  << " Telescope: " << telescopeId;
108  WARNING(err);
109  return;
110  }
111 
112  fTelescopes.push_back(new Telescope(fId, telescopeId, status));
113 }
114 
115 
116 bool
117 Eye::HasTelescope(const unsigned int telescopeId, const ComponentSelector::Status status)
118  const
119 {
120  for (ConstTelescopeIterator tIt = TelescopesBegin(status);
121  tIt != TelescopesEnd(status); ++tIt)
122  if (tIt->GetId() == telescopeId)
123  return true;
124 
125  return false;
126 }
127 
128 
131 {
132  return *fRecData;
133 }
134 
135 
136 const fevt::EyeRecData&
138  const
139 {
140  return *fRecData;
141 }
142 
143 
144 void
146 {
147  if (fRecData)
148  ERROR("EyeRecData already exists - Not Replacing");
149  else
150  fRecData = new EyeRecData(GetId());
151 }
152 
153 
156 {
157  return *fTriggerData;
158 }
159 
160 
163  const
164 {
165  return *fTriggerData;
166 }
167 
168 
169 void
171 {
172  if (fTriggerData)
173  ERROR("EyeTriggerData already exists - Not Replacing");
174  else
176 }
177 
178 
181 {
182  return *fHeader;
183 }
184 
185 
186 const fevt::EyeHeader&
188  const
189 {
190  return *fHeader;
191 }
192 
193 
194 void
196 {
197  if (fHeader) {
198  ERROR("Eye::Header already exists - Not Replacing");
199  }
200  else
201  fHeader = new EyeHeader;
202 }
203 
204 
205 // This is deprecated!
208 {
209  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::Eye::TelescopesBegin");
210 
213 }
214 
215 
216 // This is deprecated!
219  const
220 {
221  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::Eye::TelescopesBegin");
222 
225 }
226 
227 
228 // This is deprecated!
231 {
232  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::Eye::TelescopesEnd");
233 
236 }
237 
238 
239 // This is deprecated!
242  const
243 {
244  utl::IteratorDeprecator::GetInstance().Deprecated("fevt::Eye::TelescopesEnd");
245 
248 }
Telescope & GetTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Telescope by Id, throw exception if not existent.
Definition: FEvent/Eye.cc:57
Predicate specifying whether telescope is selected or not.
unsigned int GetId() const
Definition: FEvent/Eye.h:54
Trigger data for an fevt::Eye.
Eye & operator=(const Eye &eyeData)
Definition: FEvent/Eye.cc:38
fevt::EyeHeader & GetHeader()
Header for this Eye Event.
Definition: FEvent/Eye.cc:180
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
utl::ShadowPtr< EyeTriggerData > fTriggerData
Definition: FEvent/Eye.h:130
ComponentSelector::Status GetStatus() const
void MakeRecData()
Definition: FEvent/Eye.cc:145
ComponentSelector::Status fStatus
Definition: FEvent/Eye.h:132
Header of Eye-level event.
Definition: EyeHeader.h:32
Eye(const Eye &eyeData)
Definition: FEvent/Eye.cc:24
Base class for exceptions trying to access non-existing components.
void MakeTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Make Telescope telescopeId.
Definition: FEvent/Eye.cc:102
utl::ShadowPtr< EyeHeader > fHeader
Definition: FEvent/Eye.h:131
utl::ShadowPtr< EyeRecData > fRecData
Definition: FEvent/Eye.h:129
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:230
AllTelescopeIterator AllTelescopesEnd()
Definition: FEvent/Eye.h:45
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
Definition: FEvent/Eye.h:72
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void MakeHeader()
Definition: FEvent/Eye.cc:195
unsigned int fId
Definition: FEvent/Eye.h:127
AllTelescopeIterator AllTelescopesBegin()
Definition: FEvent/Eye.h:44
Status
Possible component status.
Eye-specific shower reconstruction data.
Definition: EyeRecData.h:65
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:207
bool HasTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Check if the telescope is in the event.
Definition: FEvent/Eye.cc:117
InternalTelescopeContainer fTelescopes
Definition: FEvent/Eye.h:128
fevt::EyeTriggerData & GetTriggerData()
Trigger data for this eye.
Definition: FEvent/Eye.cc:155
Fluorescence Detector Telescope Event.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
boost::filter_iterator< ComponentSelector, ConstAllTelescopeIterator > ConstTelescopeIterator
Definition: FEvent/Eye.h:73
void MakeTriggerData()
Definition: FEvent/Eye.cc:170
fevt::EyeRecData & GetRecData()
Reconstructed data for this eye.
Definition: FEvent/Eye.cc:130

, generated on Tue Sep 26 2023.