Rev 261 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 261 | Rev 264 | ||
---|---|---|---|
Line 9... | Line 9... | ||
9 | # include <string.h> |
9 | # include <string.h> |
10 | #endif _CVI_ |
10 | #endif _CVI_ |
11 | 11 | ||
12 | #include "H1D.h" |
12 | #include "H1D.h" |
13 | 13 | ||
14 | #define H1DMAX 500 |
- | |
- | 14 | ||
15 | H1D *h1[H1DMAX]; |
15 | H1D *h1[H1DMAX]; |
16 | //int Printf(char *format, ...); |
16 | //int Printf(char *format, ...); |
17 | 17 | ||
18 | int _VI_FUNC H1D_Clear(int h1d) { |
18 | int _VI_FUNC H1D_Clear(int h1d) { |
19 | if (!h1[h1d]) return -1; |
19 | if (!h1[h1d]) return -1; |
20 | memset(h1[h1d]->data, 0,h1[h1d]->size ); |
20 | memset(h1[h1d]->data, 0,h1[h1d]->size ); |
21 | h1[h1d]->min=0; |
21 | h1[h1d]->min=0; |
22 | h1[h1d]->max=0; |
22 | h1[h1d]->max=0; |
23 | h1[h1d]->nentries=0; |
23 | h1[h1d]->nentries=0; |
24 | return 0; |
24 | return 0; |
25 | 25 | ||
26 | } |
26 | } |
27 | 27 | ||
28 | int _VI_FUNC H1D_Print(int h1d) { |
28 | int _VI_FUNC H1D_Print(int h1d) { |
29 | if (!h1[h1d]) return -1; |
29 | if (!h1[h1d]) return -1; |
30 | //Printf("PrintH1D_ nx=%d minx=%f stepx=%f ny=%d miny=%f stepy=%f size=%d\n", h1[h1d]->nx, h1[h1d]->minx, h1[h1d]->stepx, h1[h1d]->ny, h1[h1d]->miny, h1[h1d]->stepy, h1[h1d]->size ) ; |
30 | //Printf("PrintH1D_ nx=%d minx=%f stepx=%f ny=%d miny=%f stepy=%f size=%d\n", h1[h1d]->nx, h1[h1d]->minx, h1[h1d]->stepx, h1[h1d]->ny, h1[h1d]->miny, h1[h1d]->stepy, h1[h1d]->size ) ; |
31 | return 0; |
31 | return 0; |
32 | 32 | ||
33 | } |
33 | } |
34 | 34 | ||
35 | int _VI_FUNC H1D_Exist(int h) { |
35 | int _VI_FUNC H1D_Exist(int h) { |
36 | if (h1[h]) return 1; |
36 | if (h1[h]) return 1; |
Line 77... | Line 77... | ||
77 | //Printf("FillH1D_ error h1d is not initialized\n"); |
77 | //Printf("FillH1D_ error h1d is not initialized\n"); |
78 | return -1; |
78 | return -1; |
79 | } |
79 | } |
80 | 80 | ||
81 | h1[h1d]->data[x]+=val; |
81 | h1[h1d]->data[x]+=val; |
82 | //Printf("%d %d data %f %f\n",x,y,val, h1[h1d]->data[idx]); |
82 | //Printf("%d %d data %f %f\n",x,y,val, h1[h1d]->data[idx]); |
83 | if (h1[h1d]->data[x]>h1[h1d]->max) h1[h1d]->max= h1[h1d]->data[x]; |
83 | if (h1[h1d]->data[x]>h1[h1d]->max) h1[h1d]->max= h1[h1d]->data[x]; |
84 | if (h1[h1d]->data[x]<h1[h1d]->min) h1[h1d]->min= h1[h1d]->data[x]; |
84 | if (h1[h1d]->data[x]<h1[h1d]->min) h1[h1d]->min= h1[h1d]->data[x]; |
85 | h1[h1d]->nentries++; |
85 | h1[h1d]->nentries++; |
86 | return 0; |
86 | return 0; |
87 | } |
87 | } |
Line 111... | Line 111... | ||
111 | if (atx<0) return 0; |
111 | if (atx<0) return 0; |
112 | if (atx*sizeof(double) < h1[h1d]->size ) return h1[h1d]->data[atx]; |
112 | if (atx*sizeof(double) < h1[h1d]->size ) return h1[h1d]->data[atx]; |
113 | 113 | ||
114 | 114 | ||
115 | return 0; |
115 | return 0; |
116 | } |
116 | } |
117 | 117 | ||
118 | 118 | ||
119 | int _VI_FUNC H1D_Init(int h1d,char *name, char *title,int nx, double minx, double maxx) { |
119 | int _VI_FUNC H1D_Init(int h1d,char *name, char *title,int nx, double minx, double maxx) { |
120 | 120 | ||
121 | if (h1[h1d]) { |
121 | if (h1[h1d]) { |
Line 144... | Line 144... | ||
144 | h1[h1d]->data = (double *) malloc(h1[h1d]->size); |
144 | h1[h1d]->data = (double *) malloc(h1[h1d]->size); |
145 | h1[h1d]->len=sizeof(H1D)-sizeof(double *)+h1[h1d]->size; |
145 | h1[h1d]->len=sizeof(H1D)-sizeof(double *)+h1[h1d]->size; |
146 | H1D_Clear(h1d); |
146 | H1D_Clear(h1d); |
147 | H1D_Print(h1d); |
147 | H1D_Print(h1d); |
148 | //Printf("InitH1D 0x%x\n", h1d ); |
148 | //Printf("InitH1D 0x%x\n", h1d ); |
149 | return |
149 | return h1d; |
150 | 150 | ||
151 | } |
151 | } |
152 | 152 | ||
153 | 153 | ||
154 | double _VI_FUNC H1D_GetXBinCenter(int h1d,int xbin) { |
154 | double _VI_FUNC H1D_GetXBinCenter(int h1d,int xbin) { |