REvent.cc
Go to the documentation of this file.
1 
6 #include <revt/REvent.h>
7 
8 #include <revt/EventTrigger.h>
9 #include <revt/Header.h>
10 #include <revt/Station.h>
11 
12 #include <det/Detector.h>
13 #include <rdet/RDetector.h>
14 
15 #include <utl/ErrorLogger.h>
16 #include <utl/AugerException.h>
17 #include <iostream>
18 #include <string>
19 
20 #include <utl/LameShadowPtr_imp.h>
22 
23 using namespace std;
24 using namespace revt;
25 using namespace det;
26 
27 
28 REvent::~REvent()
29 {
30  for (const auto s : fStations)
31  delete s.second;
32 }
33 
34 
35 REvent&
36 REvent::operator=(const REvent& rEvent)
37 {
38  if (this != &rEvent) {
39  for (const auto s : fStations)
40  delete s.second;
41  fStations.clear();
42 
43  for (auto sIt = rEvent.AllStationsBegin(); sIt != rEvent.AllStationsEnd(); ++sIt)
44  fStations.insert(make_pair(sIt->GetId(), new Station(*sIt)));
45 
46  fTrigger = rEvent.fTrigger;
47  fHeader = rEvent.fHeader;
48  fAERARootIoSourceFileName = rEvent.fAERARootIoSourceFileName;
49  fAERARootIoEventId = rEvent.fAERARootIoEventId;
50  fChannelResponseApplied = rEvent.fChannelResponseApplied;
51  }
52  return *this;
53 }
54 
55 
56 const revt::Station&
57 REvent::GetStation(const int id)
58  const
59 {
60  const auto sIt = fStations.find(id);
61  if (sIt != fStations.end() && !sIt->second->IsExcluded())
62  return *sIt->second;
63 
64  std::ostringstream err;
65  err << "Station " << id << " not present";
66  ERROR(err);
67  throw utl::NonExistentComponentException(err.str());
68 }
69 
70 
71 const revt::Station&
72 REvent::GetStationByName(const string& name)
73  const
74 {
75  const auto& radioDet = Detector::GetInstance().GetRDetector();
76  int stid = -1;
77  for (auto rdIt = radioDet.StationsBegin(); rdIt != radioDet.StationsEnd(); ++rdIt) {
78  if (rdIt->GetName() == name) {
79  stid = rdIt->GetId();
80  break;
81  }
82  }
83  if (stid == -1) {
84  ostringstream err;
85  err << " Could not find station " << name;
86  ERROR(err.str());
87  throw utl::NonExistentComponentException(err.str());
88  }
89  return GetStation(stid);
90 }
91 
92 
93 void
94 REvent::MakeStation(const int id)
95 {
96  // Check that the station exists in the Detector (Note that the
97  // detector must be set up and configured for this to work.
98  // This implies the CentralConfig must have been created with hooks
99  // to the boostrap.xml file.)
100  if (HasStation(id)) {
101  std::ostringstream warn;
102  warn << "Station " << id << " already present";
103  WARNING(warn);
104  return;
105  }
106  fStations.insert(make_pair(id, new Station(id)));
107 }
108 
109 
110 void
111 REvent::MakeStation(const string& stationName)
112 {
113  const auto& radioDet = Detector::GetInstance().GetRDetector();
114  int stid = -1;
115  for (auto rdIt = radioDet.StationsBegin(); rdIt != radioDet.StationsEnd(); ++rdIt) {
116  if (rdIt->GetName() == stationName) {
117  stid = rdIt->GetId();
118  break;
119  }
120  }
121  if (stid == -1) {
122  ostringstream err;
123  err << "Cannot find station with name " << stationName;
124  ERROR(err);
125  throw utl::NonExistentComponentException(err.str());
126  }
127  MakeStation(stid);
128 }
129 
130 
131 bool
132 REvent::HasStation(const int id)
133  const
134 {
135  const auto sIt = fStations.find(id);
136  return sIt != fStations.end() && !sIt->second->IsExcluded();
137 }
138 
139 
140 bool
141 REvent::HasStation(const string& name)
142  const
143 {
144  const auto& radioDet = Detector::GetInstance().GetRDetector();
145  int stid = -1;
146  for (auto rdIt = radioDet.StationsBegin(); rdIt != radioDet.StationsEnd(); ++rdIt) {
147  if (rdIt->GetName() == name) {
148  stid = rdIt->GetId();
149  break;
150  }
151  }
152  if (stid == -1) {
153  ostringstream err;
154  err << "Cannot find station with name " << name;
155  ERROR(err);
156  throw utl::NonExistentComponentException(err.str());
157  }
158  return HasStation(stid);
159 }
160 
161 
163 REvent::RemoveStation(const AllStationIterator it)
164 {
165  AllStationIterator it2 = it;
166  ++it2;
167  delete it.base()->second;
168  fStations.erase(it.base());
169  return it2;
170 }
171 
172 
173 void
174 REvent::MakeTrigger()
175 {
176  if (fTrigger)
177  ERROR("Trigger Object already present - Not replacing");
178  else
179  fTrigger = new EventTrigger;
180 }
Interface class to access the Event Trigger (T3)
bool fChannelResponseApplied
Definition: REvent.h:290
#define LAMESHADOWPTR_INST(_T_...)
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
utl::LameShadowPtr< EventTrigger > fTrigger
Definition: REvent.h:281
Header fHeader
Definition: REvent.h:282
AllStationIterator AllStationsEnd()
Definition: REvent.h:98
double fAERARootIoEventId
Definition: REvent.h:287
Base class for exceptions trying to access non-existing components.
boost::transform_iterator< InternalStationFunctor, InternalStationIterator, revt::Station & > AllStationIterator
Definition: REvent.h:94
AllStationIterator AllStationsBegin()
Definition: REvent.h:96
std::string fAERARootIoSourceFileName
Definition: REvent.h:286
class to hold data at the radio Station level.
constexpr double s
Definition: AugerUnits.h:163
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
int GetId() const
Get the station Id.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165

, generated on Tue Sep 26 2023.