HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoDccFrame.cxx
Go to the documentation of this file.
1 //
2 // File HarpoDccFrame.cxx
3 //
10 #include "HarpoDccFrame.h"
11 #include <cstring>
12 #include <iostream>
13 
14 ClassImp(HarpoDccFrame)
15 
16 using namespace std;
17 
18 UShort_t HarpoDccFrame::FecPerFem = 1; //1 for LLR or 6 T2K
19 
20 void HarpoDccFrame::print() const
21 {
22  cout << "---Dcc Frame Size : " << size << " CH : " << ChannelNum() << endl
23  << " Ver : " << swversion << " pkg type : " << pkgtype << endl
24  << " Dcc idx : " << dccindex << " Fem idx : " << femindex << endl
25  << " Fem Type: " << msgtype << " Evt cnt : " << femecnt << endl;
26 
27  cout << "fe:" << fecerror // ???? ignore ???
28  << "U:" << synchfail // U flag , adc not gain sync
29  << "L:" << lostsynch << endl; // L flag , ads lost synchronization
30 
31  // int readmode; // Read Out Mode ( only mode = 0 supported)
32 
33  cout << hex << " Zero Suppression : " << compress << " Args1 : " << arg1
34  << " Arg2 : " << arg2 << endl
35  << " Time Stamp : " << dec << timestamp << endl;
36  /* EvTy and Event Counter */
37  cout << " Fem Evt Type : " << evttype << " Evt cnt : " << evtcnt << endl;
38  // /* Word Count */
39  //int chwdcnt; // Channal zero word count
40  /* pointers to raw unpacked header, pulse data and trailer
41  in raw data buffer */
42  // UShort_t dccHeader;
43  //UShort_t dccData;
44  //UShort_t dccTrailer; << std::endl;
45  cout << "Frame adress : " << this << endl;
46  // cout << "FecPerFem : " << FecPerFem << endl;
47 }
48 
49 
50 /*******************************************************************************
51  Arg12ToFecAsicChannel
52 TODO: Move to RawDecode ??
53 *******************************************************************************/
54 Int_t HarpoDccFrame::Arg12ToFecAsicChannel(UShort_t fec_per_fem,
55  UShort_t arg1,UShort_t arg2,
56  UShort_t *fec,UShort_t *asic,
57  UShort_t *channel) const
58 {
59  if (fec_per_fem == 6)
60  {
61  *fec = (10*(arg1%6)/2 + arg2)/4;
62  *asic = (10*(arg1%6)/2 + arg2)%4;
63  *channel = arg1/6;
64  if ((*fec > 5) || (*asic > 3))
65  {
66  *fec = arg2 - 4;
67  *asic = 4;
68  *channel = (arg1 - 4) / 6;
69  }
70  }
71  else if (fec_per_fem == 1)
72  {
73  *fec = 0;
74  *asic = (arg1%6) + arg2;
75  *channel = arg1/6;
76  }
77  else if (fec_per_fem == 4)
78  {
79  *fec = (6*(arg1%6)/2 + arg2)/4;
80  *asic = (6*(arg1%6)/2 + arg2)%4;
81  *channel = arg1/6;
82  }
83  else
84  {
85  return(-1);
86  }
87  //cout << "FpF F:" << *fec << " A:" << *asic << " C:" << *channel << endl;
88 
89  return (0);
90 }
91 
92 
93  Int_t HarpoDccFrame::ChannelNum(UShort_t a1, UShort_t a2) const
94  {
95  UShort_t f,a,c;
96  if (Arg12ToFecAsicChannel(FecPerFem, a1, a2, &f, &a, &c) == 0) {
97  return (a*(72+4) + (c-3)); // fec == 0 in our case or (f*(72+4)*4)
98  } else {
99  return -1;
100  }
101  }
102 
104  size(0),swversion(0),pkgtype(0),dccindex(0),femindex(0),msgtype(0),
105  femecnt(0),fecerror(0),synchfail(0),lostsynch(0),readmode(0),compress(0),
106  arg1(0),arg2(0),timestamp(0),evttype(0),evtcnt(0),chwdcnt(0),
107  dccHeader(NULL),dccData(NULL),dccTrailer(NULL)
108 {
109  // cout << "+++ New DccFrame " << this << endl;
110 }
111 
113  // cout << "-- Del DccFrame " << this << endl;
114 }
115 
118  size = 0;
119  /* DCCHEADER word (p.29) */
120  swversion = 0;
121  pkgtype = 0;
122  dccindex = 0;
123  femindex = 0;
124  /* FEM Header6 short int word */
125  msgtype = 0;
126  femecnt = 0;
127 
128  fecerror = 0;
129  synchfail = 0;
130  lostsynch = 0;
131 
132  readmode = 0;
133  compress = 0;
134  /* argument words */
135  arg1 = 0;
136  arg2 = 0;
137  /* dcc time stamp */
138  timestamp = 0;
139  /* EvTy and Event Counter */
140  evttype = 0;
141  evtcnt = 0;
142  /* Word Count */
143  chwdcnt = 0;
144  /* pointers to raw unpacked header, pulse data and trailer
145  in raw data buffer */
146  dccHeader = NULL;
147  dccData = NULL;
148  dccTrailer = NULL;
149 }
150 
151 // HarpoDccFrame& HarpoDccFrame::operator=(const HarpoDccFrame &rhs) {
152 // if ( this != &rhs ) {
153 // cout << " Frame Copy " << &rhs << " to " << this << endl;
154 // memcpy(this,&rhs,sizeof(HarpoDccFrame));
155 // } else {
156 // cout << " Frame Self assignment" << this << endl;
157 // }
158 // return *this;
159 // }
160 
161 // HarpoDccFrame::HarpoDccFrame(const HarpoDccFrame &rhs) {
162 // if ( this != &rhs ) {
163 // cout << " Frame Copy " << &rhs << " to " << this << endl;
164 // memcpy(this,&rhs,sizeof(HarpoDccFrame));
165 // } else {
166 // cout << " Frame Self assignment" << this << endl;
167 // }
168 // }
const int compress
Int_t Arg12ToFecAsicChannel(UShort_t fec_per_fem, UShort_t arg1, UShort_t arg2, UShort_t *fec, UShort_t *asic, UShort_t *channel) const
UInt_t lostsynch
Definition: HarpoDccFrame.h:33
A generic class for HARPO datectors The class is ....
Definition: HarpoDccFrame.h:6
UInt_t swversion
Definition: HarpoDccFrame.h:23
UInt_t timestamp
Definition: HarpoDccFrame.h:41
void reset()
reset - clear all fields
UShort_t * dccHeader
Definition: HarpoDccFrame.h:49
UShort_t * dccTrailer
Definition: HarpoDccFrame.h:51
UShort_t * dccData
Definition: HarpoDccFrame.h:50
Int_t ChannelNum() const
Definition: HarpoDccFrame.h:59
static UShort_t FecPerFem
Definition: HarpoDccFrame.h:67
UInt_t size
reset - clear all fields
Definition: HarpoDccFrame.h:21
virtual ~HarpoDccFrame()
UInt_t synchfail
Definition: HarpoDccFrame.h:32