Jpp  18.5.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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 29 of file JRandomTimeslice.hh.

Constructor & Destructor Documentation

KM3NETDAQ::JRandomTimeslice::JRandomTimeslice ( )
inline

Default constructor.

Definition at line 35 of file JRandomTimeslice.hh.

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

Constructor.

Parameters
chronometerchronometer
simbaddetector simulator

Definition at line 45 of file JRandomTimeslice.hh.

47  {
48  using namespace JPP;
49 
50  setDAQChronometer(chronometer);
51 
52  if (simbad.hasK40Simulator() &&
53  simbad.hasPMTSimulator() &&
54  simbad.hasCLBSimulator()) {
55 
56  const double Tmin = getTimeSinceRTS(chronometer.getFrameIndex()); // [ns]
57 
58  const JTimeRange period(Tmin, Tmin + getFrameTime()); // [ns]
59 
60  JModuleData buffer;
61 
62  for (JDetector::const_iterator module = simbad->begin(); module != simbad->end(); ++module) {
63 
64  if (!module->empty()) {
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  }
void reset(size_t size)
Reset buffers.
Data structure for PMT data corresponding to a detector module.
int getFrameIndex() const
Get frame index.
bool hasPMTSimulator() const
Check availability of PMT simulator.
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
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
virtual void generateHits(const JModule &module, const JTimeRange &period, JModuleData &output) const override
Generate hits.
Data frame of one optical module.

Member Function Documentation

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.

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 90 of file JRandomTimeslice.hh.

91  {
92  using namespace std;
93  using namespace JPP;
94 
95  typedef JDAQHit::JTDC_t JTDC_t;
96 
97 
98  size_t N; // number of time intervals
99 
100  if (T_ns < 1.0)
101  N = (size_t) getFrameTime();
102  else if (T_ns < getFrameTime())
103  N = (size_t) (getFrameTime() / T_ns + 0.5);
104  else
105  N = 1;
106 
107  const JTDC_t T_step = (JTDC_t) (getFrameTime() / N); // TDC interval
108 
109 
111 
112  vector<size_t> index (N); // indices of time intervals for swapping
113  vector<buffer_type> buffer(N); // data per time interval
114 
115  for (iterator frame = this->begin(); frame != this->end(); ++frame) {
116 
117  if (!frame->empty()) {
118 
119 
120  for (size_t i = 0; i != N; ++i) {
121  index [i] = i;
122  buffer[i].clear();
123  }
124 
125 
126  vector<size_t> N_max(NUMBER_OF_PMTS, N); // number of time intervals per PMT
127  vector<JTDC_t> T_max(NUMBER_OF_PMTS, 0); // maximal time per PMT, e.g.\ due to high-rate veto
128 
129  for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
130  T_max[hit->getPMT()] = hit->getT();
131  }
132 
133  for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
134 
135  const size_t N_i = (T_max[i] + T_step) / T_step;
136 
137  if (N_i < N_max[i]) {
138  N_max[i] = N_i;
139  }
140  }
141 
142  sort(N_max.begin(), N_max.end()); // swaps by allowed time range
143 
144  for (size_t i = 0, L = 0; i != N_max.size(); ++i) {
145 
146  size_t M = N_max[i];
147 
148  if (L != M) {
149  for (size_t i = M - L - 1; i != 0; --i) {
150  std::swap(index[L + i], index[L + gRandom->Integer(i+1)]);
151  }
152  }
153 
154  L = M;
155  }
156 
157  const size_t M = N_max[NUMBER_OF_PMTS - 1];
158 
159 
160  // Wall street shuflle
161 
162  JDAQSuperFrame::const_iterator hit = frame->begin();
163 
164  for (size_t in = 0; in != M; ++in) {
165 
166  const size_t out = index[in];
167  buffer_type& zbuf = buffer[out];
168 
169  const JTDC_t T_in = in * T_step;
170  const JTDC_t T_out = out * T_step;
171 
172  for ( ; hit != frame->end() && hit->getT() < T_in + T_step; ++hit) {
173  zbuf.push_back(JDAQHit(hit->getPMT(), (hit->getT() - T_in) + T_out, hit->getToT()));
174  }
175  }
176 
177 
178  // copy back data
179 
180  for (size_t i = 0, number_of_hits = 0; i != M; ++i) {
181 
182  memcpy(frame->data() + number_of_hits, buffer[i].data(), buffer[i].size() * sizeof(JDAQHit));
183 
184  number_of_hits += buffer[i].size();
185  }
186  }
187  }
188  }
Auxiliary class for TDC constraints.
Definition: JTDC_t.hh:37
JTDC_t getT() const
Get time.
Definition: JDAQHit.hh:86
JPMT_t getPMT() const
Get PMT.
Definition: JDAQHit.hh:75
unsigned int JTDC_t
leading edge [ns]
Definition: JDAQHit.hh:39
std::vector< JHitW0 > buffer_type
hits
Definition: JPerth.cc:70
JTOT_t getToT() const
Get time-over-threshold.
Definition: JDAQHit.hh:97
Hit data structure.
Definition: JDAQHit.hh:34
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
KM3NETDAQ::JDAQTimesliceL0::ClassDef ( JDAQTimesliceL0  ,
 
)
inherited
KM3NETDAQ::JDAQTimeslice::ClassDef ( JDAQTimeslice  ,
 
)
inherited
KM3NETDAQ::JDAQPreamble::ClassDef ( JDAQPreamble  ,
 
)
inherited
KM3NETDAQ::JDAQTimesliceHeader::ClassDef ( JDAQTimesliceHeader  ,
 
)
inherited
KM3NETDAQ::JDAQHeader::ClassDef ( JDAQHeader  ,
 
)
inherited
KM3NETDAQ::JDAQChronometer::ClassDef ( JDAQChronometer  ,
 
)
inherited
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  }
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 begin() const
Definition: JDAQFrame.hh:165
Data frame of one optical module.
JDAQSuperFrame & add(const JDAQSuperFrame &super_frame)
Add data from same optical module.
const_iterator end() const
Definition: JDAQFrame.hh:166
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
Hit data structure.
Definition: JDAQHit.hh:34
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.
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  }
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  }
KM3NETDAQ::JDAQAbstractPreamble::ClassDefNV ( JDAQAbstractPreamble  ,
 
)
inherited
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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  }
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

int KM3NETDAQ::JDAQAbstractPreamble::length
protectedinherited

Definition at line 69 of file JDAQAbstractPreamble.hh.

int KM3NETDAQ::JDAQAbstractPreamble::type
protectedinherited

Definition at line 70 of file JDAQAbstractPreamble.hh.

int KM3NETDAQ::JDAQChronometer::detector_id
protectedinherited

Definition at line 187 of file JDAQChronometer.hh.

int KM3NETDAQ::JDAQChronometer::run
protectedinherited

Definition at line 188 of file JDAQChronometer.hh.

int KM3NETDAQ::JDAQChronometer::frame_index
protectedinherited

Definition at line 189 of file JDAQChronometer.hh.

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: