[165] | 1 | #include <stdio.h>
|
---|
| 2 | #include <stdlib.h>
|
---|
| 3 | #include <ctype.h>
|
---|
| 4 |
|
---|
[295] | 5 | #include <typeinfo>
|
---|
[165] | 6 | #include <iostream.h>
|
---|
| 7 | #include <string>
|
---|
| 8 | #include <list>
|
---|
| 9 | #include <map>
|
---|
| 10 | #if defined(__KCC__)
|
---|
| 11 | using std::string ;
|
---|
| 12 | #include <list.h>
|
---|
| 13 | #include <map.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include "strutil.h"
|
---|
| 17 |
|
---|
| 18 | #include "nobjmgr.h"
|
---|
| 19 | #include "servnobjm.h"
|
---|
[330] | 20 | #include "nomgadapter.h"
|
---|
[165] | 21 | #include "pistdimgapp.h"
|
---|
| 22 |
|
---|
[333] | 23 | #include "fct1dfit.h"
|
---|
| 24 | #include "fct2dfit.h"
|
---|
| 25 |
|
---|
| 26 | #include "matrix.h"
|
---|
| 27 | #include "cvector.h"
|
---|
| 28 | #include "ntuple.h"
|
---|
| 29 | #include "cimage.h"
|
---|
| 30 |
|
---|
[165] | 31 | #include "histos.h"
|
---|
| 32 | #include "histos2.h"
|
---|
| 33 | #include "ntuple.h"
|
---|
| 34 | #include "hisprof.h"
|
---|
| 35 |
|
---|
[326] | 36 | #include "piscdrawwdg.h"
|
---|
| 37 | #include "pisurfdr.h"
|
---|
[333] | 38 |
|
---|
| 39 | #include "pintuple.h"
|
---|
| 40 | #include "pintup3d.h"
|
---|
| 41 |
|
---|
[326] | 42 | #include "pipodrw.h"
|
---|
[165] | 43 |
|
---|
| 44 |
|
---|
[326] | 45 |
|
---|
[165] | 46 | /* --Methode-- */
|
---|
[333] | 47 | Services2NObjMgr::Services2NObjMgr(NamedObjMgr* omg, string& tmpdir)
|
---|
[165] | 48 | {
|
---|
| 49 | TmpDir = tmpdir;
|
---|
[171] | 50 | PDynLinkMgr::SetTmpDir(tmpdir);
|
---|
[333] | 51 | mImgapp = NULL;
|
---|
| 52 | mOmg = omg;
|
---|
[171] | 53 | dynlink = NULL;
|
---|
[165] | 54 | InitGrAttNames();
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | /* --Methode-- */
|
---|
| 58 | Services2NObjMgr::~Services2NObjMgr()
|
---|
| 59 | {
|
---|
| 60 | CloseDLL();
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | /* --Methode-- */
|
---|
[295] | 64 | void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
|
---|
[165] | 65 | {
|
---|
[295] | 66 | ObjAdaptList::iterator it;
|
---|
| 67 | for(it = objadaplist.begin(); it != objadaplist.end(); it++)
|
---|
| 68 | if (typeid(*o) == typeid(*((*it).obj))) THROW(dupIdErr);
|
---|
[165] | 69 |
|
---|
[295] | 70 | dataobj_adapter oba;
|
---|
| 71 | oba.obj = o;
|
---|
| 72 | oba.obja = oa;
|
---|
| 73 | objadaplist.push_back(oba);
|
---|
| 74 | }
|
---|
[165] | 75 |
|
---|
[295] | 76 | /* --Methode-- */
|
---|
| 77 | NObjMgrAdapter* Services2NObjMgr::GetAdapter(AnyDataObj* o)
|
---|
| 78 | {
|
---|
| 79 | ObjAdaptList::iterator it;
|
---|
| 80 | for(it = objadaplist.begin(); it != objadaplist.end(); it++)
|
---|
| 81 | if (typeid(*o) == typeid(*((*it).obj))) return((*it).obja->Clone(o));
|
---|
| 82 | return(new NObjMgrAdapter(o));
|
---|
| 83 | }
|
---|
[165] | 84 |
|
---|
[295] | 85 | /* --Methode-- */
|
---|
[333] | 86 | void Services2NObjMgr::PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, int np, string dopt)
|
---|
[295] | 87 | {
|
---|
[165] | 88 | FILE *fip;
|
---|
[326] | 89 | string fname = TmpDir + "func1_pia_dl.c";
|
---|
| 90 | string cmd;
|
---|
| 91 | int rc;
|
---|
| 92 |
|
---|
| 93 | if (!mImgapp) return;
|
---|
| 94 |
|
---|
| 95 | cmd = "rm -f " + fname;
|
---|
| 96 | rc = system(cmd.c_str());
|
---|
| 97 | // printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 98 |
|
---|
| 99 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 100 | string sn = fname;
|
---|
[333] | 101 | cout << "Services2NObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl;
|
---|
[326] | 102 | return;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | // constitution du fichier a compiler
|
---|
| 106 | fputs("#include <math.h> \n", fip);
|
---|
| 107 | fputs("double func1_pia_dl_func(double x) \n{\n", fip);
|
---|
| 108 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
|
---|
| 109 | fclose(fip);
|
---|
| 110 |
|
---|
| 111 | string func = "func1_pia_dl_func";
|
---|
| 112 | DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
|
---|
| 113 | if (!f) return;
|
---|
[333] | 114 | PlotFunc(f, nom, xmin, xmax, np, dopt);
|
---|
[326] | 115 | CloseDLL();
|
---|
| 116 | return;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | /* --Methode-- */
|
---|
[333] | 120 | void Services2NObjMgr::PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax,
|
---|
| 121 | double ymin, double ymax, int npx, int npy, string dopt)
|
---|
[326] | 122 | {
|
---|
| 123 | FILE *fip;
|
---|
| 124 | string fname = TmpDir + "func2_pia_dl.c";
|
---|
| 125 | string cmd;
|
---|
| 126 | int rc;
|
---|
| 127 |
|
---|
| 128 | if (!mImgapp) return;
|
---|
| 129 |
|
---|
| 130 | cmd = "rm " + fname;
|
---|
| 131 | rc = system(cmd.c_str());
|
---|
| 132 | // printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 133 |
|
---|
| 134 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 135 | string sn = fname;
|
---|
[333] | 136 | cout << "Services2NObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl;
|
---|
[326] | 137 | return;
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | // constitution du fichier a compiler
|
---|
| 141 | fputs("#include <math.h> \n", fip);
|
---|
| 142 | fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
|
---|
| 143 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
|
---|
| 144 | fclose(fip);
|
---|
| 145 |
|
---|
| 146 | string func = "func2_pia_dl_func";
|
---|
| 147 | DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
|
---|
| 148 | if (!f) return;
|
---|
[333] | 149 | PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
|
---|
[326] | 150 | CloseDLL();
|
---|
| 151 | return;
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | /* --Methode-- */
|
---|
[333] | 155 | void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, string & nom,
|
---|
| 156 | double xmin, double xmax, int np, string dopt)
|
---|
[326] | 157 | {
|
---|
| 158 | DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
|
---|
| 159 | if (!f) return;
|
---|
[333] | 160 | PlotFunc(f, nom, xmin, xmax, np, dopt);
|
---|
[326] | 161 | CloseDLL();
|
---|
| 162 | return;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | /* --Methode-- */
|
---|
[333] | 166 | void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, string & nom,
|
---|
| 167 | double xmin, double xmax, double ymin, double ymax, int npx, int npy, string dopt)
|
---|
[326] | 168 | {
|
---|
| 169 | DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
|
---|
| 170 | if (!f) return;
|
---|
[333] | 171 | PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
|
---|
[326] | 172 | CloseDLL();
|
---|
| 173 | return;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | /* --Methode-- */
|
---|
[333] | 177 | void Services2NObjMgr::PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, int np, string dopt)
|
---|
[326] | 178 | {
|
---|
| 179 | if (!mImgapp) return;
|
---|
| 180 |
|
---|
| 181 | int k;
|
---|
| 182 | if (np < 1) np = 1;
|
---|
| 183 | if (xmax <= xmin) xmax = xmin+1.;
|
---|
| 184 | Vector* vpy = new Vector(np);
|
---|
| 185 |
|
---|
| 186 | double xx;
|
---|
| 187 | double dx = (xmax-xmin)/np;
|
---|
| 188 | TRY {
|
---|
| 189 | for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
|
---|
| 190 | } CATCH(merr) {
|
---|
| 191 | fflush(stdout);
|
---|
| 192 | cout << endl;
|
---|
| 193 | cerr << endl;
|
---|
| 194 | string es = PeidaExc(merr);
|
---|
| 195 | cerr << "Services2NObjMgr::PlotFunc() Exception :" << merr << es;
|
---|
| 196 | delete vpy;
|
---|
| 197 | vpy = NULL;
|
---|
| 198 | } ENDTRY;
|
---|
| 199 |
|
---|
| 200 |
|
---|
| 201 | if (vpy) {
|
---|
[333] | 202 | string titre = (nom.length() < 1) ? "Function f(x)" : nom;
|
---|
[326] | 203 | P1DArrayAdapter* vya = new POVectorAdapter(vpy, true);
|
---|
| 204 | vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
|
---|
| 205 | PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ;
|
---|
| 206 | bool fgsr = true;
|
---|
| 207 | dopt = "thinline," + dopt;
|
---|
| 208 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
[333] | 209 | int rsid = mImgapp->DispScDrawer(dr, titre, opt);
|
---|
[326] | 210 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
[333] | 211 | if (nom.length() > 0) {
|
---|
| 212 | mOmg->AddObj(vpy, nom);
|
---|
| 213 | mOmg->AddWRsId(nom, rsid);
|
---|
| 214 | }
|
---|
[326] | 215 | }
|
---|
| 216 |
|
---|
| 217 | return;
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | /* --Methode-- */
|
---|
[333] | 221 | void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, double ymin, double ymax,
|
---|
[326] | 222 | int npx, int npy, string dopt)
|
---|
| 223 | {
|
---|
| 224 | if (!mImgapp) return;
|
---|
| 225 |
|
---|
| 226 | if (npx < 3) npx = 3;
|
---|
| 227 | if (npy < 3) npy = 3;
|
---|
| 228 | if (npx > 250) npx = 250;
|
---|
| 229 | if (npy > 250) npy = 250;
|
---|
| 230 | if (xmax <= xmin) xmax = xmin+1.;
|
---|
| 231 | if (ymax <= ymin) ymax = ymin+1.;
|
---|
| 232 |
|
---|
| 233 | Matrix* mtx = new Matrix(npy, npx);
|
---|
| 234 |
|
---|
| 235 | int i,j;
|
---|
| 236 | double xx, yy;
|
---|
| 237 | double dx = (xmax-xmin)/npx;
|
---|
| 238 | double dy = (ymax-ymin)/npy;
|
---|
| 239 | // printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
|
---|
| 240 | TRY {
|
---|
| 241 | for(j=0; j<npy; j++) {
|
---|
| 242 | yy = ymin+dy*j;
|
---|
| 243 | for(i=0; i<npx; i++) {
|
---|
| 244 | xx = xmin+dx*i;
|
---|
| 245 | (*mtx)(j, i) = f(xx, yy);
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
| 248 | } CATCH(merr) {
|
---|
| 249 | fflush(stdout);
|
---|
| 250 | cout << endl;
|
---|
| 251 | cerr << endl;
|
---|
| 252 | string es = PeidaExc(merr);
|
---|
| 253 | cerr << "Services2NObjMgr::PlotFunc2D() Exception :" << merr << es;
|
---|
| 254 | delete mtx; mtx = NULL;
|
---|
| 255 | } ENDTRY;
|
---|
| 256 |
|
---|
| 257 | if (mtx) {
|
---|
[333] | 258 | string titre = (nom.length() < 1) ? "Function f(x,y)" : nom;
|
---|
[326] | 259 | bool fgsr = true;
|
---|
| 260 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 261 | P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true);
|
---|
| 262 | arr->DefineXYCoordinates(xmin, ymin, dx, dy);
|
---|
| 263 | PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
|
---|
[333] | 264 | int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
|
---|
[326] | 265 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
[333] | 266 | if (nom.length() > 0) {
|
---|
| 267 | mOmg->AddObj(mtx, nom);
|
---|
| 268 | mOmg->AddWRsId(nom, rsid);
|
---|
| 269 | }
|
---|
[326] | 270 | }
|
---|
| 271 |
|
---|
| 272 | return;
|
---|
| 273 | }
|
---|
| 274 |
|
---|
| 275 | /* --Methode-- */
|
---|
[333] | 276 | void Services2NObjMgr::DisplayPoints2D(string& nom, string& expx, string& expy,
|
---|
| 277 | string& experrx, string& experry,
|
---|
| 278 | string& expcut, string dopt)
|
---|
| 279 | {
|
---|
| 280 | NObjMgrAdapter* obja=NULL;
|
---|
| 281 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 282 | if (obja == NULL) {
|
---|
| 283 | cout << "Services2NObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 284 | return;
|
---|
| 285 | }
|
---|
| 286 | if (!mImgapp) return;
|
---|
| 287 |
|
---|
| 288 | // Creation NTuple
|
---|
| 289 | char* ntn[4] = {"expx","expy","expex","expey",};
|
---|
| 290 | NTuple* nt = NULL;
|
---|
| 291 | bool haserr = false;
|
---|
| 292 |
|
---|
| 293 | if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) { haserr = true; nt = new NTuple(4, ntn); }
|
---|
| 294 | else { haserr = false; experrx = experry = "0."; nt = new NTuple(2, ntn); }
|
---|
| 295 |
|
---|
| 296 | ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
|
---|
| 297 |
|
---|
| 298 | if (nt->NEntry() < 1) {
|
---|
| 299 | cout << "Services2NObjMgr::DisplayPoints2D() Warning Zero points satisfy cut !" << endl;
|
---|
| 300 | delete nt;
|
---|
| 301 | return;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | // nt->Show();
|
---|
| 305 | // nt->Print(0,10);
|
---|
| 306 | PINTuple* pin = new PINTuple(nt, true);
|
---|
| 307 | pin->SelectXY(ntn[0], ntn[1]);
|
---|
| 308 | if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
|
---|
| 309 |
|
---|
| 310 | bool fgsr = true;
|
---|
| 311 | dopt = "defline," + dopt;
|
---|
| 312 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 313 | string titre = nom + ":" + expy + "%" + expx;
|
---|
| 314 | mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
|
---|
| 315 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
| 316 | return;
|
---|
| 317 | }
|
---|
| 318 |
|
---|
| 319 | /* --Methode-- */
|
---|
| 320 | void Services2NObjMgr::DisplayPoints3D(string& nom, string& expx, string& expy,
|
---|
| 321 | string& expz, string& expcut, string dopt)
|
---|
| 322 | {
|
---|
| 323 | NObjMgrAdapter* obja=NULL;
|
---|
| 324 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 325 | if (obja == NULL) {
|
---|
| 326 | cout << "Services2NObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 327 | return;
|
---|
| 328 | }
|
---|
| 329 | if (!mImgapp) return;
|
---|
| 330 |
|
---|
| 331 | char* ntn[3] = {"expx","expy","expz"};
|
---|
| 332 | NTuple* nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 333 |
|
---|
| 334 | string expwt = "1.";
|
---|
| 335 | ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
|
---|
| 336 |
|
---|
| 337 | if (nt->NEntry() < 1) {
|
---|
| 338 | cout << "Services2NObjMgr::DisplayPoints3D() Warning Zero points satisfy cut !" << endl;
|
---|
| 339 | delete nt;
|
---|
| 340 | return;
|
---|
| 341 | }
|
---|
| 342 | nt->Show();
|
---|
| 343 | nt->Print(0,10);
|
---|
| 344 | PINTuple3D* pin = new PINTuple3D(nt, true);
|
---|
| 345 | pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
|
---|
| 346 | bool fgsr = true;
|
---|
| 347 | dopt = "defline," + dopt;
|
---|
| 348 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 349 |
|
---|
| 350 | // Pour plot a partir de DispScDrawer
|
---|
| 351 | // string nomdisp = "_NT3D_";
|
---|
| 352 | // mImgapp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
|
---|
| 353 | // Pour plot a partir de Disp3DDrawer
|
---|
| 354 | string titre = nom + ":" + expy + "%" + expx;
|
---|
| 355 | mImgapp->Disp3DDrawer(pin, titre, opt);
|
---|
| 356 |
|
---|
| 357 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
| 358 | return;
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 | /* --Methode-- */
|
---|
| 362 | void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy,
|
---|
| 363 | string& expwt, string& expcut, string dopt)
|
---|
| 364 | {
|
---|
| 365 | NObjMgrAdapter* obja=NULL;
|
---|
| 366 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 367 | if (obja == NULL) {
|
---|
| 368 | cout << "Services2NObjMgr::DisplayPoints2DW() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 369 | return;
|
---|
| 370 | }
|
---|
| 371 | if (!mImgapp) return;
|
---|
| 372 |
|
---|
| 373 | char* ntn[3] = {"expx","expy","expw"};
|
---|
| 374 | NTuple* nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 375 |
|
---|
| 376 | string exp = "1.";
|
---|
| 377 | ComputeExpressions(obja, expx, expy, expwt, exp, expcut, nt, NULL, NULL);
|
---|
| 378 |
|
---|
| 379 | if (nt->NEntry() < 1) {
|
---|
| 380 | cout << "Services2NObjMgr::DisplayPoints2DW() Warning Zero points satisfy cut !" << endl;
|
---|
| 381 | delete nt;
|
---|
| 382 | return;
|
---|
| 383 | }
|
---|
| 384 |
|
---|
| 385 | PINTuple* pin = new PINTuple(nt, true);
|
---|
| 386 | pin->SelectXY(ntn[0], ntn[1]);
|
---|
| 387 | pin->SelectWt(ntn[2]);
|
---|
| 388 |
|
---|
| 389 | bool fgsr = true;
|
---|
| 390 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 391 | string titre = nom + ":" + expwt + "_" + expy + "%" + expx ;
|
---|
| 392 | mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
|
---|
| 393 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
| 394 | return;
|
---|
| 395 | }
|
---|
| 396 |
|
---|
| 397 | /* --Methode-- */
|
---|
| 398 | void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt,
|
---|
| 399 | string& expcut, string& nomh1, string dopt)
|
---|
| 400 | {
|
---|
| 401 | NObjMgrAdapter* obja=NULL;
|
---|
| 402 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 403 | if (obja == NULL) {
|
---|
| 404 | cout << "Services2NObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 405 | return;
|
---|
| 406 | }
|
---|
| 407 | if (!mImgapp) return;
|
---|
| 408 |
|
---|
| 409 | Histo* h1 = NULL;
|
---|
| 410 | NTuple* nt = NULL;
|
---|
| 411 | AnyDataObj* oh = NULL;
|
---|
| 412 | if (nomh1.length() > 0) oh=mOmg->GetObj(nomh1);
|
---|
| 413 | else nomh1 = "/tmp/projh1d";
|
---|
| 414 | if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) ) h1 = (Histo*)oh; // Pas de remise a zero ! h1->Zero();
|
---|
| 415 | else {
|
---|
| 416 | char* ntn[2]= {"hxval", "hwt"};
|
---|
| 417 | nt = new NTuple(2,ntn); // Creation NTuple
|
---|
| 418 | }
|
---|
| 419 | string expz = "0.";
|
---|
| 420 | ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
|
---|
| 421 |
|
---|
| 422 | if ((!h1) && (!nt)) return;
|
---|
| 423 | if (!h1) {
|
---|
| 424 | if (nt->NEntry() < 1) {
|
---|
| 425 | cout << "Services2NObjMgr::ProjectH1() Warning Zero points satisfy cut !" << endl;
|
---|
| 426 | delete nt;
|
---|
| 427 | return;
|
---|
| 428 | }
|
---|
| 429 | double xmin, xmax;
|
---|
| 430 | nt->GetMinMax(0, xmin, xmax);
|
---|
| 431 | h1 = new Histo(xmin, xmax, 100);
|
---|
| 432 | int k;
|
---|
| 433 | float* xn;
|
---|
| 434 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 435 | xn = nt->GetVec(k);
|
---|
| 436 | h1->Add(xn[0], xn[1]);
|
---|
| 437 | }
|
---|
| 438 | delete nt;
|
---|
| 439 | mOmg->AddObj(h1, nomh1);
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | mOmg->DisplayObj(nomh1, dopt);
|
---|
| 443 | return;
|
---|
| 444 | }
|
---|
| 445 |
|
---|
| 446 | /* --Methode-- */
|
---|
| 447 | void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt,
|
---|
| 448 | string& expcut, string& nomh2, string dopt)
|
---|
| 449 | {
|
---|
| 450 | NObjMgrAdapter* obja=NULL;
|
---|
| 451 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 452 | if (obja == NULL) {
|
---|
| 453 | cout << "Services2NObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 454 | return;
|
---|
| 455 | }
|
---|
| 456 | if (!mImgapp) return;
|
---|
| 457 |
|
---|
| 458 | Histo2D* h2 = NULL;
|
---|
| 459 | NTuple* nt = NULL;
|
---|
| 460 | AnyDataObj* oh = NULL;
|
---|
| 461 | if (nomh2.length() > 0) oh=mOmg->GetObj(nomh2);
|
---|
| 462 | else nomh2 = "/tmp/projh2d";
|
---|
| 463 | if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) ) h2 = (Histo2D*)oh; // Pas de remise a zero ! h2->Zero();
|
---|
| 464 | else {
|
---|
| 465 | char* ntn[3]= {"hxval", "hyval", "hwt"};
|
---|
| 466 | nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 467 | }
|
---|
| 468 | string expz = "0.";
|
---|
| 469 | ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
|
---|
| 470 |
|
---|
| 471 | if ((!h2) && (!nt)) return;
|
---|
| 472 | if (!h2) {
|
---|
| 473 | if (nt->NEntry() < 1) {
|
---|
| 474 | cout << "Services2NObjMgr::ProjectH2() Warning Zero points satisfy cut !" << endl;
|
---|
| 475 | delete nt;
|
---|
| 476 | return;
|
---|
| 477 | }
|
---|
| 478 | double xmin, xmax, ymin, ymax;
|
---|
| 479 | nt->GetMinMax(0, xmin, xmax);
|
---|
| 480 | nt->GetMinMax(0, ymin, ymax);
|
---|
| 481 | h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
|
---|
| 482 | int k;
|
---|
| 483 | float* xn;
|
---|
| 484 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 485 | xn = nt->GetVec(k);
|
---|
| 486 | h2->Add(xn[0], xn[1], xn[2]);
|
---|
| 487 | }
|
---|
| 488 | delete nt;
|
---|
| 489 | mOmg->AddObj(h2, nomh2);
|
---|
| 490 | }
|
---|
| 491 |
|
---|
| 492 | mOmg->DisplayObj(nomh2, dopt);
|
---|
| 493 | return;
|
---|
| 494 |
|
---|
| 495 | }
|
---|
| 496 |
|
---|
| 497 | /* --Methode-- cmv 13/10/98 */
|
---|
| 498 | void Services2NObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt,
|
---|
| 499 | string& expcut, string& nomprof, string dopt)
|
---|
| 500 | // Pour remplir un ``GeneralFitData'' a partir de divers objets:
|
---|
| 501 | //| nom = nom de l'objet a projeter dans un HProf.
|
---|
| 502 | //| expx = expression X de definition du bin.
|
---|
| 503 | //| expy = expression Y a additionner dans le bin.
|
---|
| 504 | //| expwt = expression W du poids a additionner.
|
---|
| 505 | //| expcut = expression du test de selection.
|
---|
| 506 | //| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
|
---|
| 507 | //| les limites Xmin,Xmax sont calculees automatiquement.
|
---|
| 508 | //| sinon ce sont celles de l'objet preexistant.
|
---|
| 509 | //| opt = options generales pour le display.
|
---|
| 510 | {
|
---|
| 511 | NObjMgrAdapter* obja=NULL;
|
---|
| 512 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 513 | if (obja == NULL) {
|
---|
| 514 | cout << "Services2NObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 515 | return;
|
---|
| 516 | }
|
---|
| 517 | if (!mImgapp) return;
|
---|
| 518 |
|
---|
| 519 | HProf* hprof = NULL;
|
---|
| 520 | NTuple* nt = NULL;
|
---|
| 521 | AnyDataObj* oh = NULL;
|
---|
| 522 | if (nomprof.length() > 0) oh=mOmg->GetObj(nomprof);
|
---|
| 523 | else nomprof = "/tmp/projprof";
|
---|
| 524 | if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) ) hprof = (HProf*)oh;
|
---|
| 525 | else {
|
---|
| 526 | char* ntn[3]= {"hxval", "hyval", "hwt"};
|
---|
| 527 | nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 528 | }
|
---|
| 529 | string expz = "0.";
|
---|
| 530 | ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
|
---|
| 531 |
|
---|
| 532 | if((!hprof) && (!nt)) return;
|
---|
| 533 | if(!hprof) {
|
---|
| 534 | if (nt->NEntry() < 1) {
|
---|
| 535 | cout << "Services2NObjMgr::ProjectHProf() Warning Zero points satisfy cut !" << endl;
|
---|
| 536 | delete nt;
|
---|
| 537 | return;
|
---|
| 538 | }
|
---|
| 539 | double xmin, xmax;
|
---|
| 540 | nt->GetMinMax(0, xmin, xmax);
|
---|
| 541 | hprof = new HProf(xmin, xmax, 100);
|
---|
| 542 | int k;
|
---|
| 543 | float* xn;
|
---|
| 544 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 545 | xn = nt->GetVec(k);
|
---|
| 546 | hprof->Add(xn[0], xn[1], xn[2]);
|
---|
| 547 | }
|
---|
| 548 | delete nt;
|
---|
| 549 | mOmg->AddObj(hprof, nomprof);
|
---|
| 550 | }
|
---|
| 551 | hprof->UpdateHisto();
|
---|
| 552 |
|
---|
| 553 | mOmg->DisplayObj(nomprof, dopt);
|
---|
| 554 | return;
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | /* --Methode-- */
|
---|
| 558 | void Services2NObjMgr::FillVect(string& nom, string& expx, string& expcut,
|
---|
| 559 | string& nomvec, string dopt)
|
---|
| 560 | {
|
---|
| 561 | NObjMgrAdapter* obja=NULL;
|
---|
| 562 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 563 | if (obja == NULL) {
|
---|
| 564 | cout << "Services2NObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 565 | return;
|
---|
| 566 | }
|
---|
| 567 | if (!mImgapp) return;
|
---|
| 568 |
|
---|
| 569 | NTuple* nt = NULL;
|
---|
| 570 | if (nomvec.length() < 1) nomvec = "/tmp/fillvec";
|
---|
| 571 |
|
---|
| 572 | char* ntn[2]= {"vecval", "vecwt"};
|
---|
| 573 | nt = new NTuple(1,ntn); // Creation NTuple
|
---|
| 574 |
|
---|
| 575 | string expwt = "1.";
|
---|
| 576 | string expz = "0.";
|
---|
| 577 | ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
|
---|
| 578 |
|
---|
| 579 | if (!nt) return;
|
---|
| 580 | if (nt->NEntry() < 1) {
|
---|
| 581 | cout << "Services2NObjMgr::FillVect() Warning Zero points satisfy cut !" << endl;
|
---|
| 582 | delete nt;
|
---|
| 583 | return;
|
---|
| 584 | }
|
---|
| 585 |
|
---|
| 586 | Vector* vec = new Vector(nt->NEntry());
|
---|
| 587 | int k;
|
---|
| 588 | float* xn;
|
---|
| 589 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 590 | xn = nt->GetVec(k);
|
---|
| 591 | (*vec)(k) = xn[0];
|
---|
| 592 | }
|
---|
| 593 | delete nt;
|
---|
| 594 | mOmg->AddObj(vec, nomvec);
|
---|
| 595 | mOmg->DisplayObj(nomvec, dopt);
|
---|
| 596 | return;
|
---|
| 597 | }
|
---|
| 598 |
|
---|
| 599 | /* --Methode-- */
|
---|
| 600 | void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz,
|
---|
| 601 | string& expt, string& expcut, string& nomnt)
|
---|
| 602 | {
|
---|
| 603 | NObjMgrAdapter* obja=NULL;
|
---|
| 604 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 605 | if (obja == NULL) {
|
---|
| 606 | cout << "Services2NObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 607 | return;
|
---|
| 608 | }
|
---|
| 609 | if (!mImgapp) return;
|
---|
| 610 |
|
---|
| 611 | bool fgnnt = false;
|
---|
| 612 | NTuple* nt = NULL;
|
---|
| 613 | AnyDataObj* oh = NULL;
|
---|
| 614 | if (nomnt.length() > 0) oh=mOmg->GetObj(nomnt);
|
---|
| 615 | else nomnt = "/tmp/fillnt";
|
---|
| 616 | if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
|
---|
| 617 | nt = (NTuple*)oh;
|
---|
| 618 | if (nt->NVar() > 10) {
|
---|
| 619 | cout << "Services2NObjMgr::FillNT() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
|
---|
| 620 | nt = NULL;
|
---|
| 621 | }
|
---|
| 622 | }
|
---|
| 623 | if (nt == NULL) {
|
---|
| 624 | char* ntn[4]= {"x", "y","z","t"};
|
---|
| 625 | nt = new NTuple(4,ntn); // Creation NTuple
|
---|
| 626 | fgnnt = true;
|
---|
| 627 | }
|
---|
| 628 |
|
---|
| 629 | ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
|
---|
| 630 |
|
---|
| 631 | if (fgnnt) mOmg->AddObj(nt, nomnt);
|
---|
| 632 | return;
|
---|
| 633 |
|
---|
| 634 | }
|
---|
| 635 |
|
---|
| 636 | /* --Methode-- */
|
---|
| 637 | void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname,
|
---|
| 638 | string const & funcname, string & nomnt)
|
---|
| 639 | {
|
---|
| 640 | if (!mImgapp) return;
|
---|
| 641 |
|
---|
| 642 | NObjMgrAdapter* obja=NULL;
|
---|
| 643 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 644 | if (obja == NULL) {
|
---|
| 645 | cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No such object" <<endl;
|
---|
| 646 | return;
|
---|
| 647 | }
|
---|
| 648 | NTupleInterface* objnt = obja->GetNTupleInterface();
|
---|
| 649 | if (objnt == NULL) {
|
---|
| 650 | cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No NTupleInterface !" <<endl;
|
---|
| 651 | return;
|
---|
| 652 | }
|
---|
| 653 |
|
---|
| 654 | NTLoopExprFunc f = (NTLoopExprFunc)LinkFunctionFromFile(fname, funcname);
|
---|
| 655 | if (!f) {
|
---|
| 656 | cerr << "Services2NObjMgr::FillNTFrCFile Error Creation NTLoopExprFunc" << endl;
|
---|
| 657 | return;
|
---|
| 658 | }
|
---|
| 659 |
|
---|
| 660 | bool fgnnt = false;
|
---|
| 661 | NTuple* nt = NULL;
|
---|
| 662 | if (nomnt.length() > 0) {
|
---|
| 663 | AnyDataObj* oh = NULL;
|
---|
| 664 | oh=mOmg->GetObj(nomnt);
|
---|
| 665 | if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
|
---|
| 666 | nt = (NTuple*)oh;
|
---|
| 667 | if (nt->NVar() > 10) {
|
---|
| 668 | cout << "Services2NObjMgr::FillNTFrCFile() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
|
---|
| 669 | nt = NULL;
|
---|
| 670 | }
|
---|
| 671 | }
|
---|
| 672 | if (nt == NULL) {
|
---|
| 673 | char* ntn[4]= {"x", "y","z","t"};
|
---|
| 674 | nt = new NTuple(4,ntn); // Creation NTuple
|
---|
| 675 | fgnnt = true;
|
---|
| 676 | }
|
---|
| 677 | }
|
---|
| 678 |
|
---|
| 679 | double xnt[10];
|
---|
| 680 | float fxnt[10];
|
---|
| 681 |
|
---|
| 682 | int i,k;
|
---|
| 683 | for(i=0; i<10; i++) fxnt[i] = xnt[i] = 0.;
|
---|
| 684 |
|
---|
| 685 |
|
---|
| 686 | // $CHECK$ A virer des que possible - Pb blocage application quand trop d'impression
|
---|
| 687 | // redirige - On redirige la sortie sur le terminal
|
---|
| 688 | bool red = mImgapp->HasRedirectedStdOutErr();
|
---|
| 689 | mImgapp->RedirectStdOutErr(false);
|
---|
| 690 |
|
---|
| 691 | TRY {
|
---|
| 692 | double* xn;
|
---|
| 693 | int kmax = objnt->NbLines();
|
---|
| 694 | for(k=0; k<kmax; k++) {
|
---|
| 695 | xn = objnt->GetLineD(k);
|
---|
| 696 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
|
---|
| 697 | if (nt) {
|
---|
| 698 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
| 699 | nt->Fill(fxnt);
|
---|
| 700 | }
|
---|
| 701 | }
|
---|
| 702 | }
|
---|
| 703 | }
|
---|
| 704 | CATCH(merr) {
|
---|
| 705 | fflush(stdout);
|
---|
| 706 | cout << endl;
|
---|
| 707 | cerr << endl;
|
---|
| 708 | string es = PeidaExc(merr);
|
---|
| 709 | cerr << "Services2NObjMgr::FillNTFrCFile() Exception :" << merr << es;
|
---|
| 710 | } ENDTRY;
|
---|
| 711 |
|
---|
| 712 | CloseDLL();
|
---|
| 713 |
|
---|
| 714 | // $CHECK$ A virer des que possible On redirige la sortie sur la fenetre PIConsole
|
---|
| 715 | mImgapp->RedirectStdOutErr(red);
|
---|
| 716 |
|
---|
| 717 | if (fgnnt) mOmg->AddObj(nt, nomnt);
|
---|
| 718 | return;
|
---|
| 719 | }
|
---|
| 720 |
|
---|
| 721 | /* --Methode-- */
|
---|
| 722 | void Services2NObjMgr::PrepareNTExpressionCFile(string & nom, string const & fname,
|
---|
| 723 | string const & funcname)
|
---|
| 724 | {
|
---|
| 725 | NObjMgrAdapter* obja=NULL;
|
---|
| 726 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 727 | if (obja == NULL) {
|
---|
| 728 | cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom << "...) No such object" <<endl;
|
---|
| 729 | return;
|
---|
| 730 | }
|
---|
| 731 | NTupleInterface* objnt = obja->GetNTupleInterface();
|
---|
| 732 | if (objnt == NULL) {
|
---|
| 733 | cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom
|
---|
| 734 | << "...) No NTupleInterface !" <<endl;
|
---|
| 735 | return;
|
---|
| 736 | }
|
---|
| 737 | string vardec = objnt->VarList_C("_xnti_");
|
---|
| 738 |
|
---|
| 739 | FILE *fip;
|
---|
| 740 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 741 | cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl;
|
---|
| 742 | return;
|
---|
| 743 | }
|
---|
| 744 | // constitution du fichier des decalarations des variables de l'interface NTuple
|
---|
| 745 | fputs("#include <stdlib.h> \n", fip);
|
---|
| 746 | fputs("#include <stdio.h> \n", fip);
|
---|
| 747 | fputs("#include <math.h> \n\n", fip);
|
---|
| 748 | fputs("/* NTupleInterface Variable declaration - Generated by piapp \n", fip);
|
---|
| 749 | fputs(" -- Services2NObjMgr::PrepareNTExpressionCFile() -- */ \n\n", fip);
|
---|
| 750 | fprintf(fip,"int %s(double* _xnti_, double* _rx_, double* _ry_, double* _rz_, \n",
|
---|
| 751 | funcname.c_str());
|
---|
| 752 | fprintf(fip," double* _rt_, int _n_, int _nmax_) \n");
|
---|
| 753 | fprintf(fip, "{ \n %s \n", vardec.c_str());
|
---|
| 754 | fputs(" if (!1) { /* Cut Expression failed */ \n", fip);
|
---|
| 755 | fputs(" *_rx_ = *_ry_ = *_rz_ = *_rt_ = 0.; return(0);", fip);
|
---|
| 756 | fputs(" } \n /* Cut expression satisfied */ \n", fip);
|
---|
| 757 | fputs(" *_rx_ = 1.; \n *_ry_ = 1.; \n *_rz_ = 1.; \n *_rt_ = 1.; \n", fip);
|
---|
| 758 | fputs(" return(1); \n} \n", fip);
|
---|
| 759 |
|
---|
| 760 | fclose(fip);
|
---|
| 761 | return;
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 |
|
---|
| 765 | /* --Methode-- cmv 13/10/98 */
|
---|
| 766 | void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
|
---|
| 767 | string& experr, string& expcut, string& nomgfd)
|
---|
| 768 | // Pour remplir un ``GeneralFitData'' a partir de divers objets:
|
---|
| 769 | //| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
|
---|
| 770 | //| Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
|
---|
| 771 | //| expx = expression X du GeneralFitData (1er abscisse)
|
---|
| 772 | //| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
|
---|
| 773 | //| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
|
---|
| 774 | //| experr = expression de l'erreur sur l'ordonnee Z
|
---|
| 775 | //| expcut = expression du test de selection
|
---|
| 776 | //| nomgfd = nom du GeneralFitData engendre (optionnel)
|
---|
| 777 | {
|
---|
| 778 | NObjMgrAdapter* obja=NULL;
|
---|
| 779 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 780 | if (obja == NULL) {
|
---|
| 781 | cout << "Services2NObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
|
---|
| 782 | return;
|
---|
| 783 | }
|
---|
| 784 | if(!mImgapp) return;
|
---|
| 785 |
|
---|
| 786 | // 2D ou 3D?
|
---|
| 787 | int nvar = 2;
|
---|
| 788 | if(expy.length()<=0) {nvar = 1; expy = "0.";}
|
---|
| 789 |
|
---|
| 790 | // Creation NTuple Buffer
|
---|
| 791 | char* ntn[4]= {"x","y","f","e"};
|
---|
| 792 | NTuple*nt = new NTuple(4,ntn);
|
---|
| 793 |
|
---|
| 794 | // Remplissage NTuple buffer
|
---|
| 795 | ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
|
---|
| 796 | if(nt->NEntry() < 1)
|
---|
| 797 | {cout<<"Services2NObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl;
|
---|
| 798 | delete nt; return;}
|
---|
| 799 |
|
---|
| 800 | //Remplissage de la structure GeneraFitData
|
---|
| 801 | if (nt->NEntry() <= 0) {
|
---|
| 802 | cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
|
---|
| 803 | delete nt;
|
---|
| 804 | return;
|
---|
| 805 | }
|
---|
| 806 |
|
---|
| 807 | GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
|
---|
| 808 | int k;
|
---|
| 809 | float* xn;
|
---|
| 810 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 811 | xn = nt->GetVec(k);
|
---|
| 812 | gfd->AddData(xn,xn[2],xn[3]);
|
---|
| 813 | }
|
---|
| 814 |
|
---|
| 815 | // Menage et table d'objets
|
---|
| 816 | delete nt;
|
---|
| 817 | mOmg->AddObj(gfd, nomgfd);
|
---|
| 818 | return;
|
---|
| 819 | }
|
---|
| 820 |
|
---|
| 821 |
|
---|
| 822 | ///////////////////// Fit 1D et 2D //////////////////////////
|
---|
| 823 | /* --Function static propre aux routines de fit 1D et 2D-- cmv 13/10/98 */
|
---|
| 824 | struct DFOptions {
|
---|
| 825 | int okres, okfun;
|
---|
| 826 | int polcx,polcy; double xc,yc;
|
---|
| 827 | double err_e, err_E;
|
---|
| 828 | double stc2;
|
---|
[341] | 829 | int nstep;
|
---|
[333] | 830 | int lp,lpg;
|
---|
| 831 | int i1,i2,j1,j2;
|
---|
| 832 | };
|
---|
| 833 | typedef struct DFOptions DFOPTIONS;
|
---|
| 834 | static void DecodeFitsOptions(string par,string step,string min,string max,string opt
|
---|
| 835 | ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O);
|
---|
| 836 | void DecodeFitsOptions(string par,string step,string min,string max,string opt
|
---|
| 837 | ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O)
|
---|
| 838 | //| Pour decoder les "string" et remplir les vecteurs du fit (cf commentaires dans Fit1D)
|
---|
| 839 | {
|
---|
| 840 | // set des vecteurs et decodage des string correspondantes
|
---|
| 841 | int NParMax = 100;
|
---|
| 842 | Par.Realloc(NParMax); Step.Realloc(NParMax);
|
---|
| 843 | Min.Realloc(NParMax); Max.Realloc(NParMax);
|
---|
| 844 | {
|
---|
| 845 | Vector* v=NULL; string* s=NULL;
|
---|
| 846 | {for(int i=0;i<NParMax;i++) {Par(i)=0.; Step(i)=1.; Min(i)=1.; Max(i)=-1.;}}
|
---|
| 847 | for(int j=0;j<4;j++) {
|
---|
| 848 | if(j==0) {v=&Par; s=∥}
|
---|
| 849 | else if(j==1) {v=&Step; s=&step;}
|
---|
| 850 | else if(j==2) {v=&Min; s=&min;}
|
---|
| 851 | else if(j==3) {v=&Max; s=&max;}
|
---|
| 852 | if(s->length()>0) *s += ",";
|
---|
| 853 | for(int i=0;i<NParMax;i++) {
|
---|
| 854 | if(s->length()<=0) break;
|
---|
| 855 | sscanf(s->c_str(),"%lf",&(*v)(i));
|
---|
| 856 | size_t p = s->find_first_of(',') + 1;
|
---|
| 857 | if(p>=s->length()) *s = ""; else *s = s->substr(p);
|
---|
| 858 | }
|
---|
| 859 | }
|
---|
| 860 | }
|
---|
| 861 |
|
---|
| 862 | // Decodage de options de opt
|
---|
| 863 | O.okres = O.okfun = 0;
|
---|
| 864 | O.polcx = O.polcy = 0;
|
---|
| 865 | O.xc = O.yc = 0.;
|
---|
| 866 | O.stc2 = 1.e-3;
|
---|
[341] | 867 | O.nstep = 100;
|
---|
[333] | 868 | O.err_e = O.err_E = -1.;
|
---|
| 869 | O.lp = 1; O.lpg = 0;
|
---|
| 870 | O.i1 = O.j1 = O.i2 = O.j2 = -1;
|
---|
| 871 |
|
---|
| 872 | if(opt.length()<=0) return;
|
---|
| 873 | opt = "," + opt + ",";
|
---|
| 874 |
|
---|
| 875 | if(strstr(opt.c_str(),",r,")) O.okres = 1; // residus
|
---|
| 876 | if(strstr(opt.c_str(),",f,")) O.okfun = 1; // fonction fittee
|
---|
| 877 | if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
|
---|
| 878 | O.polcx = 2; // Le centrage est calcule automatiquement
|
---|
| 879 | size_t p = opt.find(",x");
|
---|
| 880 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 881 | string dum = opt.substr(p,q-p);
|
---|
| 882 | if(dum.length()>2) {
|
---|
| 883 | sscanf(dum.c_str(),",x%lf",&O.xc);
|
---|
| 884 | O.polcx = 1; // Le centrage est fixe par la valeur lue
|
---|
| 885 | }
|
---|
| 886 | }
|
---|
| 887 | if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
|
---|
| 888 | O.polcy = 2; // Le centrage est calcule automatiquement
|
---|
| 889 | size_t p = opt.find(",y");
|
---|
| 890 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 891 | string dum = opt.substr(p,q-p);
|
---|
| 892 | if(dum.length()>2) {
|
---|
| 893 | sscanf(dum.c_str(),",y%lf",&O.yc);
|
---|
| 894 | O.polcy = 1; // Le centrage est fixe par la valeur lue
|
---|
| 895 | }
|
---|
| 896 | }
|
---|
| 897 | if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)"
|
---|
| 898 | size_t p = opt.find(",E");
|
---|
| 899 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 900 | string dum = opt.substr(p,q-p);
|
---|
| 901 | if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&O.err_E);
|
---|
| 902 | if(O.err_E<=0.) O.err_E = 1.;
|
---|
| 903 | O.err_e=-1.;
|
---|
| 904 | }
|
---|
| 905 | if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
|
---|
| 906 | size_t p = opt.find(",e");
|
---|
| 907 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 908 | string dum = opt.substr(p,q-p);
|
---|
| 909 | if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&O.err_e);
|
---|
| 910 | if(O.err_e<=0.) O.err_e = 1.;
|
---|
| 911 | O.err_E=-1.;
|
---|
| 912 | }
|
---|
| 913 | if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
|
---|
| 914 | size_t p = opt.find(",X");
|
---|
| 915 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 916 | string dum = opt.substr(p,q-p);
|
---|
| 917 | if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&O.stc2);
|
---|
| 918 | if(O.stc2<=0.) O.stc2 = 1.e-3;
|
---|
| 919 | }
|
---|
[341] | 920 | if(strstr(opt.c_str(),",N")) { // Nombre maximum d'iterations
|
---|
| 921 | size_t p = opt.find(",N");
|
---|
| 922 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 923 | string dum = opt.substr(p,q-p);
|
---|
| 924 | if(dum.length()>2) sscanf(dum.c_str(),",N%d",&O.nstep);
|
---|
| 925 | if(O.nstep<2) O.nstep = 100;
|
---|
| 926 | }
|
---|
[333] | 927 | if(strstr(opt.c_str(),",l")) { // niveau de print
|
---|
| 928 | size_t p = opt.find(",l");
|
---|
| 929 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 930 | string dum = opt.substr(p,q-p);
|
---|
| 931 | float ab;
|
---|
| 932 | if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
|
---|
| 933 | if(ab<0) ab = 0.;
|
---|
[341] | 934 | O.lp = (int) ab; O.lpg = int(10.*(ab-(float)O.lp+0.01));
|
---|
[333] | 935 | }
|
---|
| 936 | if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
|
---|
| 937 | size_t p = opt.find(",I");
|
---|
| 938 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 939 | string dum = opt.substr(p,q-p);
|
---|
| 940 | if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&O.i1,&O.i2);
|
---|
| 941 | }
|
---|
| 942 | if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
|
---|
| 943 | size_t p = opt.find(",J");
|
---|
| 944 | size_t q = opt.find_first_of(',',p+1);
|
---|
| 945 | string dum = opt.substr(p,q-p);
|
---|
| 946 | if(dum.length()>2) sscanf(dum.c_str(),",J%d/%d",&O.j1,&O.j2);
|
---|
| 947 | }
|
---|
| 948 | return;
|
---|
| 949 | }
|
---|
| 950 |
|
---|
| 951 | /* --Methode-- cmv 13/10/98 */
|
---|
| 952 | void Services2NObjMgr::Fit12D(string& nom, string& func,
|
---|
| 953 | string par,string step,string min,string max,
|
---|
| 954 | string opt)
|
---|
| 955 | //| --------------- Fit d'objets a 1 et 2 dimensions ---------------
|
---|
| 956 | //| nom : nom de l'objet qui peut etre:
|
---|
| 957 | //| fit-1D: Vector,Histo1D,HProf ou GeneraFitData(1D)
|
---|
[341] | 958 | //| fit-2D: Matrix,Histo2D,Image<T> ou GeneraFitData(2D)
|
---|
| 959 | //| func : pnn : fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
|
---|
| 960 | //| : Pnn : fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D
|
---|
| 961 | //| : gnn : fit gaussienne (hauteur) + polynome de degre nn 1D
|
---|
| 962 | //| : g : fit gaussienne (hauteur) 1D
|
---|
| 963 | //| : enn : fit exponentielle + polynome de degre nn 1D
|
---|
| 964 | //| : e : fit exponentielle 1D
|
---|
| 965 | //| : Gnn : fit gaussienne (volume) + polynome de degre nn 1D
|
---|
| 966 | //| : G : fit gaussienne (volume) 1D
|
---|
| 967 | //| : : fit gaussienne+fond (volume) 2D
|
---|
| 968 | //| : Gi : fit gaussienne+fond integree (volume) 2D
|
---|
| 969 | //| : d : fit DL de gaussienne+fond (volume) 2D
|
---|
| 970 | //| : di : fit DL de gaussienne+fond integree (volume) 2D
|
---|
| 971 | //| : D : fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D
|
---|
| 972 | //| : Di : fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D
|
---|
| 973 | //| : M : fit Moffat+fond (expos=p6) (volume) 2D
|
---|
| 974 | //| : Mi : fit Moffat+fond integree (expos=p6) (volume) 2D
|
---|
| 975 | //| par : p1,...,pn : valeur d'initialisation des parametres (def=0)
|
---|
| 976 | //| step : s1,...,sn : valeur des steps de depart (def=1)
|
---|
| 977 | //| min : m1,...,mn : valeur des minima (def=1)
|
---|
| 978 | //| max : M1,...,Mn : valeur des maxima (def=-1) (max<=min : pas de limite)
|
---|
[333] | 979 | //| opt : options "Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
|
---|
[341] | 980 | //| f : generation d'un Objet identique contenant la fonction fittee
|
---|
| 981 | //| r : generation d'un Objet identique contenant les residus
|
---|
| 982 | //| Xaa.b : aa.b valeur du DXi2 d'arret (def=1.e-3)
|
---|
| 983 | //| Naa : aa nombre maximum d'iterations (def=100)
|
---|
| 984 | //| la.b : niveau "a.b" de print: a=niveau de print Fit1/2D
|
---|
| 985 | //| b=niveau de debug GeneralFit
|
---|
| 986 | //| Ii1/i2 numeros des bins X de l'histos utilises pour le fit [i1,i2]
|
---|
| 987 | //|2D Jj1/j2 numeros des bins Y de l'histos utilises pour le fit [j1,j2]
|
---|
| 988 | //| - L'erreur est celle associee a l'objet (si elle existe),
|
---|
| 989 | //| elle est mise a 1 sinon, sauf si E... ou e... est precise:
|
---|
| 990 | //| Eaa.b : si |val|>=1 erreur = aa.b*sqrt(|val|)
|
---|
| 991 | //| si |val|<1 erreur = aa.b
|
---|
| 992 | //| si aa.b <=0 alors aa.b=1.0
|
---|
| 993 | //| E seul est equivalent a E1.0
|
---|
| 994 | //| eaa.b : erreur = aa.b
|
---|
| 995 | //| si aa.b <=0 alors aa.b=1.0
|
---|
| 996 | //| e seul est equivalent a e1.0
|
---|
| 997 | //| xaa.b : demande de centrage: on fit x-aa.b au lieu de x)
|
---|
| 998 | //| x : demande de centrage: on fit x-xc au lieu de x
|
---|
| 999 | //| avec xc=abscisse du milieu de l'histogramme
|
---|
| 1000 | //| Actif pour exp+poly 1D, poly 1D
|
---|
| 1001 | //| pour gauss+poly 1D, xc est le centre de la gaussienne.
|
---|
| 1002 | //|2D yaa.b et y : idem "xaa.b et x" mais pour y
|
---|
[333] | 1003 | {
|
---|
| 1004 | AnyDataObj* obj=mOmg->GetObj(nom);
|
---|
| 1005 | if (obj == NULL) {
|
---|
| 1006 | cout<<"Services2NObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
|
---|
| 1007 | return;
|
---|
| 1008 | }
|
---|
| 1009 | if (!mImgapp) return;
|
---|
| 1010 | if(func.length()<=0)
|
---|
| 1011 | {cout<<"Services2NObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
|
---|
| 1012 | return;}
|
---|
| 1013 | string ctyp = typeid(*obj).name();
|
---|
| 1014 |
|
---|
| 1015 | int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
|
---|
| 1016 | Vector* v = NULL; Histo* h = NULL;
|
---|
| 1017 | Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
|
---|
| 1018 | GeneralFitData* g = NULL;
|
---|
| 1019 |
|
---|
| 1020 | // 1D
|
---|
| 1021 | if (typeid(*obj) == typeid(Vector)) {
|
---|
| 1022 | ndim = 1;
|
---|
| 1023 | v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
|
---|
| 1024 | }
|
---|
| 1025 | else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) {
|
---|
| 1026 | ndim = 1;
|
---|
| 1027 | h = (Histo*) obj; nbinx = h->NBins(); nbiny = 1;
|
---|
| 1028 | }
|
---|
| 1029 | else if (typeid(*obj) == typeid(Matrix)) {
|
---|
| 1030 | ndim = 2;
|
---|
| 1031 | m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
|
---|
| 1032 | }
|
---|
| 1033 | else if (typeid(*obj) == typeid(Histo2D)) {
|
---|
| 1034 | ndim = 2;
|
---|
| 1035 | h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
|
---|
| 1036 | }
|
---|
| 1037 | else if (typeid(*obj) == typeid(GeneralFitData)) {
|
---|
| 1038 | g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
|
---|
| 1039 | if( g->NVar()==1) ndim = 1;
|
---|
| 1040 | else if(g->NVar()==2) ndim = 2;
|
---|
| 1041 | else {
|
---|
| 1042 | cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
|
---|
| 1043 | <<((GeneralFitData*) obj)->NVar()<<endl; return; }
|
---|
| 1044 | }
|
---|
| 1045 | else if (dynamic_cast<RzImage*>(obj)) {
|
---|
| 1046 | ndim = 2;
|
---|
| 1047 | im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
|
---|
| 1048 | }
|
---|
| 1049 | else {
|
---|
| 1050 | cout<<"Services2NObjMgr::Fit12D() Error , Objet n'est pas un "
|
---|
| 1051 | <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
|
---|
| 1052 | return;
|
---|
| 1053 | }
|
---|
| 1054 |
|
---|
| 1055 | ndata = nbinx*nbiny;
|
---|
| 1056 | if(ndata<=0)
|
---|
| 1057 | {cout<<"L'objet a "<<nbinx<<","<<nbiny<<" bins ("<<ndata<<")"<<endl; return;}
|
---|
| 1058 |
|
---|
| 1059 | // Decodage des options et des parametres, mise en forme
|
---|
| 1060 | Vector Par(1); Vector Step(1); Vector Min(1); Vector Max(1); DFOPTIONS O;
|
---|
| 1061 | DecodeFitsOptions(par,step,min,max,opt,Par,Step,Min,Max,O);
|
---|
| 1062 | O.i1 = (O.i1<0||O.i1>=nbinx)? 0: O.i1;
|
---|
| 1063 | O.i2 = (O.i2<0||O.i2>=nbinx||O.i2<O.i1)? nbinx-1: O.i2;
|
---|
| 1064 | if(ndim>=2) {
|
---|
| 1065 | O.j1 = (O.j1<0||O.j1>=nbiny)? 0: O.j1;
|
---|
| 1066 | O.j2 = (O.j2<0||O.j2>=nbiny||O.j2<O.j1)? nbiny-1: O.j2;
|
---|
| 1067 | } else O.j2 = O.j1 = 0;
|
---|
| 1068 | if(O.polcx==2) {
|
---|
| 1069 | if(v||m) O.xc = (O.i2-O.i1+1)/2.;
|
---|
| 1070 | else if(h) O.xc = (h->XMin()+h->XMax())/2.;
|
---|
| 1071 | else if(h2) O.xc = (h2->XMin()+h2->XMax())/2.;
|
---|
| 1072 | else if(g) {double mini,maxi; g->GetMinMax(2,mini,maxi); O.xc=(mini+maxi)/2.;}
|
---|
| 1073 | else if(im) {O.xc = im->XOrg() * im->XPxSize()*(O.i2-O.i1+1)/2.;}
|
---|
| 1074 | }
|
---|
| 1075 | if(O.polcy==2 && ndim>=2) {
|
---|
| 1076 | if(m) O.yc = (O.j2-O.j1+1)/2.;
|
---|
| 1077 | if(h2) O.yc = (h2->YMin()+h2->YMax())/2.;
|
---|
| 1078 | if(g) {double mini,maxi; g->GetMinMax(12,mini,maxi); O.yc=(mini+maxi)/2.;}
|
---|
| 1079 | if(im) {O.yc = im->YOrg() * im->YPxSize()*(O.j2-O.j1+1)/2.;}
|
---|
| 1080 | }
|
---|
| 1081 | if(O.lp>0)
|
---|
| 1082 | cout<<"Fit["<<nbinx<<","<<nbiny<<"] ("<<ndata<<") dim="<<ndim<<":"
|
---|
| 1083 | <<" Int=["<<O.i1<<","<<O.i2<<"],["<<O.j1<<","<<O.j2<<"]"<<endl
|
---|
| 1084 | <<" Cent="<<O.polcx<<","<<O.polcy<<","<<O.xc<<"+x"<<","<<O.yc<<"+y"
|
---|
| 1085 | <<" TypE="<<O.err_e<<","<<O.err_E
|
---|
[341] | 1086 | <<" StpX2="<<O.stc2<<" Nstep="<<O.nstep
|
---|
[333] | 1087 | <<" lp,lpg="<<O.lp<<","<<O.lpg<<endl;
|
---|
| 1088 |
|
---|
| 1089 | ///////////////////////////////////
|
---|
| 1090 | // Remplissage de GeneralFitData //
|
---|
| 1091 | ///////////////////////////////////
|
---|
| 1092 | GeneralFitData mydata(ndim,ndata,0);
|
---|
| 1093 | {for(int i=O.i1;i<=O.i2;i++) for(int j=O.j1;j<=O.j2;j++) {
|
---|
| 1094 | double x,y,f,e;
|
---|
| 1095 |
|
---|
| 1096 | if(v)
|
---|
| 1097 | {x= (double) i; f=(*v)(i); e=1.;}
|
---|
| 1098 | else if(h)
|
---|
| 1099 | {x=h->BinCenter(i); f=(*h)(i); e=(h->HasErrors())?h->Error(i):1.;}
|
---|
| 1100 | else if(m)
|
---|
| 1101 | {x=(double) i; y=(double) j; f=(*m)(j,i); e=1.;}
|
---|
| 1102 | else if(h2)
|
---|
| 1103 | {float xf,yf; h2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
|
---|
| 1104 | f=(*h2)(i,j); e=(h2->HasErrors())?h2->Error(i,j):1.;}
|
---|
| 1105 | else if(im)
|
---|
| 1106 | {x=im->XOrg()+(i+0.5)*im->XPxSize(); y=im->YOrg()+(j+0.5)*im->YPxSize();
|
---|
| 1107 | f=im->DValue(i,j); e=1.;}
|
---|
| 1108 | else if(g&&ndim==1) {x= g->X(i); f=g->Val(i); e=g->EVal(i);}
|
---|
| 1109 | else if(g&&ndim==2) {x= g->X(i); y= g->Y(i); f=g->Val(i); e=g->EVal(i);}
|
---|
| 1110 | else x=y=f=e=0.;
|
---|
| 1111 |
|
---|
| 1112 | // Gestion des erreurs a utiliser
|
---|
| 1113 | if(O.err_e>0.) e=O.err_e;
|
---|
[341] | 1114 | else if(O.err_E>0.) {e=(f<-1.||f>1.)?O.err_E*sqrt(fabs(f)):O.err_E;}
|
---|
[333] | 1115 |
|
---|
| 1116 | // Remplissage de generalfit
|
---|
| 1117 | if(func[0]=='p') {x -= O.xc; if(ndim>=2) y -= O.yc;}
|
---|
| 1118 | if(ndim==1) mydata.AddData1(x,f,e);
|
---|
| 1119 | else if(ndim==2) mydata.AddData2(x,y,f,e);
|
---|
| 1120 | }}
|
---|
| 1121 | if(mydata.NData()<=0)
|
---|
| 1122 | {cout<<"Pas de donnees dans GeneralFitData: "<<mydata.NData()<<endl;
|
---|
| 1123 | return;}
|
---|
| 1124 | if(O.lpg>1) {
|
---|
| 1125 | mydata.PrintStatus();
|
---|
| 1126 | mydata.PrintData(0);
|
---|
| 1127 | mydata.PrintData(mydata.NData()-1);
|
---|
| 1128 | }
|
---|
| 1129 |
|
---|
| 1130 | ////////////////////////////////////////////
|
---|
| 1131 | // Identification de la fonction a fitter //
|
---|
| 1132 | ////////////////////////////////////////////
|
---|
| 1133 | GeneralFunction* myfunc = NULL;
|
---|
| 1134 | if(func[0]=='p' && ndim==1) {
|
---|
| 1135 | // Fit de polynome sans passer par les GeneralFit
|
---|
| 1136 | int degre = 0;
|
---|
| 1137 | if(func.length()>1) sscanf(func.c_str()+1,"%d",°re);
|
---|
| 1138 | cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
|
---|
| 1139 | Poly p1(0);
|
---|
| 1140 | double c2rl = mydata.PolFit(0,p1,degre);
|
---|
| 1141 | cout<<"C2r_lineaire = "<<c2rl<<endl;
|
---|
| 1142 | if(O.lp>0) cout<<p1<<endl;
|
---|
| 1143 | return;
|
---|
| 1144 |
|
---|
| 1145 | } else if(func[0]=='P' && ndim==1) {
|
---|
| 1146 | // Fit de polynome
|
---|
| 1147 | int degre = 0;
|
---|
| 1148 | if(func.length()>1) sscanf(func.c_str()+1,"%d",°re);
|
---|
| 1149 | cout<<"Fit polynome 1D de degre "<<degre<<endl;
|
---|
| 1150 | Polyn1D* myf = new Polyn1D(degre,O.xc);
|
---|
| 1151 | myfunc = myf;
|
---|
| 1152 |
|
---|
| 1153 | } else if(func[0]=='e' && ndim==1) {
|
---|
| 1154 | // Fit d'exponentielle
|
---|
| 1155 | int degre =-1;
|
---|
| 1156 | if(func.length()>1) sscanf(func.c_str()+1,"%d",°re);
|
---|
| 1157 | cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl;
|
---|
| 1158 | Exp1DPol* myf;
|
---|
| 1159 | if(degre>=0) myf = new Exp1DPol((unsigned int)degre,O.xc);
|
---|
| 1160 | else myf = new Exp1DPol(O.xc);
|
---|
| 1161 | myfunc = myf;
|
---|
| 1162 |
|
---|
| 1163 | } else if(func[0]=='g' && ndim==1) {
|
---|
| 1164 | // Fit de gaussienne en hauteur
|
---|
| 1165 | int degre =-1;
|
---|
| 1166 | if(func.length()>1) sscanf(func.c_str()+1,"%d",°re);
|
---|
| 1167 | cout<<"Fit de Gaussienne_en_hauteur+polynome 1D de degre "<<degre<<endl;
|
---|
| 1168 | Gauss1DPol* myf;
|
---|
| 1169 | if(degre>=0) myf = new Gauss1DPol((unsigned int)degre,((O.polcx)?true:false));
|
---|
| 1170 | else { bool bfg = (O.polcx)?true:false; myf = new Gauss1DPol(bfg); }
|
---|
| 1171 | myfunc = myf;
|
---|
| 1172 |
|
---|
| 1173 | } else if(func[0]=='G' && ndim==1) {
|
---|
| 1174 | // Fit de gaussienne en volume
|
---|
| 1175 | int degre =-1;
|
---|
| 1176 | if(func.length()>1) sscanf(func.c_str()+1,"%d",°re);
|
---|
| 1177 | cout<<"Fit de Gaussienne_en_volume+polynome 1D de degre "<<degre<<endl;
|
---|
| 1178 | GaussN1DPol* myf;
|
---|
| 1179 | if(degre>=0) myf = new GaussN1DPol((unsigned int)degre,((O.polcx)?true:false));
|
---|
| 1180 | else { bool bfg = (O.polcx)?true:false; myf = new GaussN1DPol(bfg); }
|
---|
| 1181 | myfunc = myf;
|
---|
| 1182 |
|
---|
| 1183 | } else if(func[0]=='p' && ndim==2) {
|
---|
| 1184 | // Fit de polynome 2D sans passer par les GeneralFit
|
---|
| 1185 | int degre = 0;
|
---|
| 1186 | if(func.length()>1) sscanf(func.c_str()+1,"%d",°re);
|
---|
| 1187 | cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
|
---|
| 1188 | Poly2 p2(0);
|
---|
| 1189 | double c2rl = mydata.PolFit(0,1,p2,degre);
|
---|
| 1190 | cout<<"C2r_lineaire = "<<c2rl<<endl;
|
---|
| 1191 | if(O.lp>0) cout<<p2<<endl;
|
---|
| 1192 | return;
|
---|
| 1193 |
|
---|
| 1194 | } else if(func[0]=='P' && ndim==2) {
|
---|
| 1195 | // Fit de polynome 2D
|
---|
| 1196 | int degre = 0;
|
---|
| 1197 | if(func.length()>1) sscanf(func.c_str()+1,"%d",°re);
|
---|
| 1198 | cout<<"Fit polynome 2D de degre "<<degre<<endl;
|
---|
| 1199 | Polyn2D* myf = new Polyn2D(degre,O.xc,O.yc);
|
---|
| 1200 | myfunc = myf;
|
---|
| 1201 |
|
---|
| 1202 | } else if(func[0]=='G' && ndim==2) {
|
---|
| 1203 | // Fit de gaussienne+fond en volume
|
---|
| 1204 | int integ = 0;
|
---|
| 1205 | if(func.length()>1) if(func[1]=='i') integ=1;
|
---|
| 1206 | cout<<"Fit de Gaussienne+Fond 2D integ="<<integ<<endl;
|
---|
| 1207 | if(integ) {GauRhInt2D* myf = new GauRhInt2D; myfunc = myf;}
|
---|
| 1208 | else {GauRho2D* myf = new GauRho2D; myfunc = myf;}
|
---|
| 1209 |
|
---|
| 1210 | } else if(func[0]=='d' && ndim==2) {
|
---|
| 1211 | // Fit de DL gaussienne+fond en volume
|
---|
| 1212 | int integ = 0;
|
---|
| 1213 | if(func.length()>1) if(func[1]=='i') integ=1;
|
---|
| 1214 | cout<<"Fit de DL de Gaussienne+Fond 2D integ="<<integ<<endl;
|
---|
| 1215 | if(integ) {GdlRhInt2D* myf = new GdlRhInt2D; myfunc = myf;}
|
---|
| 1216 | else {GdlRho2D* myf = new GdlRho2D; myfunc = myf;}
|
---|
| 1217 |
|
---|
| 1218 | } else if(func[0]=='D' && ndim==2) {
|
---|
| 1219 | // Fit de DL gaussienne+fond avec coeff variable p6 en volume
|
---|
| 1220 | int integ = 0;
|
---|
| 1221 | if(func.length()>1) if(func[1]=='i') integ=1;
|
---|
| 1222 | cout<<"Fit de DL de Gaussienne+Fond avec coeff variable (p6) 2D integ="<<integ<<endl;
|
---|
| 1223 | if(integ) {Gdl1RhInt2D* myf = new Gdl1RhInt2D; myfunc = myf;}
|
---|
| 1224 | else {Gdl1Rho2D* myf = new Gdl1Rho2D; myfunc = myf;}
|
---|
| 1225 |
|
---|
| 1226 | } else if(func[0]=='M' && ndim==2) {
|
---|
| 1227 | // Fit de Moffat+fond (volume)
|
---|
| 1228 | int integ = 0;
|
---|
| 1229 | if(func.length()>1) if(func[1]=='i') integ=1;
|
---|
| 1230 | cout<<"Fit de Moffat+Fond (expos=p6) 2D integ="<<integ<<endl;
|
---|
| 1231 | if(integ) {MofRhInt2D* myf = new MofRhInt2D; myfunc = myf;}
|
---|
| 1232 | else {MofRho2D* myf = new MofRho2D; myfunc = myf;}
|
---|
| 1233 |
|
---|
| 1234 | } else {
|
---|
| 1235 | cout<<"Fonction "<<func<<" inconnue pour la dim "<<ndim<<endl;
|
---|
| 1236 | return;
|
---|
| 1237 | }
|
---|
| 1238 |
|
---|
| 1239 | /////////////////////////
|
---|
| 1240 | // Fit avec generalfit //
|
---|
| 1241 | /////////////////////////
|
---|
| 1242 | if(myfunc->NPar()>Par.NElts())
|
---|
| 1243 | {cout<<"Trop de parametres: "<<myfunc->NPar()<<">"<<Par.NElts()<<endl;
|
---|
| 1244 | if(myfunc) delete myfunc; return;}
|
---|
| 1245 | GeneralFit myfit(myfunc);
|
---|
| 1246 | myfit.SetDebug(O.lpg);
|
---|
| 1247 | myfit.SetData(&mydata);
|
---|
| 1248 | myfit.SetStopChi2(O.stc2);
|
---|
[341] | 1249 | myfit.SetMaxStep(O.nstep);
|
---|
[333] | 1250 | {for(int i=0;i<myfunc->NPar();i++) {
|
---|
| 1251 | char str[10];
|
---|
| 1252 | sprintf(str,"P%d",i);
|
---|
| 1253 | myfit.SetParam(i,str,Par(i),Step(i),Min(i),Max(i));
|
---|
| 1254 | }}
|
---|
| 1255 | if(O.lp>1) myfit.PrintFit();
|
---|
[341] | 1256 | double c2r = -1.;
|
---|
| 1257 | int rcfit = (double) myfit.Fit();
|
---|
[333] | 1258 | if(O.lp>0) myfit.PrintFit();
|
---|
[341] | 1259 | if(rcfit>0) {
|
---|
[333] | 1260 | c2r = myfit.GetChi2Red();
|
---|
[341] | 1261 | cout<<"C2r_Reduit = "<<c2r<<" nstep="<<myfit.GetNStep()<<" rc="<<rcfit<<endl;
|
---|
[333] | 1262 | Vector ParFit(myfunc->NPar());
|
---|
| 1263 | for(int i=0;i<myfunc->NPar();i++) ParFit(i)=myfit.GetParm(i);
|
---|
| 1264 | } else {
|
---|
[341] | 1265 | cout<<"echec Fit, rc = "<<rcfit<<" nstep="<<myfit.GetNStep()<<endl;
|
---|
| 1266 | myfit.PrintFitErr(rcfit);
|
---|
[333] | 1267 | }
|
---|
| 1268 |
|
---|
| 1269 | // Mise a disposition des resultats
|
---|
[341] | 1270 | if(rcfit>=0 && myfunc && (O.okres>0||O.okfun>0)) {
|
---|
[333] | 1271 | string nomres = nom + "res";
|
---|
| 1272 | string nomfun = nom + "fun";
|
---|
| 1273 | if(v) {
|
---|
| 1274 | if(O.okres) {Vector* ob = v->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
|
---|
| 1275 | if(O.okfun) {Vector* ob = v->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
|
---|
| 1276 | } else if(h) {
|
---|
| 1277 | if(O.okres) {Histo* ob = h->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
|
---|
| 1278 | if(O.okfun) {Histo* ob = h->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
|
---|
| 1279 | } else if(m) {
|
---|
| 1280 | if(O.okres) {Matrix* ob = m->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
|
---|
| 1281 | if(O.okfun) {Matrix* ob = m->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
|
---|
| 1282 | } else if(h2) {
|
---|
| 1283 | if(O.okres) {Histo2D* ob = h2->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
|
---|
| 1284 | if(O.okfun) {Histo2D* ob = h2->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
|
---|
| 1285 | } else if(im) {
|
---|
| 1286 | if(O.okres) {RzImage* ob = im->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
|
---|
| 1287 | if(O.okfun) {RzImage* ob = im->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
|
---|
| 1288 | } else if(g) {
|
---|
| 1289 | if(O.okres) {GeneralFitData* ob = g->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
|
---|
| 1290 | if(O.okfun) {GeneralFitData* ob = g->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
|
---|
| 1291 | }
|
---|
| 1292 | }
|
---|
| 1293 |
|
---|
| 1294 | // Nettoyage
|
---|
| 1295 | if(myfunc) delete myfunc;
|
---|
| 1296 | return;
|
---|
| 1297 | }
|
---|
| 1298 |
|
---|
| 1299 |
|
---|
| 1300 | /* --Methode-- */
|
---|
| 1301 | void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx,
|
---|
| 1302 | string& expy, string& expz, string& expt, string& expcut,
|
---|
| 1303 | NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
|
---|
| 1304 | {
|
---|
| 1305 | if (obja == NULL) return;
|
---|
| 1306 | NTupleInterface* objnt = obja->GetNTupleInterface();
|
---|
| 1307 | if (objnt == NULL) return;
|
---|
| 1308 | string vardec = objnt->VarList_C("_zz6qi_");
|
---|
| 1309 |
|
---|
| 1310 | PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
|
---|
| 1311 | if (!f) {
|
---|
| 1312 | cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " << endl;
|
---|
| 1313 | return;
|
---|
| 1314 | }
|
---|
| 1315 |
|
---|
| 1316 | double xnt[10];
|
---|
| 1317 | float fxnt[10];
|
---|
| 1318 |
|
---|
| 1319 | int i,k;
|
---|
| 1320 | for(i=0; i<10; i++) xnt[i] = 0.;
|
---|
| 1321 |
|
---|
| 1322 | TRY {
|
---|
| 1323 | double* xn;
|
---|
| 1324 | for(k=0; k<objnt->NbLines(); k++) {
|
---|
| 1325 | xn = objnt->GetLineD(k);
|
---|
| 1326 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
| 1327 | if (nt) {
|
---|
| 1328 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
| 1329 | nt->Fill(fxnt);
|
---|
| 1330 | }
|
---|
| 1331 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
| 1332 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
| 1333 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
| 1334 | }
|
---|
| 1335 | }
|
---|
| 1336 | }
|
---|
| 1337 | CATCH(merr) {
|
---|
| 1338 | fflush(stdout);
|
---|
| 1339 | cout << endl;
|
---|
| 1340 | cerr << endl;
|
---|
| 1341 | string es = PeidaExc(merr);
|
---|
| 1342 | cerr << "Services2NObjMgr::ComputeExpressions() Exception :" << merr << es;
|
---|
| 1343 | } ENDTRY;
|
---|
| 1344 |
|
---|
| 1345 |
|
---|
| 1346 | // Fermeture du fichier .so
|
---|
| 1347 | CloseDLL();
|
---|
| 1348 | return;
|
---|
| 1349 | }
|
---|
| 1350 |
|
---|
| 1351 |
|
---|
| 1352 | /* --Methode-- */
|
---|
| 1353 | PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy,
|
---|
| 1354 | string& expz, string& expt, string& cut)
|
---|
| 1355 | {
|
---|
| 1356 | FILE *fip;
|
---|
| 1357 | string fname = TmpDir + "expf_pia_dl.c";
|
---|
| 1358 | string cmd;
|
---|
| 1359 | int rc;
|
---|
| 1360 |
|
---|
| 1361 | cmd = "rm -f " + fname;
|
---|
| 1362 | rc = system(cmd.c_str());
|
---|
| 1363 | //DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 1364 |
|
---|
| 1365 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 1366 | string sn = fname;
|
---|
| 1367 | cout << "Services2NObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl;
|
---|
| 1368 | return(NULL);
|
---|
| 1369 | }
|
---|
| 1370 |
|
---|
| 1371 | // constitution du fichier a compiler
|
---|
| 1372 | fputs("#include <stdlib.h> \n", fip);
|
---|
| 1373 | fputs("#include <math.h> \n", fip);
|
---|
| 1374 | fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
|
---|
| 1375 | fprintf(fip,"%s \n", vardec.c_str());
|
---|
| 1376 | fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.; return(0); } \n", cut.c_str());
|
---|
| 1377 | fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
|
---|
| 1378 | fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
|
---|
| 1379 | fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
|
---|
| 1380 | fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
|
---|
| 1381 | fputs("return(1); \n} \n", fip);
|
---|
| 1382 | fclose(fip);
|
---|
| 1383 | string func = "expf_pia_dl_func";
|
---|
| 1384 | return((PlotExprFunc)LinkFunctionFromFile(fname, func));
|
---|
| 1385 | }
|
---|
| 1386 |
|
---|
| 1387 |
|
---|
| 1388 | /* --Methode-- */
|
---|
| 1389 | DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
|
---|
| 1390 | {
|
---|
| 1391 | // Le link dynamique
|
---|
| 1392 | CloseDLL();
|
---|
| 1393 | dynlink = PDynLinkMgr::BuildFromCFile(fname);
|
---|
| 1394 | if (dynlink == NULL) {
|
---|
| 1395 | cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
|
---|
| 1396 | return(NULL);
|
---|
| 1397 | }
|
---|
| 1398 |
|
---|
| 1399 | DlFunction retfunc = dynlink->GetFunction(funcname);
|
---|
| 1400 | if (retfunc == NULL) {
|
---|
| 1401 | string sn = funcname;
|
---|
| 1402 | cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
|
---|
| 1403 | CloseDLL();
|
---|
| 1404 | return(NULL);
|
---|
| 1405 | }
|
---|
| 1406 | else return(retfunc);
|
---|
| 1407 | }
|
---|
| 1408 |
|
---|
| 1409 | /* --Methode-- */
|
---|
| 1410 | void Services2NObjMgr::CloseDLL()
|
---|
| 1411 | {
|
---|
| 1412 | if (dynlink) delete dynlink; dynlink = NULL;
|
---|
| 1413 | }
|
---|
| 1414 |
|
---|
| 1415 |
|
---|
| 1416 | /* --Methode-- */
|
---|
[165] | 1417 | string Services2NObjMgr::FileName2Name(string const & fn)
|
---|
| 1418 | {
|
---|
| 1419 |
|
---|
| 1420 | char fsep[2] = {FILESEP, '\0'};
|
---|
| 1421 | char tsep[2] = {'.', '\0'};
|
---|
| 1422 | size_t p = fn.find_last_of(fsep);
|
---|
[194] | 1423 | size_t l = fn.length();
|
---|
| 1424 | if (p >= l) p = 0;
|
---|
| 1425 | else p++;
|
---|
| 1426 | size_t q = fn.find_first_of(tsep,p);
|
---|
| 1427 | if (q < p) q = l;
|
---|
[165] | 1428 | return(fn.substr(p,q-p));
|
---|
| 1429 | }
|
---|
| 1430 |
|
---|
| 1431 |
|
---|
| 1432 | typedef vector<string> GraTok;
|
---|
| 1433 |
|
---|
| 1434 | /* --Methode-- */
|
---|
| 1435 | int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
|
---|
| 1436 | {
|
---|
| 1437 | int ropt = Disp_Next;
|
---|
| 1438 | if (!mImgapp) return(ropt);
|
---|
| 1439 |
|
---|
| 1440 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
|
---|
| 1441 |
|
---|
| 1442 | if (fgsrgr) mImgapp->SaveGraphicAtt();
|
---|
| 1443 |
|
---|
[326] | 1444 | if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini
|
---|
[165] | 1445 | mImgapp->SetColAtt();
|
---|
| 1446 | mImgapp->SetLineAtt();
|
---|
| 1447 | mImgapp->SetFontAtt();
|
---|
| 1448 | mImgapp->SetMarkerAtt();
|
---|
| 1449 | mImgapp->SetColMapId();
|
---|
| 1450 | mImgapp->SetZoomAtt();
|
---|
[331] | 1451 | mImgapp->SetAxesAtt();
|
---|
| 1452 | mImgapp->SetXYLimits();
|
---|
| 1453 | mImgapp->UseXYLimits();
|
---|
[165] | 1454 | return(ropt);
|
---|
| 1455 | }
|
---|
| 1456 |
|
---|
| 1457 | // On separe en mots separes par des virgules
|
---|
| 1458 | gratt = ","+gratt;
|
---|
| 1459 | size_t p = 0;
|
---|
| 1460 | size_t q = 0;
|
---|
| 1461 | size_t l = gratt.length();
|
---|
| 1462 | string token;
|
---|
| 1463 |
|
---|
| 1464 | GraTok grt;
|
---|
| 1465 |
|
---|
| 1466 | while (q < l) {
|
---|
| 1467 | p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
|
---|
| 1468 | if (p>=l) break;
|
---|
| 1469 | q = gratt.find_first_of(" ,",p); // la fin du token;
|
---|
| 1470 | token = gratt.substr(p,q-p);
|
---|
| 1471 | grt.push_back(token);
|
---|
| 1472 | }
|
---|
| 1473 |
|
---|
| 1474 |
|
---|
| 1475 | static GrAttNames::iterator it;
|
---|
| 1476 |
|
---|
| 1477 | int k;
|
---|
| 1478 | bool fgcont = true;
|
---|
| 1479 | fgsrgr = false;
|
---|
| 1480 |
|
---|
| 1481 | for(k=0; k<grt.size(); k++) {
|
---|
| 1482 | // cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
|
---|
| 1483 |
|
---|
| 1484 | // Decodage option affichage (win, next, etc
|
---|
| 1485 | fgcont = true;
|
---|
| 1486 | if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
|
---|
| 1487 | else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
|
---|
| 1488 | else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
|
---|
| 1489 | else fgcont = false;
|
---|
| 1490 | if (fgcont) continue;
|
---|
[331] | 1491 |
|
---|
| 1492 | // Utilisation limites X-Y
|
---|
| 1493 | if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true); fgsrgr = true; continue; }
|
---|
[165] | 1494 | // Si c'est une couleur
|
---|
| 1495 | it = GrAcolors.find(grt[k]);
|
---|
| 1496 | if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 1497 | // Si c'est un attribut de lignes
|
---|
| 1498 | it = GrAlines.find(grt[k]);
|
---|
| 1499 | if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 1500 | // Si c'est un attribut de fontes
|
---|
| 1501 | it = GrAfonts.find(grt[k]);
|
---|
| 1502 | if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
|
---|
| 1503 | fgsrgr = true; continue; }
|
---|
| 1504 | // Si c'est un attribut de markers
|
---|
| 1505 | it = GrAmarkers.find(grt[k]);
|
---|
| 1506 | if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
|
---|
| 1507 | fgsrgr = true; continue; }
|
---|
| 1508 | // Si c'est un colormap
|
---|
| 1509 | it = GrAcmap.find(grt[k]);
|
---|
| 1510 | if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
|
---|
| 1511 | // Si c'est un facteur de zoom
|
---|
| 1512 | it = GrAzoom.find(grt[k]);
|
---|
| 1513 | if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
[203] | 1514 | // Si c'est un attribut d'axe
|
---|
| 1515 | it = GrAaxes.find(grt[k]);
|
---|
| 1516 | if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
[165] | 1517 |
|
---|
| 1518 | }
|
---|
| 1519 |
|
---|
| 1520 | return(ropt);
|
---|
| 1521 | }
|
---|
| 1522 |
|
---|
| 1523 |
|
---|
| 1524 |
|
---|
| 1525 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
| 1526 | // Initialisation des chaines de caracteres designant les attributs graphiques
|
---|
| 1527 |
|
---|
| 1528 | /* --Methode-- */
|
---|
| 1529 | void Services2NObjMgr::InitGrAttNames()
|
---|
| 1530 | {
|
---|
| 1531 | gratt_item gi;
|
---|
| 1532 | // Les couleurs
|
---|
| 1533 | gi.a2 = 0;
|
---|
| 1534 | gi.a1 = PI_NotDefColor;
|
---|
| 1535 | GrAcolors["defcol"] = gi;
|
---|
| 1536 | gi.a1 = PI_Black;
|
---|
| 1537 | GrAcolors["black"] = gi;
|
---|
| 1538 | gi.a1 = PI_White;
|
---|
| 1539 | GrAcolors["white"] = gi;
|
---|
| 1540 | gi.a1 = PI_Grey;
|
---|
| 1541 | GrAcolors["grey"] = gi;
|
---|
| 1542 | gi.a1 = PI_Red;
|
---|
| 1543 | GrAcolors["red"] = gi;
|
---|
| 1544 | gi.a1 = PI_Blue;
|
---|
| 1545 | GrAcolors["blue"] = gi;
|
---|
| 1546 | gi.a1 = PI_Green;
|
---|
| 1547 | GrAcolors["green"] = gi;
|
---|
| 1548 | gi.a1 = PI_Yellow;
|
---|
| 1549 | GrAcolors["yellow"] = gi;
|
---|
| 1550 | gi.a1 = PI_Magenta;
|
---|
| 1551 | GrAcolors["magenta"] = gi;
|
---|
| 1552 |
|
---|
| 1553 | gi.a1 = PI_Cyan;
|
---|
| 1554 | GrAcolors["cyan"] = gi;
|
---|
| 1555 | gi.a1 = PI_Turquoise;
|
---|
| 1556 | GrAcolors["turquoise"] = gi;
|
---|
| 1557 | gi.a1 = PI_NavyBlue;
|
---|
| 1558 | GrAcolors["navyblue"] = gi;
|
---|
| 1559 | gi.a1 = PI_Orange;
|
---|
| 1560 | GrAcolors["orange"] = gi;
|
---|
| 1561 | gi.a1 = PI_SiennaRed;
|
---|
| 1562 | GrAcolors["siennared"] = gi;
|
---|
| 1563 | gi.a1 = PI_Purple;
|
---|
| 1564 | GrAcolors["purple"] = gi;
|
---|
| 1565 | gi.a1 = PI_LimeGreen;
|
---|
| 1566 | GrAcolors["limegreen"] = gi;
|
---|
| 1567 | gi.a1 = PI_Gold;
|
---|
| 1568 | GrAcolors["gold"] = gi;
|
---|
| 1569 |
|
---|
| 1570 | // Les attributs de lignes
|
---|
| 1571 | gi.a2 = 0;
|
---|
| 1572 | gi.a1 = PI_NotDefLineAtt;
|
---|
| 1573 | GrAlines["defline"] = gi;
|
---|
| 1574 | gi.a1 = PI_NormalLine;
|
---|
| 1575 | GrAlines["normalline"] = gi;
|
---|
| 1576 | gi.a1 = PI_ThinLine;
|
---|
| 1577 | GrAlines["thinline"] = gi;
|
---|
| 1578 | gi.a1 = PI_ThickLine;
|
---|
| 1579 | GrAlines["thickline"] = gi;
|
---|
| 1580 | gi.a1 = PI_DashedLine;
|
---|
| 1581 | GrAlines["dashedline"] = gi;
|
---|
| 1582 | gi.a1 = PI_ThinDashedLine;
|
---|
| 1583 | GrAlines["thindashedline"] = gi;
|
---|
| 1584 | gi.a1 = PI_ThickDashedLine;
|
---|
| 1585 | GrAlines["thickdashedline"] = gi;
|
---|
[192] | 1586 | gi.a1 = PI_DottedLine;
|
---|
| 1587 | GrAlines["dottedline"] = gi;
|
---|
| 1588 | gi.a1 = PI_ThinDottedLine;
|
---|
| 1589 | GrAlines["thindottedline"] = gi;
|
---|
| 1590 | gi.a1 = PI_ThickDottedLine;
|
---|
| 1591 | GrAlines["thickdottedline"] = gi;
|
---|
[165] | 1592 |
|
---|
[293] | 1593 | // Les fontes
|
---|
[165] | 1594 | gi.a2 = PI_NotDefFontSize;
|
---|
| 1595 | gi.a1 = PI_NotDefFontAtt;
|
---|
| 1596 | GrAlines["deffont"] = gi;
|
---|
| 1597 |
|
---|
| 1598 | gi.a2 = PI_NormalSizeFont;
|
---|
| 1599 | gi.a1 = PI_RomanFont;
|
---|
| 1600 | GrAlines["normalfont"] = gi;
|
---|
| 1601 | gi.a1 = PI_BoldFont;
|
---|
| 1602 | GrAlines["boldfont"] = gi;
|
---|
| 1603 | gi.a1 = PI_ItalicFont;
|
---|
| 1604 | GrAlines["italicfont"] = gi;
|
---|
| 1605 | gi.a2 = PI_SmallSizeFont;
|
---|
| 1606 | gi.a1 = PI_RomanFont;
|
---|
| 1607 | GrAlines["smallfont"] = gi;
|
---|
| 1608 | gi.a1 = PI_BoldFont;
|
---|
| 1609 | GrAlines["smallboldfont"] = gi;
|
---|
| 1610 | gi.a1 = PI_ItalicFont;
|
---|
| 1611 | GrAlines["smallitalicfont"] = gi;
|
---|
| 1612 | gi.a2 = PI_BigSizeFont;
|
---|
| 1613 | gi.a1 = PI_RomanFont;
|
---|
| 1614 | GrAlines["bigfont"] = gi;
|
---|
| 1615 | gi.a1 = PI_BoldFont;
|
---|
| 1616 | GrAlines["bigboldfont"] = gi;
|
---|
| 1617 | gi.a1 = PI_ItalicFont;
|
---|
| 1618 | GrAlines["bigitalicfont"] = gi;
|
---|
[192] | 1619 | gi.a2 = PI_HugeSizeFont;
|
---|
| 1620 | gi.a1 = PI_RomanFont;
|
---|
| 1621 | GrAlines["hugefont"] = gi;
|
---|
| 1622 | gi.a1 = PI_BoldFont;
|
---|
| 1623 | GrAlines["hugeboldfont"] = gi;
|
---|
| 1624 | gi.a1 = PI_ItalicFont;
|
---|
| 1625 | GrAlines["hugeitalicfont"] = gi;
|
---|
[165] | 1626 |
|
---|
| 1627 |
|
---|
| 1628 | // Les markers
|
---|
[176] | 1629 | const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
|
---|
| 1630 | "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
|
---|
| 1631 | "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
|
---|
[165] | 1632 | PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
|
---|
| 1633 | PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
|
---|
| 1634 | PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
|
---|
| 1635 |
|
---|
| 1636 | gi.a2 = 0;
|
---|
| 1637 | gi.a1 = PI_NotDefMarker;
|
---|
| 1638 | GrAmarkers["defmarker"] = gi;
|
---|
| 1639 |
|
---|
| 1640 | for(int j=0; j<11; j++) {
|
---|
| 1641 | string smrk;
|
---|
| 1642 | char buff[16];
|
---|
| 1643 | for(int m=1; m<10; m+=2) {
|
---|
| 1644 | sprintf(buff,"%d",m);
|
---|
| 1645 | smrk = (string)mrkn[j] + (string)buff;
|
---|
| 1646 | gi.a1 = mrk[j]; gi.a2 = m;
|
---|
| 1647 | GrAmarkers[smrk] = gi;
|
---|
| 1648 | }
|
---|
| 1649 | }
|
---|
| 1650 |
|
---|
| 1651 | // Les tables de couleurs
|
---|
| 1652 | gi.a2 = 0;
|
---|
| 1653 | gi.a1 = CMAP_OTHER;
|
---|
| 1654 | GrAcmap["defcmap"] = gi;
|
---|
| 1655 | gi.a1 = CMAP_GREY32;
|
---|
| 1656 | GrAcmap["grey32"] = gi;
|
---|
| 1657 | gi.a1 = CMAP_GREYINV32;
|
---|
| 1658 | GrAcmap["greyinv32"] = gi;
|
---|
| 1659 | gi.a1 = CMAP_COLRJ32;
|
---|
| 1660 | GrAcmap["colrj32"] = gi;
|
---|
| 1661 | gi.a1 = CMAP_COLBR32;
|
---|
| 1662 | GrAcmap["colbr32"] = gi;
|
---|
| 1663 | gi.a1 = CMAP_GREY128;
|
---|
| 1664 | GrAcmap["grey128"] = gi;
|
---|
| 1665 | gi.a1 = CMAP_GREYINV128;
|
---|
| 1666 | GrAcmap["greyinv128"] = gi;
|
---|
| 1667 | gi.a1 = CMAP_COLRJ128;
|
---|
| 1668 | GrAcmap["colrj128"] = gi;
|
---|
| 1669 | gi.a1 = CMAP_COLBR128;
|
---|
| 1670 | GrAcmap["colbr128"] = gi;
|
---|
| 1671 |
|
---|
[203] | 1672 | // La valeur de zoom
|
---|
[165] | 1673 | gi.a2 = 0;
|
---|
| 1674 | gi.a1 = 0;
|
---|
| 1675 | GrAzoom["defzoom"] = gi;
|
---|
| 1676 | gi.a1 = 1;
|
---|
| 1677 | GrAzoom["zoomx1"] = gi;
|
---|
| 1678 | gi.a1 = 2;
|
---|
| 1679 | GrAzoom["zoomx2"] = gi;
|
---|
| 1680 | gi.a1 = 3;
|
---|
| 1681 | GrAzoom["zoomx3"] = gi;
|
---|
| 1682 | gi.a1 = 4;
|
---|
| 1683 | GrAzoom["zoomx4"] = gi;
|
---|
| 1684 | gi.a1 = 5;
|
---|
| 1685 | GrAzoom["zoomx5"] = gi;
|
---|
| 1686 | gi.a1 = -2;
|
---|
| 1687 | GrAzoom["zoom/2"] = gi;
|
---|
| 1688 | gi.a1 = -3;
|
---|
| 1689 | GrAzoom["zoom/3"] = gi;
|
---|
| 1690 | gi.a1 = -4;
|
---|
| 1691 | GrAzoom["zoom/4"] = gi;
|
---|
| 1692 | gi.a1 = -5;
|
---|
| 1693 | GrAzoom["zoom/5"] = gi;
|
---|
[203] | 1694 |
|
---|
| 1695 | // Attributs d'axes
|
---|
| 1696 | gi.a2 = 0;
|
---|
| 1697 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
|
---|
| 1698 | GrAaxes["stdaxes"] = gi;
|
---|
| 1699 | GrAaxes["defaxes"] = gi;
|
---|
| 1700 | GrAaxes["boxaxes"] = gi;
|
---|
| 1701 | gi.a1 = (int)kAxesDflt;
|
---|
| 1702 | GrAaxes["simpleaxes"] = gi;
|
---|
| 1703 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
|
---|
| 1704 | GrAaxes["boxaxesgrid"] = gi;
|
---|
| 1705 |
|
---|
| 1706 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
|
---|
| 1707 | GrAaxes["fineaxes"] = gi;
|
---|
| 1708 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
|
---|
| 1709 | GrAaxes["grid"] = gi;
|
---|
| 1710 | GrAaxes["fineaxesgrid"] = gi;
|
---|
| 1711 |
|
---|
[165] | 1712 | }
|
---|
[333] | 1713 |
|
---|
| 1714 |
|
---|
| 1715 | // SANS_EVOLPLANCK Attention !
|
---|
| 1716 | #include "pclassids.h"
|
---|
| 1717 |
|
---|
| 1718 | /* --Methode-- */
|
---|
| 1719 | char* Services2NObjMgr::PClassIdToClassName(int cid)
|
---|
| 1720 | {
|
---|
| 1721 | switch (cid) {
|
---|
| 1722 | case ClassId_Poly1 :
|
---|
| 1723 | return("Poly1");
|
---|
| 1724 | case ClassId_Poly2 :
|
---|
| 1725 | return("Poly2");
|
---|
| 1726 | case ClassId_Matrix :
|
---|
| 1727 | return("Matrix");
|
---|
| 1728 | case ClassId_Vector :
|
---|
| 1729 | return("Vector");
|
---|
| 1730 |
|
---|
| 1731 | case ClassId_DVList :
|
---|
| 1732 | return("DVList");
|
---|
| 1733 |
|
---|
| 1734 | case ClassId_Histo1D :
|
---|
| 1735 | return("Histo1D");
|
---|
| 1736 | case ClassId_Histo2D :
|
---|
| 1737 | return("Histo2D");
|
---|
| 1738 | case ClassId_HProf :
|
---|
| 1739 | return("HProf");
|
---|
| 1740 | case ClassId_NTuple :
|
---|
| 1741 | return("NTuple");
|
---|
| 1742 | case ClassId_GeneralFitData :
|
---|
| 1743 | return("GeneralFitData");
|
---|
| 1744 |
|
---|
| 1745 | case ClassId_Image :
|
---|
| 1746 | return("RzImage");
|
---|
| 1747 | case ClassId_Image + kuint_1 :
|
---|
| 1748 | return("ImageU1");
|
---|
| 1749 | case ClassId_Image + kint_1 :
|
---|
| 1750 | return("ImageI1");
|
---|
| 1751 | case ClassId_Image + kuint_2 :
|
---|
| 1752 | return("ImageU2");
|
---|
| 1753 | case ClassId_Image + kint_2 :
|
---|
| 1754 | return("ImageI2");
|
---|
| 1755 | case ClassId_Image + kuint_4 :
|
---|
| 1756 | return("ImageU4");
|
---|
| 1757 | case ClassId_Image + kint_4 :
|
---|
| 1758 | return("ImageI4");
|
---|
| 1759 | case ClassId_Image + kr_4 :
|
---|
| 1760 | return("ImageR4");
|
---|
| 1761 | case ClassId_Image + kr_8 :
|
---|
| 1762 | return("ImageR8");
|
---|
| 1763 |
|
---|
| 1764 | case ClassId_ZFidu :
|
---|
| 1765 | return("ZFidu");
|
---|
| 1766 |
|
---|
| 1767 | case ClassId_StarList :
|
---|
| 1768 | return("StarList");
|
---|
| 1769 | case ClassId_Transfo :
|
---|
| 1770 | return("Transfo");
|
---|
| 1771 | case ClassId_PSF :
|
---|
| 1772 | return("PSF");
|
---|
| 1773 |
|
---|
| 1774 |
|
---|
| 1775 | // - Ajout objet PPF
|
---|
| 1776 | default:
|
---|
| 1777 | return("AnyDataObj");
|
---|
| 1778 | }
|
---|
| 1779 | }
|
---|
| 1780 |
|
---|