testSEventImpl.cc
Go to the documentation of this file.
2 #include <fwk/CentralConfig.h>
3 #include <evt/Event.h>
4 #include <sevt/SEvent.h>
5 #include <sevt/SEventSimData.h>
6 #include <sevt/T3.h>
7 #include <sevt/Station.h>
8 #include <sevt/StationSimData.h>
9 #include <sevt/StationRecData.h>
10 #include <sevt/StationTriggerData.h>
11 #include <sevt/StationCalibData.h>
12 #include <sevt/StationGPSData.h>
13 #include <sevt/Header.h>
14 #include <sevt/PMT.h>
15 #include <sevt/PMTSimData.h>
16 #include <sevt/PMTRecData.h>
17 #include <sevt/PMTCalibData.h>
18 #include <sevt/EventTrigger.h>
19 
20 #include <sdet/SDetector.h>
21 #include <det/Detector.h>
22 
23 #include <utl/Trace.h>
24 #include <utl/TimeStamp.h>
25 #include <utl/UTCDateTime.h>
26 #include <utl/ErrorLogger.h>
27 #include <utl/Particle.h>
28 #include <iostream>
29 
30 #include <tst/Verify.h>
31 
32 #include <cppunit/extensions/HelperMacros.h>
33 
34 using namespace std;
35 using namespace utl;
36 using namespace tst;
37 using namespace sevt;
38 
39 
41 {
42  fEvent = nullptr;
43  fIsOwnerOfEvent = true;
44  fTestIO = false;
45  fNStations = 0;
46 }
47 
48 
50 {
51  if (fIsOwnerOfEvent)
52  delete fEvent;
53 }
54 
55 
56 void
58 {
59  if (!fEvent)
60  fEvent = new evt::Event;
61 
62  ErrorLogger::GetInstance().SetVerbosity(Verbosity::eVerbose);
63 
64  fEvent->MakeSEvent();
65 
66  // Set up the detector description
67  fwk::CentralConfig::GetInstance(BOOTSTRAPFILE);
68 
69  fTime = UTCDateTime(2002, 11, 10, 16, 45, 12).GetTimeStamp();
70  det::Detector::GetInstance().Update(fTime);
71  fEvent->GetHeader().SetTime(fTime);
72 
73  // Add all stations in the Detector (commissioned at current time) to the SEvent
74  SEvent& sEvent = fEvent->GetSEvent();
75  const sdet::SDetector& sDetector = det::Detector::GetInstance().GetSDetector();
76 
77  fNStations = 0;
78  for (const auto& station : sDetector.StationsRange()) {
79  sEvent.MakeStation(station.GetId());
80  ++fNStations;
81  }
82 }
83 
84 
85 void
86 testSEventImpl::setUp(evt::Event& event, const bool testIO)
87 {
88  delete fEvent;
89  fEvent = &event;
90  this->setUp();
91  fIsOwnerOfEvent = false;
92  fTestIO = testIO;
93 }
94 
95 
96 void
98 {
99  Header& header = sEvent.GetHeader();
100  header.SetId(999);
101  header.SetTime(fTime);
102 }
103 
104 
105 void
107 {
108  const Header& header = sEvent.GetHeader();
109 
110  CPPUNIT_ASSERT(Verify<Equal>(header.GetId(), 999));
111  CPPUNIT_ASSERT(Verify<Equal>(header.GetTime(), fTime));
112 }
113 
114 
115 void
117 {
118  SEvent& sEvent = fEvent->GetSEvent();
119  setHeaderValues(sEvent);
120  checkHeaderValues(sEvent);
121 }
122 
123 
124 void
126 {
127  SEvent& sEvent = fEvent->GetSEvent();
128 
129  CPPUNIT_ASSERT(!sEvent.HasSimData());
130  sEvent.MakeSimData();
131 
132  T3 t3;
133  t3.SetTime(UTCDateTime(2007, 1, 1, 3, 25, 0, 50000).GetTimeStamp());
134  t3.SetAlgorithm("dummy_1");
135  t3.AddStation(103, TimeInterval(0), TimeInterval(0));
136  t3.AddStation(104, TimeInterval(2), TimeInterval(0));
137  t3.AddStation(105, TimeInterval(2), TimeInterval(0));
138  t3.AddStation(106, TimeInterval(20), TimeInterval(0));
140 
141  sEvent.GetSimData().AddT3(t3);
142 
143  T3 t3_2;
144  t3_2.SetTime(UTCDateTime(2007, 1, 1, 3, 25, 30, 4000).GetTimeStamp());
145  t3_2.SetAlgorithm("dummy_2");
146  t3_2.AddStation(105, TimeInterval(0), TimeInterval(0));
147  t3_2.AddStation(101, TimeInterval(1), TimeInterval(0));
148  t3_2.AddStation(102, TimeInterval(3), TimeInterval(0));
149  t3_2.AddStation(108, TimeInterval(20), TimeInterval(30*microsecond));
150 
151  sEvent.GetSimData().AddT3(t3_2);
152 
154  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetTime(), UTCDateTime(2007, 1, 1, 3, 25, 0, 50000).GetTimeStamp()));
155  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetAlgorithm(), string("dummy_1")));
156  //CPPUNIT_ASSERT(t3It->HasStation(103));
157  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetWindow(103), TimeInterval(0)));
158  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetWindow(107), TimeInterval(30*microsecond)));
159  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetOffset(103), TimeInterval(0)));
160  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetOffset(106), TimeInterval(20)));
161 
162  ++t3It;
163 
164  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetTime(), UTCDateTime(2007, 1, 1, 3, 25, 30, 4000).GetTimeStamp()));
165  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetAlgorithm(),string("dummy_2")));
166  //CPPUNIT_ASSERT(t3It->HasStation(102));
167  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetWindow(105),TimeInterval(0)));
168  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetWindow(108),TimeInterval(30*microsecond)));
169  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetOffset(105),TimeInterval(0)));
170  CPPUNIT_ASSERT(Verify<Equal>(t3It->GetOffset(102),TimeInterval(3)));
171 
172  ++t3It;
174  CPPUNIT_ASSERT(t3It == end);
175 }
176 
177 
178 void
180 {
181  CPPUNIT_ASSERT(!sEvent.HasTrigger());
182  sEvent.MakeTrigger();
183 
184  EventTrigger& trig = sEvent.GetTrigger();
185 
186  trig.SetId(55);
187  trig.SetPreviousId(56);
188  trig.SetNStations(57);
189  trig.SetSender("bill gates");
190  trig.SetAlgorithm("al-gor-ithm");
191  trig.SetSDPAngle(0.2);
192  trig.SetTime(UTCDateTime(2004, 1, 1, 12, 0, 0).GetTimeStamp());
193 }
194 
195 
196 void
198 {
199  CPPUNIT_ASSERT(sEvent.HasTrigger());
200 
201  const EventTrigger& trig = sEvent.GetTrigger();
202 
203  CPPUNIT_ASSERT(Verify<Equal>(trig.GetId(), 55U));
204  CPPUNIT_ASSERT(Verify<Equal>(trig.GetPreviousId(), 56U));
205  CPPUNIT_ASSERT(Verify<Equal>(trig.GetNStations(), 57U));
206  CPPUNIT_ASSERT(Verify<Equal>(trig.GetSender(), string("bill gates") ));
207  CPPUNIT_ASSERT(Verify<Equal>(trig.GetAlgorithm(), string("al-gor-ithm") ));
208  CPPUNIT_ASSERT(Verify<CloseTo>(trig.GetSDPAngle(), 0.2));
209  CPPUNIT_ASSERT(Verify<Equal>(trig.GetTime(), UTCDateTime(2004, 1, 1, 12, 0, 0).GetTimeStamp()));
210 }
211 
212 
213 void
215 {
216  SEvent& sEvent = fEvent->GetSEvent();
217  setPMTRecDataValues(sEvent);
218  checkPMTRecDataValues(sEvent);
219 }
220 
221 
222 void
224 {
225  for (const auto& station : sEvent.StationsRange()) {
226 
227  for (const auto& pmt : station.PMTsRange()) {
228 
229  CPPUNIT_ASSERT(pmt.HasRecData());
230  const PMTRecData& recPMT = pmt.GetRecData();
231 
232  CPPUNIT_ASSERT(recPMT.HasVEMTrace(StationConstants::eTotal));
233  CPPUNIT_ASSERT(recPMT.HasVEMTrace(StationConstants::eHadron));
234 
235  const TraceD& recHadron = recPMT.GetVEMTrace(StationConstants::eHadron);
236  const TraceD& recTotal = recPMT.GetVEMTrace(StationConstants::eTotal);
237 
238  for (int i = 0; i <= 10; ++i) {
239  CPPUNIT_ASSERT(Verify<CloseTo>(recHadron[i], double(i)));
240  CPPUNIT_ASSERT(Verify<CloseTo>(recTotal[i], double(i+1)));
241  }
242 
243  // VEM trace iterators
244  int numSources = 0;
245  for (const auto& vem : recPMT.VEMTracesRange()) {
246  const TraceD& trace = vem.GetTrace();
247  for (int i = 0; i <= 10; ++i) {
248  if (vem.GetLabel() == StationConstants::eHadron)
249  CPPUNIT_ASSERT(Verify<CloseTo>(trace[i], double(i)));
250  if (vem.GetLabel() == StationConstants::eTotal)
251  CPPUNIT_ASSERT(Verify<CloseTo>(trace[i], double(i+1)));
252  }
253  ++numSources;
254  }
255  CPPUNIT_ASSERT(Verify<Equal>(numSources, 2));
256 
257  // getters and setters
258  CPPUNIT_ASSERT(Verify<CloseTo>(recPMT.GetRiseTime(), 10.));
259  CPPUNIT_ASSERT(Verify<CloseTo>(recPMT.GetRiseTimeRMS(), 1.));
260  CPPUNIT_ASSERT(Verify<CloseTo>(recPMT.GetFallTime(), 20.));
261  CPPUNIT_ASSERT(Verify<CloseTo>(recPMT.GetFallTimeRMS(), 2.));
262  CPPUNIT_ASSERT(Verify<CloseTo>(recPMT.GetAreaOverPeak(), 90.));
263  CPPUNIT_ASSERT(Verify<CloseTo>(recPMT.GetTotalCharge(), 100.));
264  CPPUNIT_ASSERT(Verify<CloseTo>(recPMT.GetPeakAmplitude(), 1.));
265  }
266 
267  }
268 }
269 
270 
271 void
273 {
274  for (auto& station : sEvent.StationsRange()) {
275 
276  for (auto& pmt : station.PMTsRange()) {
277 
278  // PMTRecData
279  CPPUNIT_ASSERT(!pmt.HasRecData());
280  pmt.MakeRecData();
281  PMTRecData& recPMT = pmt.GetRecData();
282 
283  // VEM trace
284  CPPUNIT_ASSERT(!recPMT.HasVEMTrace());
285  recPMT.MakeVEMTrace();
287 
288  TraceD& recHadron = recPMT.GetVEMTrace(StationConstants::eHadron);
289  TraceD& recTotal = recPMT.GetVEMTrace(StationConstants::eTotal);
290 
291  for (int i = 0; i <= 10; ++i) {
292  recHadron[i] = double(i);
293  recTotal[i] = double(i+1);
294  }
295 
296  // getters and setters
297  recPMT.SetRiseTime(10, 1);
298  recPMT.SetFallTime(20, 2);
299  recPMT.SetAreaOverPeak(90);
300  recPMT.SetTotalCharge(100);
301  recPMT.SetPeakAmplitude(1);
302 
303  }
304 
305  }
306 }
307 
308 
309 void
311 {
312  SEvent& sEvent = fEvent->GetSEvent();
313  setEventTriggerValues(sEvent);
314  checkEventTriggerValues(sEvent);
315 }
316 
317 
318 void
320 {
321  for (auto& station : sEvent.StationsRange()) {
322 
323  CPPUNIT_ASSERT(!station.HasTriggerData());
324  station.MakeTriggerData();
325 
326  StationTriggerData& stationTrig = station.GetTriggerData();
327 
328  stationTrig.SetAlgorithm(StationTriggerData::eT1Threshold);
329  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithm(), StationTriggerData::eT1Threshold));
330  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithmName(), string("T1 Threshold")));
331 
332  stationTrig.SetAlgorithm(StationTriggerData::eT2Threshold);
333  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithm(), StationTriggerData::eT2Threshold));
334  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithmName(), string("T2 Threshold")));
335 
336  stationTrig.SetAlgorithm(StationTriggerData::eTimeOverThreshold);
337  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithm(), StationTriggerData::eTimeOverThreshold));
338  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithmName(), string("Time Over Threshold")));
339 
341  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithm(), StationTriggerData::eMuon));
342  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithmName(), string("Muon")));
343 
345  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithm(), StationTriggerData::eSilent));
346  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithmName(), string("Silent")));
347 
349  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithm(), StationTriggerData::eRandom));
350  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithmName(), string("Random")));
351 
353  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithm(), StationTriggerData::eNone));
354  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithmName(), string("None")));
355 
356  stationTrig.SetAlgorithm(StationTriggerData::eTimeOverThreshold);
357  stationTrig.SetErrorCode(5);
358  stationTrig.SetOffsetMicroSecond(100);
359  stationTrig.SetWindowMicroSecond(101);
360 
361  }
362 }
363 
364 
365 void
367 {
368  for (const auto& station : sEvent.StationsRange()) {
369 
370  CPPUNIT_ASSERT(station.HasTriggerData());
371 
372  const StationTriggerData& stationTrig = station.GetTriggerData();
373  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetOffsetMicroSecond(), 100));
374  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetWindowMicroSecond(), 101));
375  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithm(), StationTriggerData::eTimeOverThreshold));
376  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetAlgorithmName(), string("Time Over Threshold")));
377  CPPUNIT_ASSERT(Verify<Equal>(stationTrig.GetErrorCode(), 5));
378  }
379 }
380 
381 
382 void
384 {
385  SEvent& sEvent = fEvent->GetSEvent();
386  setStationTriggerValues(sEvent);
387  checkStationTriggerValues(sEvent);
388 }
389 
390 
391 void
393 {
394  SEvent& sEvent = fEvent->GetSEvent();
395  setPMTSimDataValues(sEvent);
396  checkPMTSimDataValues(sEvent);
397 }
398 
399 
400 void
402 {
403  //const sdet::SDetector& theSDetector = det::Detector::GetInstance().GetSDetector();
404 
405  for (auto& station : sEvent.StationsRange()) {
406 
407  for (auto& pmt : station.PMTsRange()) {
408 
409  // PMTSimData
410  CPPUNIT_ASSERT(!pmt.HasSimData());
411  pmt.MakeSimData();
412  PMTSimData& simPMT = pmt.GetSimData();
413 
414  // PE time distribution
415  CPPUNIT_ASSERT(!simPMT.HasPETimeDistribution());
416  simPMT.MakePETimeDistribution();
418 
419  TimeDistributionI& simTot = simPMT.GetPETimeDistribution(); // defaults to total distribution
420  for (int i = -5; i < 5; ++i) {
421  simTot[i] = i;
422  CPPUNIT_ASSERT(Verify<Equal>(simTot[i], i));
423  }
424  CPPUNIT_ASSERT(Verify<Equal>(simTot.GetStart(), -5));
425  CPPUNIT_ASSERT(Verify<Equal>(simTot.GetStop(), 4));
426 
428  for (int i = -5; i < 5; ++i) {
429  simElectron[i] = i+2;
430  CPPUNIT_ASSERT(Verify<Equal>(simElectron[i], i+2));
431  }
432  CPPUNIT_ASSERT(Verify<Equal>(simElectron.GetStart(), -5));
433  CPPUNIT_ASSERT(Verify<Equal>(simElectron.GetStop(), 4));
434 
435  // Signal at base
436  CPPUNIT_ASSERT(!simPMT.HasBaseSignal());
437 
438  simPMT.MakeBaseSignal();
440 
441  TimeDistributionD& baseTot = simPMT.GetBaseSignal();
442  for (int i = -5; i < 5; ++i)
443  baseTot[i] = i+100;
444 
446  for (int i = -5; i < 5; ++i)
447  baseThirdBounce[i] = i+101;
448 
449  // Signal at filter
450  CPPUNIT_ASSERT(!simPMT.HasFilterSignal());
451 
452  simPMT.MakeFilterSignal();
454 
455  TimeDistributionD& filterTot = simPMT.GetFilterSignal();
456  for (int i = -5; i < 5; ++i)
457  filterTot[i] = i+200;
458 
460  for (int i = -5; i < 5; ++i)
461  filterHadron[i] = i+201;
462 
463  // FADC traces at PMTSimData level
464  CPPUNIT_ASSERT(!simPMT.HasFADCTrace(StationConstants::eDirectLight));
466  CPPUNIT_ASSERT(simPMT.HasFADCTrace(StationConstants::eDirectLight));
467 
468  TimeDistributionI& fadcTraceDL =
470 
471  for (int i = -10; i <= 10; ++i)
472  fadcTraceDL[i] = i+3;
473 
474  }
475 
476  }
477 }
478 
479 
480 void
482 {
483  for (const auto& station : sEvent.StationsRange()) {
484 
485  for (const auto& pmt : station.PMTsRange()) {
486 
487  // PMTSimData
488  CPPUNIT_ASSERT(pmt.HasSimData());
489  const PMTSimData& simPMT = pmt.GetSimData();
490 
491  // PE release time distributions
492  CPPUNIT_ASSERT(simPMT.HasPETimeDistribution());
493  CPPUNIT_ASSERT(simPMT.HasPETimeDistribution(StationConstants::eElectron));
494 
495  const TimeDistributionI& totalTd = simPMT.GetPETimeDistribution();
496  CPPUNIT_ASSERT(Verify<Equal>(totalTd.GetStart(), -5));
497  CPPUNIT_ASSERT(Verify<Equal>(totalTd.GetStop(), 4));
498  for (int i = -5; i < 5; ++i)
499  CPPUNIT_ASSERT(Verify<Equal>(totalTd[i], i));
500 
501  const TimeDistributionI& electronTd =
502  simPMT.GetPETimeDistribution(StationConstants::eElectron);
503  CPPUNIT_ASSERT(Verify<Equal>(electronTd.GetStart(), -5));
504  CPPUNIT_ASSERT(Verify<Equal>(electronTd.GetStop(), 4));
505  for (int i = -5; i < 5; ++i)
506  CPPUNIT_ASSERT(Verify<Equal>(electronTd[i], i+2));
507 
508  // Loop on TimeDistributions above and check contents for
509  // two sources created in setPMTValues
510  int numSources = 0;
511  for (const auto& pet : simPMT.PETimeDistributionsRange()) {
512 
513  const TimeDistributionI& td = pet.GetTimeDistribution();
514 
515  if (pet.GetLabel() == StationConstants::eTotal)
516  // loop on time distribution slots
517  for (int i = td.GetStart(); i <= td.GetStop(); ++i)
518  CPPUNIT_ASSERT(Verify<Equal>(td[i], i));
519  else if (pet.GetLabel() == StationConstants::eElectron)
520  // loop on time distribution slots
521  for (int i = td.GetStart(); i <= td.GetStop(); ++i)
522  CPPUNIT_ASSERT(Verify<Equal>(td[i], i+2));
523 
524  ++numSources;
525 
526  }
527 
528  CPPUNIT_ASSERT(Verify<Equal>(numSources, 2));
529 
530  // Base signal distributions
531  CPPUNIT_ASSERT(simPMT.HasBaseSignal());
532  CPPUNIT_ASSERT(simPMT.HasBaseSignal(StationConstants::eThirdBounce));
533 
534  for (int i = -5; i < 5; ++i)
535  CPPUNIT_ASSERT(Verify<Equal>(simPMT.GetBaseSignal()[i], i+100.));
536  for (int i = -5; i < 5; ++i)
537  CPPUNIT_ASSERT(Verify<Equal>(simPMT.GetBaseSignal(StationConstants::eThirdBounce)[i], i+101.));
538 
539  // Filter signal distributions
540  CPPUNIT_ASSERT(simPMT.HasFilterSignal());
541  CPPUNIT_ASSERT(simPMT.HasFilterSignal(StationConstants::eHadron));
542 
543  for (int i = -5; i < 5; ++i)
544  CPPUNIT_ASSERT(Verify<Equal>(simPMT.GetFilterSignal()[i], i+200.));
545  for (int i = -5; i < 5; ++i)
546  CPPUNIT_ASSERT(Verify<Equal>(simPMT.GetFilterSignal(StationConstants::eHadron)[i], i+201.));
547 
548  // FADC traces at PMTSimData level
549  const TimeDistributionI& fadcTraceDL = simPMT.GetFADCTrace(sdet::PMTConstants::eHighGain, StationConstants::eDirectLight);
550  CPPUNIT_ASSERT(Verify<Equal>(fadcTraceDL.GetStart(), -10));
551  CPPUNIT_ASSERT(Verify<Equal>(fadcTraceDL.GetStop(), 10));
552  for (int i = fadcTraceDL.GetStart(); i <= fadcTraceDL.GetStop(); ++i)
553  CPPUNIT_ASSERT(Verify<Equal>(simPMT.GetFADCTrace(sdet::PMTConstants::eHighGain, StationConstants::eDirectLight)[i], i+3));
554 
555  // check FADCTraceIterator
556  numSources = 0;
557  for (const auto& fadc : simPMT.FADCTracesRange(sdet::PMTConstants::eHighGain)) {
558  const TimeDistributionI& trace = fadc.GetTimeDistribution();
559  for (int i = trace.GetStart(); i <= trace.GetStop(); ++i)
560  CPPUNIT_ASSERT(Verify<Equal>(trace[i], i+3));
561  ++numSources;
562  }
563  CPPUNIT_ASSERT(Verify<Equal>(numSources, 1));
564 
565  }
566 
567  }
568 }
569 
570 
571 void
573 {
574  SEvent& sEvent = fEvent->GetSEvent();
575  setPMTValues(sEvent);
576  checkPMTValues(sEvent);
577 }
578 
579 
580 void
582 {
583  const sdet::SDetector& theSDetector = det::Detector::GetInstance().GetSDetector();
584 
585  for (SEvent::StationIterator sIt = sEvent.StationsBegin();
586  sIt != sEvent.StationsEnd(); ++sIt) {
587 
588  for (Station::PMTIterator pIt = sIt->PMTsBegin();
589  pIt != sIt->PMTsEnd(); ++pIt) {
590 
591  // PMT leaves
592  CPPUNIT_ASSERT(!pIt->HasFADCTrace(StationConstants::eTotal));
593  pIt->MakeFADCTrace(StationConstants::eMuon);
594  pIt->MakeFADCTrace(StationConstants::eTotal);
595 
596  // FADC traces at PMT level
597  TraceI& fadcTraceTotal = pIt->GetFADCTrace(sdet::PMTConstants::eLowGain, StationConstants::eTotal);
598  TraceI& fadcTraceMuon = pIt->GetFADCTrace(sdet::PMTConstants::eLowGain, StationConstants::eMuon);
599 
600  fadcTraceTotal.SetStart(0);
601  fadcTraceTotal.SetStop(theSDetector.GetStation(*sIt).GetFADCTraceLength());
602 
603  for (unsigned int i = fadcTraceTotal.GetStart(); i < fadcTraceTotal.GetStop(); ++i) {
604  fadcTraceTotal[i] = i;
605  fadcTraceMuon[i] = i+1;
606  }
607 
608  }
609 
610  }
611 }
612 
613 
614 void
616 {
617  for (const auto& station : sEvent.StationsRange()) {
618 
619  unsigned int expectedPMTId = 0;
620  for (const auto& pmt : station.PMTsRange()) {
621 
622  ++expectedPMTId;
623  CPPUNIT_ASSERT(pmt.GetId() == expectedPMTId);
624 
625  CPPUNIT_ASSERT(pmt.HasFADCTrace(StationConstants::eTotal));
626  CPPUNIT_ASSERT(pmt.HasFADCTrace(StationConstants::eMuon));
627 
628  const TraceI& fadcTraceTotal = pmt.GetFADCTrace(sdet::PMTConstants::eLowGain, StationConstants::eTotal);
629  const TraceI& fadcTraceMuon = pmt.GetFADCTrace(sdet::PMTConstants::eLowGain, StationConstants::eMuon);
630  for (int i = fadcTraceTotal.GetStart(); i < int(fadcTraceTotal.GetStop()); ++i) {
631  CPPUNIT_ASSERT(fadcTraceTotal[i] == i);
632  CPPUNIT_ASSERT(fadcTraceMuon[i] == i+1);
633  }
634 
635  // Loop on trace sources using FADC TraceIterator and check contents of the
636  // two sources
637  int numSources = 0;
638  for (const auto& fadc : pmt.FADCTracesRange(sdet::PMTConstants::eLowGain)) {
639 
640  const TraceI& trace = fadc.GetTrace();
641  for (int i = trace.GetStart(); i < int(trace.GetStop()); ++i) {
642 
643  if (fadc.GetLabel() == StationConstants::eTotal)
644  CPPUNIT_ASSERT(trace[i] == i);
645 
646  if (fadc.GetLabel() == StationConstants::eMuon)
647  CPPUNIT_ASSERT(trace[i] == i+1);
648  }
649  ++numSources;
650 
651  }
652 
653  CPPUNIT_ASSERT(numSources == 2); // we defined two sources: eTotal and eMuon
654 
655  }
656 
657  }
658 }
659 
660 
661 void
663 {
664  SEvent& sEvent = fEvent->GetSEvent();
665  setPMTCalibDataValues(sEvent);
666  checkPMTCalibDataValues(sEvent);
667 }
668 
669 
670 void
672 {
673  for (auto& station : sEvent.StationsRange()) {
674 
675  for (auto& pmt : station.PMTsRange()) {
676 
677  CPPUNIT_ASSERT(!pmt.HasCalibData());
678  pmt.MakeCalibData();
679 
680  PMTCalibData& calibPMT = pmt.GetCalibData();
681 
682  calibPMT.SetIsTubeOk(true);
683  calibPMT.SetRate(1);
684  calibPMT.SetOnlinePeak(2);
685  calibPMT.SetOnlineCharge(3);
686  calibPMT.SetBaseline(4, 0.4);
687  calibPMT.SetBaseline(5, 0.5, sdet::PMTConstants::eLowGain);
688  calibPMT.SetGainRatio(6, 0.6);
689  calibPMT.SetEvolution(2);
690  calibPMT.SetNumberTDA(3);
691  calibPMT.SetHighGainDelay(7, 0.7);
692  calibPMT.SetHighGainDelayChi2(8);
693 
694  vector<int> muonBase;
695  vector<int> muonPeak;
696  vector<int> muonCharge;
697  vector<int> muonShape;
698  for (int i = 0; i < 10; ++i) {
699  muonBase.push_back(i);
700  muonPeak.push_back(i+1);
701  muonCharge.push_back(i+2);
702  muonShape.push_back(i+3);
703  }
704  calibPMT.SetMuonBaseHisto(muonBase, 1);
705  calibPMT.SetMuonPeakHisto(muonPeak, 2);
706  calibPMT.SetMuonChargeHisto(muonCharge, 3);
707  calibPMT.SetMuonShapeHisto(muonShape);
708  }
709 
710  }
711 }
712 
713 
714 void
716 {
717  for (const auto& station : sEvent.StationsRange()) {
718 
719  for (const auto& pmt : station.PMTsRange()) {
720 
721  CPPUNIT_ASSERT(pmt.HasCalibData());
722  const PMTCalibData& calibPMT = pmt.GetCalibData();
723 
724  CPPUNIT_ASSERT(calibPMT.IsTubeOk());
725  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetRate(), 1.));
726  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetOnlinePeak(), 2.));
727  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetOnlineCharge(), 3.));
728  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetBaseline(), 4.));
729  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetBaselineRMS(), 0.4));
730  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetBaseline(sdet::PMTConstants::eLowGain), 5.));
731  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetBaselineRMS(sdet::PMTConstants::eLowGain), 0.5));
732  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetGainRatio(), 6.));
733  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetGainRatioRMS(), 0.6));
734  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetEvolution(), 2));
735  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetNumberTDA(), 3));
736  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetHighGainDelay(), 7.));
737  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetHighGainDelayRMS(), 0.7));
738  CPPUNIT_ASSERT(Verify<CloseTo>(calibPMT.GetHighGainDelayChi2(), 8.));
739 
740  for (int i = 0; i <= 9; ++i) {
741  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetMuonBaseHisto().at(i), i));
742  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetMuonPeakHisto().at(i), i+1));
743  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetMuonChargeHisto().at(i), i+2));
744  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetMuonShapeHisto().at(i), i+3));
745  }
746  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetMuonBaseHistoOffset(), 1));
747  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetMuonPeakHistoOffset(), 2));
748  CPPUNIT_ASSERT(Verify<Equal>(calibPMT.GetMuonChargeHistoOffset(), 3));
749  }
750 
751  }
752 }
753 
754 
755 void
757 {
758  for (auto& station : sEvent.StationsRange()) {
759 
760  CPPUNIT_ASSERT(!station.HasVEMTrace());
761  station.MakeVEMTrace();
762 
763  TraceD& totTrace = station.GetVEMTrace();
764  for (int i = 0; i <= 10; ++i)
765  totTrace[i] = i;
766 
767  station.SetTraceStartTime(UTCDateTime(2004,1,1, 12,0,0).GetTimeStamp());
768 
769  station.SetCandidate();
770  CPPUNIT_ASSERT(station.IsCandidate());
771  CPPUNIT_ASSERT(!station.IsSilent());
772  CPPUNIT_ASSERT(!station.IsRejected());
773 
774  station.SetSilent();
775  CPPUNIT_ASSERT(!station.IsCandidate());
776  CPPUNIT_ASSERT(station.IsSilent());
777  CPPUNIT_ASSERT(!station.IsRejected());
778 
779  CPPUNIT_ASSERT(!station.IsRejected());
780  station.SetRejected(StationConstants::eLightning);
781  CPPUNIT_ASSERT(!station.IsCandidate());
782  CPPUNIT_ASSERT(!station.IsSilent());
783  CPPUNIT_ASSERT(station.IsRejected());
784  CPPUNIT_ASSERT(station.GetRejectionStatus() == StationConstants::eLightning);
785 
786  station.SetRejected(StationConstants::eBadCompress);
787  CPPUNIT_ASSERT(!station.IsCandidate());
788  CPPUNIT_ASSERT(!station.IsSilent());
789  CPPUNIT_ASSERT(station.IsRejected());
790  CPPUNIT_ASSERT(station.GetRejectionStatus() ==
793 
794  station.SetRejected(StationConstants::eOutOfTime);
795  CPPUNIT_ASSERT(!station.IsCandidate());
796  CPPUNIT_ASSERT(!station.IsSilent());
797  CPPUNIT_ASSERT(station.IsRejected());
798  CPPUNIT_ASSERT(station.GetRejectionStatus() ==
802 
803  CPPUNIT_ASSERT(!station.IsLowGainSaturation());
804  CPPUNIT_ASSERT(!station.IsHighGainSaturation());
805 
806  station.SetLowGainSaturation();
807  CPPUNIT_ASSERT(station.IsLowGainSaturation());
808  CPPUNIT_ASSERT(!station.IsHighGainSaturation());
809 
810  station.SetHighGainSaturation();
811  CPPUNIT_ASSERT(station.IsLowGainSaturation());
812  CPPUNIT_ASSERT(station.IsHighGainSaturation());
813 
814  station.SetHighGainSaturation(false);
815  station.SetLowGainSaturation(false);
816  CPPUNIT_ASSERT(!station.IsLowGainSaturation());
817  CPPUNIT_ASSERT(!station.IsHighGainSaturation());
818 
819  station.SetHighGainSaturation();
820 
821  }
822 }
823 
824 
825 void
827 {
828  const sdet::SDetector& sDetector = det::Detector::GetInstance().GetSDetector();
829  const vector<int>& stationList = sDetector.GetFullStationList();
830 
831  for (const auto& s : sEvent.StationsRange()) {
832 
833  CPPUNIT_ASSERT(find(stationList.begin(), stationList.end(), s.GetId()) != stationList.end());
834 
835  unsigned int expectedPMTId = 0;
836  for (auto sIt = s.PMTsBegin(), sEnd = s.PMTsEnd(); sIt != sEnd; ++sIt) {
837  ++expectedPMTId;
838  CPPUNIT_ASSERT(s.HasPMT(expectedPMTId));
839  CPPUNIT_ASSERT(Verify<Equal>(s.GetPMT(expectedPMTId).GetId(), expectedPMTId));
840  }
841 
842  CPPUNIT_ASSERT(s.HasVEMTrace());
843 
844  const TraceD& totTrace = s.GetVEMTrace();
845  for (int i = 0; i <= 10; ++i)
846  CPPUNIT_ASSERT(Verify<CloseTo>(totTrace[i], double(i)));
847 
848  CPPUNIT_ASSERT(Verify<Equal>(s.GetTraceStartTime(), UTCDateTime(2004, 1, 1, 12, 0, 0).GetTimeStamp()));
849 
850  CPPUNIT_ASSERT(s.IsRejected());
851  CPPUNIT_ASSERT(s.GetRejectionStatus() & StationConstants::eOutOfTime);
852 
853  CPPUNIT_ASSERT(!s.IsLowGainSaturation());
854  CPPUNIT_ASSERT(s.IsHighGainSaturation());
855  }
856 }
857 
858 
859 void
861 {
862  SEvent& sEvent = fEvent->GetSEvent();
863  setStationValues(sEvent);
864  checkStationValues(sEvent);
865 }
866 
867 
868 void
870 {
871  SEvent& sEvent = fEvent->GetSEvent();
872  setStationSimDataValues(sEvent);
873  checkStationSimDataValues(sEvent);
874 }
875 
876 
877 void
879 {
880  SEvent& sEvent = fEvent->GetSEvent();
881  setStationGPSDataValues(sEvent);
882  checkStationGPSDataValues(sEvent);
883 }
884 
885 
886 void
888 {
889  for (auto& s : sEvent.StationsRange()) {
890 
891  CPPUNIT_ASSERT(!s.HasGPSData());
892  s.MakeGPSData();
893  StationGPSData& stationGPS = s.GetGPSData();
894 
895  stationGPS.SetSecond(1);
896  stationGPS.SetOffset(2);
897  stationGPS.SetCorrectedNanosecond(3);
898  stationGPS.SetTick(4);
899  stationGPS.SetTickFall(5);
900  stationGPS.SetCurrent100(6);
901  stationGPS.SetNext100(7);
902  stationGPS.SetCurrent40(8);
903  stationGPS.SetNext40(9);
904  stationGPS.SetPreviousST(10);
905  stationGPS.SetCurrentST(11);
906  stationGPS.SetNextST(12);
907 
908  }
909 }
910 
911 
912 void
914 {
915  for (const auto& s : sEvent.StationsRange()) {
916 
917  CPPUNIT_ASSERT(s.HasGPSData());
918  const StationGPSData& stationGPS = s.GetGPSData();
919 
920  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetSecond(), 1U));
921  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetOffset(), 2));
922  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetCorrectedNanosecond(), 3U));
923  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetTick(), 4U));
924  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetTickFall(), 5U));
925  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetCurrent100(), 6));
926  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetNext100(), 7));
927  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetCurrent40(), 8));
928  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetNext40(), 9));
929  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetPreviousST(), 10));
930  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetCurrentST(), 11));
931  CPPUNIT_ASSERT(Verify<Equal>(stationGPS.GetNextST(), 12));
932 
933  }
934 }
935 
936 
937 void
939 {
940  const sdet::SDetector& sDetector = det::Detector::GetInstance().GetSDetector();
941 
942  for (auto& s : sEvent.StationsRange()) {
943 
944  CPPUNIT_ASSERT(!s.HasSimData());
945  s.MakeSimData();
946  StationSimData& simStation = s.GetSimData();
947 
948  simStation.SetSimulatorSignature("All your base are belong to us");
949 
950  // make some particles
951  const CoordinateSystemPtr statCS = sDetector.GetStation(s.GetId()).GetLocalCoordinateSystem();
952 
953  const Particle aMuon(
954  Particle::eMuon, Particle::eShower,
955  Point(0,0,0, statCS), Vector(1,0,0, statCS), TimeInterval(1*ns),
956  1, 1*TeV
957  );
958 
959  // put 3 particles in list
960  for (int iP = 0; iP < 3; ++iP)
961  s.AddParticle(aMuon);
962 
963  simStation.SetPlaneFrontTime(UTCDateTime(2008, 1, 2, 10, 0).GetTimeStamp());
964 
965  if (s.GetId() == 46)
966  simStation.SetIsInsideMinRadius();
967 
968  // No check for ClearParticleList, because I would like to remove it
969 
970  // set a couple of local triggers
971  const TimeStamp st_1 = UTCDateTime(2008, 1, 2, 10, 0, 0, 450).GetTimeStamp();
972  const TimeStamp st_2 = UTCDateTime(2008, 1, 2, 10, 0, 0, 45000).GetTimeStamp();
973  CPPUNIT_ASSERT(!simStation.HasTriggerData(st_1));
974  CPPUNIT_ASSERT(!simStation.HasTriggerData(st_2));
975 
976  simStation.MakeTriggerAndGPSData(st_1);
977  CPPUNIT_ASSERT(simStation.HasTriggerData(st_1));
978  CPPUNIT_ASSERT(!simStation.HasTriggerData(st_2));
979 
980  simStation.MakeTriggerAndGPSData(st_2);
981  CPPUNIT_ASSERT(simStation.HasTriggerData(st_1));
982  CPPUNIT_ASSERT(simStation.HasTriggerData(st_2));
983 
984  StationGPSData& stationGPS = simStation.GetGPSData(st_1);
985 
986  stationGPS.SetSecond(1);
987  stationGPS.SetOffset(2);
988  stationGPS.SetCorrectedNanosecond(3);
989  stationGPS.SetTick(4);
990  stationGPS.SetTickFall(5);
991  stationGPS.SetCurrent100(6);
992  stationGPS.SetNext100(7);
993  stationGPS.SetCurrent40(8);
994  stationGPS.SetNext40(9);
995  stationGPS.SetPreviousST(10);
996  stationGPS.SetCurrentST(11);
997  stationGPS.SetNextST(12);
998 
999  StationGPSData& stationGPS_2 = simStation.GetGPSData(st_2);
1000 
1001  stationGPS_2.SetSecond(1);
1002  stationGPS_2.SetOffset(2);
1003  stationGPS_2.SetCorrectedNanosecond(45000);
1004  stationGPS_2.SetTick(4);
1005  stationGPS_2.SetTickFall(5);
1006  stationGPS_2.SetCurrent100(6);
1007  stationGPS_2.SetNext100(7);
1008  stationGPS_2.SetCurrent40(8);
1009  stationGPS_2.SetNext40(9);
1010  stationGPS_2.SetPreviousST(10);
1011  stationGPS_2.SetCurrentST(11);
1012  stationGPS_2.SetNextST(12);
1013 
1014  StationTriggerData& stationTrig = simStation.GetTriggerData(st_1);
1015 
1016  stationTrig.SetAlgorithm(StationTriggerData::eTimeOverThreshold);
1017  stationTrig.SetErrorCode(5);
1018  stationTrig.SetOffsetMicroSecond(100);
1019  stationTrig.SetWindowMicroSecond(0);
1020 
1021  StationTriggerData& stationTrig_2 = simStation.GetTriggerData(st_2);
1022 
1023  stationTrig_2.SetAlgorithm(StationTriggerData::eT1Threshold);
1024  stationTrig_2.SetErrorCode(5);
1025  stationTrig_2.SetOffsetMicroSecond(100);
1026  stationTrig_2.SetWindowMicroSecond(30);
1027 
1028  }
1029 }
1030 
1031 
1032 void
1034 {
1035  for (const auto& s : sEvent.StationsRange()) {
1036 
1037  CPPUNIT_ASSERT(s.HasSimData());
1038  const StationSimData& simStation = s.GetSimData();
1039 
1040  CPPUNIT_ASSERT(Verify<Equal>(
1041  simStation.GetSimulatorSignature(), string("All your base are belong to us")
1042  ));
1043 
1044  // particles are not streamed to file (maybe replace with optional streamer switch
1045  //int particleCount = 0;
1046  //for (StationSimData::ConstParticleIterator pIt = simStation.ParticlesBegin();
1047  // pIt != simStation.ParticlesEnd(); ++pIt) {
1048  // CPPUNIT_ASSERT(Verify<Equal>( pIt->GetName(), string("mu-")));
1049  // ++particleCount;
1050  //}
1051  //CPPUNIT_ASSERT(Verify<Equal>(particleCount, 3)); // we put 3 particles in the list
1052 
1053  CPPUNIT_ASSERT(Verify<Equal>(
1054  simStation.GetPlaneFrontTime(), UTCDateTime(2008, 1, 2, 10, 0, 0).GetTimeStamp()
1055  ));
1056 
1057  if (s.GetId() == 46)
1058  CPPUNIT_ASSERT(Verify<Equal>(simStation.IsInsideMinRadius(), true));
1059  else
1060  CPPUNIT_ASSERT(Verify<Equal>(simStation.IsInsideMinRadius(), false));
1061 
1062  TimeStamp st_1 = UTCDateTime(2008, 1, 2, 10, 0, 0, 450).GetTimeStamp();
1063  TimeStamp st_2 = UTCDateTime(2008, 1, 2, 10, 0, 0, 45000).GetTimeStamp();
1064  TimeStamp st_3 = UTCDateTime(2008, 1, 2, 10, 0, 0, 4500).GetTimeStamp();
1065 
1066  const int times = distance(simStation.TriggerTimesBegin(), simStation.TriggerTimesEnd());
1067  CPPUNIT_ASSERT(times == 2);
1068  CPPUNIT_ASSERT(!simStation.HasTriggerData(st_3));
1069  CPPUNIT_ASSERT(simStation.HasTriggerData(st_1));
1070  CPPUNIT_ASSERT(simStation.HasTriggerData(st_2));
1071  unsigned int s_1 = 3;
1072  unsigned int s_2 = 45000;
1073  CPPUNIT_ASSERT(Verify<Equal>(simStation.GetGPSData(st_1).GetCorrectedNanosecond(), s_1));
1074  CPPUNIT_ASSERT(Verify<Equal>(simStation.GetGPSData(st_2).GetCorrectedNanosecond(), s_2));
1075  CPPUNIT_ASSERT(Verify<Equal>(simStation.GetTriggerData(st_2).GetAlgorithm(), StationTriggerData::eT1Threshold));
1076  CPPUNIT_ASSERT(Verify<Equal>(simStation.GetTriggerData(st_1).GetAlgorithm(), StationTriggerData::eTimeOverThreshold));
1077 
1078  }
1079 }
1080 
1081 
1082 void
1084 {
1085  for (auto& s : sEvent.StationsRange()) {
1086 
1087  CPPUNIT_ASSERT(!s.HasRecData());
1088  s.MakeRecData();
1089  StationRecData& stationRec = s.GetRecData();
1090 
1091  stationRec.SetTotalSignal(1);
1092  stationRec.SetPeakAmplitude(2);
1093  stationRec.SetRiseTime(3, 0.3);
1094  stationRec.SetFallTime(4, 0.4);
1095  stationRec.SetResidual(5);
1096  stationRec.SetSignalStartSlot(6U);
1097  stationRec.SetSignalEndSlot(7U);
1098  stationRec.SetMuonComponent(8);
1099  stationRec.SetSignalStartTime(UTCDateTime(2005, 1, 1, 12, 0).GetTimeStamp());
1100 
1101  }
1102 }
1103 
1104 
1105 void
1107 {
1108  for (const auto& s : sEvent.StationsRange()) {
1109 
1110  CPPUNIT_ASSERT(s.HasRecData());
1111  const StationRecData& stationRec = s.GetRecData();
1112 
1113  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetTotalSignal(), 1.));
1114  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetPeakAmplitude(), 2.));
1115  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetRiseTime(), 3.));
1116  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetRiseTimeRMS(), 0.3));
1117  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetFallTime(), 4.));
1118  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetFallTimeRMS(), 0.4));
1119  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetResidual(), 5.));
1120  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetSignalStartSlot(), 6U));
1121  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetSignalEndSlot(), 7U));
1122  CPPUNIT_ASSERT(Verify<Equal>(stationRec.GetMuonComponent(), 8.));
1123  CPPUNIT_ASSERT(Verify<Equal>(
1124  stationRec.GetSignalStartTime(), UTCDateTime(2005, 1, 1, 12, 0).GetTimeStamp()
1125  ));
1126  }
1127 }
1128 
1129 
1130 void
1132 {
1133  SEvent& sEvent = fEvent->GetSEvent();
1134  setStationRecDataValues(sEvent);
1135  checkStationRecDataValues(sEvent);
1136 }
1137 
1138 
1139 void
1141 {
1142  for (auto& s : sEvent.StationsRange()) {
1143 
1144  CPPUNIT_ASSERT(!s.HasCalibData());
1145  s.MakeCalibData();
1146  StationCalibData& stationCalib = s.GetCalibData();
1147 
1148  stationCalib.SetVersion(1);
1149  stationCalib.SetStartSecond(2);
1150  stationCalib.SetEndSecond(3);
1151  stationCalib.SetNT1(4);
1152  stationCalib.SetNT2(5);
1153  stationCalib.SetNTot(6);
1154  stationCalib.SetNTubesOk(7);
1155 
1156  vector<int> muonChargeHisto;
1157  for (int i = 0; i <= 9; ++i)
1158  muonChargeHisto.push_back(i);
1159 
1160  stationCalib.SetMuonChargeHisto(muonChargeHisto, 13);
1161  }
1162 }
1163 
1164 
1165 void
1167 {
1168  for (const auto& s : sEvent.StationsRange()) {
1169 
1170  CPPUNIT_ASSERT(s.HasCalibData());
1171  const StationCalibData& stationCalib = s.GetCalibData();
1172 
1173  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetVersion(), 1));
1174  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetStartSecond(), 2U));
1175  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetEndSecond(), 3U));
1176  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetNT1(), 4U));
1177  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetNT2(), 5U));
1178  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetNTot(), 6U));
1179  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetNTubesOk(), 7U));
1180 
1181  vector<int> muonChargeHisto;
1182  for (int i = 0; i < 10; ++i)
1183  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetMuonChargeHisto().at(i), i));
1184  CPPUNIT_ASSERT(Verify<Equal>(stationCalib.GetMuonChargeHistoOffset(), 13));
1185 
1186  }
1187 }
1188 
1189 
1190 void
1192 {
1193  SEvent& sEvent = fEvent->GetSEvent();
1194  setStationCalibDataValues(sEvent);
1195  checkStationCalibDataValues(sEvent);
1196 }
1197 
1198 
1199 void
1201 {
1202  SEvent& sEvent = fEvent->GetSEvent();
1203 
1204  setAll(sEvent);
1205 
1206  evt::Event copyEvent(*fEvent);
1207  SEvent& copySEvent = copyEvent.GetSEvent(); // use copy ctor
1208 
1209  checkAll(copySEvent);
1210 }
1211 
1212 
1213 void
1215 {
1216  SEvent& sEvent = fEvent->GetSEvent();
1217 
1218  setAll(sEvent);
1219 
1220  evt::Event copyEvent;
1221  copyEvent = *fEvent; // use assignment
1222  SEvent& copySEvent = copyEvent.GetSEvent();
1223 
1224  checkAll(copySEvent);
1225 }
1226 
1227 
1228 void
1230 {
1231  setHeaderValues(sEvent);
1232  setEventTriggerValues(sEvent);
1233  setStationTriggerValues(sEvent);
1234  setPMTValues(sEvent);
1235  setPMTSimDataValues(sEvent);
1236  setPMTRecDataValues(sEvent);
1237  setPMTCalibDataValues(sEvent);
1238  setStationValues(sEvent);
1239  setStationSimDataValues(sEvent);
1240  setStationRecDataValues(sEvent);
1241  setStationCalibDataValues(sEvent);
1242  setStationGPSDataValues(sEvent);
1243 }
1244 
1245 
1246 void
1248 {
1249  const int nstations = sEvent.GetNumberOfStations();
1250 
1251  CPPUNIT_ASSERT(Verify<Equal>(nstations, fNStations));
1252 
1253  checkHeaderValues(sEvent);
1254  checkEventTriggerValues(sEvent);
1255  checkStationTriggerValues(sEvent);
1256  checkPMTValues(sEvent);
1257  checkPMTSimDataValues(sEvent);
1258  checkPMTRecDataValues(sEvent);
1259  checkPMTCalibDataValues(sEvent);
1260  checkStationValues(sEvent);
1261  checkStationSimDataValues(sEvent);
1262  checkStationRecDataValues(sEvent);
1263  checkStationCalibDataValues(sEvent);
1264  checkStationGPSDataValues(sEvent);
1265 }
1266 
1267 
1268 void
1270 {
1271  SEvent& sEvent = fEvent->GetSEvent();
1272  setSEventIterators(sEvent);
1273  checkSEventIterators(sEvent);
1274  // cleanup
1275  for (auto& s : sEvent.StationsRange()) {
1276  s.SetRejected(StationConstants::eLightning);
1277  CPPUNIT_ASSERT(!s.IsCandidate());
1278  CPPUNIT_ASSERT(!s.IsSilent());
1279  CPPUNIT_ASSERT(s.IsRejected());
1280  CPPUNIT_ASSERT(s.GetRejectionStatus() & StationConstants::eLightning);
1281  }
1282 }
1283 
1284 
1285 void
1287 {
1288  const int nStations = sEvent.GetNumberOfStations();
1289 
1290  CPPUNIT_ASSERT(nStations >= 7);
1291 
1292  SEvent::StationIterator sIt = sEvent.StationsBegin();
1293 
1294  for (int i = 0; i < 3; ++i, ++sIt)
1295  sIt->SetSilent();
1296 
1297  int mask = 1;
1298  for (int i = 0; i < 3; ++i, ++sIt) {
1299  sIt->SetRejected(mask);
1300  mask <<= 1;
1301  mask |= 1;
1302  }
1303 
1304  for ( ; sIt != sEvent.StationsEnd(); ++sIt)
1305  sIt->SetCandidate();
1306 }
1307 
1308 
1309 void
1311 {
1312  const int nStations = sEvent.GetNumberOfStations();
1313 
1314  CPPUNIT_ASSERT(nStations >= 7);
1315 
1316  int countAll = 0;
1317  for (const auto& s : sEvent.StationsRange()) {
1318  CPPUNIT_ASSERT(s.IsCandidate() || s.IsSilent() || s.IsRejected());
1319  ++countAll;
1320  }
1321 
1322  CPPUNIT_ASSERT(countAll == nStations);
1323 
1324  int countSilent = 0;
1325  for (const auto& s : sEvent.SilentStationsRange()) {
1326  CPPUNIT_ASSERT(s.IsSilent());
1327  ++countSilent;
1328  }
1329 
1330  CPPUNIT_ASSERT(countSilent == 3);
1331 
1332  int mask = 1;
1333  for (int i = 0; i < 3; ++i) {
1334  int countRejected = 0;
1335  for (const auto& s : sEvent.RejectedStationsRange(mask)) {
1336  CPPUNIT_ASSERT(s.GetRejectionStatus() & mask);
1337  for (int j = 0; j < 3; ++j)
1338  CPPUNIT_ASSERT(s.GetRejectionStatus() & (1 << (j+1)));
1339  }
1340 
1341  CPPUNIT_ASSERT(countRejected == (i + 1));
1342 
1343  mask <<= 1;
1344  mask |= 1;
1345  }
1346 
1347  int countCandidate = 0;
1348  for (const auto& s : sEvent.CandidateStationsRange()) {
1349  CPPUNIT_ASSERT(s.IsCandidate());
1350  ++countCandidate;
1351  }
1352 
1353  CPPUNIT_ASSERT(countCandidate == countAll - 6);
1354 }
void checkStationCalibDataValues(const sevt::SEvent &sEvent)
Class to access station level reconstructed data.
int GetStart() const
First slot with data.
void SetStop(const SizeType stop)
Set valid data stop bin.
Definition: Trace.h:151
Station Level Simulated Data
StationIterator StationsEnd()
End of all stations.
Definition: SEvent.h:59
utl::TraceD & GetVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal)
Traces calibrated in VEM Peak.
Definition: PMTRecData.h:46
void SetTotalSignal(const double signal, const double sErr=0)
Total integrated signal in VEM unit, averaged over pmts.
void SetMuonPeakHisto(const std::vector< int > &mph, const int offset)
Definition: PMTCalibData.h:105
void testStationGPSData()
void SetNTot(const unsigned int ntot)
total number of triggers recevied during calibration
void AddT3(const sevt::T3 &t3)
Add a T3.
Definition: SEventSimData.h:44
Point object.
Definition: Point.h:32
void SetAlgorithm(const std::string &algo)
Set the trigger algorithm.
Definition: T3.h:69
void SetSignalStartSlot(const unsigned int slot)
Start time of the signal in time slots from beginning of trace.
const std::vector< int > & GetFullStationList() const
Get list of ID&#39;s for all stations available in the database or configuration file.
Definition: SDetector.cc:110
void MakeVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal)
Definition: PMTRecData.h:52
void checkAll(const sevt::SEvent &sEvent)
void SetCurrentST(const int num)
int GetNumberOfStations() const
Get total number of stations in the event.
Definition: SEvent.h:124
SizeType GetStop() const
Get valid data stop bin.
Definition: Trace.h:148
void SetOnlineCharge(const double charge)
Definition: PMTCalibData.h:83
bool HasBaseSignal(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if signal at PMT base already exists (optionally for a given source)
Definition: PMTSimData.h:105
void setStationCalibDataValues(sevt::SEvent &sEvent)
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
Describes a particle for Simulation.
Definition: Particle.h:26
This class contains the basic information to build a surface event.
Definition: T3.h:36
void SetCurrent100(const int num)
void SetAreaOverPeak(const double areaOverPeak)
Definition: PMTRecData.h:201
void SetOffsetMicroSecond(const int offset)
void SetTime(const utl::TimeStamp &stamp)
Set the trigger time stamp.
Definition: T3.h:63
void checkEventTriggerValues(const sevt::SEvent &sEvent)
void SetTime(const utl::TimeStamp &time)
Definition: SEvent/Header.h:22
void SetNumberTDA(const int num)
Definition: PMTCalibData.h:95
void SetTime(const utl::TimeStamp &time)
Set time of the trigger.
void SetPeakAmplitude(const double peak)
Amplitude of signal Peak in VEM-Peak unit,averaged over pmts.
void checkPMTValues(const sevt::SEvent &sEvent)
sevt::StationGPSData & GetGPSData(const utl::TimeStamp &time)
Get simulated GPSData.
void testSEventIterators()
void SetNext40(const int num)
EventTrigger & GetTrigger()
Get the object with central trigger data, throw if n.a.
Definition: SEvent.h:148
Signal from photons that bounced thrice (includes all particle sources)
void SetFallTime(const double fallTime, const double rms)
Definition: PMTRecData.h:177
void SetTick(const unsigned int num)
Histogram class for time distributions with suppressed empty bins.
Traditional name.
Definition: Verbosity.h:17
int GetId() const
Definition: SEvent/Header.h:20
void SetMuonChargeHisto(const std::vector< int > &mch, const int offset)
Definition: PMTCalibData.h:107
void SetOnlinePeak(const double peak)
Definition: PMTCalibData.h:82
void SetCurrent40(const int num)
void SetHighGainDelayChi2(const double chi2)
Definition: PMTCalibData.h:100
void SetPreviousId(const unsigned int id)
Set Id of the FD trigger that contains data for this event.
Header file holding the SD Event Trigger class definition.
Definition: SEvent/Header.h:16
void checkStationTriggerValues(const sevt::SEvent &sEvent)
const std::string & GetAlgorithmName() const
void SetSimulatorSignature(const std::string &name)
Set name of the tank simulator module used to simulate this station.
void testStationCalibData()
void setStationTriggerValues(sevt::SEvent &sEvent)
bool HasPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if a PE release time distribution exists (optionally for a given source)
Definition: PMTSimData.h:65
bool HasSimData() const
check whether the SimData object exists
Definition: SEvent.h:143
#define U
void checkStationValues(const sevt::SEvent &sEvent)
bool HasFADCTrace(StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if FADC trace (prior to local trigger simulation) exists.
Definition: PMTSimData.h:186
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
void SetRiseTime(const double riseTime, const double rms)
Rise time and rise time RMS averaged over PMTs.
void SetNTubesOk(const unsigned int nTubesOk)
get numbers of tubes with calibration
const utl::TimeStamp & GetTime() const
Definition: SEvent/Header.h:19
void SetPeakAmplitude(const double peak)
Definition: PMTRecData.h:206
void SetMuonComponent(const double component)
Muon signal [number of muons].
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
sevt::StationTriggerData & GetTriggerData(const utl::TimeStamp &time)
Get simulated TriggerData.
void SetResidual(const double residual)
Residual of geometry fit.
void checkStationGPSDataValues(const sevt::SEvent &sEvent)
void SetGainRatio(const double da, const double rms)
Set dynode/anode and dynode/anode RMS.
Definition: PMTCalibData.h:91
constexpr double s
Definition: AugerUnits.h:163
class to hold reconstructed data at PMT level
Definition: PMTRecData.h:38
bool HasFilterSignal(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Check if the signal at front-end filter already exists (optionally for a given source) ...
Definition: PMTSimData.h:147
void MakeBaseSignal(const StationConstants::SignalComponent source=StationConstants::eTotal)
Create a TimeDistributionD representing signal at PMT base (optionally for a give source) ...
Definition: PMTSimData.cc:19
const double ns
Interface class to access the Event Trigger (T3)
void setPMTSimDataValues(sevt::SEvent &sEvent)
void MakeSimData()
Create the SimData object.
Definition: SEvent.cc:112
Online Calibration data.
Definition: PMTCalibData.h:27
void SetStart(const SizeType start)
Set valid data start bin.
Definition: Trace.h:145
void SetFallTime(const double fallTime, const double rms)
Fall time and fall time RMS averaged over PMTs.
void SetVersion(const int version)
version of the onboard calibration
void testStationTriggerData()
bool HasTrigger() const
check whether the central trigger object exists
Definition: SEvent.h:153
void SetSecond(const unsigned int sec)
Set end of traces raw time.
void MakeTrigger()
Create the central trigger object.
Definition: SEvent.cc:102
int GetStop() const
Last slot with data (1 less than First slot if no data)
Station Calibration data
a t3: algo, second, usecond and a vector of &lt;t3stat&gt;
Definition: XbT2.h:29
void SetOffset(const int os)
Set GPS offset compared to a reference.
void SetPlaneFrontTime(const utl::TimeStamp &time)
Set shower front plane arrival time.
void MakeStation(const int stationId)
make a station with specifying Id, throw if invalid stationId
Definition: SEvent.cc:65
utl::TimeDistributionD & GetFilterSignal(const StationConstants::SignalComponent source=StationConstants::eTotal)
get simulated signal after the filter, optionally for a given source.
Definition: PMTSimData.h:136
void SetMuonChargeHisto(const std::vector< int > &mch, const int offset)
histogram of the sum of muon charges
void setHeaderValues(sevt::SEvent &sEvent)
void SetId(const unsigned int id)
Set Id of the trigger.
void setEventTriggerValues(sevt::SEvent &sEvent)
SEventSimData & GetSimData()
Get the object with simulated data, throw if n.a.
Definition: SEvent.h:138
void SetNT1(const unsigned int nt1)
number of T1 received during calibration
void checkSEventIterators(const sevt::SEvent &sEvent)
void SetRate(const double rate)
Definition: PMTCalibData.h:81
void SetTotalCharge(const double totalCharge, const double chErr=0)
Definition: PMTRecData.h:203
void setStationGPSDataValues(sevt::SEvent &sEvent)
void setAll(sevt::SEvent &sEvent)
void SetSignalStartTime(const utl::TimeStamp time)
Start time of the signal.
constexpr double TeV
Definition: AugerUnits.h:188
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
Algorithm GetAlgorithm() const
void SetNStations(const unsigned int num)
Set number of stations in the trigger.
void setPMTRecDataValues(sevt::SEvent &sEvent)
void SetHighGainDelay(const double dt, const double rms)
Set dynode anode delay and delay RMS.
Definition: PMTCalibData.h:98
void SetSDPAngle(const double ang)
Set SDPAngle of the trigger.
void SetId(const int id)
Definition: SEvent/Header.h:23
std::vector< sevt::T3 >::iterator T3Iterator
Definition: SEventSimData.h:26
void SetNT2(const unsigned int nt2)
number of T2 received during calibration
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
Station Trigger Data description
void SetMuonBaseHisto(const std::vector< int > &mbh, const int offset)
Definition: PMTCalibData.h:103
void MakeTriggerAndGPSData(const utl::TimeStamp &time)
Creates the trigger data at the given time and also the GPS data to guarantee they are both created...
StationIterator StationsBegin()
Beginning of all stations.
Definition: SEvent.h:57
void testSEventSimData()
SizeType GetStart() const
Get valid data start bin.
Definition: Trace.h:142
void setPMTValues(sevt::SEvent &sEvent)
T3Iterator T3sEnd()
Iterator over the list of T3s.
Definition: SEventSimData.h:38
void checkStationRecDataValues(const sevt::SEvent &sEvent)
Class to hold simulated data at PMT level.
Definition: PMTSimData.h:40
void SetNext100(const int num)
total (shower and background)
void SetWindowMicroSecond(const int window)
void SetAlgorithm(const std::string &algo)
Set algorithm of the trigger.
Vector object.
Definition: Vector.h:30
void SetStartSecond(const unsigned int ss)
GPS second of start of calibration.
Detector description interface for SDetector-related data.
Definition: SDetector.h:42
void SetCorrectedNanosecond(const unsigned int ns)
Set corrected trigger nanosecond.
bool HasTriggerData(const utl::TimeStamp &time) const
Check whether there is trigger data at the given time.
void setSEventIterators(sevt::SEvent &sEvent)
void setStationValues(sevt::SEvent &sEvent)
sevt::Header & GetHeader()
Definition: SEvent.h:155
boost::indirect_iterator< InternalStationIterator, Station & > StationIterator
Iterator over all stations.
Definition: SEvent.h:52
unsigned int GetFADCTraceLength() const
void SetEndSecond(const unsigned int es)
GPS second of end of calibration.
void setStationSimDataValues(sevt::SEvent &sEvent)
void SetAlgorithm(const Algorithm algo)
void checkPMTSimDataValues(const sevt::SEvent &sEvent)
void SetEvolution(const int ev)
Definition: PMTCalibData.h:94
void MakeFilterSignal(const StationConstants::SignalComponent source=StationConstants::eTotal)
Create a TimeDistributionD representing signal after front-end filter (optionally for a given source)...
Definition: PMTSimData.cc:33
void setPMTCalibDataValues(sevt::SEvent &sEvent)
void checkHeaderValues(const sevt::SEvent &sEvent)
void SetRiseTime(const double riseTime, const double rms)
Definition: PMTRecData.h:172
utl::TimeDistributionI & GetPETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Simulated photoelectron time distribution.
Definition: PMTSimData.h:54
utl::TimeDistributionD & GetBaseSignal(const StationConstants::SignalComponent source=StationConstants::eTotal)
Get simulated signal at the PMT base, optionally for a given source.
Definition: PMTSimData.h:94
signal from direct light (includes all particle sources). Same as 0&#39;th bounce light ...
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: SDetector.cc:192
utl::TimeDistributionI & GetFADCTrace(const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain, const StationConstants::SignalComponent source=StationConstants::eTotal)
Get FADC trace by gain and source.
Definition: PMTSimData.h:173
void SetIsInsideMinRadius(const bool isIn=true)
Set flag indicating whether station is in the shower hole.
bool HasVEMTrace(const StationConstants::SignalComponent source=StationConstants::eTotal) const
Definition: PMTRecData.h:55
T3Iterator T3sBegin()
Iterator over the list of T3s.
Definition: SEventSimData.h:34
constexpr double microsecond
Definition: AugerUnits.h:147
void checkStationSimDataValues(const sevt::SEvent &sEvent)
void setStationRecDataValues(sevt::SEvent &sEvent)
void checkPMTCalibDataValues(const sevt::SEvent &sEvent)
sevt::SEvent & GetSEvent()
TimeStamp GetTimeStamp() const
Definition: UTCDateTime.cc:115
void SetNextST(const int num)
void AddStation(const int id, const utl::TimeInterval &offset, const utl::TimeInterval &window)
Add a station to request data, specifying offset and window size.
Definition: T3.cc:13
void SetIsTubeOk(const bool ok)
Definition: PMTCalibData.h:79
void checkPMTRecDataValues(const sevt::SEvent &sEvent)
void SetErrorCode(const int errorCode)
void SetMuonShapeHisto(const std::vector< int > &ms)
Definition: PMTCalibData.h:109
void SetPreviousST(const int num)
void MakeFADCTrace(StationConstants::SignalComponent source=StationConstants::eTotal)
Make FADC trace prior to local trigger simulation.
Definition: PMTSimData.cc:40
void SetSender(const std::string &sender)
Set sender of the trigger.
void testStationSimData()
void SetBaseline(const double base, const double rms, const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain)
Set baseline and baseline RMS for a particular channel (defaults to high gain channel) ...
Definition: PMTCalibData.h:86
void SetTickFall(const unsigned int num)
void MakePETimeDistribution(const StationConstants::SignalComponent source=StationConstants::eTotal)
Create a PE release time distribution (optionally for given source)
Definition: PMTSimData.cc:12
void SetSignalEndSlot(const unsigned int slot)
End time of the signal in time slots from beginning of trace.

, generated on Tue Sep 26 2023.