Jpp  debug
the software that should make you happy
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
KM3NETDAQ::JRandomTimeslice Struct Reference

Timeslice with random data. More...

#include <JRandomTimeslice.hh>

Inheritance diagram for KM3NETDAQ::JRandomTimeslice:
KM3NETDAQ::JTimesliceL0 KM3NETDAQ::JDAQTimesliceL0 KM3NETDAQ::JDAQTimeslice KM3NETDAQ::JDAQPreamble KM3NETDAQ::JDAQTimesliceHeader std::vector< JDAQSuperFrame > KM3NETDAQ::JDAQAbstractPreamble TObject KM3NETDAQ::JDAQHeader KM3NETDAQ::JDAQChronometer

Classes

struct  random_indices_t
 Auxiliary data structure for randomisation of indices. More...
 

Public Member Functions

 JRandomTimeslice ()
 Default constructor. More...
 
 JRandomTimeslice (const JDAQChronometer &chronometer, const JDetectorSimulator &simbad)
 Constructor. More...
 
void recycle (const double T_ns)
 Recycle time slice by randomly shuffling time intervals of data. More...
 
 ClassDef (JDAQTimesliceL0, 1)
 
 ClassDef (JDAQTimeslice, 4)
 
 ClassDef (JDAQPreamble, 1)
 
 ClassDef (JDAQTimesliceHeader, 2)
 
 ClassDef (JDAQHeader, 2)
 
 ClassDef (JDAQChronometer, 3)
 
void clear ()
 Clear data. More...
 
JDAQTimesliceadd (const JDAQTimeslice &timeslice)
 Add another timeslice. More...
 
std::ostream & print (std::ostream &out, const bool lpr=false) const
 Print DAQ Timeslice. More...
 
int getLength () const
 Get length. More...
 
int getDataType () const
 Get data type. More...
 
 ClassDefNV (JDAQAbstractPreamble, 1)
 
const JDAQTimesliceHeadergetDAQTimesliceHeader () const
 Get DAQ time slice header. More...
 
const JDAQHeadergetDAQHeader () const
 Get DAQ header. More...
 
void setDAQHeader (const JDAQHeader &header)
 Set DAQ header. More...
 
const JDAQChronometergetDAQChronometer () const
 Get DAQ chronometer. More...
 
void setDAQChronometer (const JDAQChronometer &chronometer)
 Set DAQ chronometer. More...
 
int getDetectorID () const
 Get detector identifier. More...
 
int getRunNumber () const
 Get run number. More...
 
int getFrameIndex () const
 Get frame index. More...
 
JDAQUTCExtended getTimesliceStart () const
 Get start of timeslice. More...
 
void setRunNumber (const int run)
 Set run number. More...
 
void setFrameIndex (const int frame_index)
 Set frame index. More...
 
void setTimesliceStart (const JDAQUTCExtended &timeslice_start)
 Set timeslice start time. More...
 

Static Public Member Functions

template<class T >
static JDAQPreamble getDAQPreamble (const T &object)
 Get DAQ preamble. More...
 

Protected Attributes

int length
 
int type
 
int detector_id
 
int run
 
int frame_index
 
JDAQUTCExtended timeslice_start
 

Detailed Description

Timeslice with random data.

Definition at line 30 of file JRandomTimeslice.hh.

Constructor & Destructor Documentation

◆ JRandomTimeslice() [1/2]

KM3NETDAQ::JRandomTimeslice::JRandomTimeslice ( )
inline

Default constructor.

Definition at line 36 of file JRandomTimeslice.hh.

37  {}

◆ JRandomTimeslice() [2/2]

KM3NETDAQ::JRandomTimeslice::JRandomTimeslice ( const JDAQChronometer chronometer,
const JDetectorSimulator simbad 
)
inline

Constructor.

Parameters
chronometerchronometer
simbaddetector simulator

Definition at line 46 of file JRandomTimeslice.hh.

48  {
49  using namespace JPP;
50 
51  setDAQChronometer(chronometer);
52 
53  if (simbad.hasK40Simulator() &&
54  simbad.hasPMTSimulator() &&
55  simbad.hasCLBSimulator()) {
56 
57  const double Tmin = getTimeSinceRTS(chronometer.getFrameIndex()); // [ns]
58 
59  const JTimeRange period(Tmin, Tmin + getFrameTime()); // [ns]
60 
61  JModuleData buffer;
62 
63  for (JDetector::const_iterator module = simbad->begin(); module != simbad->end(); ++module) {
64 
65  if (!module->empty()) {
66 
67  buffer.reset(module->size());
68 
69  simbad.generateHits(*module, period, buffer);
70 
71  this->push_back(JDAQSuperFrame(JDAQSuperFrameHeader(chronometer, module->getID())));
72 
73  simbad(*module, buffer, *(this->rbegin()));
74  }
75  }
76  }
77  }
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const override
Generate hits.
bool hasPMTSimulator() const
Check availability of PMT simulator.
bool hasK40Simulator() const
Check availability of K40 simulator.
bool hasCLBSimulator() const
Check availability of CLB simulator.
Data structure for PMT data corresponding to a detector module.
void reset(size_t size)
Reset buffers.
void setDAQChronometer(const JDAQChronometer &chronometer)
Set DAQ chronometer.
int getFrameIndex() const
Get frame index.
Data frame of one optical module.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
double getTimeSinceRTS(const int frame_index)
Get time in ns since last RTS for a given frame index.
Definition: JDAQClock.hh:263

Member Function Documentation

◆ recycle()

void KM3NETDAQ::JRandomTimeslice::recycle ( const double  T_ns)
inline

Recycle time slice by randomly shuffling time intervals of data.

Hits within one time interval are swapped with hits within another -randomly selected- time interval.
Time intervals in which a high-rate veto occurred are excluded.

Note that the time interval should be:

  • (much) larger than time differences of hits in L1 coincidence; and
  • (much) smaller than time covered by data (as per KM3NETDAQ::getFrameTime()).
Parameters
T_nstime interval

Definition at line 92 of file JRandomTimeslice.hh.

93  {
94  using namespace std;
95  using namespace JPP;
96 
98  typedef JDAQHit::JTDC_t JTDC_t;
99 
100  size_t N = (size_t) (getFrameTime() / T_ns + 0.5); // number of time intervals
101 
102  if (N < 100) { N = 100; } // allow to keep indices at time of high-rate veto
103  if (N > 50000) { N = 50000; } // maximum expected number of hits due to high-rate veto
104 
105  const JTDC_t Ts = (JTDC_t) (getFrameTime() / N); // TDC interval
106 
107  random_indices_t index (N); // indices of time intervals for swapping
108  vector<buffer_type> buffer(N); // data per time interval
109 
110  for (iterator frame = this->begin(); frame != this->end(); ++frame) {
111 
112  if (!frame->empty()) {
113 
114  for (size_t i = 0; i != N; ++i) {
115  buffer[i].clear();
116  }
117 
118  // store data per time interval
119 
121  numeric_limits<JTDC_t>::max()); // maximal time per PMT, e.g. due to high-rate veto
122 
123  for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
124 
125  T_max[hit->getPMT()] = hit->getT();
126 
127  const int i = hit->getT() / Ts;
128 
129  buffer[i].push_back(*hit);
130  }
131 
132  set<size_t> keep; // indices corresponding to times of high-rate veto
133 
134  for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) {
135  if (frame->testHighRateVeto(pmt)) {
136  keep.insert(T_max[pmt] / Ts);
137  }
138  }
139 
140  index.random_shuffle(keep); // randomly shuffle values between kept indices
141 
142  // Wall street shuflle
143 
144  JDAQSuperFrame::iterator hit = frame->begin();
145 
146  for (size_t in = 0; in != N; ++in) {
147 
148  const size_t out = index [in];
149  buffer_type& zbuf = buffer[out];
150 
151  const JTDC_t T_in = in * Ts;
152  const JTDC_t T_out = out * Ts;
153 
154  for (buffer_type::iterator i = zbuf.begin(); i != zbuf.end(); ++i, ++hit) {
155  *hit = JDAQHit(i->getPMT(), (i->getT() - T_out) + T_in, i->getToT());
156  }
157  }
158  }
159  }
160  }
Hit data structure.
Definition: JDAQHit.hh:35
unsigned int JTDC_t
leading edge [ns]
Definition: JDAQHit.hh:39
std::vector< JHitW0 > buffer_type
hits
Definition: JPerth.cc:70
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
Definition: JSTDTypes.hh:14
Auxiliary class for TDC constraints.
Definition: JTDC_t.hh:39

◆ ClassDef() [1/6]

KM3NETDAQ::JDAQTimesliceL0::ClassDef ( JDAQTimesliceL0  ,
 
)
inherited

◆ ClassDef() [2/6]

KM3NETDAQ::JDAQTimeslice::ClassDef ( JDAQTimeslice  ,
 
)
inherited

◆ ClassDef() [3/6]

KM3NETDAQ::JDAQPreamble::ClassDef ( JDAQPreamble  ,
 
)
inherited

◆ ClassDef() [4/6]

KM3NETDAQ::JDAQTimesliceHeader::ClassDef ( JDAQTimesliceHeader  ,
 
)
inherited

◆ ClassDef() [5/6]

KM3NETDAQ::JDAQHeader::ClassDef ( JDAQHeader  ,
 
)
inherited

◆ ClassDef() [6/6]

KM3NETDAQ::JDAQChronometer::ClassDef ( JDAQChronometer  ,
 
)
inherited

◆ clear()

void KM3NETDAQ::JDAQTimeslice::clear ( )
inlineinherited

Clear data.

Definition at line 97 of file JDAQTimeslice.hh.

98  {
99  for (iterator i = this->begin(); i != this->end(); ++i) {
100  i->clear();
101  }
102 
104  }

◆ add()

JDAQTimeslice& KM3NETDAQ::JDAQTimeslice::add ( const JDAQTimeslice timeslice)
inlineinherited

Add another timeslice.

Parameters
timeslicetimeslice
Returns
this timeslice

Definition at line 133 of file JDAQTimeslice.hh.

134  {
135  using namespace std;
136 
138 
139  for (const_iterator i = this->begin(); i != this->end(); ++i) {
140  buffer[i->getModuleIdentifier()] = distance(static_cast<const JDAQTimeslice&>(*this).begin(),i);
141  }
142 
143  for (JDAQTimeslice::const_iterator i = timeslice.begin(); i != timeslice.end(); ++i) {
144 
145  map<JDAQModuleIdentifier, int>::const_iterator p = buffer.find(i->getModuleIdentifier());
146 
147  if (p != buffer.end()) {
148 
149  JDAQSuperFrame& frame = this->at(p->second);
150 
151  frame.add(*i);
152 
153  sort(frame.begin(), frame.end());
154 
155  } else {
156 
157  this->push_back(*i);
158  }
159  }
160 
161  return *this;
162  }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
const_iterator end() const
Definition: JDAQFrame.hh:166
const_iterator begin() const
Definition: JDAQFrame.hh:165
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.

◆ print()

std::ostream& KM3NETDAQ::JDAQTimeslice::print ( std::ostream &  out,
const bool  lpr = false 
) const
inlineinherited

Print DAQ Timeslice.

Parameters
outoutput stream
lprlong print
Returns
output stream

Definition at line 172 of file JDAQTimeslice.hh.

173  {
174  using namespace std;
175 
176  out << this->ClassName() << endl;
177  out << dynamic_cast<const JDAQPreamble&> (*this) << endl;
178  out << dynamic_cast<const JDAQChronometer&>(*this) << endl;
179 
180  for (JDAQTimeslice::const_iterator frame = this->begin(); frame != this->end(); ++frame) {
181 
182  out << ' ' << setw(10) << frame->getModuleID();
183  out << ' ' << setw(6) << frame->getLength();
184  out << ' ' << setw(6) << frame->getDataType();
185  out << ' ' << setw(6) << frame->getTimesliceStart();
186  out << ' ' << setw(8) << setfill('0') << hex << frame->getStatus() << dec << setfill(' ');
187  out << '|' << setw(8) << setfill('0') << hex << frame->getFIFOStatus() << dec << setfill(' ');
188  out << ' ' << setw(2) << frame->getUDPNumberOfReceivedPackets();
189  out << '/' << setw(2) << frame->getUDPMaximalSequenceNumber();
190  out << ' ' << setw(6) << frame->size();
191 
192  if (!lpr) {
193 
194  if (!frame->empty()) {
195 
196  out << ' ' << setw(10) << frame-> begin()->getT();
197  out << " ... ";
198  out << ' ' << setw(10) << frame->rbegin()->getT();
199  }
200 
201  out << endl;
202 
203  } else {
204 
205  out << endl;
206 
207  int n = 1;
208 
209  for (JDAQFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit, ++n) {
210  out << setw(2) << (int) hit->getPMT() << ' '
211  << setw(8) << (int) hit->getT() << ' '
212  << setw(3) << (int) hit->getToT() << (n%10 == 0 ? '\n' : ' ');
213  }
214 
215  out << endl;
216  }
217  }
218 
219  return out;
220  }
const int n
Definition: JPolint.hh:786

◆ getDAQPreamble()

template<class T >
static JDAQPreamble KM3NETDAQ::JDAQPreamble::getDAQPreamble ( const T &  object)
inlinestaticinherited

Get DAQ preamble.

This method should be used for binary I/O to get the actual data for the given object.
To this end, the following method should be overloaded for the corresponding data type.

   size_t  getSizeof(const T&);
Parameters
objectobject
Returns
preamble

Definition at line 76 of file JDAQPreamble.hh.

77  {
78  static JDAQPreamble preamble;
79 
80  preamble.length = getSizeof(object);
81  preamble.type = KM3NETDAQ::getDataType<T>();
82 
83  return preamble;
84  }
friend size_t getSizeof()
Definition of method to get size of data type.

◆ getLength()

int KM3NETDAQ::JDAQAbstractPreamble::getLength ( ) const
inlineinherited

Get length.

Returns
number of bytes

Definition at line 49 of file JDAQAbstractPreamble.hh.

50  {
51  return length;
52  }

◆ getDataType()

int KM3NETDAQ::JDAQAbstractPreamble::getDataType ( ) const
inlineinherited

Get data type.

Returns
data type

Definition at line 60 of file JDAQAbstractPreamble.hh.

61  {
62  return type;
63  }

◆ ClassDefNV()

KM3NETDAQ::JDAQAbstractPreamble::ClassDefNV ( JDAQAbstractPreamble  ,
 
)
inherited

◆ getDAQTimesliceHeader()

const JDAQTimesliceHeader& KM3NETDAQ::JDAQTimesliceHeader::getDAQTimesliceHeader ( ) const
inlineinherited

Get DAQ time slice header.

Returns
DAQ time slice header

Definition at line 43 of file JDAQTimesliceHeader.hh.

44  {
45  return static_cast<const JDAQTimesliceHeader&>(*this);
46  }

◆ getDAQHeader()

const JDAQHeader& KM3NETDAQ::JDAQHeader::getDAQHeader ( ) const
inlineinherited

Get DAQ header.

Returns
DAQ header

Definition at line 49 of file JDAQHeader.hh.

50  {
51  return static_cast<const JDAQHeader&>(*this);
52  }

◆ setDAQHeader()

void KM3NETDAQ::JDAQHeader::setDAQHeader ( const JDAQHeader header)
inlineinherited

Set DAQ header.

Parameters
headerDAQ header

Definition at line 60 of file JDAQHeader.hh.

61  {
62  static_cast<JDAQHeader&>(*this) = header;
63  }

◆ getDAQChronometer()

const JDAQChronometer& KM3NETDAQ::JDAQChronometer::getDAQChronometer ( ) const
inlineinherited

Get DAQ chronometer.

Returns
DAQ chronometer

Definition at line 88 of file JDAQChronometer.hh.

89  {
90  return static_cast<const JDAQChronometer&>(*this);
91  }

◆ setDAQChronometer()

void KM3NETDAQ::JDAQChronometer::setDAQChronometer ( const JDAQChronometer chronometer)
inlineinherited

Set DAQ chronometer.

Parameters
chronometerDAQ chronometer

Definition at line 99 of file JDAQChronometer.hh.

100  {
101  static_cast<JDAQChronometer&>(*this) = chronometer;
102  }

◆ getDetectorID()

int KM3NETDAQ::JDAQChronometer::getDetectorID ( ) const
inlineinherited

Get detector identifier.

Returns
detector identifier

Definition at line 110 of file JDAQChronometer.hh.

111  {
112  return detector_id;
113  }

◆ getRunNumber()

int KM3NETDAQ::JDAQChronometer::getRunNumber ( ) const
inlineinherited

Get run number.

Returns
run number

Definition at line 121 of file JDAQChronometer.hh.

122  {
123  return run;
124  }

◆ getFrameIndex()

int KM3NETDAQ::JDAQChronometer::getFrameIndex ( ) const
inlineinherited

Get frame index.

Returns
frame index

Definition at line 132 of file JDAQChronometer.hh.

133  {
134  return frame_index;
135  }

◆ getTimesliceStart()

JDAQUTCExtended KM3NETDAQ::JDAQChronometer::getTimesliceStart ( ) const
inlineinherited

Get start of timeslice.

Returns
timeslice start

Definition at line 144 of file JDAQChronometer.hh.

145  {
146  return timeslice_start;
147  }

◆ setRunNumber()

void KM3NETDAQ::JDAQChronometer::setRunNumber ( const int  run)
inlineinherited

Set run number.

Parameters
runrun number

Definition at line 155 of file JDAQChronometer.hh.

156  {
157  this->run = run;
158  }

◆ setFrameIndex()

void KM3NETDAQ::JDAQChronometer::setFrameIndex ( const int  frame_index)
inlineinherited

Set frame index.

Parameters
frame_indexframe index

Definition at line 166 of file JDAQChronometer.hh.

167  {
168  this->frame_index = frame_index;
169  }

◆ setTimesliceStart()

void KM3NETDAQ::JDAQChronometer::setTimesliceStart ( const JDAQUTCExtended timeslice_start)
inlineinherited

Set timeslice start time.

Parameters
timeslice_starttimeslice start time

Definition at line 177 of file JDAQChronometer.hh.

178  {
179  this->timeslice_start = timeslice_start;
180  }

Member Data Documentation

◆ length

int KM3NETDAQ::JDAQAbstractPreamble::length
protectedinherited

Definition at line 69 of file JDAQAbstractPreamble.hh.

◆ type

int KM3NETDAQ::JDAQAbstractPreamble::type
protectedinherited

Definition at line 70 of file JDAQAbstractPreamble.hh.

◆ detector_id

int KM3NETDAQ::JDAQChronometer::detector_id
protectedinherited

Definition at line 187 of file JDAQChronometer.hh.

◆ run

int KM3NETDAQ::JDAQChronometer::run
protectedinherited

Definition at line 188 of file JDAQChronometer.hh.

◆ frame_index

int KM3NETDAQ::JDAQChronometer::frame_index
protectedinherited

Definition at line 189 of file JDAQChronometer.hh.

◆ timeslice_start

JDAQUTCExtended KM3NETDAQ::JDAQChronometer::timeslice_start
protectedinherited

Definition at line 190 of file JDAQChronometer.hh.


The documentation for this struct was generated from the following file: