Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Ars.hh
Go to the documentation of this file.
1 #ifndef __ANTARESDAQ__ARS__
2 #define __ANTARESDAQ__ARS__
3 
4 #include <ostream>
5 #include <iomanip>
6 
7 #include <TROOT.h>
8 #include <TObject.h>
9 
10 #include "DataTypes.hh"
11 
12 
13 /**
14  * ARS timestamp LSB [ns]
15  */
16 static const double ARS_TIMESTAMP_NS = 25.0;
17 
18 
19 /**
20  * ARS item interface.
21  */
22 class ARS_Item {
23 public:
24  /**
25  * Virtual destructor.
26  */
27  virtual ~ARS_Item() {}
28 
29  ClassDef(ARS_Item,2);
30 };
31 
32 
33 /**
34  * ARS STATUS
35  */
36 class Status_Item :
37  public ARS_Item
38 {
39 public:
40  /** ARS status */
41  unsigned char status;
42 
43  /** ARS timestamp (24 bits) */
44  unsigned int timestamp;
45 
46  /**
47  * Default constructor.
48  */
50  status(0),
51  timestamp(0)
52  {}
53 
54  /**
55  * Print ASCII.
56  *
57  * \param out output stream
58  * \param object Status item
59  * \return output stream
60  */
61  friend std::ostream& operator<<(std::ostream& out, const Status_Item& object)
62  {
63  using namespace std;
64 
65  return out << setw(2) << setfill('0') << hex << (int) object.status
66  << setw(6) << setfill('0') << hex << object.timestamp
67  << setfill(' ') << dec;
68  }
69 
70  /** ROOT class definition */
72 };
73 
74 
75 /**
76  * ARS RTS
77  */
78 class RTS_Item :
79  public Status_Item
80 {
81 public:
82  /**
83  * Default constructor.
84  */
86  Status_Item()
87  {}
88 
89  /** ROOT class definition */
90  ClassDef(RTS_Item, 2);
91 };
92 
93 
94 /**
95  * ARS CRM
96  */
97 class CRM_Item :
98  public Status_Item
99 {
100 public:
101  /** ARS Count Rate Monitor value */
102  unsigned char crm;
103 
104  /**
105  * Default constructor.
106  */
108  Status_Item(),
109  crm(0)
110  {}
111 
112  /**
113  * Print ASCII.
114  *
115  * \param out output stream
116  * \param object CRM item
117  * \return output stream
118  */
119  friend std::ostream& operator<<(std::ostream& out, const CRM_Item& object)
120  {
121  using namespace std;
122 
123  out << static_cast<const Status_Item&>(object);
124  out << setw(2) << hex << object.crm << dec;
125 
126  return out;
127  }
128 
129  /** ROOT class definition */
130  ClassDef(CRM_Item, 2);
131 };
132 
133 
134 /**
135  * ARS SPE
136  */
137 class SPE_Item :
138  public Status_Item
139 {
140 public:
141  /** ARS Analogue to Voltage Convertor */
142  unsigned char avc;
143 
144  /** ARS Time to Voltage Convertor */
145  unsigned char tvc;
146 
147  /**
148  * Default constructor.
149  */
151  Status_Item(),
152  avc(0),
153  tvc(0)
154  {}
155 
156  /**
157  * Print ASCII.
158  *
159  * \param out output stream
160  * \param object SPE item
161  * \return output stream
162  */
163  friend std::ostream& operator<<(std::ostream& out, const SPE_Item& object)
164  {
165  using namespace std;
166 
167  out << static_cast<const Status_Item&>(object);
168  out << setw(2) << setfill('0') << hex << (int) object.avc
169  << setw(2) << setfill('0') << hex << (int) object.tvc
170  << setfill(' ') << dec;
171 
172  return out;
173  }
174 
175  /** ROOT class definition */
176  ClassDef(SPE_Item, 2);
177 };
178 
179 
180 /**
181  * Anode waveform sample
182  */
183 class AWF_Sample {
184 public:
185  /** TVC */
186  unsigned char time;
187  /** AVC */
188  unsigned char anode;
189 
190  /**
191  * Default constructor.
192  */
194  time(0),
195  anode(0)
196  {}
197 
198  /**
199  * Virtual destructor.
200  */
201  virtual ~AWF_Sample() {};
202 
203  /** ROOT class definition */
204  ClassDef(AWF_Sample, 2);
205 };
206 
207 
208 /**
209  * Dynode waveform sample
210  */
211 class DWF_Sample :
212  public AWF_Sample
213 {
214 public:
215  /** AVC dynode 1 */
216  unsigned char dynode1;
217  /** AVC dynode 2 */
218  unsigned char dynode2;
219 
220  /**
221  * Default constructor.
222  */
224  AWF_Sample(),
225  dynode1(0),
226  dynode2(0)
227  {}
228 
229  /** ROOT class definition */
230  ClassDef(DWF_Sample, 2);
231 };
232 
233 
234 /**
235  * ARS WF header interface
236  *
237  * Note that the waveform header is padded to 4x4 Bytes
238  * due to the minimal bus transfer size of 4 words.
239  */
240 class WF_Header :
241  public SPE_Item
242 {
243 public:
244  /** Waveform address */
245  unsigned char waveformAddress;
246 
247  /**
248  * Default constructor.
249  */
251  SPE_Item(),
252  waveformAddress(0)
253  {}
254 
255  /** ROOT class definition */
256  ClassDef(WF_Header, 2);
257 };
258 
259 
260 /**
261  * ARS waveform
262  */
263 template<class T>
264 class WF_Item :
265  public WF_Header
266 {
267 protected:
268  /**
269  * number of waveform samples
270  */
271  static const unsigned int NUMBER_OF_SAMPLES = 128;
272 
273  /** data */
274  T data_[NUMBER_OF_SAMPLES];
275 
276 public:
277 
278  typedef T* iterator; //!< iterator
279  typedef const T* const_iterator; //!< const iterator
280 
281  /** begin iterator of waveform data */
282  iterator begin() { return data_; }
283 
284  /** end iterator of waveform data */
285  iterator end() { return data_ + NUMBER_OF_SAMPLES; }
286 
287  /** access to waveform data */
288  const T& operator[](const int i) { return data_[i]; }
289 
290  /**
291  * Default constructor.
292  */
294  WF_Header()
295  {}
296 
297  /** ROOT class definition */
298  ClassDef(WF_Item, 2);
299 };
300 
303 
304 
305 /**
306  * ARS Anode waveform
307  */
308 class AWF_Item :
309  public WF_Item<AWF_Sample>
310 {
311 public:
312  /**
313  * Default constructor.
314  */
316 
317  /** ROOT class definition */
318  ClassDef(AWF_Item, 2);
319 };
320 
321 
322 /**
323  * ARS Dynode waveform
324  */
325 class DWF_Item :
326  public WF_Item<DWF_Sample>
327 {
328 public:
329  /**
330  * Default constructor.
331  */
334  {}
335 
336  /** ROOT class definition */
337  ClassDef(DWF_Item, 2);
338 };
339 
340 
341 /**
342  * Determine the TVC number.
343  *
344  * \param timestamp ARS time stamp
345  * \param tvc ARS TVC value
346  * \return 0/1
347  */
348 inline int getTVC(const unsigned int timestamp,
349  const unsigned char tvc)
350 {
351  switch (timestamp & 0x3) {
352 
353  case 0:
354  if (tvc & 0x80)
355  return 1;
356  else
357  return 0;
358  break;
359 
360  case 1:
361  return 0;
362  break;
363 
364  case 2:
365  if (tvc & 0x80)
366  return 0;
367  else
368  return 1;
369  break;
370 
371  case 3:
372  return 1;
373  break;
374  }
375 
376  return 0;
377 }
378 
379 
380 /**
381  * equal operator for Status item
382  *
383  * \param first Status item
384  * \param second Status item
385  * \return true if first equals second; else false
386  */
387 inline bool operator==(const Status_Item& first, const Status_Item& second)
388 {
389  return (first.timestamp == second.timestamp);
390 }
391 
392 
393 /**
394  * not-equal operator for Status item
395  *
396  * \param first Status item
397  * \param second Status item
398  * \return true if first not equals second; else false
399  */
400 inline bool operator!=(const Status_Item& first, const Status_Item& second)
401 {
402  return (first.timestamp != second.timestamp);
403 }
404 
405 
406 /**
407  * comparator for Status item; earliest hit first
408  *
409  * \param first Status item
410  * \param second Status item
411  * \return true if first earlier than second; else false
412  */
413 inline bool operator<(const Status_Item& first, const Status_Item& second)
414 {
415  return (first.timestamp < second.timestamp);
416 }
417 
418 
419 /**
420  * equal operator for SPE item
421  *
422  * \param first SPE item
423  * \param second SPE item
424  * \return true if first equals second; else false
425  */
426 inline bool operator==(const SPE_Item& first, const SPE_Item& second)
427 {
428  return (first.timestamp == second.timestamp &&
429  first.tvc == second.tvc);
430 }
431 
432 
433 /**
434  * not-equal operator for SPE item
435  *
436  * \param first SPE item
437  * \param second SPE item
438  * \return true if first not equals second; else false
439  */
440 inline bool operator!=(const SPE_Item& first, const SPE_Item& second)
441 {
442  return (first.timestamp != second.timestamp ||
443  first.tvc != second.tvc);
444 }
445 
446 
447 /**
448  * comparator for SPE item; earliest hit first
449  *
450  * \param first SPE item
451  * \param second SPE item
452  * \return true if first earlier than second; else false
453  */
454 inline bool operator<(const SPE_Item& first, const SPE_Item& second)
455 {
456  if (first.timestamp == second.timestamp) {
457 
458  const int firstTvcInUse = getTVC(first.timestamp, first.tvc);
459  const int secondTvcInUse = getTVC(second.timestamp, second.tvc);
460 
461  if (firstTvcInUse == secondTvcInUse)
462  return first.tvc < second.tvc;
463  else
464  return firstTvcInUse < secondTvcInUse; //!
465 
466  } else {
467  return first.timestamp < second.timestamp;
468  }
469 }
470 
471 
472 /**
473  * comparator for SPE item; earliest hit first
474  *
475  * \param first SPE item
476  * \param second timestamp
477  * \return true if first earlier than second; else false
478  */
479 inline bool operator<(const SPE_Item& first, const unsigned int second)
480 {
481  return first.timestamp < second;
482 }
483 
484 
485 /**
486  * comparator for SPE item; earliest hit first
487  *
488  * \param first timestamp
489  * \param second SPE item
490  * \return true if first earlier than second; else false
491  */
492 inline bool operator<(const unsigned int first, const SPE_Item& second)
493 {
494  return first < second.timestamp;
495 }
496 
497 #endif
unsigned char crm
ARS Count Rate Monitor value.
Definition: Ars.hh:102
unsigned char time
TVC.
Definition: Ars.hh:186
Dynode waveform sample.
Definition: Ars.hh:211
iterator end()
end iterator of waveform data
Definition: Ars.hh:285
unsigned char status
ARS status.
Definition: Ars.hh:41
WF_Header()
Default constructor.
Definition: Ars.hh:250
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1578
SPE_Item()
Default constructor.
Definition: Ars.hh:150
T * iterator
iterator
Definition: Ars.hh:278
ClassDef(ARS_Item, 2)
AWF_Sample()
Default constructor.
Definition: Ars.hh:193
ARS SPE.
Definition: Ars.hh:137
DWF_Sample()
Default constructor.
Definition: Ars.hh:223
Status_Item()
Default constructor.
Definition: Ars.hh:49
unsigned char anode
AVC.
Definition: Ars.hh:188
AWF_Item()
Default constructor.
Definition: Ars.hh:315
DWF_Item()
Default constructor.
Definition: Ars.hh:332
CRM_Item()
Default constructor.
Definition: Ars.hh:107
friend std::ostream & operator<<(std::ostream &out, const SPE_Item &object)
Print ASCII.
Definition: Ars.hh:163
unsigned char tvc
ARS Time to Voltage Convertor.
Definition: Ars.hh:145
ARS RTS.
Definition: Ars.hh:78
#define ClassDefT2(name, template)
Definition: JRoot.hh:35
WF_Item()
Default constructor.
Definition: Ars.hh:293
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
ClassDef(Status_Item, 2)
ROOT class definition.
bool operator==(Packet const &p, ID const &id)
unsigned char avc
ARS Analogue to Voltage Convertor.
Definition: Ars.hh:142
friend std::ostream & operator<<(std::ostream &out, const Status_Item &object)
Print ASCII.
Definition: Ars.hh:61
Anode waveform sample.
Definition: Ars.hh:183
ARS item interface.
Definition: Ars.hh:22
unsigned char waveformAddress
Waveform address.
Definition: Ars.hh:245
do set_variable OUTPUT_DIRECTORY $WORKDIR T
friend std::ostream & operator<<(std::ostream &out, const CRM_Item &object)
Print ASCII.
Definition: Ars.hh:119
unsigned int timestamp
ARS timestamp (24 bits)
Definition: Ars.hh:44
const T * const_iterator
const iterator
Definition: Ars.hh:279
unsigned char dynode1
AVC dynode 1.
Definition: Ars.hh:216
#define ClassImpT(name, template)
Definition: JRoot.hh:38
ARS WF header interface.
Definition: Ars.hh:240
const T & operator[](const int i)
access to waveform data
Definition: Ars.hh:288
RTS_Item()
Default constructor.
Definition: Ars.hh:85
int getTVC(const unsigned int timestamp, const unsigned char tvc)
Determine the TVC number.
Definition: Ars.hh:348
ARS CRM.
Definition: Ars.hh:97
JNullType operator!=(JAnyType, JAnyType)
iterator begin()
begin iterator of waveform data
Definition: Ars.hh:282
ARS Dynode waveform.
Definition: Ars.hh:325
ARS Anode waveform.
Definition: Ars.hh:308
virtual ~ARS_Item()
Virtual destructor.
Definition: Ars.hh:27
virtual ~AWF_Sample()
Virtual destructor.
Definition: Ars.hh:201
unsigned char dynode2
AVC dynode 2.
Definition: Ars.hh:218
ARS STATUS.
Definition: Ars.hh:36
static const double ARS_TIMESTAMP_NS
ARS timestamp LSB [ns].
Definition: Ars.hh:16
ARS waveform.
Definition: Ars.hh:264