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