[808] | 1 | #include <stdio.h>
|
---|
| 2 | #include <stdlib.h>
|
---|
[987] | 3 | #include <math.h>
|
---|
[2322] | 4 | #include <iostream>
|
---|
[808] | 5 | #include <string>
|
---|
| 6 |
|
---|
| 7 | // Pour le test
|
---|
[2615] | 8 | #include "sopnamsp.h"
|
---|
[808] | 9 | #include "histinit.h"
|
---|
| 10 | #include "histos.h"
|
---|
| 11 | #include "histos2.h"
|
---|
| 12 | #include "ntuple.h"
|
---|
| 13 | #include "tarray.h"
|
---|
| 14 |
|
---|
| 15 |
|
---|
| 16 | #include "fmath.h"
|
---|
[3077] | 17 | #include "srandgen.h"
|
---|
[808] | 18 |
|
---|
| 19 |
|
---|
| 20 | int main(int narg, char* arg[])
|
---|
| 21 | {
|
---|
| 22 |
|
---|
| 23 | SophyaInit();
|
---|
| 24 |
|
---|
| 25 | cout << "Hash check, OMatrix : " << hex << PIOPersist::Hash("OMatrix") << dec << endl;
|
---|
| 26 |
|
---|
| 27 | cout << "Test Creation / PPersist Save NTuple, Histo, ..." << endl;
|
---|
| 28 |
|
---|
| 29 | try {
|
---|
| 30 | POutPersist so("tobjio2.ppf");
|
---|
| 31 |
|
---|
| 32 | NTuple *nt;
|
---|
| 33 | float xnt[4];
|
---|
| 34 | char *ntn[4] = {"x","y","ex","ey"};
|
---|
| 35 | int nent,i;
|
---|
| 36 | nent = 1000;
|
---|
| 37 | nt = new NTuple(2,ntn); // Creation NTuple (AVEC new )
|
---|
| 38 | for(i=0; i<nent; i++) {
|
---|
| 39 | xnt[0] = i*50./nent; xnt[1] = 0.2*xnt[0]*xnt[0]+(NorRand()*xnt[0]/3.);
|
---|
| 40 | nt->Fill(xnt);
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | string nom = "nt21";
|
---|
| 44 | cout << "Writing " << nom << endl;
|
---|
| 45 | so.PutObject(*nt, nom);
|
---|
| 46 |
|
---|
| 47 | string nx, ny, nz;
|
---|
| 48 | string ex,ey,ez;
|
---|
| 49 | nx = "x"; ny = "y";
|
---|
| 50 | nent = 20;
|
---|
| 51 | nt = new NTuple(4,ntn); // Creation NTuple (AVEC new )
|
---|
| 52 | for(i=0; i<nent; i++) {
|
---|
| 53 | xnt[0] = i*50./nent; xnt[1] = 0.2*xnt[0]*xnt[0]+(NorRand()*xnt[0]/3.);
|
---|
| 54 | xnt[2] = sqrt((double) xnt[0]); xnt[3] = xnt[0]*2;
|
---|
| 55 | nt->Fill(xnt);
|
---|
| 56 | }
|
---|
| 57 | nom = "nt22";
|
---|
| 58 | cout << "Writing " << nom << endl;
|
---|
| 59 | so.PutObject(*nt, nom);
|
---|
| 60 |
|
---|
| 61 | { // Objet Histo-2D
|
---|
[1092] | 62 | r_8 x,y,w;
|
---|
[808] | 63 | int i,j;
|
---|
| 64 | Histo2D* h = new Histo2D(-10.,10.,25,-10.,10.,25);
|
---|
| 65 | for(i=0; i<25; i++) for(j=0; j<25; j++) {
|
---|
| 66 | h->BinCenter(i,j,x,y);
|
---|
| 67 | w = 100.*exp(-0.5*(x*x/9. + y*y/9.));
|
---|
| 68 | h->Add(x,y,w);
|
---|
| 69 | w = 50.*exp(-0.5*((x+10.)*(x+10.)/9. + (y+10.)*(y+10.)/9.));
|
---|
| 70 | h->Add(x,y,w);
|
---|
| 71 | }
|
---|
| 72 | nom = "h2d";
|
---|
| 73 | cout << "Writing " << nom << endl;
|
---|
| 74 | so.PutObject(*h, nom);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | { // Matrices
|
---|
| 79 | TArray<double> * mtx = new TArray<double>(50, 50);
|
---|
| 80 | int i,j;
|
---|
| 81 | double xp,yp,rp;
|
---|
| 82 | for(i=0; i<50; i++)
|
---|
| 83 | for(j=0; j<50; j++) {
|
---|
| 84 | xp = i-15; yp = j-25;
|
---|
| 85 | rp = (xp*xp)/16.+(yp*yp)/16.;
|
---|
| 86 | (*mtx)(j,i,0) = 11.*exp(-rp);
|
---|
| 87 | xp = i-35; yp = j-15;
|
---|
| 88 | rp = (xp*xp)/9.+(yp*yp)/9.;
|
---|
| 89 | (*mtx)(j,i,0) += 3.*exp(-rp);
|
---|
| 90 | xp = i-45; yp = j-40;
|
---|
| 91 | rp = (xp*xp)/10.+(yp*yp)/20.;
|
---|
| 92 | (*mtx)(j,i,0) += 6.*exp(-rp);
|
---|
| 93 | }
|
---|
| 94 | nom = "mtx1";
|
---|
| 95 | cout << "Writing " << nom << endl;
|
---|
| 96 | so.PutObject(*mtx, nom);
|
---|
| 97 |
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 | catch (PThrowable exc) {
|
---|
| 101 | cerr << " Catched Exception PThrowable - Msg= " << exc.Msg() << endl;
|
---|
| 102 | }
|
---|
| 103 | cout << " End --- exit .... " << endl;
|
---|
| 104 | }
|
---|
| 105 |
|
---|