FdCalibrator.cc
Go to the documentation of this file.
1 
9 #include "FdCalibrator.h"
10 
11 #include <fwk/CentralConfig.h>
12 #include <fwk/RunController.h>
13 
14 #include <utl/config.h>
15 #include <utl/Reader.h>
16 #include <utl/ErrorLogger.h>
17 #include <utl/AugerUnits.h>
18 
19 #include <evt/Event.h>
20 
21 #include <fevt/FEvent.h>
22 #include <fevt/Eye.h>
23 #include <fevt/Header.h>
24 #include <fevt/EyeHeader.h>
25 #include <fevt/EyeTriggerData.h>
26 #include <fevt/Telescope.h>
27 #include <fevt/Channel.h>
28 #include <fevt/ChannelRecData.h>
29 #include <fevt/Pixel.h>
30 #include <fevt/PixelRecData.h>
31 #include <fevt/PixelTriggerData.h>
32 #include <fevt/TelescopeTriggerData.h>
33 #include <fevt/SLTData.h>
34 
35 #include <det/Detector.h>
36 
37 #include <fdet/Eye.h>
38 #include <fdet/Telescope.h>
39 #include <fdet/Camera.h>
40 #include <fdet/Channel.h>
41 #include <fdet/Pixel.h>
42 #include <fdet/FDetector.h>
43 
44 #include <utl/Trace.h>
45 #include <utl/TraceAlgorithm.h>
46 
47 #include <AugerEvent.h>
48 #include <EyeEvent.hh>
49 #include <EyeEventHeader.hh>
50 #include <EyeT3Data.hh>
51 #include <FadcData.hh>
52 #include <FdNumbering.hh>
53 #include <FDEventLibVersion.hh>
54 
55 #include <sstream>
56 #include <cmath>
57 #include <iomanip>
58 
59 using namespace FdCalibratorOG;
60 using namespace fevt;
61 using namespace fdet;
62 using namespace utl;
63 using namespace fwk;
64 using namespace std;
65 
66 
69 {
70  Branch topB = CentralConfig::GetInstance()->GetTopBranch("FdCalibrator");
71 
72  if (!topB) {
73  ERROR("Could not find branch FdCalibrator");
74  return eFailure;
75  }
76 
77  topB.GetChild("verbosity").GetData(fVerbosity);
78  topB.GetChild("correctUncorrectedTimes").GetData(fCorrectTimes);
79  topB.GetChild("firstMeanSlot").GetData(fFirstMeanSlot);
80  topB.GetChild("lastMeanSlot").GetData(fLastMeanSlot);
81  topB.GetChild("recoverSaturatedTraces").GetData(fRecoverSaturatedTraces);
82  topB.GetChild("calibrationCorrection").GetData(fCalibrationCorrection);
83  topB.GetChild("heatCalibrationEpochs").GetData(fHeatCaliEpochs);
84  topB.GetChild("heatCalibrationCorrection").GetData(fHeatCalibration);
85 
86  if (fCalibrationCorrection.size() != 5) {
87  ERROR( "Calibration Correction must have size of 5!");
88  return eFailure;
89  }
90 
91  // info output
92  ostringstream info;
93  info << "\n"
94  " Version: " << GetVersionInfo(VModule::eRevisionNumber) << "\n"
95  " Parameters:\n"
96  " correct times: " << fCorrectTimes << "\n"
97  " first mean slot: " << fFirstMeanSlot << "\n"
98  " last mean slot: " << fLastMeanSlot << "\n"
99  " saturation recovery is " << (fRecoverSaturatedTraces ? "on" : "off") << "\n"
100  "Calibration correction: ";
101  for (unsigned int i = 0; i < fCalibrationCorrection.size(); ++i)
102  info << fCalibrationCorrection[i] << ' ';
103  INFO(info);
104 
105  for (unsigned int i = 0; i < fCalibrationCorrection.size(); ++i) {
106 
107  if (fCalibrationCorrection[i] != 1 && (i+1) != 5) {
108  ostringstream warn;
109  warn << "Calibration correction of " << fCalibrationCorrection[i] << " "
110  "is applied to eye: " << i+1 << ". "
111  "ARE YOU SURE??";
112  WARNING(warn);
113  }
114 
115  if ((i+1) == 5 && fCalibrationCorrection[i] == 0)
116  INFO("HEAT calbration correction will be esimated using a parametrization");
117  }
118  return eSuccess;
119 }
120 
121 
124 {
125  if (!event.HasRawEvent())
126  return eContinueLoop;
127 
128  AugerEvent& rawEvent = event.GetRawEvent();
129 
130  if (rawEvent.EyesBegin() != rawEvent.EyesEnd())
131  ++RunController::GetInstance().GetRunData().GetNamedCounters()["FdCalibrator/FdEvents"];
132 
133  for (AugerEvent::EyeIterator eyeIter = rawEvent.EyesBegin();
134  eyeIter != rawEvent.EyesEnd(); ++eyeIter) {
135 
136  TEyeEvent& eyeEvent = *eyeIter;
137  const unsigned int eyeNo = eyeEvent.GetEventHeader()->GetEyeNo();
138 #if FDEVENTLIB_VERSION_CODE < ModuleVersionCode(4, 0, 0)
139  //const unsigned int eyeNo = eyeEvent.GetEventHeader()->GetEyeNo();
140  if (eyeNo > 4) {
141  ostringstream msg;
142  msg << "Trying to read data with eye ids > 4 (HEAT) using an "
143  "FDEventLib older than v4r0. Old FDEventLibs do not support "
144  "HEAT data. I will skip this eye (id=" << eyeNo << ").";
145  WARNING(msg);
146  continue;
147  }
148 #endif
149 
150  if (eyeNo == 5 && fCalibrationCorrection[eyeNo-1] == 0) {
151  const unsigned int gpsSec =
152  eyeEvent.GetEventHeader()->GetTimeStamp()->GetGPSSec();
153  fCalibrationCorrection[eyeNo-1] = GetHeatCalibrationCorrection(gpsSec);
154  }
155 
156  if (ApplyTimeCorrections(event, eyeEvent)) {
157  FillTriggerData(event, eyeEvent);
158  FillChannelRecData(event, eyeEvent);
159  FillCalibratedPixels(event, eyeEvent);
160  FillDAQInformation(event, eyeEvent);
161  }
162 
163  }
164  return eSuccess;
165 }
166 
167 
170 {
171  return eSuccess;
172 }
173 
174 
175 void
176 FdCalibrator::FillTriggerData(evt::Event& event, TEyeEvent& eyeEvent)
177 {
178  // first the eye trigger data ...
179 
180  TEyeT3Data* const t3Data = eyeEvent.GetT3Data();
181  TEyeEventHeader* const eyeHeader = eyeEvent.GetEventHeader();
182  const int eyeId = eyeEvent.GetEventHeader()->GetEyeNo();
183  FEvent& fevent = event.GetFEvent();
184  fevt::Eye& eye = fevent.GetEye(eyeId);
185 
186  if (t3Data) {
187 
188  if (!eye.HasTriggerData())
189  eye.MakeTriggerData();
190  fevt::EyeTriggerData& eyeTrig = eye.GetTriggerData();
191 
192  eyeTrig.SetT3Accepted(true);
193 
194  const TEyeEventHeader::EEventClass eventClass =
195  eyeHeader->GetEventClass();
196  const string eventClassString =
197  string(TEyeEventHeader::GetVerboseEventClass(eventClass));
198  eyeTrig.SetT3Class(eventClassString);
199 
200  try {
201 
202  const TimeStamp t3TimeStamp(int(fevent.GetHeader().GetTime().GetGPSSecond()),
203  t3Data->GetTimeAtGround());
204  eyeTrig.SetT3Time(t3TimeStamp);
205 
206  } catch (OutOfBoundException& e) {
207 
208  WARNING(e.GetMessage());
209  WARNING("T3 time at ground seems to have an invalid value. "
210  "Setting it to zero.");
211  eyeTrig.SetT3Time(0);
212 
213  }
214  eyeTrig.SetT3SDP(t3Data->GetSDPTheta(),
215  t3Data->GetSDPPhi(),
216  t3Data->GetAzimuthAtGround());
217  eyeTrig.SetT3NPixels(t3Data->GetNPixels());
218  }
219 
220  // ... then the mirror trigger data ...
221 
222  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
223  const fdet::Eye& detEye = detFD.GetEye(eyeId);
224  TEyePixelData* eyePixelData = eyeEvent.GetPixelData();
225 
226  for (fdet::Eye::TelescopeIterator telIter = detEye.TelescopesBegin();
227  telIter != detEye.TelescopesEnd(); ++telIter) {
228 
229  const unsigned int mirrorId = telIter->GetId();
230 
231  if (eyeHeader->IsMirrorDataPresent(mirrorId)) {
232 
233  if (!eye.HasTelescope(mirrorId))
234  eye.MakeTelescope(mirrorId);
235 
236  fevt::Telescope& tel = eye.GetTelescope(mirrorId);
237 
238  if (fVerbosity) {
239  ostringstream info;
240  info << "Fill trigger-info for mirror: " << mirrorId;
241  INFO(info);
242  }
243 
244  if (tel.HasTriggerData()) {
245  if (fVerbosity) {
246  ostringstream warn;
247  warn << " Mirror " << mirrorId << " has already trigger-data. Skipping.";
248  WARNING(warn);
249  }
250  continue;
251  }
252 
253  tel.MakeTriggerData();
254  fevt::TelescopeTriggerData& telTrigger = tel.GetTriggerData();
255 
256  telTrigger.SetTLTAccepted(true);
257 
258  const fdet::Camera& theCam = telIter->GetCamera();
259  const unsigned int sltNumberOfBins = (unsigned int)(theCam.GetSLTTraceLength());
260 
261  // fill telescope trigger data
262  vector<fevt::SLTData> sltData;
263  TMirrorPixelData* const miPixelData = eyePixelData->GetPixelData(mirrorId);
264 
265  for (unsigned int t2bin = 0; t2bin < sltNumberOfBins; ++t2bin) {
266  fevt::SLTData sltDataCol(20);
267  for (unsigned int col = 1; col <= 20; ++col) {
268  TMirrorPixelData::PixelDataWord word = miPixelData->GetPixelData(col, t2bin);
269  sltDataCol.SetSLTDataWord(col, PixelDataGetWord(word));
270  }
271  sltData.push_back(sltDataCol);
272  }
273  telTrigger.SetSLTData(sltData);
274 
275  // Filling of multiplicity
276  // TODO: Multiplicity is always 1000 (also for HEAT!). Possibly move to FModelConfig?
277  const unsigned int kNMultiplicityBins = 1000;
278  const double kMultiplicityBinSize = 100*ns;
279  telTrigger.MakeMultiplicity(kNMultiplicityBins, kMultiplicityBinSize);
280  TraceI& multiplicityTrace = telTrigger.GetMultiplicity();
281  TMirrorPixelData::MultiplicityDataWord multiplicityData =
282  miPixelData->GetMultiplicityData();
283 
284  ostringstream info;
285  if (fVerbosity)
286  info << "TLT multiplicity: ";
287  for (unsigned int tbin = 0; tbin < kNMultiplicityBins; ++tbin) {
288  info << multiplicityData[tbin] << ", ";
289  multiplicityTrace[tbin] = multiplicityData[tbin];
290  }
291  if (fVerbosity)
292  INFO(info);
293 
294  }
295  }
296 }
297 
298 
299 void
300 FdCalibrator::FillChannelRecData(evt::Event& event, TEyeEvent& eyeEvent)
301 {
302  TEyePixelList* const eyePixelList = eyeEvent.GetPixelList();
303  TEyeFADCData* const eyeFADCData = eyeEvent.GetFADCData();
304  const unsigned int npixels = eyePixelList->GetNumPixels();
305 
306  const int eyeId = eyeEvent.GetEventHeader()->GetEyeNo();
307  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
308  const fdet::Eye& detEye = detFD.GetEye(eyeId);
309 
310  FEvent& fdEvent = event.GetFEvent();
311  fevt::Eye& eye = fdEvent.GetEye(eyeId);
312 
313  for (unsigned int iPixel = 0; iPixel < npixels; ++iPixel) {
314 
315  if (fVerbosity) {
316  ostringstream info;
317  info << "copying trace for pixel: " << iPixel;
318  INFO(info);
319  }
320 
321  FdUtil::Fd::FdPixelNumber pixelNumber = eyePixelList->GetPixel(iPixel);
322 
323  const unsigned int mirrorId = FdUtil::Fd::GetEyeMirrorNo(pixelNumber);
324  const unsigned int mirrorChannelId = FdUtil::Fd::GetMirrorPixelNo(pixelNumber);
325 
326  if (!eye.HasTelescope(mirrorId))
327  eye.MakeTelescope(mirrorId);
328  fevt::Telescope& tel = eye.GetTelescope(mirrorId);
329 
330  // copy fadc trace
331  const TFADCData* const fadcData = eyeFADCData->GetFADCData(pixelNumber);
332 
333  // Protect yourself against the stupid non-existent traces...
334  if (!fadcData)
335  continue;
336 
337  TFADCData::FADCDataWord fadcword = fadcData->GetFADCTrace();
338 
339  const fdet::Telescope& detTel = detEye.GetTelescope(mirrorId);
340  const fdet::Camera& theCam = detTel.GetCamera();
341 
342  const double fadcBinSize = theCam.GetFADCBinSize();
343  const unsigned int fadcBinLength = (unsigned int)(theCam.GetFADCTraceLength());
344  const unsigned int fadcDynamicRange = (unsigned int)(theCam.GetADCDynamicRange());
345  const int adcOverFlow = (1 << fadcDynamicRange) - 1;
346 
347  // copy the Raw trace into an utl::Trace
348 
349  utl::TraceI rawFADCTrace(fadcBinLength, fadcBinSize);
350 
351  const unsigned int startBin = fadcData->GetTraceStartBin();
352  const unsigned int endBin = fadcData->GetTraceEndBin();
353 
354  // sanity check, MAM 09/23/04
355  if (startBin > 200)
356  continue;
357 
358  rawFADCTrace.SetStart(startBin);
359  rawFADCTrace.SetStop(endBin);
360 
361  // loop on fadc bin
362  bool isSaturated = false;
363  bool firstSatBinSet = false;
364  int firstSatBin = 0;
365  int lastSatBin = 0;
366 
367  ostringstream info;
368  info << "trace data: ";
369  for (unsigned int pos = startBin; pos <= endBin; ++pos) {
370 
371  rawFADCTrace[pos] = int(FADCDataWordGetData(&fadcword[pos]));
372 
373  if (rawFADCTrace[pos] >= adcOverFlow) {
374  isSaturated = true;
375  if (!firstSatBinSet) {
376  firstSatBinSet = true;
377  firstSatBin = pos;
378  }
379  lastSatBin = pos;
380  }
381  if (fVerbosity) {
382  info << rawFADCTrace[pos] << ", ";
383  }
384  }
385  if (fVerbosity)
386  INFO(info);
387 
388  // find baseline in first portion of trace
389  double baseline = 0;
390  try {
391  baseline = TraceAlgorithm::Mean(rawFADCTrace, fFirstMeanSlot, fLastMeanSlot);
392  } catch (utl::InvalidTraceBoundException& ex) {
393  ERROR(ex.GetMessage());
394  continue;
395  }
396 
397  if (!tel.HasChannel(mirrorChannelId))
398  tel.MakeChannel(mirrorChannelId);
399  fevt::Channel& thisChannel = tel.GetChannel(mirrorChannelId);
400 
401  if (!thisChannel.HasRecData())
402  thisChannel.MakeRecData();
403 
404  ChannelRecData& channelRecData = thisChannel.GetRecData();
405 
406  channelRecData.SetBaseLine(baseline);
407 
408  if (!channelRecData.HasFADCTrace(FdConstants::eTotal))
409  channelRecData.MakeFADCTrace(rawFADCTrace, FdConstants::eTotal);
410  else
411  WARNING("channel recdata exists! Not overwriting....");
412 
413  if (isSaturated) {
414  channelRecData.SetChannelSaturated();
415  channelRecData.SetFirstSatBin(firstSatBin);
416  channelRecData.SetLastSatBin(lastSatBin);
417  }
418  }
419 }
420 
421 
422 void
423 FdCalibrator::FillCalibratedPixels(evt::Event& event, TEyeEvent& eyeEvent)
424 {
425  TEyePixelList* const eyePixelList = eyeEvent.GetPixelList();
426  TEyeFADCData* const eyeFADCData = eyeEvent.GetFADCData();
427  TEyePixelData* const eyePixelData = eyeEvent.GetPixelData();
428  const unsigned int npixels = eyePixelList->GetNumPixels();
429 
430  const int eyeId = eyeEvent.GetEventHeader()->GetEyeNo();
431  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
432  const fdet::Eye& detEye = detFD.GetEye(eyeId);
433 
434  FEvent& fdEvent = event.GetFEvent();
435  fevt::Eye& eye = fdEvent.GetEye(eyeId);
436 
437  ostringstream info;
438  info << "Eye " << eyeId << ": nPixels=" << npixels;
439  int countSaturated = 0;
440  int countErrors = 0;
441  int countVirtuals = 0;
442  int countNoCalib = 0;
443  int countCalibrated = 0;
444 
445  for (unsigned int iPixel = 0; iPixel < npixels; ++iPixel) {
446 
447  FdUtil::Fd::FdPixelNumber pixelNumber = eyePixelList->GetPixel(iPixel);
448 
449  const unsigned int mirrorId = FdUtil::Fd::GetEyeMirrorNo(pixelNumber);
450  const unsigned int mirrorChannelId = FdUtil::Fd::GetMirrorPixelNo(pixelNumber);
451 
452  if (!eye.HasTelescope(mirrorId))
453  eye.MakeTelescope(mirrorId);
454  fevt::Telescope& tel = eye.GetTelescope(mirrorId);
455 
456  const fdet::Telescope& detTel = detEye.GetTelescope(mirrorId);
457  const fdet::Camera& detCamera = detTel.GetCamera();
458  const fdet::Channel& thisChannel = detTel.GetChannel(mirrorChannelId);
459 
460  // virtual channels must be treated differently
461  if (thisChannel.IsVirtual()) {
462  ++countVirtuals;
463  continue;
464  }
465 
466  // copy fadc trace
467 
468  const TFADCData* const fadcData = eyeFADCData->GetFADCData(pixelNumber);
469 
470  // Protect yourself against the stupid non-existent traces...
471  if (!fadcData) {
472  ++countErrors;
473  continue;
474  }
475 
476  TFADCData::FADCDataWord fadcword = fadcData->GetFADCTrace();
477 
478  const double fadcBinSize = detCamera.GetFADCBinSize();
479  const unsigned int fadcBinLength = (unsigned int)(detCamera.GetFADCTraceLength());
480  const unsigned int fadcDynamicRange = (unsigned int)(detCamera.GetADCDynamicRange());
481  const int adcOverFlow = (1 << fadcDynamicRange) - 1;
482 
483  // copy the Raw trace into an utl::Trace
484 
485  utl::TraceI rawFADCTrace(fadcBinLength, fadcBinSize);
486  utl::TraceB rawFLTtrace(fadcBinLength, fadcBinSize);
487 
488  const unsigned int startBin = fadcData->GetTraceStartBin();
489  const unsigned int endBin = fadcData->GetTraceEndBin();
490 
491  // sanity check, MAM 09/23/04
492  if (startBin > 200)
493  continue;
494 
495  rawFADCTrace.SetStart(startBin);
496  rawFADCTrace.SetStop(endBin);
497  rawFLTtrace.SetStart(startBin);
498  rawFLTtrace.SetStop(endBin);
499 
500  bool hasSaturated = false;
501 
502  // loop on fadc bin
503  for (unsigned int pos = startBin; pos <= endBin; ++pos) {
504 
505 #if FDEVENTLIB_VERSION_CODE >= ModuleVersionCode(4, 0, 5)
506  rawFLTtrace[pos] = bool(FADCDataWordGetPixelTrigger(&fadcword[pos]));
507 #else
508  rawFLTtrace[pos] = bool(FADCDataWordPixelTrigger(&fadcword[pos]));
509 #endif
510  rawFADCTrace[pos] = int(FADCDataWordGetData(&fadcword[pos]));
511 
512  if (rawFADCTrace[pos] >= adcOverFlow)
513  hasSaturated = true;
514  }
515 
516  // Correct for channel/pixel mismatch
517  const fdet::Channel& detChannel = detTel.GetChannel(mirrorChannelId);
518  unsigned int pixelId = detChannel.GetPixelId();
519  if (mirrorChannelId != pixelId) {
520  ostringstream info;
521  info << "remapped pixel during calibration: channel=" << mirrorChannelId
522  << " -> pixel=" << pixelId;
523  INFO(info);
524  }
525 
526  if (!tel.HasPixel(pixelId))
527  tel.MakePixel(pixelId);
528  fevt::Pixel& pixel = tel.GetPixel(pixelId);
529 
530  if (hasSaturated) {
531  ++countSaturated;
532  pixel.SetHighGainSaturation();
533  if (fRecoverSaturatedTraces)
534  RecoverSaturatedTrace(rawFADCTrace, pixel, tel);
535  } else
536  pixel.SetNoSaturation();
537 
538  if (!pixel.HasTriggerData())
539  pixel.MakeTriggerData();
540 
541  PixelTriggerData& triggerdata = pixel.GetTriggerData();
542 
543  triggerdata.SetThreshold(fadcData->GetActualThreshold());
544  triggerdata.SetPreviousThreshold(fadcData->GetPreviousThreshold());
545  triggerdata.SetThresholdChanged();
546  triggerdata.SetMean(fadcData->GetMean());
547  triggerdata.SetVariance(fadcData->GetVariance());
548  triggerdata.SetRate(fadcData->GetActualRate());
549 
550  triggerdata.MakeFLTTrace(rawFLTtrace);
551 
552  if (!ApplyCalibration(rawFADCTrace, pixel)) {
553  pixel.SetStatus(ComponentSelector::eBadCalibration);
554  ++countNoCalib;
555  continue;
556  }
557  ++countCalibrated;
558 
559  // RU Wed May 18 10:08:27 CEST 2005
560  // the FirstTriggeredTimeBin info was missing in event structure
561  if (pixel.HasRecData()) {
562 
563  const TMirrorPixelData* const miPixelData =
564  eyePixelData->GetPixelData(mirrorId);
565 
566  if (!miPixelData) {
567  ERROR("No TMirrorPixelData available in TEyePixelData!");
568  continue;
569  }
570 
571  // note TMirrorPixelData::GetFirstTriggeredTimeBin(FdUtil::Fd::FdPixelNumber, unsigned int, unsigned int)
572  // does currently (v4.1.2 not work correctly)
573  const int triggerpos =
574  miPixelData->GetFirstTriggeredTimeBin(FdUtil::Fd::GetColumnNo(FdUtil::Fd::GetPixelNumber(pixelNumber)),
575  FdUtil::Fd::GetRowNo(FdUtil::Fd::GetPixelNumber(pixelNumber)));
576  pixel.GetRecData().SetFirstTriggeredTimeBin(triggerpos);
577 
578  }
579  }
580  info << ", nCal=" << countCalibrated << ", nSat=" << countSaturated << ", nNoCal=" << countNoCalib
581  << ", nErr=" << countErrors << ", nVirt=" << countVirtuals;
582  INFO(info);
583 }
584 
585 
586 void
587 FdCalibrator::FillDAQInformation(evt::Event& event, TEyeEvent& eyeEvent)
588 {
589  FEvent& fevent = event.GetFEvent();
590 
591  TEyeEventHeader* const eyeHeader = eyeEvent.GetEventHeader();
592  const int eyeId = eyeHeader->GetEyeNo();
593 
594  if (!fevent.HasEye(eyeId, fevt::ComponentSelector::eInDAQ))
596  fevt::Eye& eyeDAQ = fevent.GetEye(eyeId, fevt::ComponentSelector::eInDAQ);
597 
598  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
599  const fdet::Eye& detEye = detFD.GetEye(eyeDAQ);
600 
601  for (fdet::Eye::TelescopeIterator iTel = detEye.TelescopesBegin();
602  iTel != detEye.TelescopesEnd(); ++iTel) {
603 
604  const unsigned int telId = iTel->GetId();
605 
606  if (eyeHeader->IsMirrorPresent(telId) &&
609 
610  }
611 }
612 
613 
614 bool
615 FdCalibrator::ApplyTimeCorrections(evt::Event& event, TEyeEvent& eyeEvent)
616 {
617  if (!event.HasFEvent())
618  event.MakeFEvent();
619  FEvent& fevent = event.GetFEvent();
620 
621  TEyeEventHeader* const eyeHeader = eyeEvent.GetEventHeader();
622  const int eyeId = eyeHeader->GetEyeNo();
623 
624  if (!fevent.HasEye(eyeId))
625  fevent.MakeEye(eyeId);
626 
627  // correct trigger time if real data and not already done online
628  if (eyeHeader->GetEventType() != TEyeEventHeader::kSimulated) {
629 
630 #if FDEVENTLIB_VERSION_CODE >= ModuleVersionCode(2, 6, 0)
631  TEyeEventHeader::ETimeCorrectionQuality corrQuality =
632  eyeHeader->GetTimeCorrectionQuality();
633  const bool badCorrection = (corrQuality < TEyeEventHeader::kFullQuality);
634 #else
635  Float_t t10, offset;
636  eyeHeader->GetTimeCorrectionParameters(&t10, &offset);
637  const bool badCorrection = (t10 < 50 || t10 > 150);
638 #endif
639 
640  if (badCorrection) {
641 
642  EyeHeader& headerEye = fevent.GetEye(eyeId).GetHeader();
643  headerEye.SetBadTimeCorrection(true);
644 
645  if (fCorrectTimes) {
646  CorrectFDTime(eyeHeader);
647 
648  const unsigned int sec = eyeHeader->GetTimeStamp()->GetGPSSec();
649  const unsigned int nsec = eyeHeader->GetTimeStamp()->GetNanoSec();
650 
651  const utl::TimeStamp tstamp(sec,nsec);
652  Header& headerFEvent = fevent.GetHeader();
653 
654  headerEye.SetOfflineTimeCorrected(true); // set a flag
655  headerEye.SetTimeStamp(tstamp); // set the corrected time
656  headerFEvent.SetTime(tstamp);
657  }
658  }
659  }
660 
661  // check for time-zero events (bug in split-event merging...)
662  FdRoot::TTimeStamp uninitializedTimeStamp(FdRoot::TTimeStamp::FromGPS(0, 0));
663  if (eyeHeader->GetTimeStamp()->GetUnixSec() <= uninitializedTimeStamp.GetUnixSec()) {
664 
665  ostringstream info;
666  info << "correcting GPS second=" << eyeHeader->GetTimeStamp()->GetSec()
667  << " for eye ID="
668  << eyeId;
669 
670  AdjustMirrorTimes(eyeHeader, fevent, fevent.GetEye(eyeId));
671 
672  info << " corrected GPS time: "
673  << eyeHeader->GetTimeStamp()->GetSec() << '\n';
674 
675  // check if still bad ...
676  if (eyeHeader->GetTimeStamp()->GetSec() <= uninitializedTimeStamp.GetUnixSec()) {
677  info << " ==> GPS correction failed - skipping eye!";
678  WARNING(info);
679  return false;
680  }
681  }
682 
683  // correction for the SD- FD time offset for this eye
684  // Definition: SD_FD_Offset = SD_time - FD_time
685  // ===> SD_time = FD_time + SD_FD_Offset
686  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
687 
688  const double SD_FD_Offset = detFD.GetEye(eyeId).GetSDTimeOffset().GetInterval();
689 
690  unsigned int sec = eyeHeader->GetTimeStamp()->GetGPSSec();
691  const unsigned int nsec = eyeHeader->GetTimeStamp()->GetNanoSec() + int(SD_FD_Offset);
692 
693  // correction for wrong leap second in start of 2006
694  // (note correction is from 4 Jan 2006 - 23 Jan 2006)
695  if (sec >= 820374477 && sec < 822020847)
696  ++sec;
697 
698  const utl::TimeStamp tstamp(sec, nsec);
699  EyeHeader& headerEye = fevent.GetEye(eyeId).GetHeader();
700  Header& headerFEvent = fevent.GetHeader();
701 
702  headerEye.SetTimeStamp(tstamp); // set the corrected time
703  headerFEvent.SetTime(tstamp);
704 
705  return true;
706 }
707 
708 
709 bool
711  const
712 {
713  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
714  const fdet::Pixel& detPixel = detFD.GetPixel(pixel);
715 
716  const int telId = detPixel.GetTelescopeId();
717  const int eyeId = detPixel.GetEyeId();
718  const int pixelId = detPixel.GetId();
719 
720  // Get the calibration constant for this channel
721  const int channelId = detPixel.GetChannelId();
722  const fdet::Pixel& channel =
723  detFD.GetEye(eyeId).GetTelescope(telId).GetPixel(channelId);
724 
725  const TabulatedFunction* calibration = nullptr;
726  try {
727  calibration = &channel.GetEndToEndCalibrationConstant();
729  { }
730 
731  if (!calibration || !calibration->GetNPoints()) {
732  ostringstream err;
733  err << "Could not find calibration for eye " << eyeId
734  << " tel " << telId << " pix " << pixelId;
735  ERROR(err);
736  return false;
737  }
738 
739  // check calibration status
740  if (channel.GetStatus() == fdet::Pixel::eBadCalibration) {
741  ostringstream warn;
742  warn << " bad calibration data for eye " << eyeId
743  << " tel " << telId << " pix " << pixelId << " channel " << channelId
744  << " status = " << detPixel.GetStatus();
745  WARNING(warn);
746  return false;
747  } else if (channel.GetStatus() != fdet::Pixel::eGood) {
748  ostringstream err;
749  err << " unknown calibration status for eye " << eyeId
750  << " tel " << telId << " pix " << pixelId << " channel " << channelId
751  << " status = " << detPixel.GetStatus();
752  ERROR(err);
753  throw DataNotFoundInDBException(err.str());
754  }
755 
756  const double bestCalibConst = channel.GetEndToEndCalibrationAtReferenceWavelength();
757 
758  // find baseline in first portion of trace
759  double baseline = 0;
760  try {
761  baseline = TraceAlgorithm::Mean(rawtrace, fFirstMeanSlot, fLastMeanSlot);
762  } catch (utl::InvalidTraceBoundException& ex) {
763  ERROR(ex.GetMessage());
764  return false;
765  }
766 
767  // subtract baseline
768  const TraceD baselineSubtractedTrace = (rawtrace - baseline);
769 
770  if (!pixel.HasRecData())
771  pixel.MakeRecData();
772  PixelRecData& recdata = pixel.GetRecData();
773 
774  // apply calibration constant
775  if (recdata.HasPhotonTrace()) {
776  WARNING("Pixel already calibrated ! Skipping!");
777  return true;
778  }
779 
780  recdata.MakePhotonTrace(baselineSubtractedTrace * bestCalibConst * fCalibrationCorrection[eyeId-1]);
781 
782  const TraceD& photontrace = recdata.GetPhotonTrace();
783 
784  // get rms
785  const double rms =
786  TraceAlgorithm::StandardDeviation(photontrace, fFirstMeanSlot, fLastMeanSlot);
787 
788  recdata.SetBaseline(0); // by definition
789  recdata.SetRMS(rms);
790 
791  return true;
792 }
793 
794 
795 void
796 FdCalibrator::CorrectFDTime(TEyeEventHeader* const eyeHeader)
797 {
798  const int eyeId = eyeHeader->GetEyeNo();
799  det::Detector& theDet=det::Detector::GetInstance();
800  const fdet::FDetector& detFD = theDet.GetFDetector();
801 
802  // code below is needed, if this is the first event to be processed (--> detector
803  // not yet updated)
804  const utl::TimeStamp detTime = theDet.GetTime();
805 
806  if (!detTime) {
807  const unsigned int sec = eyeHeader->GetTimeStamp()->GetGPSSec();
808  const unsigned int nsec = eyeHeader->GetTimeStamp()->GetNanoSec();
809  const utl::TimeStamp tstamp(sec, nsec);
810  theDet.Update(tstamp);
811  }
812 
813  // get average correction value for this month
814  const fdet::Eye& detEye = detFD.GetEye(eyeId);
815  const utl::TabulatedFunction& timeCorrection =
816  detEye.GetTimeCorrectionFactors();
817 
818  // there may be no values in FTelescopeList (warning printed in Eye.cc)
819  if (timeCorrection.GetNPoints() < 1)
820  return;
821 
822  int year, month, day;
823  eyeHeader->GetTimeStamp()->GetDate(kTRUE, 0, &year, &month, &day);
824  double iMonth = month + (year - 2004) * 12;
825 
826  // some out of bound checks ...
827  if (iMonth < timeCorrection.GetX(0)) {
828  INFO("Warning - request for time correction before 2004");
829  iMonth = timeCorrection.GetX(0);
830  } else if (iMonth > timeCorrection.GetX(timeCorrection.GetNPoints() - 1)) {
831  INFO("Warning - request for time correction ouside range");
832  iMonth = timeCorrection.GetX(timeCorrection.GetNPoints() - 1);
833  }
834 
835  // recalculate mirror offsets and event timestamp
836  const float t_10 = (1. - timeCorrection.Y(iMonth)) * 100.;
837  const float offset = 4.*utl::ns; // average
838 
839  cerr << " CorrectFDTime(): " << year << '/' << month << '/' << day << "\n"
840  " --> field: " << iMonth << " value: " << t_10 << "\n"
841  " before : " << eyeHeader->GetTimeStamp()->GetGPSSec()
842  << " s" << eyeHeader->GetTimeStamp()->GetNanoSec() << " ns\n";
843 
844  eyeHeader->SetTimeCorrectionParameters(t_10, offset);
845  eyeHeader->AdjustMirrorTimes();
846 
847  cerr << " after : " << eyeHeader->GetTimeStamp()->GetGPSSec()
848  << " s" << eyeHeader->GetTimeStamp()->GetNanoSec() << " ns" << endl;
849 }
850 
851 
852 // --> basically a copy of the TEyeEventHeader function
853 void
854 FdCalibrator::AdjustMirrorTimes(TEyeEventHeader* const eyeHeader,
855  fevt::FEvent& theFEvent,
856  fevt::Eye& theEye)
857 {
858  FdRoot::TTimeStamp first(time_t(INT_MAX), 0);
859  UInt_t first_mirror = 0;
860 
861  // --- find the earliest mirror
862 
863  for (UInt_t i = 0; i < FdUtil::Fd::kEYE_NMIRRORS; ++i) {
864  const UInt_t j = i + FdUtil::Fd::kEYE_FIRST_MIRROR;
865  if (eyeHeader->IsMirrorDataPresent(j)) {
866 
867  const FdRoot::TTimeStamp mirrorTimeStamp =
868  *eyeHeader->GetRawMirrorTimeStamp(j);
869 
870  cerr << "\t FdCalibrator::AdjustMirrorTimes() -- mirror "
871  << j
872  << ", raw mirror time stamp "
873  << mirrorTimeStamp << endl;
874 
875  if (mirrorTimeStamp < first) {
876  first = mirrorTimeStamp;
877  first_mirror = i;
878  }
879  }
880  }
881 
882  // --- correct the time of the first mirror
883 
884  UInt_t sec_out, nsec_out;
885 
886  eyeHeader->DoTimeCorrection(first.GetSec(), first.GetNanoSec(), &sec_out, &nsec_out);
887 
888  // TTimeStamp has internally Unix time format
889 
890  FdRoot::TTimeStamp corrected(FdRoot::TTimeStamp::FromGPS(sec_out, nsec_out));
891  eyeHeader->SetTimeStamp(corrected);
892 
893  const unsigned int sec = eyeHeader->GetTimeStamp()->GetGPSSec();
894  const unsigned int nsec = eyeHeader->GetTimeStamp()->GetNanoSec();
895 
896  utl::TimeStamp tstamp(sec, nsec);
897  theEye.GetHeader().SetTimeStamp(tstamp);
898  theEye.GetHeader().SetOfflineTimeCorrected(true);
899  fevt::Telescope& telescope = theEye.GetTelescope(first_mirror + FdUtil::Fd::kEYE_FIRST_MIRROR);
900  telescope.SetTimeOffset(0);
901 
902  theFEvent.GetHeader().SetTime(tstamp);
903 
904  // --- adjust now the offsets for all mirrors which are present
905 
906  for (UInt_t i = 0; i < FdUtil::Fd::kEYE_NMIRRORS; ++i) {
907 
908  const UInt_t j = i + FdUtil::Fd::kEYE_FIRST_MIRROR;
909 
910  if (eyeHeader->IsMirrorDataPresent(j) && i != first_mirror) {
911 
912  const FdRoot::TTimeStamp mirrorTimeStamp =
913  *eyeHeader->GetRawMirrorTimeStamp(j);
914  eyeHeader->DoTimeCorrection(mirrorTimeStamp.GetSec(),
915  mirrorTimeStamp.GetNanoSec(), &sec_out, &nsec_out);
916 
917  // now calculate offset, might be in next second
918  UInt_t mirrorTimeOffset;
919 
920  if (sec_out > UInt_t(eyeHeader->GetTimeStamp()->GetSec()))
921  mirrorTimeOffset = 1000000000 + nsec_out - eyeHeader->GetTimeStamp()->GetNanoSec();
922  else
923  mirrorTimeOffset = nsec_out - eyeHeader->GetTimeStamp()->GetNanoSec();
924  fevt::Telescope& telescope = theEye.GetTelescope(j);
925  telescope.SetTimeOffset(mirrorTimeOffset);
926 
927  }
928  }
929 }
930 
931 
932 void
934  fevt::Pixel& pixel,
935  fevt::Telescope& telEvent)
936 {
937  const unsigned int eyeId = telEvent.GetEyeId();
938  const unsigned int telId = telEvent.GetId();
939 
940  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
941  const fdet::Eye& detEye = detFD.GetEye(eyeId);
942  const fdet::Telescope& detTel = detEye.GetTelescope(telId);
943 
944  const fdet::Camera& detCamera = detTel.GetCamera();
945  const unsigned int fadcDynamicRange = (unsigned int) detCamera.GetADCDynamicRange();
946  const int adcOverFlow = (1 << fadcDynamicRange) - 1;
947 
948  const fdet::Channel& detChannel = detTel.GetChannel(pixel);
949  const unsigned int channelId = detChannel.GetId();
950  const double channelGain = detChannel.GetElectronicsGain();
951  const unsigned int virtualChannelId = detChannel.GetVirtualChannelId();
952  const double virtualChannelGain = detTel.GetChannel(virtualChannelId).GetElectronicsGain();
953 
954  ChannelRecData& channelRecData = telEvent.GetChannel(channelId).GetRecData();
955 
956  const unsigned int startBin = channelRecData.GetFirstSatBin();
957  const unsigned int endBin = channelRecData.GetLastSatBin();
958 
959  // prepare list of channel data sharing the same virtual channel
960  const ChannelRecData* vChannelRecData = nullptr;
961  vector<const ChannelRecData*> otherChannels;
962  vector<double> electronicGains;
963 
964  for (fevt::Telescope::ConstChannelIterator chanIter = telEvent.ChannelsBegin();
965  chanIter != telEvent.ChannelsEnd(); ++chanIter) {
966 
967  const unsigned int thisChannelId = chanIter->GetId();
968  if (!chanIter->HasRecData())
969  continue;
970 
971  const ChannelRecData& recData = chanIter->GetRecData();
972  const fdet::Channel& thisDetChannel = detTel.GetChannel(thisChannelId);
973 
974  if (thisDetChannel.IsVirtual()) {
975  if (thisChannelId == virtualChannelId) { // virtual channel for de-saturation
976  if (recData.ChannelIsSaturated()) {
977  const unsigned int t1 = recData.GetFirstSatBin();
978  const unsigned int t2 = recData.GetLastSatBin();
979  if ((startBin <= t1 && t1 <= endBin) ||
980  (startBin <= t2 && t2 <= endBin)) {
981  WARNING("trace recovery failed because virtual channel"
982  " is saturated!");
983  pixel.SetLowGainSaturation();
984  return;
985  }
986  }
987  vChannelRecData = &recData;
988  }
989 
990  } else if (thisChannelId != channelId) {
991 
992  const unsigned int thisVirtualChannelId =
993  detTel.GetChannel(thisChannelId).GetVirtualChannelId();
994 
995  if (thisVirtualChannelId == virtualChannelId) { // other pixels in same virtual channel
996  if (recData.ChannelIsSaturated()) {
997  const unsigned int t1 = recData.GetFirstSatBin();
998  const unsigned int t2 = recData.GetLastSatBin();
999  if ((startBin <= t1 && t1 <= endBin) ||
1000  (startBin <= t2 && t2 <= endBin)) {
1001  WARNING("more than one saturated channels in same time range!!");
1002  return;
1003  }
1004  }
1005  otherChannels.push_back(&recData);
1006  electronicGains.push_back(thisDetChannel.GetElectronicsGain());
1007  }
1008  }
1009  }
1010 
1011  if (!vChannelRecData) {
1012  ERROR("Missing virtual channel data!!");
1013  pixel.SetLowGainSaturation();
1014  return;
1015  }
1016 
1017  const TraceI& virtualTrace = vChannelRecData->GetFADCTrace(FdConstants::eTotal);
1018 
1019  // correct trace according to Eq. (1) in GAP-2006-104
1020 
1021  for (unsigned int pos = startBin; pos <= endBin; ++pos) {
1022  const int adcValue = rawFADCTrace[pos];
1023  if (adcValue >= adcOverFlow) {
1024  double otherChannelADCSum = 0;
1025  for (unsigned int i = 0; i < otherChannels.size(); ++i) {
1026  const TraceI& thisTrace = otherChannels[i]->GetFADCTrace(FdConstants::eTotal);
1027  const double adcValue = thisTrace[pos] - otherChannels[i]->GetBaseLine();
1028  otherChannelADCSum += adcValue/electronicGains[i];
1029  }
1030  const double vADCBaseLineSub = virtualTrace[pos] - vChannelRecData->GetBaseLine();
1031  const double recoveredSignal =
1032  (vADCBaseLineSub/virtualChannelGain - otherChannelADCSum) * channelGain;
1033  rawFADCTrace[pos] = int(recoveredSignal + 0.5);
1034  channelRecData.AddDeSaturatedBin(pos);
1035  }
1036  }
1037  pixel.SetSaturationRecovered();
1038 }
1039 
1040 
1041 double
1042 FdCalibrator::GetHeatCalibrationCorrection(const unsigned int gpsSecond)
1043  const
1044 {
1045  int thisBin = -1;
1046  for (unsigned int i = 0; i < fHeatCaliEpochs.size(); ++i) {
1047  if (fHeatCaliEpochs[i] > gpsSecond) {
1048  thisBin = i - 1;
1049  break;
1050  }
1051  }
1052 
1053  int lastBin = fHeatCaliEpochs.size() - 2;
1054 
1055  std::vector<double> p;
1056  if (thisBin == -1) {
1057  for (unsigned int i = 0; i < 3; ++i)
1058  p.push_back(fHeatCalibration[3*lastBin + i]);
1059  } else {
1060  for (unsigned int i = 0; i < 3; ++i)
1061  p.push_back(fHeatCalibration[3*thisBin + i]);
1062  }
1063 
1064  /*
1065  cout <<"thisBin: " << thisBin <<"\n";
1066  cout << "gpsSecond " << gpsSecond << "\n";
1067  cout << p[0] << " " << p[1] << " " << p[2] <<"\n";
1068  */
1069  unsigned int lastEpoch = fHeatCaliEpochs[lastBin+1];
1070  int x;
1071 
1072  if (thisBin > -1) // means that gpsSecond is within Epoch range
1073  x = gpsSecond - 1016048411;
1074  else // means that gpsSecond is greater than Epoch range
1075  x = lastEpoch - 1016048411;
1076 
1077  const double HEATcali =
1078  p[0] + p[1] * x + p[2] * pow(x, 2);
1079 
1080  return HEATcali;
1081 }
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
Branch GetTopBranch() const
Definition: Branch.cc:63
Status GetStatus() const
Get the pixel status flag.
double StandardDeviation(const std::vector< double > &v, const double mean)
Definition: Functions.cc:26
ChannelIterator ChannelsBegin()
void FillChannelRecData(evt::Event &event, TEyeEvent &eyeEvent)
unsigned int GetId() const
By default from 1..440.
Trigger data for an fevt::Eye.
void Update(const utl::TimeStamp &time, const bool invData=true, const bool invComp=true, const bool forceRadio=false)
Update detector: deletes currently constructed stations and sets new time.
Definition: Detector.cc:179
unsigned int GetNPoints() const
void SetStop(const SizeType stop)
Set valid data stop bin.
Definition: Trace.h:151
double GetFADCBinSize() const
void SetNoSaturation()
Definition: FEvent/Pixel.h:62
Description of trigger data for one Telescope.
Definition: SLTData.h:34
Description of the electronic channel for the 480 channels of the crate.
bool HasTriggerData() const
const utl::TabulatedFunction & GetTimeCorrectionFactors() const
bool HasRecData() const
Header & GetHeader()
Definition: FEvent.h:92
fevt::EyeHeader & GetHeader()
Header for this Eye Event.
Definition: FEvent/Eye.cc:180
unsigned int GetTelescopeId() const
1..6 for normal FD, 1..3 for HEAT
ChannelRecData & GetRecData()
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
const utl::TabulatedFunction & GetEndToEndCalibrationConstant() const
end to end calibration function
bool HasFEvent() const
const Pixel & GetPixel(const fevt::Pixel &eventPixel) const
Get fdet::Pixel from fevt::Channel.
Definition: FDetector.cc:198
void SetThreshold(const int t)
Header of Eye-level event.
Definition: EyeHeader.h:32
utl::TimeStamp GetTime() const
Get time pertaining to the detector description.
Definition: Detector.h:134
Fluorescence Detector Pixel Trigger Data.
const utl::TimeStamp & GetTime() const
Time of the event.
Definition: FEvent/Header.h:25
Class to hold collection (x,y) points and provide interpolation between them.
void SetT3Accepted(bool is)
void SetTimeOffset(const unsigned int toffset)
bool HasRecData() const
Definition: FEvent/Pixel.h:43
PixelTriggerData & GetTriggerData()
Definition: FEvent/Pixel.h:45
void SetT3SDP(double theta, double phi, double azimuthAtGround)
unsigned int GetEyeId() const
int GetLastSatBin() const
find last saturated bin for this channel
bool IsVirtual() const
ChannelIterator ChannelsEnd()
const Channel & GetChannel(const unsigned int channelId) const
Get Channel by id, throw utl::NonExistentComponentException if n.a.
double GetEndToEndCalibrationAtReferenceWavelength() const
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void MakeEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Definition: FEvent.cc:115
Base class for exceptions trying to access non-existing components.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Definition: FDetector.cc:68
Detector description interface for Eye-related data.
Definition: FDetector/Eye.h:45
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
void SetTimeStamp(const utl::TimeStamp ts)
Definition: EyeHeader.h:137
double pow(const double x, const unsigned int i)
void MakeTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Make Telescope telescopeId.
Definition: FEvent/Eye.cc:102
double GetElectronicsGain() const
void SetT3NPixels(unsigned int n)
void SetLowGainSaturation()
Definition: FEvent/Pixel.h:63
void SetRate(const double r)
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
void SetT3Time(const utl::TimeStamp &time)
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
utl::TraceI & GetFADCTrace(const FdConstants::LightSource source=FdConstants::eTotal)
Exception for reporting variable out of valid range.
const Pixel & GetPixel(const unsigned int pixelId) const
Get Pixel by id, throw utl::NonExistentComponentException if n.a.
void RecoverSaturatedTrace(utl::TraceI &rawFADCTrace, fevt::Pixel &pixel, fevt::Telescope &telEvent)
void MakePixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Make Pixel telescopeId.
bool HasPixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Check if the pixel is in the event.
Class representing a document branch.
Definition: Branch.h:107
Exception to use in case requested data not found in the database with detailed printout.
utl::TraceD & GetPhotonTrace(const FdConstants::LightSource source=FdConstants::eTotal)
Definition: PixelRecData.h:35
Channel & GetChannel(const unsigned int channelId)
void SetTime(const utl::TimeStamp &time)
Definition: FEvent/Header.h:29
void MakeMultiplicity(const unsigned int size=0, const double binSize=0)
void SetBaseLine(double baseline)
set baseline
Fluorescence Detector Pixel event.
Definition: FEvent/Pixel.h:28
unsigned int GetChannelId() const
const double ns
TelescopeIterator TelescopesBegin() const
Beginning of the collection of telescopes.
Definition: FDetector/Eye.h:79
const Telescope & GetTelescope(const unsigned int telescopeId) const
Find Telescope by numerical Id.
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
void SetStart(const SizeType start)
Set valid data start bin.
Definition: Trace.h:145
unsigned int GetId() const
Eye numerical Id.
bool HasPhotonTrace(const FdConstants::LightSource source=FdConstants::eTotal) const
Check that trace for source /par source is present.
Definition: PixelRecData.h:48
void SetLastSatBin(const int lsb)
set last saturated bin for this channel
const fdet::FDetector & GetFDetector() const
Definition: Detector.cc:131
unsigned int GetId() const
void SetBadTimeCorrection(const bool isBad)
Definition: EyeHeader.h:142
void SetT3Class(const std::string &label)
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
Fluorescence Detector Channel Event.
bool HasTriggerData() const
Definition: FEvent/Eye.h:110
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
void MakeFADCTrace(unsigned int size, double binning, const FdConstants::LightSource source=FdConstants::eTotal)
bool ApplyTimeCorrections(evt::Event &event, TEyeEvent &eyeEvent)
bool ChannelIsSaturated() const
check saturation flag for this channel
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
a second level trigger
Definition: XbT2.h:8
Eye & GetEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
return Eye by id
Definition: FEvent.cc:70
void SetFirstTriggeredTimeBin(const int bin)
returns the first triggerd time bin of trace (T1)
Definition: PixelRecData.h:100
void SetChannelSaturated()
set saturation flag for this channel
void SetMean(const double m)
void MakeChannel(const unsigned int channelId)
void MakePhotonTrace(unsigned int size, double binning, const FdConstants::LightSource source=FdConstants::eTotal)
Definition: PixelRecData.cc:29
double GetInterval() const
Get the time interval as a double (in Auger base units)
Definition: TimeInterval.h:69
double GetHeatCalibrationCorrection(const unsigned int gpsSecond) const
void SetStatus(ComponentSelector::Status status)
Definition: FEvent/Pixel.h:53
boost::filter_iterator< TelIsCommissioned, InternalConstTelescopeIterator > TelescopeIterator
An iterator over telescopes.
Definition: FDetector/Eye.h:76
void AddDeSaturatedBin(const int bin)
Add one de-saturated bin to this trace.
Pixel & GetPixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Pixel by Id, throw exception if not existent.
void MakeFLTTrace(const utl::TraceB &flt)
int GetFirstSatBin() const
find first saturated bin for this channel
void SetFirstSatBin(const int fsb)
set first saturated bin for this channel
bool HasEye(const unsigned int eyeId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Definition: FEvent.cc:57
void SetOfflineTimeCorrected(const bool isSet)
Definition: EyeHeader.h:144
const utl::TimeInterval & GetSDTimeOffset() const
Time Offset of this eye with respect to SD.
void SetPreviousThreshold(const int t)
Fluorescence Detector Channel Reconstructed Data Event.
void SetTLTAccepted(const bool is)
Detector description interface for Telescope-related data.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
bool HasChannel(const unsigned int channelId) const
void FillCalibratedPixels(evt::Event &event, TEyeEvent &eyeEvent)
unsigned long GetGPSSecond() const
GPS second.
Definition: TimeStamp.h:124
unsigned int GetId() const
void SetSLTDataWord(unsigned int col, const unsigned int sltDataWord)
Definition: SLTData.cc:102
bool ApplyCalibration(const utl::TraceI &rawtrace, fevt::Pixel &pixel) const
void SetVariance(const double v)
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
boost::indirect_iterator< InternalConstChannelIterator, const Channel & > ConstChannelIterator
An iterator over available channles for read.
Description of a pixel.
unsigned int GetVirtualChannelId() const
void SetHighGainSaturation()
Definition: FEvent/Pixel.h:64
total (shower and background)
const double & GetX(const unsigned int idx) const
Exception thrown when trying to access invalid bounds in Trace.
bool HasRawEvent() const
TelescopeIterator TelescopesEnd() const
End of the collection of telescopes.
Definition: FDetector/Eye.h:83
double GetBaseLine() const
get baseline
void SetSLTData(const std::vector< fevt::SLTData > &s)
constexpr double ns
Definition: AugerUnits.h:162
fevt::EyeTriggerData & GetTriggerData()
Trigger data for this eye.
Definition: FEvent/Eye.cc:155
void SetSaturationRecovered()
Definition: FEvent/Pixel.h:65
void MakeTriggerData()
Definition: FEvent/Pixel.cc:31
void SetRMS(const double rms)
Definition: PixelRecData.h:107
void FillDAQInformation(evt::Event &event, TEyeEvent &eyeEvent)
Fluorescence Detector Telescope Event.
double Mean(const std::vector< double > &v)
Definition: Functions.h:31
void SetBaseline(const double bl)
Definition: PixelRecData.h:106
void SetThresholdChanged(const bool changed=true)
Description of trigger data for one Telescope.
double Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
void FillTriggerData(evt::Event &event, TEyeEvent &eyeEvent)
void MakeRecData()
Definition: FEvent/Pixel.cc:21
void AdjustMirrorTimes(TEyeEventHeader *eyeheader, fevt::FEvent &theFEvent, fevt::Eye &theEye)
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasFADCTrace(const FdConstants::LightSource source) const
Check that source /par source is present.
fevt::TelescopeTriggerData & GetTriggerData()
Header for an fevt::FEvent.
Definition: FEvent/Header.h:16
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Definition: FdCalibrator.cc:68
void CorrectFDTime(TEyeEventHeader *eyeheader)
Fluorescence Detector Pixel Reconstructed Data.
Definition: PixelRecData.h:27
void MakeTriggerData()
Definition: FEvent/Eye.cc:170
constexpr double day
Definition: AugerUnits.h:151
const std::string & GetMessage() const
Retrieve the message from the exception.
unsigned int GetEyeId() const
1..5 (4x normal FD, 1x HEAT)
PixelRecData & GetRecData()
Definition: FEvent/Pixel.h:40
Description of a camera.
const double year
Definition: GalacticUnits.h:22
bool HasTriggerData() const
Definition: FEvent/Pixel.h:48
unsigned int GetPixelId() const

, generated on Tue Sep 26 2023.