Subversion Repositories f9daq

Rev

Rev 230 | Rev 247 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
230 f9daq 1
#include <TH1D.h>
2
#include <TStyle.h>
3
#include <TPad.h>
4
#include "mH1D.h"
5
 
6
double H1DGetBinContent(H1D *h1d,int atx){
7
 
8
if (!h1d) return 0;
9
if (h1d->nx <= atx)  return 0;  
10
if (atx < h1d->size ) return h1d->data[atx];
11
 
12
 
13
return 0;
14
}
15
 
16
 
17
int H1Dload(char *fname){
18
 
19
FILE *fp= fopen(fname ,"rb");
20
if (!fp) return -1;
21
H1D *h = new H1D;
22
int size=sizeof(H1D);
23
int nb1 = fread(h,1, size,fp);
24
if (size + h->size !=h->len ) printf("WRONG HEADER ! Check sizeof H2D on CVI\n");
25
 
26
size=h->size;
27
h->data = new double[size];
28
int nb  = fread(h->data,1, size,fp);
29
printf("hdr nb=%d : sizeof(HDR)=%d +datasize=%d == len=%d\t",nb1,sizeof(H1D), h->size, h->len);
30
printf("data nb=%d size=%d\n",nb,size);
31
 
32
TH1D *h1d = new TH1D(h->name, h->title,
33
                     h->nx, h->minx-0.5*h->stepx,h->minx+(h->nx-0.5)*h->stepx );
34
h1d->SetTitle(h->title);
35
h1d->SetTitle("");
36
h1d->GetXaxis()->SetTitle(h->titlex);
37
h1d->GetYaxis()->SetTitle(h->titley);
246 f9daq 38
printf("TH1D name='%s' title='%s' x='%s' y='%s'\nnx=%d min=%f max=%f \n",h->name, h->title,h->titlex, h->titley,
230 f9daq 39
                     h->nx, h->minx,h->minx+h->nx*h->stepx);
40
 
41
 
42
//h2d->ls();
43
//h2d->Print();
44
 
45
for (int ix=0;ix<h->nx;ix++){
46
 
47
         double g=H1DGetBinContent(h,ix);
48
     h1d->SetBinContent(ix+1, g);
49
//       if (g>0) printf("i %d j %d v %g\n",ix+1,iy+1,g);
50
 
51
}
52
 
53
gStyle->SetOptStat(0);
54
h1d->Draw("colz");
246 f9daq 55
 
230 f9daq 56
char hname[100];
57
sprintf(hname,"%s.pdf",fname);
58
gPad->SaveAs(hname);
246 f9daq 59
h1d->FitPanel();
230 f9daq 60
return 0;
61
}