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