Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
oncsSub_idcaenv792.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file oncsSub_idcaenv792.cc
1 #include "oncsSub_idcaenv792.h"
2 #include <cstring>
3 
5  :oncsSubevent_w4 (data)
6 {
7  samples = 0;
8 }
9 
10 int *oncsSub_idcaenv792::decode ( int *nwout)
11 {
12  int *p;
13 
14 
15  int i,channel;
16  int *SubeventData = &SubeventHdr->data;
17 
18  samples = ( *SubeventData >> 8) & 0x3f; // get bits 8-13
19 
20  // std::cout << "Samples: " << samples << std::endl;
21 
22  p = new int [32]; // we always get 32 channels, even if some channels are 0.
23  memset ( p, 0, 32*4); // clear the array
24 
25 
26  for ( i = 0; i< samples; i++)
27  {
28  if ( ( ( SubeventData[i+1] >> 24) & 7) == 0)
29  {
30  if ( getHitFormat() == IDCAENV785N) // the 785N has the channel info in bits 17...20
31  {
32  channel = (SubeventData[i+1] >> 17) & 0x1f;
33  }
34  else
35  {
36  channel = (SubeventData[i+1] >> 16) & 0x3f;
37  }
38 
39  p[channel] = SubeventData[i+1] & 0xfff;
40 
41  // std::cout << std::hex << SubeventData[i+1] << " " << channel << " " << p[channel] << std::dec << std::endl;
42  }
43  }
44  evnr = SubeventData[samples +1] & 0xffffff;
45 
46  *nwout = 32;
47  return p;
48 }
49 
50 int oncsSub_idcaenv792::iValue(const int ch)
51 {
52 
54 
55  if ( ch < 0 || ch >31 ) return 0;
56 
57  return decoded_data1[ch];
58 
59 }
60 
61 int oncsSub_idcaenv792::iValue(const int,const char *what)
62 {
63 
65 
66  if ( strcmp(what,"SAMPLES") == 0 )
67  {
68  return samples;
69  }
70 
71  if ( strcmp(what,"EVNR") == 0 )
72  {
73  return evnr;
74  }
75 
76  return 0;
77 
78 }
79 
80 
82 {
83  int i,j;
84  // int *SubeventData = &SubeventHdr->data;
85 
86  os << "Samples: " << iValue(0,"SAMPLES") << std::endl;
87  os << "Evt Nr: " << iValue(0,"EVNR") << std::endl;
88 
89 
90  // for ( i = 0; i <= samples ; i++)
91  // {
92  // os << std::hex << std::setw(3) << i << " " << (( SubeventData[i] >> 24) & 7) << " "
93  // << ( SubeventData[i] & 0xffffff ) << std::dec << std::endl ;
94  // }
95 
96 
97  for ( i = 0; i < 32 ; i+=4)
98  {
99 
100  os << std::setw(6) << i << " | ";
101  for ( j = 0; j < 4; j++)
102  {
103  os << std::setw(8) << iValue(j+i) << " ";
104  }
105  os << std::endl;
106  }
107  os << std::endl;
108 }
109