| [165] | 1 | //  Adaptateurs et Drawers divers pour Outils PEIDA++ | 
|---|
|  | 2 | //                             R. Ansari  06-08/98 | 
|---|
|  | 3 | // LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA | 
|---|
|  | 4 |  | 
|---|
| [2615] | 5 | #include "sopnamsp.h" | 
|---|
| [165] | 6 | #include "pipodrw.h" | 
|---|
|  | 7 | #include "generalfit.h" | 
|---|
|  | 8 |  | 
|---|
|  | 9 |  | 
|---|
|  | 10 | //================================================================ | 
|---|
|  | 11 | // PIGFFDrawer | 
|---|
|  | 12 | //================================================================ | 
|---|
|  | 13 |  | 
|---|
|  | 14 | PIGFFDrawer::PIGFFDrawer(GeneralFunction* f) | 
|---|
|  | 15 | : mFunc(f), mNParms(f->NPar()), mParms(new double[mNParms]) | 
|---|
|  | 16 | { | 
|---|
|  | 17 | ASSERT(f->NVar() == 1); | 
|---|
|  | 18 | } | 
|---|
|  | 19 |  | 
|---|
|  | 20 | PIGFFDrawer::~PIGFFDrawer() | 
|---|
|  | 21 | { | 
|---|
|  | 22 | delete[] mParms; | 
|---|
|  | 23 | } | 
|---|
|  | 24 |  | 
|---|
|  | 25 | void | 
|---|
|  | 26 | PIGFFDrawer::SetParms(double const* p) | 
|---|
|  | 27 | { | 
|---|
|  | 28 | for (int i=0; i<mNParms; i++) | 
|---|
|  | 29 | mParms[i] = p[i]; | 
|---|
|  | 30 | } | 
|---|
|  | 31 |  | 
|---|
|  | 32 |  | 
|---|
|  | 33 | void | 
|---|
| [205] | 34 | PIGFFDrawer::Draw(PIGraphicUC* g, double /*xmin*/, double/*ymin*/, double/*xmax*/, double/*ymax*/) | 
|---|
| [165] | 35 | { | 
|---|
|  | 36 | PIGrCoord x1, x2, y1, y2; | 
|---|
|  | 37 | g->GetGrSpace(x1, x2, y1, y2); | 
|---|
| [205] | 38 | double xMax = x2; | 
|---|
|  | 39 | double xMin = x1; | 
|---|
|  | 40 | double yMax = y2; | 
|---|
|  | 41 | double yMin = y1; | 
|---|
|  | 42 | double xStep = (xMax - xMin)/100; | 
|---|
|  | 43 | double xOld = xMin; | 
|---|
|  | 44 | double yOld = 0; | 
|---|
|  | 45 | //  double yOld = f->Value(&xMin, mParms); | 
|---|
|  | 46 | for (double x = xMin+xStep; x<xMax; x+=xStep) { | 
|---|
|  | 47 | double y = 0; // $CHECK$ | 
|---|
|  | 48 | //    double y = f->Value(&x, mParms); | 
|---|
| [165] | 49 | if (y>yMin && yOld>yMin && | 
|---|
|  | 50 | y<yMax && yOld<yMax) | 
|---|
|  | 51 | g->DrawLine(xOld, yOld, x, y); | 
|---|
|  | 52 | xOld = x; | 
|---|
|  | 53 | yOld = y; | 
|---|
|  | 54 | } | 
|---|
|  | 55 | } | 
|---|
|  | 56 |  | 
|---|
| [584] | 57 |  | 
|---|
| [165] | 58 | // ---------------------------------------------------------- | 
|---|
| [584] | 59 | // Adaptateur d'Histo-2D Peida++ a P2DArrayAdapter | 
|---|
| [165] | 60 | // ---------------------------------------------------------- | 
|---|
|  | 61 |  | 
|---|
|  | 62 | /* --Methode-- */ | 
|---|
| [584] | 63 | POH2DAdapter::POH2DAdapter(Histo2D* h2d, bool ad) | 
|---|
|  | 64 | : P2DArrayAdapter(h2d->NBinX(), h2d->NBinY()) | 
|---|
| [165] | 65 | { | 
|---|
| [584] | 66 | aDel = ad; mH2d = h2d; | 
|---|
|  | 67 | DefineXYCoordinates(h2d->XMin(), h2d->YMin(), h2d->WBinX(), h2d->WBinY() ); | 
|---|
| [165] | 68 | } | 
|---|
|  | 69 |  | 
|---|
|  | 70 | /* --Methode-- */ | 
|---|
| [584] | 71 | POH2DAdapter::~POH2DAdapter() | 
|---|
| [165] | 72 | { | 
|---|
| [584] | 73 | if (aDel)  delete mH2d; | 
|---|
| [165] | 74 | } | 
|---|
|  | 75 |  | 
|---|
|  | 76 | /* --Methode-- */ | 
|---|
| [584] | 77 | double POH2DAdapter::Value(int ix, int iy) | 
|---|
|  | 78 | { | 
|---|
|  | 79 | return((*mH2d)(ix, iy)); | 
|---|
| [165] | 80 | } | 
|---|
|  | 81 |  | 
|---|
| [584] | 82 |  | 
|---|
|  | 83 | #ifdef SANS_EVOLPLANCK | 
|---|
|  | 84 |  | 
|---|
| [165] | 85 | // ---------------------------------------------------------- | 
|---|
| [584] | 86 | // Adaptateur de vecteurs Peida++ a P1DArrayAdapter | 
|---|
| [165] | 87 | // ---------------------------------------------------------- | 
|---|
|  | 88 |  | 
|---|
|  | 89 | /* --Methode-- */ | 
|---|
| [584] | 90 | POVectorAdapter::POVectorAdapter(Vector* v, bool ad) | 
|---|
|  | 91 | : P1DArrayAdapter(v->NElts()) | 
|---|
| [165] | 92 | { | 
|---|
| [584] | 93 | aDel = ad; mVec = v; | 
|---|
| [165] | 94 | } | 
|---|
|  | 95 |  | 
|---|
|  | 96 | /* --Methode-- */ | 
|---|
| [584] | 97 | POVectorAdapter::~POVectorAdapter() | 
|---|
| [165] | 98 | { | 
|---|
| [584] | 99 | if (aDel) delete mVec; | 
|---|
| [165] | 100 | } | 
|---|
|  | 101 |  | 
|---|
|  | 102 | /* --Methode-- */ | 
|---|
| [584] | 103 | double POVectorAdapter::Value(int i) | 
|---|
|  | 104 | { | 
|---|
|  | 105 | return((*mVec)(i)); | 
|---|
| [165] | 106 | } | 
|---|
|  | 107 |  | 
|---|
|  | 108 | // ---------------------------------------------------------- | 
|---|
|  | 109 | // Adaptateur de matrice Peida++ a P2DArrayAdapter | 
|---|
|  | 110 | // Attention  Y: Lignes (rows)  X: Colonnes | 
|---|
|  | 111 | // ---------------------------------------------------------- | 
|---|
|  | 112 |  | 
|---|
|  | 113 | /* --Methode-- */ | 
|---|
|  | 114 | POMatrixAdapter::POMatrixAdapter(Matrix* mtx, bool ad) | 
|---|
|  | 115 | : P2DArrayAdapter(mtx->NCol(), mtx->NRows()) | 
|---|
|  | 116 | { | 
|---|
|  | 117 | aDel = ad; mMtx = mtx; | 
|---|
|  | 118 | } | 
|---|
|  | 119 |  | 
|---|
|  | 120 | /* --Methode-- */ | 
|---|
|  | 121 | POMatrixAdapter::~POMatrixAdapter() | 
|---|
|  | 122 | { | 
|---|
|  | 123 | if (aDel)  delete mMtx; | 
|---|
|  | 124 | } | 
|---|
|  | 125 |  | 
|---|
|  | 126 | /* --Methode-- */ | 
|---|
| [205] | 127 | double POMatrixAdapter::Value(int ix, int iy) | 
|---|
| [165] | 128 | { | 
|---|
|  | 129 | // Attention MatrixAdapter(X=Colonne, Y= Row) = Matrix(row, col) | 
|---|
|  | 130 | return((*mMtx)(iy, ix)); | 
|---|
|  | 131 | } | 
|---|
|  | 132 |  | 
|---|
| [584] | 133 | #endif   // SANS_EVOLPLANCK | 
|---|
| [165] | 134 |  | 
|---|