[2414] | 1 | /*
|
---|
| 2 | * This example demonstrate how to call HBOOK from C (ntuple part).
|
---|
| 3 | *
|
---|
| 4 | * For question/problems contact: Heplib.Support@cern.ch
|
---|
| 5 | *
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include <stdlib.h>
|
---|
| 9 | #include <cfortran.h>
|
---|
| 10 | #include <packlib.h>
|
---|
| 11 |
|
---|
| 12 | #define PAWC_SIZE 50000
|
---|
| 13 |
|
---|
| 14 | typedef struct { float PAW[PAWC_SIZE]; } PAWC_DEF;
|
---|
| 15 | #define PAWC COMMON_BLOCK(PAWC,pawc)
|
---|
| 16 | COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
|
---|
| 17 |
|
---|
| 18 | main()
|
---|
| 19 | {
|
---|
| 20 | int hid=1,istat=0,icycle=0;
|
---|
| 21 | int i,i1,j;
|
---|
| 22 | int nvar;
|
---|
| 23 | float r[3];
|
---|
| 24 | char chtag_in[3][6]={"X","Y","Z"};
|
---|
| 25 | char chtag_out[5][8],chtitl[80];
|
---|
| 26 | float rmin[5],rmax[5];
|
---|
| 27 | int record_size=1024;
|
---|
| 28 |
|
---|
| 29 | HLIMIT(PAWC_SIZE);
|
---|
| 30 | HROPEN(1,"example","ntuple-example.hbook","N",record_size,istat);
|
---|
| 31 | HBOOKN(hid," An Ntuple",3," ",5000,chtag_in);
|
---|
| 32 |
|
---|
| 33 | for (i=0;i<10000;i++){
|
---|
| 34 | for(i1=0;i1<3;i1++)
|
---|
| 35 | for (j=0,r[i1]=0.;j<10;r[i1] += rand()/32768. -0.5 ,j++);
|
---|
| 36 | HFN(hid,r);
|
---|
| 37 | }
|
---|
| 38 | nvar=5;
|
---|
| 39 | HGIVEN(hid,chtitl,nvar,chtag_out,rmin,rmax);
|
---|
| 40 | printf(" title obtained:%s\n variables %d\ntags:>%s< >%s< >%s<\n",
|
---|
| 41 | chtitl,nvar,chtag_out[0],chtag_out[1],chtag_out[2]);
|
---|
| 42 | printf(" rmin: %e %e %e\n",rmin[0],rmin[1],rmin[2]);
|
---|
| 43 | printf(" rmax: %e %e %e\n",rmax[0],rmax[1],rmax[2]);
|
---|
| 44 |
|
---|
| 45 | HROUT(0,icycle," ");
|
---|
| 46 | HREND("example");
|
---|
| 47 | KUCLOS(1," ",1);
|
---|
| 48 | }
|
---|