SEvent/Station.cc
Go to the documentation of this file.
1 #include <sevt/Station.h>
2 #include <sevt/SEvent.h>
3 #include <sevt/Scintillator.h>
4 #include <sevt/PMT.h>
5 #include <sevt/StationTriggerData.h>
6 #include <sevt/StationSimData.h>
7 #include <sevt/StationRecData.h>
8 #include <sevt/StationCalibData.h>
9 #include <sevt/StationGPSData.h>
10 #include <sevt/StationConstants.h>
11 #include <sevt/ScintillatorSimData.h>
12 #include <det/Detector.h>
13 #include <sdet/SDetector.h>
14 #include <sdet/Station.h>
15 #include <sdet/PMTConstants.h>
16 #include <sdet/Scintillator.h>
17 #include <utl/Particle.h>
18 #include <utl/ErrorLogger.h>
19 #include <utl/AugerException.h>
20 
21 #include <cstddef>
22 #include <iostream>
23 #include <algorithm>
24 
25 using namespace std;
26 using namespace utl;
27 using namespace det;
28 
29 
30 namespace sevt {
31 
32  Station::Station(const int id) :
33  fId(id)
34  {
35  /* PMTs are generated based on the PMTs which exist in SDetector Station at
36  the present time. */
37  const auto& dStation = Detector::GetInstance().GetSDetector().GetStation(id);
38 
39  for (const auto& pmt : dStation.PMTsRange())
40  fPMTs.push_back(new PMT(pmt.GetId(), id, pmt.GetType()));
41 
42  if (dStation.HasScintillator())
44 
45  if (dStation.HasSmallPMT())
47  }
48 
49 
51  {
52  for (const auto p : fPMTs)
53  delete p;
54  }
55 
56 
57  Station&
58  Station::operator=(const Station& station)
59  {
60  if (this == &station)
61  return *this;
62 
63  fId = station.fId;
64 
65  for (const auto p : fPMTs)
66  delete p;
67  fPMTs.clear();
68  for (const auto p : station.fPMTs)
69  fPMTs.push_back(new PMT(*p));
70 
71  fSimData = station.fSimData;
72  fRecData = station.fRecData;
73  fCalibData = station.fCalibData;
74  fTriggerData = station.fTriggerData;
75  fGPSData = station.fGPSData;
77  fTrace = station.fTrace;
79  copy(begin(station.fSaturation), end(station.fSaturation), begin(fSaturation));
81  fT2Life = station.fT2Life;
82  fSignals = station.fSignals;
83  fScintillator = station.fScintillator;
84  fSmallPMTData = station.fSmallPMTData;
85 
86  return *this;
87  }
88 
89 
90  bool
91  Station::HasPMT(const unsigned int pmtId)
92  const
93  {
94  for (const auto p : fPMTs)
95  if (p->GetId() == pmtId)
96  return true;
97  return false;
98  }
99 
100 
101  void
102  Station::MakePMT(const unsigned int pmtId, const int stationId, const sdet::PMTConstants::PMTType type)
103  {
104  if (HasPMT(pmtId)) {
105  std::ostringstream err;
106  err << "PMT with id " << pmtId << "already exists!";
107  ERROR(err);
108  throw utl::InvalidConfigurationException(err.str());
109  }
110  fPMTs.push_back(new PMT(pmtId, stationId, type));
111  }
112 
113 
114  const PMT&
115  Station::GetPMT(const unsigned int pmtId)
116  const
117  {
118  for (const auto p : fPMTs)
119  if (p->GetId() == pmtId)
120  return *p;
121  std::ostringstream err;
122  err << "Invalid PMT id " << pmtId;
123  ERROR(err);
124  throw utl::NonExistentComponentException(err.str());
125  }
126 
127 
128  const PMT&
130  const
131  {
132  // Check to ensure that there is only one PMT of the given type
134  std::ostringstream err;
135  err << "The station appears to contain more than one scintillator PMT"
136  "which is neither expected nor allowed.";
137  ERROR(err);
138  throw utl::DoesNotComputeException(err.str());
139  }
140  // Find and return PMT of requested type
141  for (const auto p : fPMTs)
142  if (p->GetType() == sdet::PMTConstants::eScintillator)
143  return *p;
144  std::ostringstream err;
145  err << "Scintillator PMT does not exist.";
146  ERROR(err);
147  throw utl::NonExistentComponentException(err.str());
148  }
149 
150 
151  const PMT&
153  const
154  {
155  // Check to ensure that there is only one PMT of the given type
157  std::ostringstream err;
158  err << "The station appears to contain more than one small PMT"
159  "which is neither expected nor allowed.";
160  ERROR(err);
161  throw utl::DoesNotComputeException(err.str());
162  }
163  // Find and return PMT of requested type
164  for (const auto p : fPMTs)
166  return *p;
167  std::ostringstream err;
168  err << "Small PMT does not exist.";
169  ERROR(err);
170  throw utl::NonExistentComponentException(err.str());
171  }
172 
173 
174  unsigned int
176  const
177  {
178  if (type == sdet::PMTConstants::eAnyType)
179  return fPMTs.size();
180 
181  unsigned int n = 0;
182  for (const auto p : fPMTs)
183  if (p->GetType() == type)
184  ++n;
185  return n;
186  }
187 
188 
189  void
191  {
192  if (fSimData)
193  ERROR("SimData already exists - Not Replacing");
194  else
195  fSimData = new StationSimData;
196  }
197 
198 
199  void
201  {
202  if (fRecData)
203  ERROR("Rec Data already exists - Not Replacing");
204  else
205  fRecData = new StationRecData;
206  }
207 
208 
209  void
211  {
212  if (fTriggerData)
213  ERROR("Trigger Data already exists - Not Replacing");
214  else
216  }
217 
218 
219  void
221  {
222  if (fCalibData)
223  ERROR("Calib Data already exists - Not Replacing");
224  else
226  }
227 
228 
229  void
231  {
232  if (fGPSData)
233  ERROR("GPS Data already exists - Not Replacing");
234  else
235  fGPSData = new StationGPSData;
236  }
237 
238 
239  void
241  {
243  throw utl::DoesNotComputeException("Trying to change the status of the station from non-candidate to candidate!");
244  }
245 
246 
247  void
248  Station::SetRejected(const int reason)
249  {
250  /*
251  * fRejectionStatus is already set to 0 (eNoRejection) by default
252  * in Station constructor. Attempts to manually set it to 0
253  * are likely misguided.
254  */
255  if (reason == StationConstants::eNoRejection) {
256  std::ostringstream err;
257  err << "Attempting to set station as rejected with status of "
258  << "not rejected (fRejectionStatus = " << reason << ").";
259  throw utl::DoesNotComputeException(err.str());
260  }
262  fRejectionStatus |= reason;
263  }
264 
265 
266 
267  void
269  {
271  throw utl::DoesNotComputeException("Trying to change the status of the station from rejected to silent!");
273  }
274 
275 
276  void
278  {
279  const auto& dStation = Detector::GetInstance().GetSDetector().GetStation(*this);
280  fTrace.AddTrace(dStation.GetFADCTraceLength(), dStation.GetFADCBinSize(), source);
281  }
282 
283 
284  bool
286  const
287  {
288  return Detector::GetInstance().GetSDetector().GetStation(*this).IsUUB();
289  }
290 
291 
292  void
294  {
295  if (!HasSimData())
296  MakeSimData();
297  fSimData->AddParticle(particle);
298 
299  if (fScintillator && !fScintillator->HasSimData())
300  fScintillator->MakeSimData();
301 
302  /*
303  * Although particle is always added to StationSimData,
304  * it is only added to the Station (that is, WCD) particle
305  * counters (muons, electrons, etc.) if it's injection
306  * trajectory intersects the WCD. It is only added to the
307  * Scintillator particle counters if it's injection trajectory
308  * intersects the Scintillator
309  */
310 
311  // It's insane to do this for every particle... but the idea
312  // of caching the sdet Station in the sevt Station also seems
313  // insane. Regardless, we need a better solution.
314  const auto& dStation = Detector::GetInstance().GetSDetector().GetStation(fId);
315  if (dStation.IsHit(particle.GetPosition(), particle.GetDirection()))
316  fSimData->CountParticle(particle);
317  if (fScintillator && dStation.GetScintillator().IsHit(particle.GetPosition(), particle.GetDirection()))
318  fScintillator->GetSimData().CountParticle(particle);
319  }
320 
321 }
utl::ShadowPtr< StationRecData > fRecData
Class to access station level reconstructed data.
bool HasPMT(const unsigned int pmtId) const
Check if a particular PMT object exists.
utl::ShadowPtr< SmallPMTData > fSmallPMTData
Station Level Simulated Data
void AddTrace(const int size, const double binSize, const int label)
Definition: MultiTrace.h:76
class to hold data at PMT level
Definition: SEvent/PMT.h:28
utl::TimeStamp fTraceStartTime
void MakeSimData()
Make station simulated data object.
Describes a particle for Simulation.
Definition: Particle.h:26
utl::ShadowPtr< StationSimData > fSimData
Base class for exceptions arising because configuration data are not valid.
void SetCandidate()
Set candidate station flag.
SignalSegmentCollection fSignals
Base class for exceptions trying to access non-existing components.
void MakeTriggerData()
Make trigger data object.
StationConstants::ReconstructionStatus fReconstructionStatus
utl::ShadowPtr< StationGPSData > fGPSData
class to hold data at Station level
bool HasSimData() const
Check whether station simulated data exists.
void SetRejected(const int reason)
Set rejected station flag.
Station Calibration data
class to hold data for station SPMT
Definition: SmallPMTData.h:18
void MakeVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal)
Make a VEM trace object.
std::vector< PMT * > fPMTs
void AddParticle(const utl::Particle &particle)
Station & operator=(const Station &station)
bool IsUUB() const
Base class for inconsistency/illogicality exceptions.
utl::MultiTraceD fTrace
void MakeRecData()
Make station reconstructed data object.
class to hold data for station Scintillator
PMT & GetPMT(const unsigned int pmtId)
Retrive a PMT by Id.
PMT & GetScintillatorPMT()
Station Trigger Data description
unsigned int GetNPMTs(const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eAnyType) const
Number of pmts.
struct particle_info particle[80]
utl::ShadowPtr< Scintillator > fScintillator
bool fSaturation[sdet::PMTConstants::eNumberOfGains]
const Point & GetPosition() const
Position of the particle.
Definition: Particle.h:110
void MakePMT(const unsigned int pmtId, const int stationId, const sdet::PMTConstants::PMTType type=sdet::PMTConstants::eWaterCherenkovLarge)
PMT & GetSmallPMT()
void MakeGPSData()
Make GPS data object.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
const Vector & GetDirection() const
Unit vector giving particle direction.
Definition: Particle.h:114
void MakeCalibData()
Make calibration data object.
utl::ShadowPtr< StationCalibData > fCalibData
utl::ShadowPtr< StationTriggerData > fTriggerData
void SetSilent()
Set silent station flag.

, generated on Tue Sep 26 2023.