StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BsmdRawData.cxx
1 #include "BsmdRawData.h"
2 
3 
4 #include <TArrayC.h>
5 #include <TArrayS.h>
6 #include <TObjArray.h>
7 
8 ClassImp(BsmdRawData)
9 
10 
11 //--------------------------------------------------
12 //
13 //--------------------------------------------------
15  used=new TArrayS ;
16  caps=new TArrayC ;
17  head=new TArrayS ;
18  data=new TArrayS ;
19  clear();
20 }
21 
22 //--------------------------------------------------
23 //
24 //--------------------------------------------------
25 BsmdRawData :: ~BsmdRawData() {
26  delete caps;
27  delete used;
28  delete head;
29  delete data;
30 }
31 
32 
33 //--------------------------------------------------
34 //
35 //--------------------------------------------------
36 void BsmdRawData :: clear() {
37  caps->Reset();
38  used->Reset();
39  head->Reset();
40  data->Reset();
41  nBlock=0;
42 }
43 
44 //--------------------------------------------------
45 //--------------------------------------------------
46 int BsmdRawData ::headSize() const{
47 return nBlock>0 ? head->GetSize()/ nBlock: 0;
48 }
49 
50 //--------------------------------------------------
51 //--------------------------------------------------
52 int BsmdRawData ::dataBlockSize() const{
53 return nBlock>0 ? data->GetSize()/ nBlock: 0;
54 }
55 
56 //--------------------------------------------------
57 //--------------------------------------------------
58 void BsmdRawData :: print(int k, FILE *fd) const{
59  fprintf(fd,"BsmdRawData:: print() \n");
60  fprintf(fd,"used %.0f blocks\n", used->GetSum());
61 
62  unsigned char *capsA=(unsigned char*)caps->GetArray();
63  unsigned short *usedA=(unsigned short *)used->GetArray();
64  int i;
65  for(i=0;i<used->GetSize();i++) {
66  if(!usedA[i]) continue;
67  printf("i=%d used=%d caps=%d\n",i,usedA[i],capsA[i]);
68  }
69 
70  int hSize=headSize();
71  int bSize=dataBlockSize();
72  fprintf(fd,"No. of nonzero blocks %d, size: heder=%d, dataBlock=%d\n", nBlock,hSize,bSize);
73  if(nBlock<=0) return;
74 
75  if(k<=0) return;
76 
77  unsigned short *headA=(unsigned short *)head->GetArray();
78  unsigned short *dataA=(unsigned short *)data->GetArray();
79  int ib;
80 
81  for(ib=0;ib<nBlock;ib++) {
82  int j;
83  printf("\n======\nSMD BANK=%d header size=%d\n",ib,hSize);
84  for(j = 0;j<hSize;j++) {
85  if(j%16==0) printf("\n");
86  printf("0x%04x ",headA[ib*hSize+j]);
87  }
88  printf("\n");
89  if(k<=1) continue;
90 
91  printf("\n======\nSMD BANK=%d data size=%d\n",ib,bSize);
92  for(j = 0;j<bSize;j++) {
93  if(j%16==0) printf("\n");
94  printf("0x%04x ",dataA[ib*bSize+j]);
95  }
96  printf("\n");
97  }
98 
99 
100 
101 
102 }
103 
104