Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRandomTimeslice.hh
Go to the documentation of this file.
1 #ifndef __JTIMESLICE__JRANDOMTIMESLICE__
2 #define __JTIMESLICE__JRANDOMTIMESLICE__
3 
4 #include <exception>
5 #include <algorithm>
6 
7 #include <TRandom3.h>
8 
10 #include "JDetector/JTimeRange.hh"
11 #include "JDAQ/JDAQ.hh"
12 #include "JDAQ/JDAQClock.hh"
13 #include "JDAQ/JDAQTimeslice.hh"
14 
15 
16 /**
17  * \author mdejong
18  */
19 
20 namespace KM3NETDAQ {
21 
23 
24 
25  /**
26  * Timeslice with random data.
27  */
29  public JDAQTimeslice
30  {
31  public:
32  /**
33  * Default constructor.
34  */
37  {}
38 
39 
40  /**
41  * Constructor.
42  *
43  * \param chronometer chronometer
44  * \param simbad detector simulator
45  */
46  JRandomTimeslice(const JDAQChronometer& chronometer,
47  const JDetectorSimulator& simbad) :
49  {
50  using namespace JDETECTOR;
51 
52  setDAQChronometer(chronometer);
53 
54  if (simbad.hasK40Simulator() &&
55  simbad.hasPMTSimulator() &&
56  simbad.hasCLBSimulator()) {
57 
58  const double Tmin = getTimeSinceRTS(chronometer.getFrameIndex()); // [ns]
59 
60  const JTimeRange period(Tmin, Tmin + getFrameTime()); // [ns]
61 
62  JModuleData buffer;
63 
64  for (JDetector::const_iterator module = simbad->begin(); module != simbad->end(); ++module) {
65 
66  buffer.reset(module->size());
67 
68  simbad.generateHits(*module, period, buffer);
69 
70  this->push_back(JDAQSuperFrame(JDAQSuperFrameHeader(chronometer, module->getID())));
71 
72  simbad(*module, buffer, *(this->rbegin()));
73  }
74  }
75  }
76  };
77 }
78 
79 
80 #endif
81 
Timeslice with random data.
void reset(size_t size)
Reset buffers.
Data structure for PMT data corresponding to a detector module.
JRandomTimeslice(const JDAQChronometer &chronometer, const JDetectorSimulator &simbad)
Constructor.
int getFrameIndex() const
Get frame index.
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const
Generate hits.
bool hasPMTSimulator() const
Check availability of PMT simulator.
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
Data time slice.
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
bool hasK40Simulator() const
Check availability of K40 simulator.
bool hasCLBSimulator() const
Check availability of CLB simulator.
double getTimeSinceRTS(const int frame_index)
Get time in ns since last RTS for a given frame index.
Definition: JDAQClock.hh:263
KM3NeT DAQ constants, bit handling, etc.
Data frame of one optical module.
JRandomTimeslice()
Default constructor.