FdTriggerSimulator.cc
Go to the documentation of this file.
1 
12 //#warning Needs some refurbishment to adapt to the new hardware in HEAT (read comment below)
13 /* =========================================================
14  FdTriggerSimulator needs some refurbishment to adapt to
15  the new hardware in HEAT (and AN), i.e.:
16  old | new
17  --------------------
18  FADC 1000 | 2000
19  (100ns) | (50ns)
20  FLT-Mult 1000 | 1000
21  SLT 1000 | 1000
22 ========================================================= */
23 
24 #include <iostream>
25 #include <iomanip>
26 
27 #include <utl/config.h>
28 #include <utl/Reader.h>
29 #include <utl/ErrorLogger.h>
30 #include <utl/AugerUnits.h>
31 #include <utl/MathConstants.h>
32 #include <utl/PhysicalConstants.h>
33 #include <utl/TabulatedFunction.h>
34 #include <utl/TabulatedFunctionErrors.h>
35 #include <utl/Trace.h>
36 #include <utl/MultiTabulatedFunction.h>
37 #include <utl/Point.h>
38 #include <utl/UTMPoint.h>
39 #include <utl/TimeStamp.h>
40 #include <utl/TimeInterval.h>
41 #include <utl/UTCDateTime.h>
42 #include <utl/AugerException.h>
43 
44 #include <fwk/CentralConfig.h>
45 #include <fwk/RunController.h>
46 #include <fwk/LocalCoordinateSystem.h>
47 
48 #include <det/Detector.h>
49 #include <fdet/FDetector.h>
50 #include <fdet/Eye.h>
51 #include <fdet/Camera.h>
52 #include <fdet/Channel.h>
53 #include <fdet/Pixel.h>
54 #include <fdet/Telescope.h>
55 
56 #include <evt/Event.h>
57 #include <evt/ShowerSimData.h>
58 #include <fevt/FEvent.h>
59 #include <fevt/Eye.h>
60 #include <fevt/EyeHeader.h>
61 #include <fevt/EyeTriggerData.h>
62 #include <fevt/Telescope.h>
63 #include <fevt/TelescopeSimData.h>
64 #include <fevt/TelescopeTriggerData.h>
65 #include <fevt/SLTData.h>
66 #include <fevt/PixelSimData.h>
67 #include <fevt/PixelTriggerData.h>
68 #include <fevt/Pixel.h>
69 #include <fevt/ChannelSimData.h>
70 #include <fevt/Channel.h>
71 
72 // #include <io/FDasToOfflineEventConverter.h>
73 #include <AugerEvent.h>
74 
75 //-- FD-Event-Lib
76 #include <FDEventLibVersion.hh>
77 #include <MiEvent.hh>
78 #include <MiEventHeader.hh>
79 #include <MiRun.hh>
80 #include <EyeEvent.hh>
81 
82 #include <FdNumbering.hh>
83 
84 #ifdef FDLIB_V3R3 // FDEventLib above v3r3
85 // EYE T3
86 #include <EyeEventClassifier.hh>
87 // Telescope TLT
88 #include <PrototypeTltProcessor.hh>
89 
90 #ifdef FDLIB_V3R5 // FDEventLib above v3r5
91 #include <MStcCutTlt.hh> //new multiplicity TLT
92 #endif // IF FDEventLib above v3r5
93 
94 #endif // IF FDEventLib above v3r3
95 
96 #include "SltPatternData.h"
97 #include "FdTriggerSimulator.h"
98 
99 #include <sstream>
100 
101 using namespace FdUtil;
102 using namespace FdTriggerSimulatorOG;
103 using namespace std;
104 using namespace utl;
105 using namespace evt;
106 using namespace fwk;
107 using namespace det;
108 using namespace fevt;
109 using namespace io;
110 
111 // T3 settings from Evb
113 #define EVENTCLASSIFIER_PARAMETERS_STD { \
114  "Standard parameter set", /* fName */ \
115  0.15, /* fNT3ToNT1RatioCut */ \
116  250, /* fMinMaxCut */ \
117  200, /* fSamePixelTimeCut1 */ \
118  200, /* fSamePixelTimeCut2 */ \
119  1000, /* fCloseShowerCut */ \
120  0.5, /* fSamePixelTimeRatioCut */ \
121 }
122 
123 #define EVENTCLASSIFIER_PARAMETERS_OLD { \
124  "Old parameter set", /* fName */ \
125  0, /* fNT3ToNT1RatioCut => no kLargeEvents */ \
126  200, /* fMinMaxCut */ \
127  0, /* fSamePixelTimeCut1 => no ratio calculation*/ \
128  100, /* fSamePixelTimeCut2 */ \
129  1000, /* fCloseShowerCut */ \
130  1, /* fSamePixelTimeRatioCut => no ratio cut */ \
131 }
132 
133 // settings #1 for HEAT never used
134 
136 #define EVENTCLASSIFIER_PARAMETERS_HEAT_2 { \
137  "Parameter set 2 for HEAT", /* fName */ \
138  0.15, /* fNT3ToNT1RatioCut */ \
139  125, /* fMinMaxCut */ \
140  100, /* fSamePixelTimeCut1 */ \
141  100, /* fSamePixelTimeCut2 */ \
142  1000, /* fCloseShowerCut */ \
143  0.5, /* fSamePixelTimeRatioCut */ \
144 }
145 
146 
147 FdTriggerSimulator::FdTriggerSimulator()
148 #ifdef FDLIB_V3R3
149  :
150  fT3(0),
151  fTltProcessor(0),
152  fTltLogFile(0)
153 #endif
154 { }
155 
156 
159 {
160  CentralConfig* const cc = CentralConfig::GetInstance();
161  Branch topB = cc->GetTopBranch("FdTriggerSimulator");
162 
163  topB.GetChild("verbosityLevel").GetData(fVerbosity);
164  topB.GetChild("colRO").GetData(fColRO);
165  topB.GetChild("rowRO").GetData(fRowRO);
166 
167  fStartMultiplicityTLT = UTCDateTime(2030,1,1,0,0,0,0).GetTimeStamp();
168  if (topB.GetChild("StartMultiplicityTLT"))
169  topB.GetChild("StartMultiplicityTLT").GetData(fStartMultiplicityTLT);
170 
171  fTLTPrintLevel = 0;
172  if (topB.GetChild("TltPrintLevel"))
173  topB.GetChild("TltPrintLevel").GetData(fTLTPrintLevel);
174 
175  string levelStr;
176  topB.GetChild("minimalTriggerLevel").GetData(levelStr);
177  if (levelStr=="T3") {
178  fMinRequiredTriggerLevel = eT3;
179  } else if (levelStr=="TLT") {
180  fMinRequiredTriggerLevel = eTLT;
181  } else if (levelStr=="SLT") {
182  fMinRequiredTriggerLevel = eSLT;
183  } else if (levelStr=="FLT") {
184  fMinRequiredTriggerLevel = eFLT;
185  } else if (levelStr=="all") {
186  fMinRequiredTriggerLevel = eNoTrigger;
187  } else {
188  ostringstream err;
189  err << " unkown enumeration value: \"" << levelStr <<
190  "\" used. Check your xml/xsd files!";
191  ERROR (err.str());
192  return eFailure;
193  }
194 
195  fMaxSimTriggerLevel = eT3;
196  if (!topB.GetChild("maximumSimulatedTriggerLevel")==0) {
197  string levelStr;
198  topB.GetChild("maximumSimulatedTriggerLevel").GetData(levelStr);
199  if (levelStr=="T3") {
200  fMaxSimTriggerLevel = eT3;
201  } else if (levelStr=="TLT") {
202  fMaxSimTriggerLevel = eTLT;
203  } else if (levelStr=="SLT") {
204  fMaxSimTriggerLevel = eSLT;
205  } else if (levelStr=="FLT") {
206  fMaxSimTriggerLevel = eFLT;
207  } else if (levelStr=="all") {
208  fMaxSimTriggerLevel = eNoTrigger;
209  } else {
210  ostringstream err;
211  err << " unkown enumeration value: \"" << levelStr <<
212  "\" used. Check your xml/xsd files!";
213  ERROR (err.str());
214  return eFailure;
215  }
216  }
217 
218  // check FdEventLib version
219 #ifndef FDLIB_V3R3
220  if (fMinRequiredTriggerLevel<eSLT) {
221  ERROR("Without FDEventLib >=v3r3 there is no support for FD TLT/T3 simulations! You need to upgrade! ");
222  return eFailure;
223  }
224 #endif
225 
226  // info output
227  ostringstream info;
228  info << " Version: "
229  << GetVersionInfo(VModule::eRevisionNumber) << "\n"
230  " Parameters:\n"
231  " verbosity: " << fVerbosity << "\n"
232  " add. columns readout: " << fColRO << "\n"
233  " add. rows readout: " << fRowRO << "\n"
234  "multiplicityTLT after: " << fStartMultiplicityTLT << "\n"
235  " TLT printlevel: " << fTLTPrintLevel << "\n"
236  " min trigger level: ";
237  switch (fMinRequiredTriggerLevel) {
238  case eT3: info << "T3\n"; break;
239  case eTLT: info << "TLT\n"; break;
240  case eSLT: info << "SLT\n"; break;
241  case eFLT: info << "FLT\n"; break;
242  case eNoTrigger: info << "no trigger\n"; break;
243  default: info << "UNKOWN \n"; break;
244  }
245  info << "max sim.trigger level: ";
246  switch (fMaxSimTriggerLevel) {
247  case eT3: info << "T3\n"; break;
248  case eTLT: info << "TLT\n"; break;
249  case eSLT: info << "SLT\n"; break;
250  case eFLT: info << "FLT\n"; break;
251  case eNoTrigger: info << "no trigger\n"; break;
252  default: info << "UNKOWN\n"; break;
253  }
254 
255  INFO(info);
256 
257  fTltLogFile = fopen("Tlt.log", "w");
258 
259 #ifndef FDLIB_V3R3
260  WARNING("\n For TLT and T3 simulations you need FDEventLib >= v3r3 \n");
261 #endif
262 
263  return eSuccess;
264 }
265 
266 
268 FdTriggerSimulator::Run(evt::Event& event)
269 {
270  if (!event.HasFEvent()) {
271  ERROR("Event has no FEvent.");
272  return eFailure;
273  }
274  FEvent& fEvent = event.GetFEvent();
275 
276  // Generated event print-out ////////////////////////////////////////
277  if (fVerbosity >= 1) {
278  cout <<"****************************************"
279  <<"***************************************"<<endl;
280  cout << "***** Event no. "<<fEvent.GetHeader().GetId()<<endl;;
281  cout << "Timestamp " << event.GetHeader().GetTime()<< endl;
282  cout <<"****************************************"
283  <<"***************************************"<<endl;
284  }
285  // Generated event print-out ////////////////////////////////////////
286 
287  // initialize TLT
288 #ifdef FDLIB_V3R3
289  // INIT TLT
290  if (fMaxSimTriggerLevel <= eTLT) {
291 
292  bool newTLT = false;
293  ostringstream TLTinfo;
294  if (event.GetHeader().GetTime() < fStartMultiplicityTLT) { //prototype TLT
295  if (!dynamic_cast<PrototypeTltProcessor*>(fTltProcessor)) {
296  delete fTltProcessor;
297  fTltProcessor = nullptr;
298  TLTinfo << "Initializing Prototype-TLT processor ("
299  << UTCDateTime(event.GetHeader().GetTime())
300  << " is before switch-time " << UTCDateTime(fStartMultiplicityTLT) << ")";
301  fTltProcessor = new PrototypeTltProcessor();
302  newTLT = true;
303  }
304  } else {
305 # ifdef FDLIB_V3R5
306  if (!dynamic_cast<MStcCutTlt*>(fTltProcessor)) {
307  delete fTltProcessor;
308  fTltProcessor = nullptr;
309  TLTinfo << "Initializing Multiplicity-TLT processor ("
310  << UTCDateTime(event.GetHeader().GetTime())
311  << " is after switch-time " << UTCDateTime(fStartMultiplicityTLT) << ")";
312  MiReadout::MStcCutTltParametersRec tlt_parrec = MSTC_TLT_DEFAULT_PARAMETERS;
313  fTltProcessor = new MStcCutTlt(&tlt_parrec); //new TLT (GAP-2007-118)
314  newTLT = true;
315  }
316 # else
317  if (!dynamic_cast<PrototypeTltProcessor*>(fTltProcessor)) {
318  delete fTltProcessor;
319  fTltProcessor = nullptr;
320  WARNING("\n For multiplicity TLT simulations you need FDEventLib >= v3r5 (switching to prototype TLT!)\n");
321  fTltProcessor = new PrototypeTltProcessor();
322  newTLT = true;
323  }
324 # endif
325  }
326  if (newTLT) {
327  INFO(TLTinfo);
328 
329  fTltProcessor->SetLogfile(fTltLogFile);
330  // fTltProcessor->SetPrintLevel(2); //default 2
331  fTltProcessor->SetPrintLevel(fTLTPrintLevel);
332  //cout << " TLT: load default config" << endl;
333  //MiReadout::TltParametersRec tltpar = DEFAULT_TLT_PARAMETERS;
334  //fTltProcessor->SetParameters( &tltpar );
335  //cout << " TLT: load default config. done." << endl;
336 
337  /*
338  --- modify some of the TLT parameters ...
339  // 15, fCoincidenceWindow
340  // true, fEnableMultipleRejection
341  // 10, fNumPatternToAnalyse
342  // 10 , fKeepRejectedFraction
343  // 10, fFirstSltBin
344  // 35, fLastSltBin
345  // 120, fMaxEventSize
346  // 0.40, fCutParameter1
347  // 0.90 fCutParameter2
348  */
349 
350  ofstream gTltOut("Tlt.out");
351  fTltProcessor->PrintSettings(gTltOut);
352  }
353  }
354 
355  if (fMaxSimTriggerLevel <= eT3) {
356  // INIT T3
357  if (!fT3) {
358  INFO("Initializing T3 processor");
359 # if FDEVENTLIB_VERSION_CODE >= ModuleVersionCode (4, 0, 6)
360  fT3 = &EyeEventClassifier::GetInstance();
361  EyeEventClassifier::GetInstance().SetLogLevel(2);
362 # else
363  fT3 = new EyeEventClassifier();
364 # endif
365  fT3->SetLogLevel(2);
366  }
367  }
368 
369 #else
370 
371  WARNING("\n For TLT and T3 simulations you need FDEventLib >= v3r3 \n");
372 
373 #endif
374 
375  const fdet::FDetector& theFDet = Detector::GetInstance().GetFDetector();
376 
377  bool eventWithTrigger = false;
378 
379  for (fevt::FEvent::EyeIterator iEye = fEvent.EyesBegin(ComponentSelector::eInDAQ);
380  iEye != fEvent.EyesEnd(ComponentSelector::eInDAQ); ++iEye) {
381 
382  if (iEye->GetStatus() == fevt::ComponentSelector::eDeSelected)
383  continue;
384 
385  const fdet::Eye& eyeDet = theFDet.GetEye(*iEye);
386  const TimeInterval& offsetFdSd = eyeDet.GetSDTimeOffset();
387 
388  bool eyeWithTrigger = false;
389 
390  TEyeEvent eyeEvent; // RU Fri May 13 11:22:22 CEST 2005
391 #if FDEVENTLIB_VERSION_CODE >= ModuleVersionCode(4,0,0)
392  TEyeGeometryData* const geoData = eyeEvent.GetGeometryData();
393 #endif
394 
395  for (fevt::Eye::TelescopeIterator iTel = iEye->TelescopesBegin(ComponentSelector::eInDAQ);
396  iTel != iEye->TelescopesEnd(ComponentSelector::eInDAQ); ++iTel) {
397 
398 #if FDEVENTLIB_VERSION_CODE >= ModuleVersionCode(4,0,0)
399  // Set up the telescope axis pointing for the T3.
400  // The angles have to be in degrees in the coordinate system at the
401  // telescope position with X pointing east and Z pointing up.
402  // Thus the usual LocalCoordinateSystem gobbledigob.
403  const fdet::Telescope& telDet = eyeDet.GetTelescope(iTel->GetId());
404  const utl::Vector& axis = telDet.GetAxis();
406  geoData->SetAxisDirection(iTel->GetId(),
407  axis.GetPhi(localTelCS) / degree,
408  (kPi/2.-axis.GetTheta(localTelCS)) / degree);
409 #endif
410 
411  if (!iTel->HasSimData())
412  continue;
413 
414  const bool foundFLT = FLTSim(*iTel); // Check for channel FLT trigger
415 
416  if (foundFLT || fMinRequiredTriggerLevel >= eNoTrigger) {
417 
418  const int timeT2_1000 = SLTSim(*iTel);
419 
420  if (timeT2_1000 || fMinRequiredTriggerLevel >= eFLT) {
421 
422  ++RunController::GetInstance().GetRunData().GetNamedCounters()["FdTriggerSimulator/SLT"];
423 
424  const int timeShift_100 = ShiftEventToSLT(*iTel, timeT2_1000);
425  TMirrorEvent* const mirrorEvent = MakeMirrorEvent(*iTel, event, offsetFdSd, timeShift_100);
426  bool foundTLT = TLTSim(mirrorEvent, *iTel);
427 
428  if (foundTLT || fMinRequiredTriggerLevel >= eSLT) {
429 
430  ++RunController::GetInstance().GetRunData().GetNamedCounters()["FdTriggerSimulator/TLT"];
431 
432  eyeEvent.AddEvent(mirrorEvent);
433  eyeWithTrigger = true;
434  }
435 
436  delete mirrorEvent;
437 
438  }
439  }
440  }
441 
442  if (eyeWithTrigger) {
443 
444  if (fVerbosity >= 1)
445  cout <<endl<< "**************** Event with SLTrigger on Eye "
446  <<(*iEye).GetId()<<" ************************" << endl << endl;
447 
448  const bool foundT3 = T3Sim(eyeEvent, *iEye);
449 
450 #ifndef FDLIB_V3R3
451  // for the case of no TLT/T3 simulation: put a valid timestamp into the T3 data
452  // structure, in order to make the CentralTriggerSimulator work.
453  const bool hasSimShower = event.HasSimShower(); // drum+photon simulation has no simshower
454  const TimeStamp& coreTime = (hasSimShower ? event.GetSimShower().GetTimeStamp() : event.GetHeader().GetTime());
455  const Point& eyePos = Detector::GetInstance().GetFDetector().GetEye(*iEye).GetPosition();
456  const Point& corePos = (hasSimShower ? event.GetSimShower().GetPosition() : eyePos);
457  const TimeStamp t3Time = coreTime + TimeInterval((eyePos-corePos).GetMag()/kSpeedOfLight);
458  iEye->GetTriggerData().SetT3Time(t3Time); // time at core as seen by eye
459 #endif
460 
461  if (foundT3 || fMinRequiredTriggerLevel >= eTLT) {
462 
463  eventWithTrigger = true;
464  INFO("\n\n**************** Event with triggered eye ! ****************\n\n");
465  AddEyeEvent(*iEye, event, eyeEvent);
466 
467  ++RunController::GetInstance().GetRunData().GetNamedCounters()["FdTriggerSimulator/T3"];
468 
469  }
470  }
471  } // end loop over Eyes
472 
473  if (eventWithTrigger)
474  ++RunController::GetInstance().GetRunData().GetNamedCounters()["FdTriggerSimulator/triggeredEvents"];
475  else
476  INFO("No trigger");
477 
478  return eSuccess;
479 
480 }
481 
482 
484 FdTriggerSimulator::Finish()
485 {
486 #ifdef FDLIB_V3R3
487  if (fMaxSimTriggerLevel <= eTLT && fTltLogFile) {
488  fclose(fTltLogFile);
489  }
490 #endif
491 
492  return eSuccess;
493 }
494 
495 
496 bool
497 FdTriggerSimulator::FLTSim(fevt::Telescope& tel)
498 {
499  const fdet::Telescope& detTel = Detector::GetInstance().GetFDetector().GetTelescope(tel);
500 
501  TelescopeSimData& telSim = tel.GetSimData();
502 
503  const unsigned int telId = tel.GetId();
504  const unsigned int eyeId = tel.GetEyeId();
505 
506  // RESET FLT
507  fChannelReadOutList.clear();
508  fChannelFLT.clear();
509  fFLT.clear();
510  fMultiplicity.clear();
511 
512  unsigned int nPixShower = 0;
513  unsigned int nPixFLT = 0;
514  unsigned int nPixFLTShower = 0;
515  unsigned int nPixFLTBg = 0;
516 
517  bool haspixel = false;
518 
519  // loop channels
520  for (unsigned int channelId = 1; channelId <= detTel.GetLastPixelId(); ++channelId) {
521 
522  const fdet::Channel& detChannel = detTel.GetChannel(channelId);
523  unsigned int pixelId = detChannel.GetPixelId(); // mapped pixel id
524 
525  if (!tel.HasChannel(channelId))
526  continue;
527  fevt::Channel& channel = tel.GetChannel(channelId);
528 
529  if (!channel.HasSimData())
530  continue;
531  fevt::ChannelSimData& channel_sim = channel.GetSimData();
532 
533  if (!channel_sim.HasFADCTrace(fevt::FdConstants::eTotal))
534  continue;
535 
536  int threshold = 0;
537  if (!tel.HasPixel(pixelId))
538  continue;
539  fevt::Pixel& pixel = tel.GetPixel(pixelId);
540 
541  if (pixel.GetStatus() == ComponentSelector::eDeSelected)
542  continue;
543 
544  if (!pixel.HasSimData())
545  continue;
546  fevt::PixelSimData& sim = pixel.GetSimData();
547  const bool hasShowerPhotons = sim.HasPhotonTrace(fevt::FdConstants::eTotal);
548 
549  if (fVerbosity >= 1 && !haspixel) {
550  cout << endl << ">============== FIRST LEVEL TRIGGER on Mirror/Eye "
551  << telId << "/" << eyeId << " ===============< "<< endl;
552  haspixel = true;
553  }
554 
555  threshold = sim.GetThreshold();
556  int nBox = sim.GetNumSamples();
557  const TraceI& fadc_trace = channel_sim.GetFADCTrace(fevt::FdConstants::eTotal);
558 
559  if (hasShowerPhotons)
560  ++nPixShower;
561 
562  // Debug ==========================================================
563  // Debug photon signal and ADC's
564  // these are only shower photons !!!!
565  if (hasShowerPhotons) {
567  if (fVerbosity >= 2) {
568  unsigned int duration = 0;
569  unsigned int t0_ph = 0;
570  for (unsigned int t = 0; t < phTrace.GetSize(); ++t) {
571  if (phTrace[t] > 0) {
572  if (duration == 0) {
573  t0_ph = t;
574  }
575  ++duration;
576  }
577  }
578  if (duration > 0) {
579  cout << endl
580  << " photons: pixel ID = " << pixelId
581  << " signal duration : " << t0_ph << " -> " << t0_ph+duration-1
582  << endl;
583  for (unsigned int t = t0_ph; t < t0_ph + duration; ++t) {
584  cout << "[" << setw(3)<<t << "] signal = " << setw(10)<<phTrace[t]
585  << " --> ADC = " << setw(4) << fadc_trace[t]
586  << endl;
587  }
588  }
589  }
590  }
591  // END Debug =====================================================
592 
593  // the first possible t1 bin is around 10, IF there is no signal in bin 0 !
594  if (T1Trigger(channelId, threshold, nBox, fadc_trace, sim, detChannel)) {
595 
596  ++nPixFLT;
597  if (hasShowerPhotons) {
598  ++nPixFLTShower;
599  } else {
600  ++nPixFLTBg;
601  }
602  }
603 
604  } // loop pixels
605 
606  telSim.SetNumberOfFltPixels(nPixFLT);
607  telSim.SetNumberOfFltPixelsFromShower(nPixFLTShower);
608  telSim.SetNumberOfFltPixelsFromBackground(nPixFLTBg);
609  telSim.SetNumberOfPixelsWithShowerPhotons(nPixShower);
610 
611  if (fVerbosity > 0) {
612  ostringstream msg;
613  msg << "FLT simulation for eye=" << eyeId << " telescope=" << telId
614  << " number of FLT pixels=" << nPixFLT;
615  INFO(msg);
616  }
617 
618  return nPixFLT > 0;
619 }
620 
621 
622 int
623 FdTriggerSimulator::SLTSim(fevt::Telescope& tel)
624 {
625  if (fMaxSimTriggerLevel > eSLT) {
626  if (fVerbosity > 1) {
627  INFO("skipping SLT simulation");
628  }
629  return 0;
630  }
631 
632  const unsigned int telId = tel.GetId();
633  const int eyeId = tel.GetEyeId();
634 
635  if (fVerbosity >= 1) {
636  cout << endl<<">============== SECOND LEVEL TRIGGER on Mirror/Eye "
637  <<telId <<"/"<<eyeId<<" ==============< "<< endl;
638  }
639 
640 //#warning Where to get the length of the simulated traces here?
641  // take trace length as photon trace length + full FADC trace length
642  // this convention is used in FdElectronicsSimulatorOG
643  const fdet::Telescope& detTel = Detector::GetInstance().GetFDetector().GetTelescope(tel);
644  const fdet::Camera& detCamera = detTel.GetCamera();
645  const unsigned int numFADCBin = detCamera.GetFADCTraceLength();
646  const unsigned int lastFLTbin = tel.GetSimData().GetNumberOfPhotonBins() + numFADCBin;
647 
648  int timeT2_1000 = T2Trigger(detTel, lastFLTbin); // T2 time in units of 100 ns
649  fevt::TelescopeSimData& telSim = tel.GetSimData();
650  telSim.SetSltTriggerTime(timeT2_1000*10); // convert to ADC bin
651 
652  if (fVerbosity > 0) {
653  ostringstream msg;
654  msg << "SLT simulation for eye=" << eyeId << " telescope=" << telId;
655  if (timeT2_1000) {
656  msg << " SLT trigger time=" << timeT2_1000*10 << " [100ns]";
657  } else {
658  msg << " NO SLT";
659  }
660  INFO(msg);
661  }
662 
663  return timeT2_1000;
664 }
665 
666 
667 int
668 FdTriggerSimulator::ShiftEventToSLT(fevt::Telescope& tel, int timeT2_1000)
669 {
670  const fdet::Camera& detCamera = Detector::GetInstance().GetFDetector().GetTelescope(tel).GetCamera();
671  const int SLTbin = detCamera.GetSLTTriggerBin();
672  const int adcTraceLength = detCamera.GetFADCTraceLength();
673 
674  int timeT2_100 = timeT2_1000*10;
675 
676  // if event has no SLT, but we want to trigger anyway:
677  // re-define event start bin
678  if (fMinRequiredTriggerLevel >= eFLT && // -> FLT, all
679  timeT2_100 <= 0) {
680  timeT2_100 = SLTbin;
681  }
682 
683  // if no SLT trigger time is available
684  if (timeT2_100 < 0) {
685  ERROR("No valid SLT trigger time is available for this event!");
686  return -1;
687  }
688 
689  // ++++ SLT trigger is only issued every 1000ns: ++++++=
690  int timeShift_1000 = int(double(timeT2_100 - SLTbin)/10); // center at SLTbin
691  int timeShift_100 = 10 * timeShift_1000;
692 
693  // +++++ FIRST check for event start time BEFORE start of trace simulation ++++++
694  if (timeT2_100 < SLTbin) {
695  ostringstream err;
696  err << " >>>>> Warning T2 = " << timeT2_100
697  << " too low. SLTbin=" << SLTbin << ". Resetting Time Offset (was "
698  << timeShift_100 << ")";
699  ERROR(err);
700  timeShift_100 = 0;
701  timeShift_1000 = 0;
702  }
703 
704 //#warning Where to get the length of the simulated traces here?
705  // take trace length as photon trace length + full FADC trace length
706  // this convention is used in FdElectronicsSimulatorOG
707  int numSimT1Bin = tel.GetSimData().GetNumberOfPhotonBins(); // ->ADC bins
708  if (numSimT1Bin > 0)
709  numSimT1Bin += adcTraceLength;
710  else
711  numSimT1Bin = 2*adcTraceLength; // workaround for missing numberofphotonbins in old Offline files
712 
713  // ++++ SECOND check for event end time AFTER end of trace simulation +++++
714  if (timeT2_100 + adcTraceLength-SLTbin > numSimT1Bin) {
715 //if (timeT2_100+kActualT1Bins-fBinShift>kNumT1Bins) {
716 // 1000 300 2000
717  ostringstream err;
718  err << " >>>>> Warning timeT2_100 = " << timeT2_100
719  << " too high: resetting Time Offset (was " << timeShift_100 << ")"
720  << " adcTraceLength=" << adcTraceLength
721  << " SLTbin="<< SLTbin << " numSimT1Bin=" << numSimT1Bin;
722  ERROR(err);
723 
724  const double sltBinsPerFltBin = detCamera.GetFADCBinSize() / (100.*ns);
725  timeShift_1000 = int( (-adcTraceLength+numSimT1Bin) * sltBinsPerFltBin) / 10;
726  timeShift_100 = timeShift_1000 * 10;
727  timeT2_1000 = (timeShift_100 + SLTbin) / 10;
728  timeT2_100 = timeT2_1000 * 10;
729  }
730 
731  // Debug ==========================================================
732  if (fVerbosity >= 1) {
733  cout << " >>>>> Shifting traces to SLT trigger time: Time Offset is " << timeShift_100
734  << " [100 ns] "
735  " ( = " << timeT2_100 << " - " << SLTbin << " )"
736  " <<<<<" << endl << endl;
737  }
738  // End Debug ==========================================================
739 
740  const fdet::FDetector& detFD = Detector::GetInstance().GetFDetector();
741  const fdet::Telescope& detTel = detFD.GetTelescope(tel);
742 
743  DoPixelList(timeShift_100, detTel); // Prepare list of pixel to be read-out
744  fevt::TelescopeSimData& telSim = tel.GetSimData();
745  telSim.SetNumberOfReadOutPixels(fChannelReadOutList.size());
746  telSim.SetSltTimeShift(timeShift_100);
747 
748  return timeShift_100;
749 }
750 
751 
752 bool
753 FdTriggerSimulator::TLTSim(TMirrorEvent *tel, fevt::Telescope& evtTel)
754 {
755 #ifdef FDLIB_V3R3
756 
757  if (fMaxSimTriggerLevel > eTLT) {
758  if (fVerbosity > 1) {
759  INFO("skipping TLT simulation");
760  }
761  return true;
762  }
763 
764  const unsigned int telId = tel->GetEventHeader()->GetMirrorNo();
765  const unsigned int eyeId = tel->GetEventHeader()->GetEyeNo();
766 
767  // Debug ==========================================================
768  if (fVerbosity >= 1) {
769  ostringstream info;
770  info << endl << " >============== THIRD LEVEL TRIGGER on mirror "
771  << telId << " eye " << eyeId << " ==============< "<< endl << endl;
772  INFO(info);
773  }
774  // END Debug ==========================================================
775 
776  fTltProcessor->Clear();
777  fTltProcessor->Decide(tel);
778 
779  bool result = fTltProcessor->IsEventAccepted();
780  TMirrorEventHeader::EMiEventLabel tltLabel = fTltProcessor->GetEventLabel();
781 
782  // set FDAS data structure
783  tel->GetEventHeader()->SetEventLabel(tltLabel);
784 
785  // set Offline data structure
786  fevt::TelescopeTriggerData& telTrigger = evtTel.GetTriggerData();
787  telTrigger.SetTLTAccepted(result);
788  telTrigger.SetTLTLabel(tel->GetEventHeader()->GetVerboseEventLabel(tltLabel));
789 
790  ostringstream thisT3info;
791  thisT3info<< " +++++++++++++++++++++ "
792  "TLT "
793  << (result ? "accepted" : "rejected")
794  //<< " type = " << tel->GetEventHeader()->GetVerboseEventType(miType)
795  << " label = " << tel->GetEventHeader()->GetVerboseEventLabel(tltLabel)
796  << " ++++++++++++";
797  INFO(thisT3info);
798 
799  return result;
800 #else // if not using FDLIB_V3R3
801  return true;
802 #endif
803 }
804 
805 
806 bool
807 FdTriggerSimulator::T3Sim(TEyeEvent& eye, fevt::Eye& evtEye)
808 {
809  // Init T3
810  evtEye.MakeTriggerData();
811  fevt::EyeTriggerData& eyeTrig = evtEye.GetTriggerData();
812 
813  eyeTrig.SetT3SDP(0,0,0); // theta and phi of SDP
814  eyeTrig.SetT3NPixels(0);
815 
816 #ifdef FDLIB_V3R3
817 
818  if (fMaxSimTriggerLevel > eT3) {
819  if (fVerbosity > 1) {
820  INFO("skipping T3 simulation");
821  }
822  return true;
823  }
824 
825  const unsigned int eyeId = eye.GetEventHeader()->GetEyeNo();
826 
827  // Debug ==========================================================
828  if (fVerbosity >= 1) {
829  ostringstream info;
830  info << endl << " >============== T3 LEVEL TRIGGER on eye "
831  << eyeId << " ==============< "<< endl << endl;
832  INFO(info);
833  }
834  // END Debug ==========================================================
835 
836  /*
837  TEyeEventHeader::EEventClass event_class = fT3->GetEventClass();
838 
839  header->SetEventClass(event_class);
840 
841 
842  // // only EventClass kShowerCandidate & kIsShower are sent as T3 to CDAS !!!
843  // // now also kCloseShower, sa 20040615
844  // if ( event_class == TEyeEventHeader::kShowerCandidate
845  // || event_class == TEyeEventHeader::kIsShower
846  // || event_class == TEyeEventHeader::kCloseShower) {
847 
848  */
849 
850  // -------- T3 --------
851  TEyeEventHeader::EEventClass t3class = eye.GetEventHeader()->GetEventClass();
852 
853  ostringstream thisT3info;
854  // only do T3 for TLT pre-selected events
855  if (t3class != TEyeEventHeader::kLargeEvent &&
856  t3class != TEyeEventHeader::kRejected &&
857  t3class != TEyeEventHeader::kIsMuon &&
858  t3class != TEyeEventHeader::kNoise) {
859 
860  // T3 parameters have to be set according to DAQ
861  // if changed in the future, this has to be modified (last change 2016/11/28)
862  TimeStamp T3time = TimeStamp(eye.GetEventHeader()->GetTimeStamp()->GetGPSSec());
863  EyeEventClassifier::EventClassifierParameters t3config_STD = EVENTCLASSIFIER_PARAMETERS_STD;
864  EyeEventClassifier::EventClassifierParameters t3config_OLD = EVENTCLASSIFIER_PARAMETERS_OLD;
865  EyeEventClassifier::EventClassifierParameters t3config_HE2 = EVENTCLASSIFIER_PARAMETERS_HEAT_2;
866  static string t3config_last = "none";
867  if (eyeId < 5) {
868  if (T3time < UTCDateTime(2004,5,10).GetTimeStamp()) {
869  if (t3config_last != string("old")) {
870  fT3->SetParameters(t3config_OLD, true);
871  t3config_last = string("old");
872  }
873  } else {
874  if (t3config_last != string("std")) {
875  fT3->SetParameters(t3config_STD, true);
876  t3config_last = string("std");
877  }
878  }
879  } else {
880  if (T3time < UTCDateTime(2012,2,15).GetTimeStamp()) {
881  if (t3config_last != string("std")) {
882  fT3->SetParameters(t3config_STD, true);
883  t3config_last = string("std");
884  }
885  } else {
886  if (t3config_last != string("he2")) {
887  fT3->SetParameters(t3config_HE2, true);
888  t3config_last = string("he2");
889  }
890  }
891  }
892  fT3->DoClassification (&eye);
893 
894  t3class = fT3->GetEventClass();
895  eye.GetEventHeader()->SetEventClass(t3class);
896 
897  float t3Azimuth = fT3->GetAzimuthAtGround();
900  int timeAtGround = fT3->GetTimeAtGround();
902  int nPix = fT3->GetNPixels();
904  float sdpTheta = fT3->GetSDPTheta();
906  float sdpPhi = fT3->GetSDPPhi();
907  /* Total shower signal in ADC counts*/
908  float t3TotalSignal = fT3->GetTotalSignal();
909  // T3PixelList* t3PixelList = fT3->GetT3PixelList();
910 
911  // fill FADS T3 data
912  eye.GetT3Data()->SetNPixels(nPix);
913  eye.GetT3Data()->SetSDPTheta(sdpTheta);
914  eye.GetT3Data()->SetSDPPhi(sdpPhi);
915  eye.GetT3Data()->SetAzimuthAtGround(t3Azimuth);
916  eye.GetT3Data()->SetTimeAtGround(timeAtGround);
917  eye.GetT3Data()->SetTotalSignal(t3TotalSignal);
918 
919  // fill Offline T3 data
920  eyeTrig.SetT3Time(TimeStamp(eye.GetEventHeader()->GetTimeStamp()->GetGPSSec(),
921  timeAtGround));
922  eyeTrig.SetT3SDP(sdpTheta, sdpPhi, t3Azimuth);
923  eyeTrig.SetT3NPixels(nPix);
924  eyeTrig.SetT3Class(eye.GetEventHeader()->GetVerboseEventClass(t3class));
925 
926  thisT3info << " +++++++++++ T3 resulting eventClass = "
927  << eye.GetEventHeader()->GetVerboseEventClass(t3class)
928  << " +++++++++++++++";
929 
930  } else {
931 
932  thisT3info << " +++++++++++ T3 not used due to eventClass = "
933  << eye.GetEventHeader()->GetVerboseEventClass(t3class)
934  << " +++++++++++++++";
935 
936  }
937 
938  INFO(thisT3info);
939  thisT3info.str("");
940 
941  switch (t3class) {
942  case TEyeEventHeader::kCloseShower:
943  case TEyeEventHeader::kShowerCandidate:
944  case TEyeEventHeader::kHorizontalShower:
945  case TEyeEventHeader::kIsShower:
946  {
947  thisT3info << " ++++++++++++ T3: accepted ";
948 
949  // ----------- do the EyeTriggerData ---------------
950  // (maybe move this into the FDasToOfflineConverter)
951  eyeTrig.SetT3Accepted(true);
952  }
953 
954  //nT3 ++;
955  //if (T3Type==TEyeEventHeader::kUnClassified)
956  //T3Type = t3class;
957  INFO(thisT3info);
958  return true;
959 
960  default:
961  thisT3info << " ++++++++++++ T3: rejected ";
962  //T3Type = t3class;
963  INFO(thisT3info);
964  return false;
965  };
966 
967 #else // if not using FDLIB_V3R3
968  return true;
969 #endif
970 }
971 
972 
974 void
975 FdTriggerSimulator::DoPixelList(int sltTimeShift,
976  const fdet::Telescope& detTel)
977 {
978  vector<int> survivingFLT; // just for debug output
979  vector<int> timeOfStart; // FLT pixel time shifted to SLT trigger (just for debug)
980  vector<int> rejectedFLT; // just for debug output
981  vector<unsigned int> neighbourPixels; // just for debug output
982 
983  int nPixON = 0; // number of FLT pixels in trace time window
984 
985  const double fltBinsPer100ns = detTel.GetChannel(1).GetFADCBinSize() / (100.*ns);
986 
987  const int sltTimeShiftInFltBins = int(sltTimeShift / fltBinsPer100ns);
988 
989  // loop over pixels
990  for (list<int>::iterator iChannelFLT = fChannelFLT.begin();
991  iChannelFLT != fChannelFLT.end(); ) {
992 
993  int channelId = *iChannelFLT;
994  const fdet::Channel& detChannel = detTel.GetChannel(channelId);
995 
996  // Debug ==========================================================
997  if (fVerbosity >= 4)
998  cout << " DoPixelList test pixel with FLT channelId=" << channelId;
999  // END Debug ==========================================================
1000 
1001  // scan shifted trace for FLT
1002  bool fltInShiftedWindow = false;
1003  if (fFLT.count(channelId)) {
1004 
1005  // loop FLT trace and search for any FLT in trace time window
1006  for (FltTrace::const_iterator bin = fFLT[channelId].begin();
1007  bin != fFLT[channelId].end(); ++bin) {
1008 
1009  // shift to SLT time
1010  const int tbin = bin->first;
1011  const int shiftBin = tbin - sltTimeShiftInFltBins;
1012 
1013  // check trace time window
1014  if (shiftBin >= 0 && shiftBin < detChannel.GetFADCTraceLength()) {
1015  timeOfStart.push_back(tbin);
1016  survivingFLT.push_back(channelId);
1017  fltInShiftedWindow = true;
1018  break;
1019  }
1020  } // end loop bins
1021 
1022  if (fltInShiftedWindow) {
1023 
1024  // Debug ==========================================================
1025  if (fVerbosity >= 4)
1026  cout << " : readout " << endl;
1027  // END Debug ==========================================================
1028 
1029  ++nPixON;
1030  fChannelReadOutList.push_back(channelId);
1031  ++iChannelFLT; // move to next channel
1032 
1033  } else {
1034 
1035  // Debug ==========================================================
1036  if (fVerbosity >= 4)
1037  cout << " : has no FLT in trace (REMOVE FLT)!" << endl;
1038  // END Debug ==========================================================
1039 
1040  rejectedFLT.push_back(channelId);
1041  iChannelFLT = fChannelFLT.erase(iChannelFLT); // turn off FLT
1042 
1043  // Debug ==========================================================
1044  if (fVerbosity >= 2) // by sergio
1045  cout << " &&&& Pixel " << channelId << " is out of time (REMOVE FLT)!" << endl;
1046  // END Debug ==========================================================
1047 
1048  } // if else (fltInShiftedWindow)
1049 
1050  } else {
1051 
1052  ++iChannelFLT; // move to next channel
1053  // Debug ==========================================================
1054  if (fVerbosity >= 4)
1055  cout << " : ERROR fFLT not filled !" << endl;
1056  // END Debug ==========================================================
1057 
1058  }
1059 
1060  } // end loop channels
1061 
1062  // select pixels close to the FLT pixels (NEIGHBORS)
1063  for (list<int>::const_iterator iChannelFLT = fChannelFLT.begin();
1064  iChannelFLT != fChannelFLT.end(); ++iChannelFLT) {
1065 
1066  int channelId = *iChannelFLT;
1067  //int pixelId = detTel.GetChannel(channelId).GetPixelId();
1068 
1069  int col = ((channelId-1)/22) + 1;
1070  int row = ((channelId-1)%22) + 1;
1071 
1072  for (int c_neigh = -fColRO; c_neigh <= fColRO; ++c_neigh) {
1073  for (int r_neigh = -fRowRO; r_neigh <= fRowRO; ++r_neigh) {
1074 
1075  int c = col + c_neigh;
1076  int r = row + r_neigh;
1077  if (c >= 1 && c <= 20 && r >= 1 && r <= 22) {
1078 
1079  int neigh_channel = 22 * (c - 1) + r;
1080 
1081  // flag non-FLT pixel in vicinity of FLT
1082  if (find(fChannelReadOutList.begin(), fChannelReadOutList.end(), neigh_channel) ==
1083  fChannelReadOutList.end()) {
1084  fChannelReadOutList.push_back(neigh_channel);
1085  neighbourPixels.push_back(neigh_channel);
1086  }
1087  }
1088  } // loop rows
1089  } // loop cols
1090  } // end loop channels
1091 
1092  // now add the virtual channel
1093  for (list<int>::const_iterator iReadOutChannel = fChannelReadOutList.begin();
1094  iReadOutChannel != fChannelReadOutList.end(); ++iReadOutChannel) {
1095 
1096  unsigned int channelId = *iReadOutChannel;
1097 
1098  // check if already virtual channel and not pixel
1099  if (channelId > detTel.GetLastPixelId())
1100  continue;
1101 
1102  int virtual_channel = detTel.GetChannel(channelId).GetVirtualChannelId();
1103 
1104  if (find(fChannelReadOutList.begin(), fChannelReadOutList.end(), virtual_channel) ==
1105  fChannelReadOutList.end()) {
1106  fChannelReadOutList.push_back(virtual_channel);
1107  }
1108 
1109  }
1110  // -- end algorithm --
1111 
1112  // DEBUG ==========================================================================
1113  // T1 summary
1114  if (fVerbosity >= 1) {
1115 
1116  int tstartmin = 9999999;
1117  int tstartmax =-9999999;
1118 
1119  int maxmult = 0;
1120  int t_maxmult = 0;
1121  bool first = true;
1122 
1123  for (unsigned int k = 0; k < timeOfStart.size(); ++k) {
1124 
1125  int t_bin = timeOfStart[k];
1126 
1127  int mult = 0;
1128  if (fMultiplicity.count(t_bin)) {
1129  mult = fMultiplicity[t_bin];
1130  }
1131 
1132  if (fVerbosity >= 4) {
1133  cout << " surviving FLT in pixelId=" << setw(2) << survivingFLT[k]
1134  << " time of start " << setw(4) << timeOfStart[k]
1135  << " FLT multiplicity at bin " << setw(3) << mult
1136  << endl;
1137  } else if (fVerbosity >= 2) { // by sergio
1138  cout << "flt pixel no " << setw(2) << k
1139  << " time of start " << setw(4) << timeOfStart[k]
1140  << " multiplicity " << setw(3) << mult
1141  << endl;
1142  }
1143 
1144  if (first) {
1145  first = false;
1146  tstartmin = timeOfStart[k];
1147  tstartmax = timeOfStart[k];
1148  maxmult = mult;
1149  t_maxmult = timeOfStart[k];
1150  } else {
1151  if (timeOfStart[k] < tstartmin)
1152  tstartmin = timeOfStart[k];
1153  if (timeOfStart[k] > tstartmax)
1154  tstartmax = timeOfStart[k];
1155  if (mult > maxmult) {
1156  maxmult = mult;
1157  t_maxmult = timeOfStart[k];
1158  }
1159  }
1160  }
1161 
1162  if (fVerbosity >= 4) { // by Ralf
1163  for (unsigned int k = 0; k < rejectedFLT.size(); ++k) {
1164  int channelId = rejectedFLT[k];
1165  cout << " rejected FLT in channelId=" << setw(2) << channelId;
1166  if (fVerbosity >= 5) {
1167  cout << " FLTtrace: ";
1168  if (fFLT.count(channelId)) {
1169  bool firstInTrace = true;
1170  int previous = -100;
1171  for (FltTrace::const_iterator bin = fFLT[channelId].begin();
1172  bin != fFLT[channelId].end(); ++bin) {
1173  if (previous != (bin->first-1)) {
1174  if (firstInTrace) {
1175  firstInTrace = false;
1176  cout << bin->first;
1177  } else {
1178  cout << "-" << previous << ", " << bin->first;
1179  }
1180  }
1181  previous = bin->first;
1182  } // loop tbin
1183  if (!firstInTrace) {
1184  cout << "-end";
1185  }
1186  } // if channel had FLT
1187  }
1188  cout << endl;
1189  }
1190  }
1191 
1192  cout << endl
1193  << " NpixON=" << nPixON
1194  << ", NpixRO=" << fChannelReadOutList.size()
1195  << ", Max mult= " << maxmult
1196  << " @ t = " << t_maxmult
1197  << ", time of start: min " << tstartmin
1198  << ", max " << tstartmax
1199  << endl;
1200 
1201  if (fVerbosity >= 2) {
1202  cout << endl << " *** List of Read Out pixels ***" << endl;
1203 
1204  int n = 0;
1205  for (list<int>::const_iterator iReadOutPixel = fChannelReadOutList.begin();
1206  iReadOutPixel!=fChannelReadOutList.end(); ++iReadOutPixel) {
1207  // loop read out pixels
1208 
1209  unsigned int p = int(*iReadOutPixel);
1210 
1211  if (p <= detTel.GetLastPixelId()) {
1212 
1213  int col = ((p-1) / 22) + 1;
1214  int row = ((p-1) % 22) + 1;
1215  ++n;
1216 
1217  if (find(neighbourPixels.begin(), neighbourPixels.end(), p) == neighbourPixels.end()) {
1218 
1219  cout << setw(4) << n
1220  << " pixel " << setw(3) << p
1221  << " col " << setw(3) << col
1222  << " row " << setw(3) << row
1223  << endl;
1224 
1225  } else {
1226 
1227  cout << setw(4) << n
1228  << " pixel " << setw(3) << p
1229  << " col " << setw(3) << col
1230  << " row " << setw(3) << row
1231  << " --> neighbour "
1232  << endl;
1233  }
1234 
1235  } else {
1236  int virt = (p-1)%2 + 1;
1237  int col = ((p-1) - detTel.GetLastPixelId())/2 + 1;
1238  cout << setw(4) << n
1239  << " pixel " << setw(3) << p
1240  << " col " << setw(3) << col
1241  << " virt " << setw(3) << virt
1242  << " --> virtual"
1243  << endl;
1244  }
1245  }
1246  }
1247  }
1248  // ENd DEBUG ========================================================================
1249 
1250 } // End of DoPixelList
1251 
1252 
1253 bool
1254 FdTriggerSimulator::T1Trigger(unsigned int channelId,
1255  unsigned int pixelthresh,
1256  unsigned int nSamp,
1257  const TraceI& trace,
1258  PixelSimData& pixelSim,
1259  const fdet::Channel& detChannel)
1260 {
1261  const unsigned int FLTprolongation = detChannel.GetFLTProlongation(); // [bins]
1262 
1263  unsigned int tstart = 0;
1264  unsigned int tend = 0;
1265  unsigned int prolongationCounter = 0;
1266  bool pulse = false;
1267  bool hasFLT = false;
1268 
1269  unsigned int maxBoxcarSum = 0;
1270  double meanBoxcarSum = 0;
1271  double rmsBoxcarSum = 0;
1272  unsigned int ntslots = 0;
1273  double squareBoxcarSum = 0;
1274 
1275  vector<int> boxcar(nSamp, 0);
1276 
1277  for (unsigned int iBin = 0; iBin < trace.GetSize(); ++iBin) { // loop over tslots
1278 
1279  // build boxcar
1280  for (unsigned int i = 0; i < nSamp-1; ++i)
1281  boxcar[i] = boxcar[i+1];
1282  boxcar[nSamp-1] = trace [iBin];
1283 
1284  // sum up
1285  unsigned int boxcarsum = 0;
1286  for(unsigned int l = 0; l < nSamp; ++l) {
1287  boxcarsum += boxcar[l];
1288  }
1289 
1290  // neglect the first partially filled boxcarsums
1291  if (iBin > nSamp-1) {
1292  ++ntslots;
1293  meanBoxcarSum += boxcarsum;
1294  squareBoxcarSum += boxcarsum*boxcarsum;
1295  }
1296 
1297  if (boxcarsum > maxBoxcarSum)
1298  maxBoxcarSum = boxcarsum;
1299 
1300  // Test FLT on running sums wrt threshold
1301  bool bin_above_threshold = (boxcarsum > pixelthresh);
1302  if (bin_above_threshold) {
1303 
1304  hasFLT = true;
1305  prolongationCounter = 0; // FLT prolongation counter
1306 
1307  if (!pulse) { // start of new FLT region (pulse)
1308 
1309  pulse = true;
1310  tstart = iBin; // start of pulse/region
1311 
1312  // DEBUG ==========================================================================
1313  if (fVerbosity >= 1) {
1314  cout << "##### FLT start " << setw(5) << iBin
1315  << " pixel " << setw(3) << channelId
1316  << "; sum(" << nSamp << ") = " << setw(5) << boxcarsum
1317  << " threshold = " << pixelthresh
1318  << endl;
1319  }
1320  // ENDDEBUG ==========================================================================
1321 
1322  }
1323 
1324  // DEBUG ==========================================================================
1325  if (fVerbosity >= 2) {
1326  int col = ((channelId - 1) / 22) + 1;
1327  int row = ((channelId - 1) % 22) + 1;
1328  cout << " > FLT Pixel # " << channelId << " col " << col << " row " << row
1329  << " ==> OVER threshold @ time " << iBin
1330  << " sum: " << boxcarsum << ", thres: " << pixelthresh
1331  << endl;
1332  }
1333  // END DEBUG ==========================================================================
1334 
1335  } else { // if (bin_above_threshold)
1336 
1337  if (pulse) { // if first bin below threshold after FLT pulse
1338 
1339  pulse = false; // prepare next FLT pulse
1340  prolongationCounter = 0; // FLT prolongation counter (start)
1341  tend = iBin-1; // end of FLT pulse
1342  }
1343 
1344  } // if (bin_above_threshold) else
1345 
1346 
1347  if (hasFLT && prolongationCounter < FLTprolongation) {
1348 
1349  if (bin_above_threshold) {
1350 
1351  if (!fMultiplicity.count(iBin)) {
1352  fMultiplicity[iBin] = 0; // count FLTs in this time bin
1353  }
1354  ++fMultiplicity[iBin]; // count FLTs in this time bin
1355 
1356  fFLT[channelId][iBin] = 1;
1357 
1358  } else {
1359 
1360  fFLT[channelId][iBin] = 2;
1361 
1362  }
1363 
1364  }
1365 
1366  ++prolongationCounter;
1367 
1368  } // end loop over tslots
1369 
1370  // DEBUG ==========================================================================
1371  if (fVerbosity >= 4 && hasFLT) { // by ralf
1372  cout << "##### FLT summary channelId=" << channelId << " start=" << tstart << " length=" << tend-tstart+1
1373  << " end=" << tend
1374  << " FLTtrace(start-1|end+1): ";
1375  unsigned int i;
1376  for (i = tstart-1; i <= tend+1; ++i) {
1377  if (fFLT[channelId].count(i))
1378  cout << "1";
1379  else
1380  cout << "0";
1381  }
1382  for (i = tend; i < trace.GetSize(); ++i) {
1383  if (!fFLT[channelId].count(i))
1384  break;
1385  }
1386  cout << " first_0_bin=" << i
1387  << endl;
1388  } else if (fVerbosity >= 2 && hasFLT) { // by sergio
1389  cout << "##### FLT start = " << tstart << " length = " << tend-tstart+1
1390  << ", end time = " << tend
1391  << endl;
1392  }
1393  // END DEBUG ==========================================================================
1394 
1395  if (ntslots) {
1396  meanBoxcarSum /= ntslots;
1397  rmsBoxcarSum = std::sqrt(double(squareBoxcarSum - ntslots * meanBoxcarSum * meanBoxcarSum)/(ntslots-1));
1398  }
1399 
1400  // remember all triggered pixels
1401  if (hasFLT) {
1402  fChannelFLT.push_back(channelId);
1403  }
1404 
1405  pixelSim.SetMaxBoxcarsum(maxBoxcarSum);
1406  pixelSim.SetFltTime(tstart);
1407  pixelSim.SetFltDuration(tend-tstart-1);
1408  pixelSim.SetMeanBoxcarsum(meanBoxcarSum);
1409  pixelSim.SetRmsBoxcarsum(rmsBoxcarSum);
1410 
1411  return hasFLT;
1412 }
1413 
1414 
1415 int
1416 FdTriggerSimulator::T2Trigger(const fdet::Telescope& detTel, unsigned int lastFLTbin)
1417 {
1418  //const fdet::FDetector& detFD = Detector::GetInstance().GetFDetector();
1419 
1420  //if (fMultiplicity.size()<1) {
1421  //return 0;
1422  //}
1423 
1424  // Algorithm to select pixels
1425 
1426  int timeT2 = 0;
1427 
1428  const int pebit = 0;
1429  const int triggerbit = 0;
1430  const int sparebit = 1;
1431 
1432  // this is just for debugging
1433  map<int, int> sltMultiplicity;
1434  vector<int> usedSltPixels;
1435 
1436  // RESET SLT memory
1437  fSLT.clear();
1438 
1439  const double fltBinsPer50ns = detTel.GetChannel(1).GetFADCBinSize() / (50.*ns);
1440  int numT2bins = int(lastFLTbin * fltBinsPer50ns);
1441 
1442  // 50 ns SLT time slices : loop over time (2000*2 = 4000 bins)
1443  for (int tt2 = 0; tt2 < numT2bins; ++tt2) {
1444 
1445  int tt2_100 = tt2/2; // convert to 100ns binning (units of 100 ns (FLT))
1446  int flt_index = int(tt2/fltBinsPer50ns);
1447  int tt2_1000 = tt2/20; // convert to 1000ns binning
1448  int tt2_1000_comp = tt2_1000;
1449 
1450  // define SLT window for pattern recognition
1451  const int sltWindow = 5;
1452  int col_cycle_load = (tt2%20) + 1; // define column of SLT memory to be refreshed
1453  int col_cycle_compare_low = col_cycle_load - sltWindow + 1; // start compare window
1454  if (col_cycle_compare_low < 1)
1455  col_cycle_compare_low += 20;
1456  int col_cycle_compare_up = col_cycle_compare_low + sltWindow - 1; // end compare window
1457 
1458  // column overflow for pattern recognition
1459  if (col_cycle_compare_up > 20) {
1460  col_cycle_compare_up = 20;
1461  tt2_1000_comp -= 1;
1462  if (tt2_1000_comp < 0)
1463  tt2_1000_comp = 0; // there are no FLTs anyway ...
1464  }
1465 
1466  // ++ Load SLT column col_cycle_load at time tt2 ++
1467 
1468  int npixtot = 0;
1469  /* THIS DOES NOT TAKE INTO ACCOUNT PROLONGATED FLT TRACES !!!!!!!!!!
1470  if (fMultiplicity.count(tt2_100)) {
1471  npixtot = fMultiplicity[tt2_100]; // number of FLT pixels at tt2
1472  }
1473  */
1474  for (map<int, FltTrace>::const_iterator iFltTrace = fFLT.begin();
1475  iFltTrace != fFLT.end(); ++iFltTrace) {
1476  const FltTrace& fltTrace = iFltTrace->second;
1477  if (fltTrace.count(flt_index))
1478  ++npixtot;
1479  }
1480 
1481  int rowMask = 0;
1482 
1483  // Debug =====================================================
1484  if (fVerbosity >= 3) {
1485  cout << " SLT 50ns bin: " << setw(4) << tt2
1486  << ", /2: " << setw(4) << tt2_100
1487  << ", /20: " << setw(3) << tt2_1000
1488  << ", loadCol: " << setw(2) << col_cycle_load
1489  << ", compCol: " << setw(2) << col_cycle_compare_low
1490  << " - " << setw(2) << col_cycle_compare_up
1491  << " compBin1000: " << setw(3) << tt2_1000_comp
1492  << " nFLT: " << setw(3) << npixtot
1493  << " mask: ";
1494  if (npixtot == 0) {
1495  if (fVerbosity >= 4) { // by ralf
1496  cout << "0000000000000000000000.";
1497  } else { // by sergio
1498  cout << "0000000000000000000000";
1499  }
1500  }
1501  }
1502 
1503  // END Debug =====================================================
1504 
1505  if (npixtot > 0) {
1506 
1507  // loop row
1508  for (int row = 1; row <= 22; ++row) {
1509 
1510  int channelMask = (1<<(row-1));
1511  int channelId = 22*(col_cycle_load-1) + row;
1512 
1513  if (fFLT.count(channelId) &&
1514  fFLT[channelId].count(flt_index)) {
1515  rowMask |= channelMask;
1516  }
1517 
1518  // Debug =====================================================
1519  if (fVerbosity >= 3) {
1520  if (fFLT.count(channelId) &&
1521  fFLT[channelId].count(flt_index)) {
1522  if ((fVerbosity >= 4) &&
1523  (fFLT[channelId][flt_index]==2))
1524  cout << "2";
1525  else
1526  cout << "1";
1527  } else
1528  cout << "0";
1529  }
1530  // END Debug =====================================================
1531 
1532  } // loop row
1533 
1534  } // if npixtot>0
1535 
1536  if (!fSLT.count(tt2_1000)) {
1537  fSLT[tt2_1000] = SLTData(detTel.GetLastColumn());
1538  }
1539 
1540  fSLT[tt2_1000].SetRowMask(col_cycle_load, rowMask);
1541  fSLT[tt2_1000].SetParityError(col_cycle_load, pebit);
1542  fSLT[tt2_1000].SetTrigger(col_cycle_load, triggerbit);
1543  fSLT[tt2_1000].SetSpare(col_cycle_load, sparebit);
1544 
1545  // ++ collect SLT channels in window ++
1546 
1547  set<int> pixInCycle; // loop channel matrix 5x22
1548  for (int col = col_cycle_compare_low; col <= col_cycle_compare_up; ++col) {
1549  for (int row = 1; row <= 22; ++row) {
1550 
1551  int channelId = 22*(col-1) + row;
1552 
1553  if (fSLT.count(tt2_1000_comp) &&
1554  fSLT[tt2_1000_comp].HasPixel(channelId)) {
1555 
1556  pixInCycle.insert(channelId); // retrieve channel within current cycle
1557  // (sorted by column!)
1558 
1559  // Debug ===================================================== by sergio
1560  if (fVerbosity == 2 && npixtot > 0)
1561  cout << setw(2) << pixInCycle.size()-1
1562  << ". pixel " << setw(3) << channelId
1563  << " col " << setw(3) << col << " row " << setw(3) << row << endl;
1564  // END Debug =====================================================
1565 
1566  } // if FLT
1567  } // loop row
1568  } // loop col
1569 
1570  // Debug =====================================================
1571  if (fVerbosity >= 3)
1572  cout << ", nPixCycle: " << setw(3) << pixInCycle.size() << endl;
1573  if (fVerbosity >= 2 && npixtot > 0)
1574  cout << " @ SLT time " << setw(3) << tt2 << " col [" << setw(2) << col_cycle_compare_low
1575  << "-" << setw(2) << col_cycle_compare_up << "] -> there are " << setw(2)
1576  << npixtot << " pixels of which " << setw(2) << pixInCycle.size() << " within cycle" << endl;
1577  if (fVerbosity >= 200) {
1578  cout << " pixincycle list: ";
1579  for (set<int>::iterator cyclePixel = pixInCycle.begin();
1580  cyclePixel!=pixInCycle.end(); ++cyclePixel) {
1581  cout << *cyclePixel << " ";
1582  }
1583  }
1584  // END Debug =====================================================
1585 
1586  // ####### SLT GEOMETRY ####### ++++= pattern search ++++++
1587 
1588  unsigned int pattern = 0;
1589  int multipattern = 0;
1590  int colPrev = 0;
1591 
1592  // start loop over pixels within current SLT cycle
1593  for (set<int>::iterator cyclePixel = pixInCycle.begin();
1594  cyclePixel != pixInCycle.end(); ++cyclePixel) {
1595 
1596  int channelId = *cyclePixel; // p[0] is the origin of the pattern
1597  int col = (channelId-1)/22 + 1;
1598  int row = (channelId-1)%22 + 1;;
1599 
1600  if (col != colPrev)
1601  multipattern = 0;
1602  colPrev = col;
1603 
1604  // SLT REQUIRES source pixel at 1st COLUMN
1605  if (col != col_cycle_compare_low)
1606  continue;
1607 
1608  // SLT Pattern search
1609  unsigned int SLTpattern = TestPattern(pixInCycle, col, row,
1610  multipattern,
1611  usedSltPixels);
1612  if (SLTpattern > 0)
1613  pattern = SLTpattern;
1614 
1615  // set SLT time
1616  if (pattern > 0) {
1617 
1618  if (timeT2 == 0)
1619  timeT2 = tt2-(sltWindow-1); // set SLT time T2 (start of SLT window!!)
1620 
1621  if (fSLT.count(tt2_1000_comp)) {
1622  fSLT[tt2_1000_comp].SetSLTPattern(col, pattern);
1623  } else {
1624  //ERROR ("MISSING SLT DATA ?????!!!!! ");
1625  }
1626 
1627  // Debug ===================================================== only if pixInCycle.size()>3
1628  //if (fVerbosity>=6)
1629  //cout << " -> pattern " << setw(3) << pattern;
1630  // END Debug =====================================================
1631 
1632  } // pattern>0
1633 
1634  } // end loop pixels in cycle
1635 
1636  // Debug =====================================================
1637  if (fVerbosity >= 1 && fVerbosity < 3 && pattern > 0 && pixInCycle.size() > 3)
1638  cout << "=-=-=-=-> SecondLevelTrigger at time " << setw(4) << tt2
1639  << " col " << setw(2) << col_cycle_compare_low << " with pattern " << setw(3) << pattern << endl;
1640  // END Debug =================================================
1641 
1642  // Debug bits ================================================
1643  if (fVerbosity >= 2 && pattern > 0 && pixInCycle.size() > 3) {
1644  for (int col = col_cycle_compare_low; col <= col_cycle_compare_up; ++col) {
1645  cout << " ==> col " << setw(2) << col << " pixel bits: ";
1646  for (int b = 0; b < 22; ++b) {
1647  unsigned int mask = (1 << b);
1648  if (fSLT[tt2_1000_comp].GetRowMask(col) & mask)
1649  cout << "1";
1650  else
1651  cout << "0";
1652  }
1653  if (col == col_cycle_compare_low) {
1654  cout << " -+-+-+- pattern: " << setw(3) << pattern << " = ";
1655  for (int b = 23; b < 30; ++b) {
1656  unsigned int mask = (1 << b);
1657  if (fSLT[tt2_1000_comp].GetSLTDataWord(col) & mask)
1658  cout << "1";
1659  else
1660  cout << "0";
1661  }
1662  }
1663  cout << endl;
1664  } // end loop col
1665  } // END Debug bits =========================================
1666 
1667  // Debug =====================================================
1668  //if (fVerbosity>=5) {
1669  // cout << endl;
1670  //}
1671  // END Debug =====================================================
1672 
1673  if (col_cycle_load == 1)
1674  usedSltPixels.clear();
1675  else if (col_cycle_load == 20)
1676  sltMultiplicity[tt2_1000] = usedSltPixels.size();
1677 
1678  } // end loop over times tt2
1679 
1680  // Fill SLTWord at timeT2 (50ns)
1681 
1682  int timeT2_1000 = timeT2/20;
1683  int timeT2_100 = timeT2_1000*10;
1684  timeT2 = timeT2_1000*20;
1685 
1686  // SLT Debug =====================================================
1687  int SLT_T2[20];
1688  for (int tr_col = 1; tr_col <= 20; ++tr_col) {
1689  if (fSLT.count(timeT2_1000)) {
1690  SLT_T2[tr_col-1] = fSLT[timeT2_1000].GetSLTDataWord(tr_col);
1691  }
1692  }
1693  if (fVerbosity >= 1 && timeT2_100 > 0) {
1694  cout << "\n"
1695  " **** SLT T2 time (units of 100 ns) is: " << timeT2_100
1696  << " (50ns: " << timeT2 << ", 1000ns: " << timeT2_1000 << ")"
1697  " first SLT pattern was: "
1698  "\n"
1699  " ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ "
1700  "\n" << endl;
1701  for (int col = 1; col <= 20; ++col) {
1702  cout << " ==> col " << setw(2) << col << " pixel bits: ";
1703  for (int b = 0; b < 22; ++b){
1704  unsigned int mask = (1 << b);
1705  if (SLT_T2[col-1] & mask)
1706  cout << "1";
1707  else
1708  cout << "0";
1709  }
1710  unsigned int pattern = SLT_T2[col-1] & 0x03f800000;
1711  pattern = pattern >> 23;
1712  cout << " -+-+-+- pattern: " << setw(3) << pattern << endl;
1713  }
1714  cout << "\n"
1715  "-+-+- SLT multiplicity at each 1 mus ===>" << endl;
1716  for (int t = 0; t < numT2bins/20; ++t) {
1717  int sltM = 0;
1718  if (sltMultiplicity.count(t) > 0)
1719  sltM = sltMultiplicity[t];
1720  cout << setw(4) << sltM << ", ";
1721  if ((t+1)%20 == 0)
1722  cout << endl;
1723  }
1724  cout << endl;
1725  }
1726  // END SLT Debug =====================================================
1727 
1728  return timeT2_1000;
1729 }
1730 
1731 
1732 unsigned int
1733 FdTriggerSimulator::TestPattern(const set<int>& pixInCycle, int col, int row,
1734  int& multipattern,
1735  vector<int>& usedInSlt)
1736 {
1737  if (pixInCycle.size() <= 3) {
1738  return 0;
1739  }
1740 
1741  int pixelnumber;
1742  int pixels;
1743  unsigned int pattnum = 0;
1744 
1745  int p[4]; // pixels numbers for this pattern
1746  short r[4]; // row number
1747  short c[4]; // col number
1748  p[0] = 22*(col-1) + row; //p[0] is the origin of the pattern
1749  c[0] = ((p[0] - 1) / 22) + 1;
1750  r[0] = ((p[0] - 1) % 22) + 1;
1751 
1752  // find candidate pixels of the pattern, given the starting pixel
1753 
1754  for (unsigned int patt = 1; patt < 109; ++patt) { // start loop over 108 patterns
1755 
1756  //usedInSlt.clear();
1757  pixels = 1;
1758 
1759  for (int m = 1; m < 4; ++m ) { //start loop over neighbours
1760 
1761  if ((row%2) == 0) { // even row
1762  p[m] = p[0] + kSltDiffEven[patt-1][m-1]; //abs pixel number
1763  pixelnumber = p[m];
1764  } else { // odd row
1765  p[m] = p[0] + kSltDiffOdd[patt-1][m-1]; // abs pixel number
1766  pixelnumber = p[m];
1767  }
1768 
1769  c[m] = ((p[m] - 1) / 22 ) + 1; //col for this pixel
1770  r[m] = ((p[m] - 1) % 22 ) + 1; //row for this pixel
1771 
1772  if (abs(r[0] - r[m]) > 4)
1773  pixelnumber = 0; // to avoid patterns across row 1->22
1774 
1775  if (pixInCycle.find(pixelnumber)!=pixInCycle.end()) {
1776  ++pixels;
1777  }
1778 
1779  }// end loop over neighbours
1780 
1781  if (pixels == 4) {
1782 
1783  pattnum = patt;
1784  ++multipattern;
1785  for (int m = 0; m < 4; ++m) {
1786  if (find(usedInSlt.begin(), usedInSlt.end(), p[m]) == usedInSlt.end())
1787  usedInSlt.push_back(p[m]);
1788  }
1789 
1790  // Debug ================================================
1791  if (fVerbosity >= 6) { // by ralf
1792  cout << "\n ### FOUND PATTERN no. " << setw(3) << patt
1793  << " = [";
1794  for (int dbgM = 1; dbgM < 4; ++dbgM) {
1795  if ((row%2) == 0) { // even row
1796  cout << kSltDiffEven[patt-1][dbgM-1]; //abs pixel number
1797  } else { // odd row
1798  cout << kSltDiffOdd[patt-1][dbgM-1]; // abs pixel number
1799  }
1800  cout << ", ";
1801  }
1802  cout << "] = {" << p[0] << ", " << p[1] << ", " << p[2] << ", " << p[3] << "}"
1803  << " from col " << c[0] << " row " << r[0] << " - mult = " << multipattern
1804  << endl;
1805  } else if (fVerbosity >= 2) { // by sergio
1806  cout << " ### FOUND PATTERN n." << setw(3) << patt
1807  << " = ["<< setw(3) << p[0] << "," << setw(3)<< p[1] << ","
1808  << setw(3)<< p[2] << "," << setw(3)<< p[3] << "]"
1809  << " from col " << setw(2)<< c[0] << " row "
1810  << setw(2)<< r[0] << " - mult = " << multipattern << endl;
1811  }
1812  if (fVerbosity >= 7) {
1813  for (int testCol = 0; testCol < 4; ++testCol) {
1814  cout << " col=" << col+testCol << " ";
1815  for (int testRow = 1; testRow <= 22; ++testRow) {
1816  int testPxlId = (col+testCol-1)*22 + testRow;
1817  if (pixInCycle.find(testPxlId) == pixInCycle.end())
1818  cout << ".";
1819  else {
1820  bool testIsPat = false;
1821  for (int testM = 1; testM < 4; ++testM) { // start loop over neighbours
1822  int testPxlIdSLT = 0;
1823  if ((row%2) == 0) { // even row
1824  testPxlIdSLT = p[0] + kSltDiffEven[patt-1][testM-1]; //abs pixel number
1825  } else { // odd row
1826  testPxlIdSLT = p[0] + kSltDiffOdd[patt-1][testM-1]; // abs pixel number
1827  }
1828  if (testPxlId == testPxlIdSLT)
1829  testIsPat = true;
1830  }
1831  if (testIsPat || (col+testCol == col && testRow == row))
1832  cout << "+";
1833  else
1834  cout << "1";
1835  }
1836  }
1837  cout << "\n";
1838  }
1839  }
1840  // END Debug ================================================
1841 
1842  }
1843 
1844  } // end loop over patterns
1845 
1846  if (multipattern > 1) { // if exist MULTIPATTERN
1847  pattnum = 127;
1848  } // end if MULTIPATTERN
1849 
1850  return pattnum;
1851 }
1852 
1853 
1854 TMirrorEvent*
1855 FdTriggerSimulator::MakeMirrorEvent(fevt::Telescope& tel,
1856  const evt::Event& event,
1857  const TimeInterval& offsetFdSd,
1858  const int sltTimeShift)
1859 {
1860  const fdet::Telescope& detTel = Detector::GetInstance().GetFDetector().GetTelescope(tel);
1861  const fdet::Camera& detCamera = detTel.GetCamera();
1862  const int SLTbin = detCamera.GetSLTTriggerBin();
1863  const double binsize = detCamera.GetFADCBinSize();
1864  const unsigned int tracelength = detCamera.GetFADCTraceLength();
1865 
1867 
1868  const fevt::FEvent& theFEvent = event.GetFEvent();
1869  const int eyeId = tel.GetEyeId();
1870  const int telId = tel.GetId();
1871 
1872  tel.MakeTriggerData();
1873  fevt::TelescopeTriggerData& telTrigger = tel.GetTriggerData();
1874 
1875  // RU Fri May 13 11:09:20 CEST 2005
1876  TMirrorEvent* const MirrorEvent = new TMirrorEvent();
1877 
1878  // Objects to build the event
1879  TMirrorEventHeader* const header = MirrorEvent->GetEventHeader();
1880  TMirrorPixelData* const pixelData = MirrorEvent->GetPixelData();
1881  TMirrorPixelList* const pixelList = MirrorEvent->GetPixelList();
1882  TMirrorFADCData* const fadcData = MirrorEvent->GetFADCData();
1883 
1884  // EventHeader Info
1885  header->SetEventLabel(TMirrorEventHeader::kUnlabelled); // classifcation is done by TLT (kShowerEvent)
1886  //header->SetEventLabel( TMirrorEventHeader::kShowerEvent );
1887  header->SetEventNo(theFEvent.GetHeader().GetId());
1888  header->SetEventType(TMirrorEventHeader::kSimulatedEvent);
1889 #if FDEVENTLIB_VERSION_CODE < ModuleVersionCode(4,0,0)
1890  header->SetTriggerNum(3000);
1891 #else /* pre-v4 */
1892  header->SetTriggerNo(3000);
1893 #endif /* FDEventLib at least as recent as v4 */
1894  /*
1895  * SLT page size is 1000 for old and new (HEAT) electronics.
1896  * TODO: Should be in FModelConfig?
1897  */
1898  const int onePage = 1000;
1899 
1900  const int nextPageDelay = onePage - SLTbin;
1901 
1902  // Time assigned in the LightAtDiaphragmSimulator as the begin of the
1903  // photon trace. This time represents the time of the first photons at the
1904  // apperture of the telescope
1905  // WARNING: In FdElectronicsSimulator the start time of the "prolonged" ADC
1906  // traces (PhotonStartTime-(SLTbin*binsize))
1907  TimeStamp timeEvent = tel.GetSimData().GetPhotonsStartTime();
1908  const double eventStart = (sltTimeShift + (onePage-SLTbin)) * 100.*ns; // used to be FADC bin size, but that's not correct! (This is SLT!)
1909  timeEvent += TimeInterval(eventStart);
1910  timeEvent -= offsetFdSd;
1911 
1912  ostringstream info;
1913  info << "Creating mirror event";
1914  info << " eye=" << eyeId << " tel=" << telId
1915  << " run=1 event=" << theFEvent.GetHeader().GetId()
1916  << " tStart=" << eventStart/ns << " ns";
1917  INFO(info);
1918 
1919  UInt_t nextPageNanoTime = timeEvent.GetGPSNanoSecond();
1920  UInt_t nextPageSec = timeEvent.GetGPSSecond();
1921 
1922  header->SetNextPageNanoTime(nextPageNanoTime);
1923  header->SetNextPageTime(nextPageSec);
1924  header->SetTriggerSource(TMirrorEventHeader::kInternalTrigger);
1925  header->SetTimeCorrectionParameters(100.0, 0.0);
1926 
1927  header->SetEyeNo(eyeId);
1928  header->SetMirrorNo(telId);
1929  header->SetNextPageDelay(nextPageDelay);
1930 
1931  //#warning ATTENTION! Run number in the FDAS output file is set to 1 (one). Not suitable for blind analysis
1932  header->SetRunNo(1);
1933 
1934  header->SetT3Id(4097);
1935  header->SetTimeStampHigh(header->GetGPSTime()); // TODO is this needed ?
1936  header->SetTimeStampLow(0);
1937 
1938  //MirrorEvent->GetEventHeader()->Dump();
1939 
1940  // Real signal
1941 
1942  // PixelList Info
1943  pixelList->SetNumPixels(0);
1944 
1945  Fd::PixelNumberRec pixelObj;
1946  Fd::PixelNumber pixel = &pixelObj;
1947  Fd::SetEyeNo(pixel, eyeId);
1948  Fd::SetMirrorNo(pixel, telId);
1949 
1950  for (list<int>::iterator iReadOutChannel = fChannelReadOutList.begin();
1951  iReadOutChannel != fChannelReadOutList.end(); ++iReadOutChannel) {
1952 
1953  const unsigned int channelId = *iReadOutChannel;
1954  // Debug ================================================
1955  if (fVerbosity >= 11)
1956  cout << " adding trace eyeId=" << eyeId
1957  << " telId=" << telId
1958  << " pixelId=" << channelId
1959  << " (eyePixId=" << Fd::GetEyePixelNo( pixel ) << ")";
1960  // END Debug ================================================
1961 
1962  const fdet::Channel& detChannel = detTel.GetChannel(channelId);
1963  if (!detChannel.IsVirtual()) {
1964  const unsigned int pixelId = detChannel.GetPixelId();
1965  if (tel.HasPixel(pixelId, fevt::ComponentSelector::eDeSelected) &&
1968  if (fVerbosity >= 11) {
1969  cout << " pixel is eDeSelected, status=";
1970  if (tel.HasPixel(pixelId, fevt::ComponentSelector::eExists))
1971  cout << tel.GetPixel(pixelId, fevt::ComponentSelector::eExists).GetStatus();
1972  else
1973  cout << "doesn't exist";
1974  cout << endl;
1975  }
1976  continue;
1977  }
1978  }
1979 
1980  // eye_no and mirror_no will not change
1981  Fd::SetPixelNo(pixel, channelId);
1982  pixelList->AddPixel(pixel);
1983 
1984  // FADCData info
1985 
1986  // union which contains eye, mirror and pixel number
1987  //Fd::PixelNumber pnumber = pixelList->GetPixel(i);
1988  // pnumber is used to select from internal 22*24 matrix
1989  TFADCData* const data = fadcData->GetPixelFADCData(pixel);
1990  // access to the first bin, others are word[1] ... [999]
1991  TFADCData::FADCDataWord word = data->GetFADCTrace();
1992  data->SetPixelNumber(pixel); // v2r0
1993 
1994  // The hardware trace starts at bin 0 and ends at bin 999 (1000 bins)
1995  // The number of bins readout can be limited around the peak of interest
1996  // as it is done for the calibration
1997  //const fdet::Channel& detChannel = detTel.GetChannel(channelId);
1998 
1999  data->SetTraceStartBin(0);
2000  data->SetTraceEndBin(tracelength-1);
2001  if (tracelength == 1000)
2002  data->SetTraceResolution(TFADCData::kFADC_RESOLUTION_1000_BINS);
2003  else if (tracelength == 2000)
2004  data->SetTraceResolution(TFADCData::kFADC_RESOLUTION_2000_BINS);
2005  // 4000 is not tested and thus not supported by FDEventLib
2006  //else if (tracelength == 4000) {
2007  // data->SetTraceResolution(TFADCData::kFADC_RESOLUTION_4000_BINS);
2008  else {
2009  ostringstream errMsg;
2010  errMsg << "FADC trace length of " << tracelength
2011  << " has no correspondance in FDEventLib";
2012  ERROR(errMsg);
2013  throw OutOfBoundException(errMsg.str());
2014  }
2015 
2016  // set mean, variance and threshold
2017  unsigned int Mean = 0;
2018  unsigned int RMS = 0;
2019  unsigned int actualThr = 0;
2020  if (channelId <= detTel.GetLastPixelId()) {
2021  // mapped pixel Id
2022  const unsigned int pixelId = detTel.GetChannel(channelId).GetPixelId();
2023  if (tel.HasPixel(pixelId)) {
2024  const fevt::PixelSimData& pxsimdata = tel.GetPixel(pixelId).GetSimData();
2025  Mean = int(ceil(pxsimdata.GetMean()));
2026  RMS = int(ceil(pxsimdata.GetRMS()));
2027  actualThr = pxsimdata.GetThreshold();
2028  }
2029  }
2030 
2031  data->SetVariance(RMS*RMS);
2032  data->SetMean(Mean);
2033  data->GetPixelMonitorData()->fActualThreshold = actualThr;
2034 
2035  // Debug ================================================
2036  if (fVerbosity >= 11)
2037  cout << " rms=" << RMS
2038  << " mean=" << Mean
2039  << " threshold=" << actualThr;
2040  // END Debug ================================================
2041 
2042  if (!tel.HasChannel(channelId)) { // skip non-sim pixels
2043 
2044  ostringstream err;
2045  err << " Channel/pixel with id=" << channelId << " was listed for FADC readout, "
2046  << " but there is no object like this available!"
2047  << endl;
2048  ERROR(err.str());
2049 
2050  } else {
2051 
2052  const fevt::Channel& ch = tel.GetChannel(channelId);
2053  const fevt::ChannelSimData& channel_sim = ch.GetSimData();
2054  const TraceI& fadc_trace = channel_sim.GetFADCTrace(fevt::FdConstants::eTotal);
2055  const int nFADCbins = fadc_trace.GetSize();
2056 
2057  // Debug ================================================
2058  if (fVerbosity >= 11)
2059  cout << " simTraceSize=" << nFADCbins << " trace:" << endl;
2060  // END Debug ================================================
2061 
2062  const double sltBinsPerFltBin = detCamera.GetFADCBinSize() / (100.*ns);
2063  const int fltTimeShift = int(sltTimeShift / sltBinsPerFltBin);
2064 
2065  for(unsigned int k = 0; k < tracelength; ++k) {
2066 
2067  // Accessing via bits.fadcData is dangerous, names will change in v2r0
2068  // better use FADCDataWordSetData(&word[k],p0_data[k]) which is just a
2069  // macro and as fast as the direct access but portable.
2070  // I didn't provide C++ accessors for these elements simply for
2071  // speed reasons.
2072  FADCDataWordSetWord(&word[k], 0); // 16 bits of the union FDAS
2073 
2074  const int tbin = k + fltTimeShift;
2075 
2076  unsigned short int value = 0;
2077  if (tbin >= nFADCbins) {
2078  ostringstream err;
2079  err << "Bin=" << tbin << " out of simulated FADC trace min=" << 0
2080  << " max=" << nFADCbins-1 << " THIS SHOULD NEVER HAPPEN!"
2081  << endl;
2082  ERROR(err.str());
2083  } else
2084  value = fadc_trace[tbin];
2085 
2086  // Debug ================================================
2087  if (fVerbosity >= 12)
2088  cout << " trace bin: " << setw(4) << k
2089  << " shifted " << setw(4) << tbin
2090  << " value=" << setw(5) << value;
2091  // END Debug ================================================
2092 
2093  if (fFLT.count(channelId) &&
2094  fFLT[channelId].count(tbin)) {
2095 
2096  if (fFLT[channelId][tbin] == 1) {
2097 
2098  // trigger bit
2099  value |= (1<<15);
2100 
2101  // Debug ================================================
2102  if (fVerbosity >= 12)
2103  cout << " FLT bit set";
2104  // END Debug ================================================
2105 
2106  } else if (fFLT[channelId][tbin] == 2) {
2107  // Debug ================================================
2108  if (fVerbosity >= 12)
2109  cout << " (FLT prolongated)";
2110  // END Debug ================================================
2111 
2112  }
2113 
2114  }
2115 
2116  FADCDataWordSetWord( &(word[k]), value ); // FDAS
2117 
2118  // Debug ================================================
2119  if (fVerbosity >= 12)
2120  cout << endl;
2121  // END Debug ================================================
2122 
2123  } // loop fadc bins
2124  } // has channel
2125 
2126  delete data; // RU: THIS IS NOT DONE AUTOMATICALLY !!!
2127 
2128  } // loop read out pixels
2129 
2130  // Filling TMirrorPixelData
2131  // I assume that all bits of the TMirrorPixelData are cleared
2132  // ---> ALSO DO SHIFT TO SLT TRIGGER TIME !!!
2133  vector<fevt::SLTData> sltData;
2134  const unsigned int nSltBins = detCamera.GetSLTTraceLength();
2135  for (unsigned int t2bin = 0; t2bin < nSltBins; ++t2bin ) { // 100 bins of 1mu s each
2136 
2137  const int t2binShift = t2bin + sltTimeShift/10;
2138 
2139  if (fVerbosity > 101) {
2140  cout << " add slt t2bin=" << t2bin << " t2binShift=" << t2binShift << " \n";
2141  }
2142 
2143  fevt::SLTData sltDataCol(20);
2144  for (unsigned int col = 1; col <= 20; ++col) {
2145  TMirrorPixelData::PixelDataWord pword = pixelData->GetPixelData(col, t2bin);
2146  int slt_word = 0;
2147  if (fSLT.count(t2binShift)) {
2148  slt_word = fSLT[t2binShift].GetSLTDataWord(col);
2149  }
2150  PixelDataSetWord(pword, slt_word); // FDAS
2151  sltDataCol.SetSLTDataWord(col, slt_word); // Offline
2152  }
2153  sltData.push_back(sltDataCol);
2154  }
2155  telTrigger.SetSLTData(sltData);
2156 
2157  // Filling of multiplicity
2158  // Multiplicity is always 1000 words
2159  const double multiplicityBinsPerFltBin = (100.*ns) / detCamera.GetFADCBinSize();
2160  telTrigger.MakeMultiplicity(1000, binsize);
2161  TraceI& multiplicityTrace = telTrigger.GetMultiplicity();
2162  TMirrorPixelData::MultiplicityDataWord multiplicityData = pixelData->GetMultiplicityData();
2163  for (unsigned int tbin = 0; tbin < 1000; ++tbin) {
2164 
2165  // DKH: For HEAT, every second fMultiplicity bin is taken
2166  const int tbinShift = (tbin + sltTimeShift) * multiplicityBinsPerFltBin;
2167 
2168  int multiplicity = 0;
2169  // Note that fMultiplicity is in the same units as the FADC traces (50ns for HEAT)
2170  if (fMultiplicity.count(tbinShift))
2171  multiplicity = fMultiplicity[tbinShift];
2172 
2173  multiplicityData[tbin] = multiplicity; // FDEventLib
2174  multiplicityTrace[tbin] = multiplicity; // Offline
2175  }
2176 
2177  return MirrorEvent;
2178 }
2179 
2180 
2181 bool
2182 FdTriggerSimulator::AddEyeEvent(fevt::Eye& eye, evt::Event& event,
2183  TEyeEvent& EyeEvent)
2184 {
2186 
2187  eye.MakeHeader();
2188 
2189  fevt::FEvent& theFEvent = event.GetFEvent();
2190  fevt::EyeHeader& headerEye = eye.GetHeader();
2191  fevt::Header& headerFEvent = theFEvent.GetHeader();
2192  evt::Header& evtHeader = event.GetHeader();
2193 
2194  const int eyeId = eye.GetId();
2195  const int eventId = theFEvent.GetHeader().GetId();
2196  const int runId = 1; // TODO make this configuratble at least via xml
2197 
2198  TEyeEventHeader* const eyeheader = EyeEvent.GetEventHeader();
2199 
2200  eyeheader->SetEventNo(eventId);
2201  eyeheader->SetRunNo(runId);
2202  eyeheader->SetTimeCorrectionParameters(100, 0);
2203  //eyeheader->Set
2205  //SetEyeDaqDeadTime(unsigned long long dead_time)
2206  //SetIsRejectedT3 CDAS veta
2207  //SetLidarIsTriggered()
2208  //SetMirrorDaqDeadTime(unsigned long long,unsigned int mirror_id);
2209  //SetMirrorNSkippedTriggers(unsigned int,unsigned int mirror_id);
2210  //void SetMirrorPresent(UInt_t);
2211  //SetNRejectedT3(unsigned int n_rejected) by CDAS
2212  //SetTotalT3DeadTime(float total_time)
2213 
2214 
2215  // Added by T. Porter - need to fill some more of the header parameters
2216  // based on current eye for HRec/HSim to work
2217  eyeheader->SetEyeNo(eyeId);
2218 
2219  // RawEvent part of the Event
2220  if (!event.HasRawEvent()) {
2221  INFO ("Making raw event for the current event");
2222  event.MakeRawEvent();
2223  }
2224 
2225  // this fills the AUGER raw event
2226  AugerEvent& rawEvent = event.GetRawEvent();
2227  rawEvent.PushEvent(EyeEvent);
2228  rawEvent.EventId = eventId;
2229 
2230  // Fill offline header
2231  unsigned int sec = eyeheader->GetTimeStamp()->GetGPSSec();
2232  unsigned int nsec = eyeheader->GetTimeStamp()->GetNanoSec();
2233  utl::TimeStamp tstamp(sec, nsec);
2234 
2235  //unsigned int runno = eyeheader->GetRunNo();
2236  //unsigned int evno = eyeheader->GetEventNo();
2237  int eclass = eyeheader->GetEventClass();
2238  int etype = eyeheader->GetEventType();
2239 
2240  // fill evt::Header of Event
2241  const utl::TimeStamp& previous_time = evtHeader.GetTime();
2242  std::string previous_str = evtHeader.GetId();
2243  if (previous_time.GetGPSSecond() == 0 ||
2244  previous_time > tstamp) {
2245  event.GetHeader().SetTime(tstamp);
2246  }
2247 
2248  /*
2249  ostringstream id_str;
2250  if (previous_str!="")
2251  id_str << previous_str << "__";
2252  id_str << "eye" << eyeid
2253  << "_run" << runno
2254  << "_event" << evno;
2255  theEvent.GetHeader().SetId(id_str.str());
2256  */
2257 
2258  // Fill header of FEvent
2259  headerFEvent.SetNEyes(headerFEvent.GetNEyes() + 1);
2260 
2261  // Fill header of eye
2262  headerEye.SetTimeStamp(tstamp);
2263  headerEye.SetEventNumber(eventId);
2264  headerEye.SetRunNumber(runId);
2265  headerEye.SetEventType(static_cast<fevt::EyeHeader::EventType>(etype));
2266  headerEye.SetEventClass(static_cast<fevt::EyeHeader::EventClass>(eclass));
2267 
2268  // set telescopes in DAQ bits
2270  iTel != eye.TelescopesEnd(fevt::ComponentSelector::eInDAQ); ++iTel) {
2271  eyeheader->SetMirrorPresent(iTel->GetId());
2272  }
2273 
2274  const fdet::FDetector& detFD = Detector::GetInstance().GetFDetector();
2275  const fdet::Eye& detEye = detFD.GetEye(eye);
2276 
2277  // copy the telescope time offset into the Offline data structure
2278  for (unsigned int iMirror = detEye.GetFirstTelescopeId();
2279  iMirror <= detEye.GetLastTelescopeId(); ++iMirror) {
2280 
2281  if (eyeheader->IsMirrorDataPresent(iMirror)) {
2282 
2283  if (!eye.HasTelescope(iMirror, ComponentSelector::eInDAQ))
2284  eye.MakeTelescope(iMirror, ComponentSelector::eInDAQ);
2285 
2286  fevt::Telescope& telescope = eye.GetTelescope(iMirror, ComponentSelector::eInDAQ);
2287  telescope.SetTimeOffset(eyeheader->GetMirrorTimeOffset(iMirror));
2288 
2289  } // if present in FDEventLib event
2290  }
2291 
2292  return true;
2293 }
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
unsigned int GetId() const
Definition: FEvent/Eye.h:54
Trigger data for an fevt::Eye.
ComponentSelector::Status GetStatus() const
Definition: FEvent/Pixel.h:54
double GetFADCBinSize() const
const double degree
Point object.
Definition: Point.h:32
Description of trigger data for one Telescope.
Definition: SLTData.h:34
Description of the electronic channel for the 480 channels of the crate.
double GetPhi(const CoordinateSystemPtr &coordinateSystem) const
azimuth (phi) angle in spherical and cylindrical coordinates
Definition: BasicVector.h:254
Header & GetHeader()
Definition: FEvent.h:92
fevt::EyeHeader & GetHeader()
Header for this Eye Event.
Definition: FEvent/Eye.cc:180
int GetNumberOfPhotonBins() const
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
evt::Header & GetHeader()
void SetRmsBoxcarsum(double v)
Definition: PixelSimData.h:147
void SetNumberOfReadOutPixels(const int n)
void SetStatus(const ComponentSelector::Status status)
bool HasFEvent() const
double GetTheta(const CoordinateSystemPtr &coordinateSystem) const
zenith (theta) angle in spherical coordinates
Definition: BasicVector.h:248
int GetId() const
Definition: FEvent/Header.h:21
int GetThreshold() const
Get the simulated trigger threshold of the pixel.
Definition: PixelSimData.h:132
Header of Eye-level event.
Definition: EyeHeader.h:32
void SetT3Accepted(bool is)
void SetTimeOffset(const unsigned int toffset)
void SetT3SDP(double theta, double phi, double azimuthAtGround)
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
unsigned int GetEyeId() const
bool IsVirtual() const
utl::Vector GetAxis() const
const Channel & GetChannel(const unsigned int channelId) const
Get Channel by id, throw utl::NonExistentComponentException if n.a.
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
PixelSimData & GetSimData()
Definition: FEvent/Pixel.h:35
bool HasFADCTrace(const FdConstants::LightSource source) const
Check that source /par source is present.
void Init()
Initialise the registry.
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
boost::filter_iterator< ComponentSelector, AllEyeIterator > EyeIterator
selective Eye iterators
Definition: FEvent.h:55
utl::TimeStamp GetPhotonsStartTime() const
Start Time of the photons trace.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
bool HasPhotonTrace(const FdConstants::LightSource source) const
Check that trace for source /par source is present.
Definition: PixelSimData.h:51
Fluorescence Detector Channel Simulated Data Event.
unsigned int GetFirstTelescopeId() const
First telescope id in the eye.
void SetTimeStamp(const utl::TimeStamp ts)
Definition: EyeHeader.h:137
void MakeTelescope(const unsigned int telescopeId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Make Telescope telescopeId.
Definition: FEvent/Eye.cc:102
void SetT3NPixels(unsigned int n)
ChannelSimData & GetSimData()
void SetStatus(const ComponentSelector::Status status)
Definition: FEvent/Eye.h:119
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
bool HasSimData() const
const utl::TimeStamp & GetTime() const
Definition: Event/Header.h:33
Exception for reporting variable out of valid range.
void SetNumberOfFltPixelsFromBackground(const int n)
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
bool HasPixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData) const
Check if the pixel is in the event.
fevt::TelescopeSimData & GetSimData()
Description of simulated data for one Telescope.
Class representing a document branch.
Definition: Branch.h:107
const short kSltDiffOdd[][3]
void SetMeanBoxcarsum(double v)
Definition: PixelSimData.h:146
unsigned int GetLastPixelId() const
Channel & GetChannel(const unsigned int channelId)
void MakeMultiplicity(const unsigned int size=0, const double binSize=0)
Fluorescence Detector Pixel event.
Definition: FEvent/Pixel.h:28
const double ns
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:230
constexpr double kPi
Definition: MathConstants.h:24
double abs(const SVector< n, T > &v)
const Data result[]
void SetEventType(const EventType et)
Definition: EyeHeader.h:140
const double tracelength
Definition: FitterUtil.h:12
const Telescope & GetTelescope(const unsigned int telescopeId) const
Find Telescope by numerical Id.
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
int GetFADCTraceLength() const
#define EVENTCLASSIFIER_PARAMETERS_HEAT_2
void SetNumberOfFltPixels(const int n)
utl::TraceI & GetFADCTrace(const FdConstants::LightSource source=FdConstants::eTotal)
#define EVENTCLASSIFIER_PARAMETERS_OLD
bool HasSimData() const
Definition: FEvent/Pixel.h:38
boost::filter_iterator< ComponentSelector, AllTelescopeIterator > TelescopeIterator
selective Telescope iterators
Definition: FEvent/Eye.h:72
SizeType GetSize() const
Definition: Trace.h:156
void SetT3Class(const std::string &label)
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
Fluorescence Detector Channel Event.
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
void MakeHeader()
Definition: FEvent/Eye.cc:195
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
void SetFltTime(int v)
Definition: PixelSimData.h:148
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:207
double GetRMS() const
Get the ADC variance.
Definition: PixelSimData.h:127
void SetSltTimeShift(const int n)
void SetNumberOfPixelsWithShowerPhotons(const int n)
Pixel & GetPixel(const unsigned int pixelId, const ComponentSelector::Status status=ComponentSelector::eHasData)
Retrieve Pixel by Id, throw exception if not existent.
int GetNumSamples() const
Get the no. of samples for running sums.
Definition: PixelSimData.h:117
int GetFLTProlongation() const
const std::string & GetId() const
Get the event identifier.
Definition: Event/Header.h:31
const utl::TimeInterval & GetSDTimeOffset() const
Time Offset of this eye with respect to SD.
constexpr double kSpeedOfLight
void SetTLTAccepted(const bool is)
Detector description interface for Telescope-related data.
A TimeInterval is used to represent time elapsed between two events.
Definition: TimeInterval.h:43
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
bool HasChannel(const unsigned int channelId) const
const Telescope & GetTelescope(const fevt::Telescope &eventTel) const
Get fdet::Telescope from fevt::Telescope.
Definition: FDetector.cc:150
unsigned long GetGPSSecond() const
GPS second.
Definition: TimeStamp.h:124
void SetNumberOfFltPixelsFromShower(const int n)
double GetFADCBinSize() const
double GetGPSNanoSecond() const
GPS nanosecond.
Definition: TimeStamp.h:127
unsigned int GetId() const
void SetSLTDataWord(unsigned int col, const unsigned int sltDataWord)
Definition: SLTData.cc:102
void SetNEyes(const int n)
Definition: FEvent/Header.h:28
const short kSltDiffEven[][3]
uint16_t * data
Definition: dump1090.h:228
double GetMean() const
Get the ADC baseline.
Definition: PixelSimData.h:122
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
unsigned int GetVirtualChannelId() const
utl::Point GetPosition() const
utl::TraceD & GetPhotonTrace(const FdConstants::LightSource source=FdConstants::eTotal)
Simulated Photon Trace.
Definition: PixelSimData.h:37
Vector object.
Definition: Vector.h:30
unsigned int GetLastTelescopeId() const
Last telescope id in the eye.
bool HasRawEvent() const
Main configuration utility.
Definition: CentralConfig.h:51
int GetNEyes() const
Number of eyes in the event.
Definition: FEvent/Header.h:23
void SetSLTData(const std::vector< fevt::SLTData > &s)
fevt::EyeTriggerData & GetTriggerData()
Trigger data for this eye.
Definition: FEvent/Eye.cc:155
static int binsize
Definition: XbAlgo.cc:25
unsigned int GetLastColumn() const
Fluorescence Detector Telescope Event.
double Mean(const std::vector< double > &v)
Definition: Functions.h:31
void SetTLTLabel(const std::string &label)
Description of trigger data for one Telescope.
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
void SetRunNumber(const unsigned int runno)
Definition: EyeHeader.h:138
void SetEventClass(const EventClass ec)
Definition: EyeHeader.h:141
void SetRowMask(unsigned int col, const int mask)
Definition: SLTData.cc:126
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
constexpr double m
Definition: AugerUnits.h:121
fevt::TelescopeTriggerData & GetTriggerData()
Header for an fevt::FEvent.
Definition: FEvent/Header.h:16
TimeStamp GetTimeStamp() const
Definition: UTCDateTime.cc:115
boost::filter_iterator< ComponentSelector, ConstAllTelescopeIterator > ConstTelescopeIterator
Definition: FEvent/Eye.h:73
void MakeTriggerData()
Definition: FEvent/Eye.cc:170
void SetEventNumber(const unsigned int evno)
Definition: EyeHeader.h:139
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
void SetFltDuration(int v)
Definition: PixelSimData.h:149
#define EVENTCLASSIFIER_PARAMETERS_STD
void SetSltTriggerTime(const int n)
Fluorescence Detector Pixel Simulated Data.
Definition: PixelSimData.h:28
Global event header.
Definition: Event/Header.h:27
Description of a camera.
void SetMaxBoxcarsum(int v)
Definition: PixelSimData.h:145
unsigned int GetPixelId() const

, generated on Tue Sep 26 2023.