CEvent.cc
Go to the documentation of this file.
1 
6 #include <iostream>
7 #include <boost/format.hpp>
8 #include <cevt/CEvent.h>
9 #include <cevt/CEventSimData.h>
10 // #include <cevt/EventTrigger.h>
11 // #include <cevt/Header.h>
12 #include <cevt/Station.h>
13 //#include <cevt/SQualityCuts.h>
14 #include <utl/ErrorLogger.h>
15 #include <utl/AugerException.h>
16 
17 #include <utl/LameShadowPtr_imp.h>
19 
20 using namespace std;
21 using namespace cevt;
22 
23 
24 
25 CEvent::CEvent()
26 {
27 }
28 
29 
30 CEvent::CEvent(const CEvent& cEvent)
31 {
32  *this = cEvent;
33 }
34 
35 
36 CEvent::~CEvent()
37 {
38  for (InternalStationIterator sIt = fStations.begin();
39  sIt != fStations.end(); ++sIt)
40  delete *sIt;
41 }
42 
43 
44 CEvent&
45 CEvent::operator=(const CEvent& cEvent)
46 {
47  if (this != &cEvent) {
48 
49  for (InternalStationIterator sIt = fStations.begin();
50  sIt != fStations.end(); ++sIt)
51  delete *sIt;
52 
53  fStations.clear();
54 
55  for (ConstStationIterator sIt = cEvent.StationsBegin();
56  sIt != cEvent.StationsEnd(); ++sIt)
57  fStations.push_back(new Station(*sIt));
58 
59 // fTrigger = cEvent.fTrigger;
60 // fHeader = cEvent.fHeader;
61  }
62 
63  return *this;
64 }
65 
66 
67 Station&
68 CEvent::GetStation(const int id)
69 {
70  const StationIterator sEnd = StationsEnd();
71  for (StationIterator sIt = StationsBegin(); sIt != sEnd; ++sIt)
72  if (sIt->GetId() == id)
73  return *sIt;
74 
75  ostringstream error;
76  error << "Station " << id << " not present";
77  ERROR(error);
78  throw utl::NonExistentComponentException(error.str());
79 }
80 
81 
82 const Station&
83 CEvent::GetStation(const int id)
84  const
85 {
86  const ConstStationIterator sEnd = StationsEnd();
87  for (ConstStationIterator sIt = StationsBegin(); sIt != sEnd; ++sIt)
88  if (sIt->GetId() == id)
89  return *sIt;
90 
91  ostringstream error;
92  error << "Station " << id << " not present";
93  ERROR(error);
94  throw utl::NonExistentComponentException(error.str());
95 }
96 
97 
98 void
99 CEvent::MakeStation(const int id)
100 {
101  if (HasStation(id)) {
102 
103  ostringstream error;
104  error << "Station " << id << " already present";
105  WARNING(error);
106  return;
107 
108  }
109 
110  fStations.push_back(new Station(id));
111 }
112 
113 
114 bool
115 CEvent::HasStation(const int id)
116  const
117 {
118  const ConstStationIterator sEnd = StationsEnd();
119  for (ConstStationIterator sIt = StationsBegin(); sIt != sEnd; ++sIt)
120  if (sIt->GetId() == id)
121  return true;
122 
123  return false;
124 }
125 
126 
128 CEvent::RemoveStation(const StationIterator it)
129 {
130  delete *it.base();
131  return CEvent::StationIterator(fStations.erase(it.base()));
132 }
133 
134 
135 // CBT - Not used for now
136 // void
137 // CEvent::MakeTrigger()
138 // {
139 // if (fTrigger) {
140 // ERROR("Trigger Object already present - Not replacing");
141 // }
142 // else
143 // fTrigger = new EventTrigger;
144 // }
145 
146 // CBT - Not used for now
147 // void
148 // CEvent::SetQualityCuts(const SQualityCuts& cuts)
149 // {
150 // fQualityCuts = new SQualityCuts(cuts);
151 
152 // ostringstream stationInfo;
153 // ostringstream pmtInfo;
154 // const SQualityCuts::StationMasks& c = fQualityCuts->GetStationMasks();
155 // for (SQualityCuts::StationMasks::const_iterator cIt = c.begin();
156 // cIt != c.end(); ++cIt) {
157 // const int stationId = cIt->first;
158 // if (HasStation(stationId)) {
159 // Station& station = GetStation(stationId);
160 // pmtInfo.str("");
161 // const SQualityCuts::Mask& mask = cIt->second;
162 // for (Station::PadIterator pmtIt = station.PadsBegin();
163 // pmtIt != station.PadsEnd(); ++pmtIt) {
164 // if (pmtIt->HasCalibData()) {
165 // PadCalibData& calib = pmtIt->GetCalibData();
166 // const int pmtId = pmtIt->GetId();
167 // if (mask.CutPad(pmtId)) {
168 // calib.SetIsTubeOk(false);
169 // pmtInfo << " Pad" << pmtId;
170 // } else if (mask.CutLowGain(pmtId)) {
171 // calib.SetIsLowGainOk(false);
172 // pmtInfo << " LG" << pmtId;
173 // }
174 // }
175 // }
176 // const string pmts = pmtInfo.str();
177 // if (!pmts.empty())
178 // stationInfo << boost::format("\n %|1$05|: %2%") % stationId % pmts;
179 // }
180 // }
181 // const string stations = stationInfo.str();
182 // if (!stations.empty()) {
183 // ostringstream info;
184 // info << " Tagged stations:" << stations;
185 // INFO(info);
186 // }
187 // }
188 
189 
190 void
191 CEvent::MakeSimData()
192 {
193  if (fSimData) {
194  ERROR("SimData already exists - Not Replacing");
195  }
196  else
197  fSimData = new CEventSimData;
198 }
199 
200 
201 
202 // Configure (x)emacs for this file ...
203 // Local Variables:
204 // mode: c++
205 // compile-command: "make -C .. CEvent/CEvent.o"
206 // End:
InternalStationCollection::iterator InternalStationIterator
Definition: CEvent.h:50
#define LAMESHADOWPTR_INST(_T_...)
StationIterator StationsEnd()
End of all stations.
Definition: CEvent.h:67
Base class for exceptions trying to access non-existing components.
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
class to hold data at Station level
StationIterator StationsBegin()
Beginning of all stations.
Definition: CEvent.h:64
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
Definition: CEvent.h:61
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
Definition: CEvent.h:59
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
Interface class to hold simulated data belonging to surface events.
Definition: CEventSimData.h:22
Interface class to access to the SD part of an event.
Definition: CEvent.h:46

, generated on Tue Sep 26 2023.