[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 |
|
---|
| 11 | #include "strutil.h"
|
---|
| 12 |
|
---|
| 13 | #include "nobjmgr.h"
|
---|
| 14 | #include "servnobjm.h"
|
---|
[330] | 15 | #include "nomgadapter.h"
|
---|
[165] | 16 | #include "pistdimgapp.h"
|
---|
| 17 |
|
---|
[333] | 18 | #include "fct1dfit.h"
|
---|
| 19 | #include "fct2dfit.h"
|
---|
| 20 |
|
---|
| 21 | #include "matrix.h"
|
---|
| 22 | #include "cvector.h"
|
---|
| 23 | #include "ntuple.h"
|
---|
| 24 | #include "cimage.h"
|
---|
| 25 |
|
---|
[165] | 26 | #include "histos.h"
|
---|
| 27 | #include "histos2.h"
|
---|
| 28 | #include "ntuple.h"
|
---|
| 29 | #include "hisprof.h"
|
---|
| 30 |
|
---|
[326] | 31 | #include "piscdrawwdg.h"
|
---|
| 32 | #include "pisurfdr.h"
|
---|
[333] | 33 |
|
---|
| 34 | #include "pintuple.h"
|
---|
| 35 | #include "pintup3d.h"
|
---|
| 36 |
|
---|
[326] | 37 | #include "pipodrw.h"
|
---|
[165] | 38 |
|
---|
| 39 |
|
---|
[326] | 40 |
|
---|
[165] | 41 | /* --Methode-- */
|
---|
[333] | 42 | Services2NObjMgr::Services2NObjMgr(NamedObjMgr* omg, string& tmpdir)
|
---|
[165] | 43 | {
|
---|
| 44 | TmpDir = tmpdir;
|
---|
[171] | 45 | PDynLinkMgr::SetTmpDir(tmpdir);
|
---|
[333] | 46 | mImgapp = NULL;
|
---|
| 47 | mOmg = omg;
|
---|
[171] | 48 | dynlink = NULL;
|
---|
[165] | 49 | InitGrAttNames();
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | /* --Methode-- */
|
---|
| 53 | Services2NObjMgr::~Services2NObjMgr()
|
---|
| 54 | {
|
---|
| 55 | CloseDLL();
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | /* --Methode-- */
|
---|
[295] | 59 | void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
|
---|
[165] | 60 | {
|
---|
[295] | 61 | ObjAdaptList::iterator it;
|
---|
| 62 | for(it = objadaplist.begin(); it != objadaplist.end(); it++)
|
---|
[495] | 63 | #ifdef SANS_EVOLPLANCK
|
---|
[295] | 64 | if (typeid(*o) == typeid(*((*it).obj))) THROW(dupIdErr);
|
---|
[495] | 65 | #else
|
---|
| 66 | if (typeid(*o) == typeid(*((*it).obj)))
|
---|
| 67 | throw(DuplicateIdExc("Services2NObjMgr::RegisterClass() - Duplicate class"));
|
---|
| 68 | #endif
|
---|
[295] | 69 | dataobj_adapter oba;
|
---|
| 70 | oba.obj = o;
|
---|
| 71 | oba.obja = oa;
|
---|
| 72 | objadaplist.push_back(oba);
|
---|
| 73 | }
|
---|
[165] | 74 |
|
---|
[295] | 75 | /* --Methode-- */
|
---|
| 76 | NObjMgrAdapter* Services2NObjMgr::GetAdapter(AnyDataObj* o)
|
---|
| 77 | {
|
---|
| 78 | ObjAdaptList::iterator it;
|
---|
| 79 | for(it = objadaplist.begin(); it != objadaplist.end(); it++)
|
---|
| 80 | if (typeid(*o) == typeid(*((*it).obj))) return((*it).obja->Clone(o));
|
---|
| 81 | return(new NObjMgrAdapter(o));
|
---|
| 82 | }
|
---|
[165] | 83 |
|
---|
[295] | 84 | /* --Methode-- */
|
---|
[333] | 85 | void Services2NObjMgr::PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, int np, string dopt)
|
---|
[295] | 86 | {
|
---|
[165] | 87 | FILE *fip;
|
---|
[326] | 88 | string fname = TmpDir + "func1_pia_dl.c";
|
---|
| 89 | string cmd;
|
---|
| 90 | int rc;
|
---|
| 91 |
|
---|
| 92 | if (!mImgapp) return;
|
---|
| 93 |
|
---|
| 94 | cmd = "rm -f " + fname;
|
---|
| 95 | rc = system(cmd.c_str());
|
---|
| 96 | // printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 97 |
|
---|
| 98 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 99 | string sn = fname;
|
---|
[449] | 100 | cout << "Services2NObjMgr/PlotFunc_Error: fopen( " << sn << endl;
|
---|
[326] | 101 | return;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | // constitution du fichier a compiler
|
---|
| 105 | fputs("#include <math.h> \n", fip);
|
---|
| 106 | fputs("double func1_pia_dl_func(double x) \n{\n", fip);
|
---|
| 107 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
|
---|
| 108 | fclose(fip);
|
---|
| 109 |
|
---|
| 110 | string func = "func1_pia_dl_func";
|
---|
| 111 | DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
|
---|
| 112 | if (!f) return;
|
---|
[333] | 113 | PlotFunc(f, nom, xmin, xmax, np, dopt);
|
---|
[326] | 114 | CloseDLL();
|
---|
| 115 | return;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | /* --Methode-- */
|
---|
[333] | 119 | void Services2NObjMgr::PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax,
|
---|
| 120 | double ymin, double ymax, int npx, int npy, string dopt)
|
---|
[326] | 121 | {
|
---|
| 122 | FILE *fip;
|
---|
| 123 | string fname = TmpDir + "func2_pia_dl.c";
|
---|
| 124 | string cmd;
|
---|
| 125 | int rc;
|
---|
| 126 |
|
---|
| 127 | if (!mImgapp) return;
|
---|
| 128 |
|
---|
| 129 | cmd = "rm " + fname;
|
---|
| 130 | rc = system(cmd.c_str());
|
---|
| 131 | // printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 132 |
|
---|
| 133 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 134 | string sn = fname;
|
---|
[449] | 135 | cout << "Services2NObjMgr/PlotFunc2D_Error: fopen( " << sn << endl;
|
---|
[326] | 136 | return;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | // constitution du fichier a compiler
|
---|
| 140 | fputs("#include <math.h> \n", fip);
|
---|
| 141 | fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
|
---|
| 142 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
|
---|
| 143 | fclose(fip);
|
---|
| 144 |
|
---|
| 145 | string func = "func2_pia_dl_func";
|
---|
| 146 | DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
|
---|
| 147 | if (!f) return;
|
---|
[333] | 148 | PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
|
---|
[326] | 149 | CloseDLL();
|
---|
| 150 | return;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | /* --Methode-- */
|
---|
[333] | 154 | void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, string & nom,
|
---|
| 155 | double xmin, double xmax, int np, string dopt)
|
---|
[326] | 156 | {
|
---|
| 157 | DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
|
---|
| 158 | if (!f) return;
|
---|
[333] | 159 | PlotFunc(f, nom, xmin, xmax, np, dopt);
|
---|
[326] | 160 | CloseDLL();
|
---|
| 161 | return;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | /* --Methode-- */
|
---|
[333] | 165 | void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, string & nom,
|
---|
| 166 | double xmin, double xmax, double ymin, double ymax, int npx, int npy, string dopt)
|
---|
[326] | 167 | {
|
---|
| 168 | DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
|
---|
| 169 | if (!f) return;
|
---|
[333] | 170 | PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
|
---|
[326] | 171 | CloseDLL();
|
---|
| 172 | return;
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | /* --Methode-- */
|
---|
[333] | 176 | void Services2NObjMgr::PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, int np, string dopt)
|
---|
[326] | 177 | {
|
---|
| 178 | if (!mImgapp) return;
|
---|
| 179 |
|
---|
| 180 | int k;
|
---|
| 181 | if (np < 1) np = 1;
|
---|
| 182 | if (xmax <= xmin) xmax = xmin+1.;
|
---|
| 183 | Vector* vpy = new Vector(np);
|
---|
| 184 |
|
---|
| 185 | double xx;
|
---|
| 186 | double dx = (xmax-xmin)/np;
|
---|
[495] | 187 | #ifdef SANS_EVOLPLANCK
|
---|
[326] | 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;
|
---|
[495] | 199 | #else
|
---|
| 200 | try {
|
---|
| 201 | for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
|
---|
| 202 | }
|
---|
| 203 | catch ( PException exc ) {
|
---|
| 204 | fflush(stdout);
|
---|
| 205 | cout << endl;
|
---|
| 206 | cerr << endl;
|
---|
| 207 | cerr << "Services2NObjMgr::PlotFunc() Exception :" << exc.Msg() << endl;
|
---|
| 208 | delete vpy;
|
---|
| 209 | vpy = NULL;
|
---|
| 210 | }
|
---|
| 211 | #endif
|
---|
[326] | 212 |
|
---|
| 213 | if (vpy) {
|
---|
[344] | 214 | string titre;
|
---|
| 215 | if (nom.length() < 1) {
|
---|
| 216 | titre = "Function f(x)";
|
---|
[466] | 217 | nom = "/autoc/f_x";
|
---|
[344] | 218 | }
|
---|
| 219 | else titre = nom;
|
---|
| 220 |
|
---|
| 221 | P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);
|
---|
[326] | 222 | vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
|
---|
| 223 | PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ;
|
---|
| 224 | bool fgsr = true;
|
---|
| 225 | dopt = "thinline," + dopt;
|
---|
| 226 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
[333] | 227 | int rsid = mImgapp->DispScDrawer(dr, titre, opt);
|
---|
[326] | 228 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
[333] | 229 | if (nom.length() > 0) {
|
---|
| 230 | mOmg->AddObj(vpy, nom);
|
---|
| 231 | mOmg->AddWRsId(nom, rsid);
|
---|
| 232 | }
|
---|
[326] | 233 | }
|
---|
| 234 |
|
---|
| 235 | return;
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | /* --Methode-- */
|
---|
[333] | 239 | void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, double ymin, double ymax,
|
---|
[326] | 240 | int npx, int npy, string dopt)
|
---|
| 241 | {
|
---|
| 242 | if (!mImgapp) return;
|
---|
| 243 |
|
---|
| 244 | if (npx < 3) npx = 3;
|
---|
| 245 | if (npy < 3) npy = 3;
|
---|
| 246 | if (npx > 250) npx = 250;
|
---|
| 247 | if (npy > 250) npy = 250;
|
---|
| 248 | if (xmax <= xmin) xmax = xmin+1.;
|
---|
| 249 | if (ymax <= ymin) ymax = ymin+1.;
|
---|
| 250 |
|
---|
| 251 | Matrix* mtx = new Matrix(npy, npx);
|
---|
| 252 |
|
---|
| 253 | int i,j;
|
---|
| 254 | double xx, yy;
|
---|
| 255 | double dx = (xmax-xmin)/npx;
|
---|
| 256 | double dy = (ymax-ymin)/npy;
|
---|
| 257 | // printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
|
---|
[495] | 258 | #ifdef SANS_EVOLPLANCK
|
---|
[326] | 259 | TRY {
|
---|
| 260 | for(j=0; j<npy; j++) {
|
---|
| 261 | yy = ymin+dy*j;
|
---|
| 262 | for(i=0; i<npx; i++) {
|
---|
| 263 | xx = xmin+dx*i;
|
---|
| 264 | (*mtx)(j, i) = f(xx, yy);
|
---|
| 265 | }
|
---|
| 266 | }
|
---|
| 267 | } CATCH(merr) {
|
---|
| 268 | fflush(stdout);
|
---|
| 269 | cout << endl;
|
---|
| 270 | cerr << endl;
|
---|
| 271 | string es = PeidaExc(merr);
|
---|
| 272 | cerr << "Services2NObjMgr::PlotFunc2D() Exception :" << merr << es;
|
---|
| 273 | delete mtx; mtx = NULL;
|
---|
| 274 | } ENDTRY;
|
---|
[495] | 275 | #else
|
---|
| 276 | try {
|
---|
| 277 | for(j=0; j<npy; j++) {
|
---|
| 278 | yy = ymin+dy*j;
|
---|
| 279 | for(i=0; i<npx; i++) {
|
---|
| 280 | xx = xmin+dx*i;
|
---|
| 281 | (*mtx)(j, i) = f(xx, yy);
|
---|
| 282 | }
|
---|
| 283 | }
|
---|
| 284 | }
|
---|
| 285 | catch ( PException exc ) {
|
---|
| 286 | fflush(stdout);
|
---|
| 287 | cout << endl;
|
---|
| 288 | cerr << endl;
|
---|
| 289 | cerr << "Services2NObjMgr::PlotFunc2D() Exception :" << exc.Msg() << endl;
|
---|
| 290 | delete mtx; mtx = NULL;
|
---|
| 291 | }
|
---|
| 292 | #endif
|
---|
[326] | 293 |
|
---|
| 294 | if (mtx) {
|
---|
[344] | 295 | string titre;
|
---|
| 296 | if (nom.length() < 1) {
|
---|
| 297 | titre = "Function f(x,y)";
|
---|
[466] | 298 | nom = "/autoc/f2d_xy";
|
---|
[344] | 299 | }
|
---|
| 300 | else titre = nom;
|
---|
[326] | 301 | bool fgsr = true;
|
---|
| 302 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
[344] | 303 | P2DArrayAdapter* arr = new POMatrixAdapter(mtx, false);
|
---|
[326] | 304 | arr->DefineXYCoordinates(xmin, ymin, dx, dy);
|
---|
| 305 | PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
|
---|
[333] | 306 | int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
|
---|
[326] | 307 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
[333] | 308 | if (nom.length() > 0) {
|
---|
| 309 | mOmg->AddObj(mtx, nom);
|
---|
| 310 | mOmg->AddWRsId(nom, rsid);
|
---|
| 311 | }
|
---|
[326] | 312 | }
|
---|
| 313 |
|
---|
| 314 | return;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | /* --Methode-- */
|
---|
[333] | 318 | void Services2NObjMgr::DisplayPoints2D(string& nom, string& expx, string& expy,
|
---|
| 319 | string& experrx, string& experry,
|
---|
[357] | 320 | string& expcut, string dopt, string loop)
|
---|
[333] | 321 | {
|
---|
| 322 | NObjMgrAdapter* obja=NULL;
|
---|
| 323 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 324 | if (obja == NULL) {
|
---|
[449] | 325 | cout << "Services2NObjMgr::DisplayPoints2D() Error , No such object " << nom << endl;
|
---|
[333] | 326 | return;
|
---|
| 327 | }
|
---|
| 328 | if (!mImgapp) return;
|
---|
| 329 |
|
---|
| 330 | // Creation NTuple
|
---|
| 331 | char* ntn[4] = {"expx","expy","expex","expey",};
|
---|
| 332 | NTuple* nt = NULL;
|
---|
| 333 | bool haserr = false;
|
---|
| 334 |
|
---|
| 335 | if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) { haserr = true; nt = new NTuple(4, ntn); }
|
---|
| 336 | else { haserr = false; experrx = experry = "0."; nt = new NTuple(2, ntn); }
|
---|
| 337 |
|
---|
[357] | 338 | ComputeExpressions(obja, expx, expy, experrx, experry, expcut, loop, nt, NULL, NULL);
|
---|
[333] | 339 |
|
---|
| 340 | if (nt->NEntry() < 1) {
|
---|
| 341 | cout << "Services2NObjMgr::DisplayPoints2D() Warning Zero points satisfy cut !" << endl;
|
---|
| 342 | delete nt;
|
---|
| 343 | return;
|
---|
| 344 | }
|
---|
| 345 |
|
---|
| 346 | // nt->Show();
|
---|
| 347 | // nt->Print(0,10);
|
---|
| 348 | PINTuple* pin = new PINTuple(nt, true);
|
---|
| 349 | pin->SelectXY(ntn[0], ntn[1]);
|
---|
| 350 | if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
|
---|
| 351 |
|
---|
| 352 | bool fgsr = true;
|
---|
| 353 | dopt = "defline," + dopt;
|
---|
| 354 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 355 | string titre = nom + ":" + expy + "%" + expx;
|
---|
| 356 | mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
|
---|
| 357 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
| 358 | return;
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 | /* --Methode-- */
|
---|
| 362 | void Services2NObjMgr::DisplayPoints3D(string& nom, string& expx, string& expy,
|
---|
[357] | 363 | string& expz, string& expcut, string dopt, string loop)
|
---|
[333] | 364 | {
|
---|
| 365 | NObjMgrAdapter* obja=NULL;
|
---|
| 366 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 367 | if (obja == NULL) {
|
---|
[449] | 368 | cout << "Services2NObjMgr::DisplayPoints3D() Error , No such object " << nom << endl;
|
---|
[333] | 369 | return;
|
---|
| 370 | }
|
---|
| 371 | if (!mImgapp) return;
|
---|
| 372 |
|
---|
| 373 | char* ntn[3] = {"expx","expy","expz"};
|
---|
| 374 | NTuple* nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 375 |
|
---|
| 376 | string expwt = "1.";
|
---|
[357] | 377 | ComputeExpressions(obja, expx, expy, expz, expwt, expcut, loop, nt, NULL, NULL);
|
---|
[333] | 378 |
|
---|
| 379 | if (nt->NEntry() < 1) {
|
---|
| 380 | cout << "Services2NObjMgr::DisplayPoints3D() Warning Zero points satisfy cut !" << endl;
|
---|
| 381 | delete nt;
|
---|
| 382 | return;
|
---|
| 383 | }
|
---|
| 384 | nt->Show();
|
---|
| 385 | nt->Print(0,10);
|
---|
| 386 | PINTuple3D* pin = new PINTuple3D(nt, true);
|
---|
| 387 | pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
|
---|
| 388 | bool fgsr = true;
|
---|
| 389 | dopt = "defline," + dopt;
|
---|
| 390 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 391 |
|
---|
| 392 | // Pour plot a partir de DispScDrawer
|
---|
| 393 | // string nomdisp = "_NT3D_";
|
---|
| 394 | // mImgapp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
|
---|
| 395 | // Pour plot a partir de Disp3DDrawer
|
---|
| 396 | string titre = nom + ":" + expy + "%" + expx;
|
---|
| 397 | mImgapp->Disp3DDrawer(pin, titre, opt);
|
---|
| 398 |
|
---|
| 399 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
| 400 | return;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | /* --Methode-- */
|
---|
| 404 | void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy,
|
---|
[357] | 405 | string& expwt, string& expcut, string dopt, string loop)
|
---|
[333] | 406 | {
|
---|
| 407 | NObjMgrAdapter* obja=NULL;
|
---|
| 408 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 409 | if (obja == NULL) {
|
---|
[449] | 410 | cout << "Services2NObjMgr::DisplayPoints2DW() Error , No such object " << nom << endl;
|
---|
[333] | 411 | return;
|
---|
| 412 | }
|
---|
| 413 | if (!mImgapp) return;
|
---|
| 414 |
|
---|
| 415 | char* ntn[3] = {"expx","expy","expw"};
|
---|
| 416 | NTuple* nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 417 |
|
---|
| 418 | string exp = "1.";
|
---|
[357] | 419 | ComputeExpressions(obja, expx, expy, expwt, exp, expcut, loop, nt, NULL, NULL);
|
---|
[333] | 420 |
|
---|
| 421 | if (nt->NEntry() < 1) {
|
---|
| 422 | cout << "Services2NObjMgr::DisplayPoints2DW() Warning Zero points satisfy cut !" << endl;
|
---|
| 423 | delete nt;
|
---|
| 424 | return;
|
---|
| 425 | }
|
---|
| 426 |
|
---|
| 427 | PINTuple* pin = new PINTuple(nt, true);
|
---|
| 428 | pin->SelectXY(ntn[0], ntn[1]);
|
---|
| 429 | pin->SelectWt(ntn[2]);
|
---|
| 430 |
|
---|
| 431 | bool fgsr = true;
|
---|
| 432 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 433 | string titre = nom + ":" + expwt + "_" + expy + "%" + expx ;
|
---|
| 434 | mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
|
---|
| 435 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
| 436 | return;
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 | /* --Methode-- */
|
---|
| 440 | void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt,
|
---|
[357] | 441 | string& expcut, string& nomh1, string dopt, string loop)
|
---|
[333] | 442 | {
|
---|
| 443 | NObjMgrAdapter* obja=NULL;
|
---|
| 444 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 445 | if (obja == NULL) {
|
---|
[449] | 446 | cout << "Services2NObjMgr::ProjectH1() Error , No such object " << nom << endl;
|
---|
[333] | 447 | return;
|
---|
| 448 | }
|
---|
| 449 | if (!mImgapp) return;
|
---|
| 450 |
|
---|
| 451 | Histo* h1 = NULL;
|
---|
| 452 | NTuple* nt = NULL;
|
---|
| 453 | AnyDataObj* oh = NULL;
|
---|
| 454 | if (nomh1.length() > 0) oh=mOmg->GetObj(nomh1);
|
---|
| 455 | else nomh1 = "/tmp/projh1d";
|
---|
| 456 | if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) ) h1 = (Histo*)oh; // Pas de remise a zero ! h1->Zero();
|
---|
| 457 | else {
|
---|
| 458 | char* ntn[2]= {"hxval", "hwt"};
|
---|
| 459 | nt = new NTuple(2,ntn); // Creation NTuple
|
---|
| 460 | }
|
---|
| 461 | string expz = "0.";
|
---|
[357] | 462 | ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, loop, nt, h1, NULL);
|
---|
[333] | 463 |
|
---|
| 464 | if ((!h1) && (!nt)) return;
|
---|
| 465 | if (!h1) {
|
---|
| 466 | if (nt->NEntry() < 1) {
|
---|
| 467 | cout << "Services2NObjMgr::ProjectH1() Warning Zero points satisfy cut !" << endl;
|
---|
| 468 | delete nt;
|
---|
| 469 | return;
|
---|
| 470 | }
|
---|
| 471 | double xmin, xmax;
|
---|
| 472 | nt->GetMinMax(0, xmin, xmax);
|
---|
| 473 | h1 = new Histo(xmin, xmax, 100);
|
---|
| 474 | int k;
|
---|
| 475 | float* xn;
|
---|
| 476 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 477 | xn = nt->GetVec(k);
|
---|
| 478 | h1->Add(xn[0], xn[1]);
|
---|
| 479 | }
|
---|
| 480 | delete nt;
|
---|
| 481 | mOmg->AddObj(h1, nomh1);
|
---|
| 482 | }
|
---|
| 483 |
|
---|
| 484 | mOmg->DisplayObj(nomh1, dopt);
|
---|
| 485 | return;
|
---|
| 486 | }
|
---|
| 487 |
|
---|
| 488 | /* --Methode-- */
|
---|
| 489 | void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt,
|
---|
[357] | 490 | string& expcut, string& nomh2, string dopt, string loop)
|
---|
[333] | 491 | {
|
---|
| 492 | NObjMgrAdapter* obja=NULL;
|
---|
| 493 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 494 | if (obja == NULL) {
|
---|
[449] | 495 | cout << "Services2NObjMgr::ProjectH2() Error , No such object " << nom << endl;
|
---|
[333] | 496 | return;
|
---|
| 497 | }
|
---|
| 498 | if (!mImgapp) return;
|
---|
| 499 |
|
---|
| 500 | Histo2D* h2 = NULL;
|
---|
| 501 | NTuple* nt = NULL;
|
---|
| 502 | AnyDataObj* oh = NULL;
|
---|
| 503 | if (nomh2.length() > 0) oh=mOmg->GetObj(nomh2);
|
---|
| 504 | else nomh2 = "/tmp/projh2d";
|
---|
| 505 | if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) ) h2 = (Histo2D*)oh; // Pas de remise a zero ! h2->Zero();
|
---|
| 506 | else {
|
---|
| 507 | char* ntn[3]= {"hxval", "hyval", "hwt"};
|
---|
| 508 | nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 509 | }
|
---|
| 510 | string expz = "0.";
|
---|
[357] | 511 | ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, h2);
|
---|
[333] | 512 |
|
---|
| 513 | if ((!h2) && (!nt)) return;
|
---|
| 514 | if (!h2) {
|
---|
| 515 | if (nt->NEntry() < 1) {
|
---|
| 516 | cout << "Services2NObjMgr::ProjectH2() Warning Zero points satisfy cut !" << endl;
|
---|
| 517 | delete nt;
|
---|
| 518 | return;
|
---|
| 519 | }
|
---|
| 520 | double xmin, xmax, ymin, ymax;
|
---|
| 521 | nt->GetMinMax(0, xmin, xmax);
|
---|
[466] | 522 | nt->GetMinMax(1, ymin, ymax);
|
---|
[333] | 523 | h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
|
---|
| 524 | int k;
|
---|
| 525 | float* xn;
|
---|
| 526 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 527 | xn = nt->GetVec(k);
|
---|
| 528 | h2->Add(xn[0], xn[1], xn[2]);
|
---|
| 529 | }
|
---|
| 530 | delete nt;
|
---|
| 531 | mOmg->AddObj(h2, nomh2);
|
---|
| 532 | }
|
---|
| 533 |
|
---|
| 534 | mOmg->DisplayObj(nomh2, dopt);
|
---|
| 535 | return;
|
---|
| 536 |
|
---|
| 537 | }
|
---|
| 538 |
|
---|
| 539 | /* --Methode-- cmv 13/10/98 */
|
---|
| 540 | void Services2NObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt,
|
---|
[357] | 541 | string& expcut, string& nomprof, string dopt, string loop)
|
---|
| 542 | // Pour remplir un ``GeneralFitData'' a partir de divers objets:
|
---|
[333] | 543 | //| nom = nom de l'objet a projeter dans un HProf.
|
---|
| 544 | //| expx = expression X de definition du bin.
|
---|
| 545 | //| expy = expression Y a additionner dans le bin.
|
---|
| 546 | //| expwt = expression W du poids a additionner.
|
---|
| 547 | //| expcut = expression du test de selection.
|
---|
| 548 | //| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
|
---|
| 549 | //| les limites Xmin,Xmax sont calculees automatiquement.
|
---|
| 550 | //| sinon ce sont celles de l'objet preexistant.
|
---|
| 551 | //| opt = options generales pour le display.
|
---|
| 552 | {
|
---|
| 553 | NObjMgrAdapter* obja=NULL;
|
---|
| 554 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 555 | if (obja == NULL) {
|
---|
[449] | 556 | cout << "Services2NObjMgr::ProjectHProf() Error , No such object " << nom << endl;
|
---|
[333] | 557 | return;
|
---|
| 558 | }
|
---|
| 559 | if (!mImgapp) return;
|
---|
| 560 |
|
---|
| 561 | HProf* hprof = NULL;
|
---|
| 562 | NTuple* nt = NULL;
|
---|
| 563 | AnyDataObj* oh = NULL;
|
---|
| 564 | if (nomprof.length() > 0) oh=mOmg->GetObj(nomprof);
|
---|
| 565 | else nomprof = "/tmp/projprof";
|
---|
| 566 | if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) ) hprof = (HProf*)oh;
|
---|
| 567 | else {
|
---|
| 568 | char* ntn[3]= {"hxval", "hyval", "hwt"};
|
---|
| 569 | nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 570 | }
|
---|
| 571 | string expz = "0.";
|
---|
[357] | 572 | ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, NULL, hprof);
|
---|
[333] | 573 |
|
---|
| 574 | if((!hprof) && (!nt)) return;
|
---|
| 575 | if(!hprof) {
|
---|
| 576 | if (nt->NEntry() < 1) {
|
---|
| 577 | cout << "Services2NObjMgr::ProjectHProf() Warning Zero points satisfy cut !" << endl;
|
---|
| 578 | delete nt;
|
---|
| 579 | return;
|
---|
| 580 | }
|
---|
| 581 | double xmin, xmax;
|
---|
| 582 | nt->GetMinMax(0, xmin, xmax);
|
---|
| 583 | hprof = new HProf(xmin, xmax, 100);
|
---|
| 584 | int k;
|
---|
| 585 | float* xn;
|
---|
| 586 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 587 | xn = nt->GetVec(k);
|
---|
| 588 | hprof->Add(xn[0], xn[1], xn[2]);
|
---|
| 589 | }
|
---|
| 590 | delete nt;
|
---|
| 591 | mOmg->AddObj(hprof, nomprof);
|
---|
| 592 | }
|
---|
| 593 | hprof->UpdateHisto();
|
---|
| 594 |
|
---|
| 595 | mOmg->DisplayObj(nomprof, dopt);
|
---|
| 596 | return;
|
---|
| 597 | }
|
---|
| 598 |
|
---|
[357] | 599 |
|
---|
[333] | 600 | /* --Methode-- */
|
---|
[357] | 601 | void Services2NObjMgr::FillVect(string& nom, string& expx, string& expv,
|
---|
| 602 | string& expcut, string& nomvec, string dopt, string loop)
|
---|
[333] | 603 | {
|
---|
| 604 | NObjMgrAdapter* obja=NULL;
|
---|
| 605 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 606 | if (obja == NULL) {
|
---|
[357] | 607 | cout << "Services2NObjMgr::FillVect() Error , No such object: " << nom << endl;
|
---|
[333] | 608 | return;
|
---|
| 609 | }
|
---|
| 610 | if (!mImgapp) return;
|
---|
| 611 |
|
---|
[357] | 612 | Vector* v1 = NULL;
|
---|
| 613 | AnyDataObj* ov = NULL;
|
---|
| 614 | ov=mOmg->GetObj(nomvec);
|
---|
| 615 | if (ov != NULL) v1 = dynamic_cast<Vector *>(ov);
|
---|
| 616 | if (v1 == NULL) {
|
---|
| 617 | cout << "Services2NObjMgr::FillVect() Error , No such object or not a vector: " << nomvec << endl;
|
---|
| 618 | return;
|
---|
| 619 | }
|
---|
| 620 |
|
---|
| 621 | char* ntn[2]= {"vi", "vv"};
|
---|
| 622 | NTuple* nt = new NTuple(2,ntn); // Creation NTuple
|
---|
| 623 |
|
---|
| 624 | string expz = "0.";
|
---|
| 625 | ComputeExpressions(obja, expx, expv, expz, expz, expcut, loop, nt);
|
---|
| 626 |
|
---|
| 627 | if (!nt) return;
|
---|
| 628 | if (nt->NEntry() < 1) {
|
---|
| 629 | cout << "Services2NObjMgr::FillVect() Warning Zero points satisfy cut !" << endl;
|
---|
| 630 | delete nt;
|
---|
| 631 | return;
|
---|
| 632 | }
|
---|
| 633 |
|
---|
| 634 | int i,k;
|
---|
| 635 | double* xn;
|
---|
| 636 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 637 | xn = nt->GetLineD(k);
|
---|
| 638 | i = xn[0]+0.5;
|
---|
| 639 | if ( (i < 0) || i >= v1->NElts() ) continue;
|
---|
| 640 | (*v1)(i) = xn[1];
|
---|
| 641 | }
|
---|
| 642 | delete nt;
|
---|
| 643 |
|
---|
| 644 |
|
---|
| 645 | mOmg->DisplayObj(nomvec, dopt);
|
---|
| 646 | return;
|
---|
| 647 | }
|
---|
| 648 |
|
---|
| 649 | /* --Methode-- */
|
---|
| 650 | void Services2NObjMgr::FillMatx(string& nom, string& expx, string& expy, string& expv,
|
---|
| 651 | string& expcut, string& nommtx, string dopt, string loop)
|
---|
| 652 | {
|
---|
| 653 | NObjMgrAdapter* obja=NULL;
|
---|
| 654 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 655 | if (obja == NULL) {
|
---|
| 656 | cout << "Services2NObjMgr::FillMatx() Error , No such objet " << nom << endl;
|
---|
| 657 | return;
|
---|
| 658 | }
|
---|
| 659 | if (!mImgapp) return;
|
---|
| 660 |
|
---|
| 661 | Matrix* mtx = NULL;
|
---|
| 662 | AnyDataObj* om = NULL;
|
---|
| 663 | om=mOmg->GetObj(nommtx);
|
---|
| 664 | if (om != NULL) mtx = dynamic_cast<Matrix *>(om);
|
---|
| 665 | if (mtx == NULL) {
|
---|
| 666 | cout << "Services2NObjMgr::FillMatx() Error , No such object or not a matrix " << nommtx << endl;
|
---|
| 667 | return;
|
---|
| 668 | }
|
---|
| 669 |
|
---|
| 670 | char* ntn[3]= {"mi", "mj", "mv"};
|
---|
| 671 | NTuple* nt = new NTuple(3,ntn); // Creation NTuple
|
---|
| 672 |
|
---|
| 673 | string expz = "0.";
|
---|
| 674 | ComputeExpressions(obja, expx, expy, expv, expz, expcut, loop, nt);
|
---|
| 675 |
|
---|
| 676 | if (!nt) return;
|
---|
| 677 | if (nt->NEntry() < 1) {
|
---|
| 678 | cout << "Services2NObjMgr::FillMatx() Warning Zero points satisfy cut !" << endl;
|
---|
| 679 | delete nt;
|
---|
| 680 | return;
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | int ic, jl, k;
|
---|
| 684 | double* xn;
|
---|
| 685 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 686 | xn = nt->GetLineD(k);
|
---|
| 687 | ic = xn[0]+0.5;
|
---|
| 688 | jl = xn[1]+0.5;
|
---|
| 689 | if ( (ic < 0) || ic >= mtx->NCol() ) continue;
|
---|
| 690 | if ( (jl < 0) || jl >= mtx->NRows() ) continue;
|
---|
| 691 | (*mtx)(jl, ic) = xn[2];
|
---|
| 692 | }
|
---|
| 693 | delete nt;
|
---|
| 694 |
|
---|
| 695 |
|
---|
| 696 | mOmg->DisplayObj(nommtx, dopt);
|
---|
| 697 | return;
|
---|
| 698 |
|
---|
| 699 | }
|
---|
| 700 |
|
---|
| 701 | /* --Methode-- */
|
---|
| 702 | void Services2NObjMgr::ExpressionToVector(string& nom, string& expx, string& expcut,
|
---|
| 703 | string& nomvec, string dopt, string loop)
|
---|
| 704 | {
|
---|
| 705 | NObjMgrAdapter* obja=NULL;
|
---|
| 706 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 707 | if (obja == NULL) {
|
---|
[449] | 708 | cout << "Services2NObjMgr::ExpressionToVector() Error , No such object " << nom << endl;
|
---|
[357] | 709 | return;
|
---|
| 710 | }
|
---|
| 711 | if (!mImgapp) return;
|
---|
| 712 |
|
---|
[333] | 713 | NTuple* nt = NULL;
|
---|
[357] | 714 | if (nomvec.length() < 1) nomvec = "/tmp/expvec";
|
---|
[333] | 715 |
|
---|
| 716 | char* ntn[2]= {"vecval", "vecwt"};
|
---|
| 717 | nt = new NTuple(1,ntn); // Creation NTuple
|
---|
| 718 |
|
---|
| 719 | string expwt = "1.";
|
---|
| 720 | string expz = "0.";
|
---|
[357] | 721 | ComputeExpressions(obja, expx, expz, expz, expwt, expcut, loop, nt, NULL, NULL);
|
---|
[333] | 722 |
|
---|
| 723 | if (!nt) return;
|
---|
| 724 | if (nt->NEntry() < 1) {
|
---|
[357] | 725 | cout << "Services2NObjMgr::ExpressionToVector() Warning Zero points satisfy cut !" << endl;
|
---|
[333] | 726 | delete nt;
|
---|
| 727 | return;
|
---|
| 728 | }
|
---|
| 729 |
|
---|
| 730 | Vector* vec = new Vector(nt->NEntry());
|
---|
| 731 | int k;
|
---|
| 732 | float* xn;
|
---|
| 733 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 734 | xn = nt->GetVec(k);
|
---|
| 735 | (*vec)(k) = xn[0];
|
---|
| 736 | }
|
---|
| 737 | delete nt;
|
---|
| 738 | mOmg->AddObj(vec, nomvec);
|
---|
| 739 | mOmg->DisplayObj(nomvec, dopt);
|
---|
| 740 | return;
|
---|
| 741 | }
|
---|
| 742 |
|
---|
| 743 | /* --Methode-- */
|
---|
[447] | 744 | void Services2NObjMgr::NtFromASCIIFile(string& nom,string& filename,double def_val)
|
---|
| 745 | // Pour remplir un ntuple "nom" existant a partir du fichier
|
---|
| 746 | // ASCII table "filename". Si il y a plus de variables dans le
|
---|
| 747 | // ntuple que dans le fichier "filename",
|
---|
| 748 | // les sur-numeraires sont mises a "def_val" par defaut.
|
---|
| 749 | {
|
---|
[455] | 750 | AnyDataObj* mobj = mOmg->GetObj(nom);
|
---|
[447] | 751 | if(mobj == NULL)
|
---|
| 752 | {cout<<"NtFromASCIIFile() Error, object "<<nom<<" not existing"<<endl;
|
---|
| 753 | return;}
|
---|
| 754 | if(typeid(*mobj) != typeid(NTuple))
|
---|
| 755 | {cout<<"NtFromASCIIFile() Error, object "<<nom<<" not an NTuple"<<endl;
|
---|
| 756 | return;}
|
---|
| 757 | if (!mImgapp) return;
|
---|
| 758 |
|
---|
| 759 | NTuple* nt = (NTuple*) mobj;
|
---|
[449] | 760 | nt->FillFromASCIIFile(filename, def_val);
|
---|
[447] | 761 | return;
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 | /* --Methode-- */
|
---|
[333] | 765 | void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz,
|
---|
[357] | 766 | string& expt, string& expcut, string& nomnt, string loop)
|
---|
[333] | 767 | {
|
---|
| 768 | NObjMgrAdapter* obja=NULL;
|
---|
| 769 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 770 | if (obja == NULL) {
|
---|
[449] | 771 | cout << "Services2NObjMgr::FillNT() Error , No such object " << nom << endl;
|
---|
[333] | 772 | return;
|
---|
| 773 | }
|
---|
| 774 | if (!mImgapp) return;
|
---|
| 775 |
|
---|
| 776 | bool fgnnt = false;
|
---|
| 777 | NTuple* nt = NULL;
|
---|
| 778 | AnyDataObj* oh = NULL;
|
---|
| 779 | if (nomnt.length() > 0) oh=mOmg->GetObj(nomnt);
|
---|
| 780 | else nomnt = "/tmp/fillnt";
|
---|
| 781 | if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
|
---|
| 782 | nt = (NTuple*)oh;
|
---|
| 783 | if (nt->NVar() > 10) {
|
---|
[449] | 784 | cout << "Services2NObjMgr::FillNT() Warning , Max 10 var in NTuple -> new NTuple" << endl;
|
---|
[333] | 785 | nt = NULL;
|
---|
| 786 | }
|
---|
| 787 | }
|
---|
| 788 | if (nt == NULL) {
|
---|
| 789 | char* ntn[4]= {"x", "y","z","t"};
|
---|
| 790 | nt = new NTuple(4,ntn); // Creation NTuple
|
---|
| 791 | fgnnt = true;
|
---|
| 792 | }
|
---|
| 793 |
|
---|
[357] | 794 | ComputeExpressions(obja, expx, expy, expz, expt, expcut, loop, nt, NULL, NULL);
|
---|
[333] | 795 |
|
---|
| 796 | if (fgnnt) mOmg->AddObj(nt, nomnt);
|
---|
| 797 | return;
|
---|
| 798 |
|
---|
| 799 | }
|
---|
| 800 |
|
---|
| 801 | /* --Methode-- */
|
---|
| 802 | void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname,
|
---|
[357] | 803 | string const & funcname, string & nomnt, string loop)
|
---|
[333] | 804 | {
|
---|
| 805 | if (!mImgapp) return;
|
---|
| 806 |
|
---|
| 807 | NObjMgrAdapter* obja=NULL;
|
---|
| 808 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 809 | if (obja == NULL) {
|
---|
| 810 | cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No such object" <<endl;
|
---|
| 811 | return;
|
---|
| 812 | }
|
---|
[344] | 813 | bool adel = true;
|
---|
| 814 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
[333] | 815 | if (objnt == NULL) {
|
---|
[449] | 816 | cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) Not an NTupleInterface !" <<endl;
|
---|
[333] | 817 | return;
|
---|
| 818 | }
|
---|
| 819 |
|
---|
| 820 | NTLoopExprFunc f = (NTLoopExprFunc)LinkFunctionFromFile(fname, funcname);
|
---|
| 821 | if (!f) {
|
---|
| 822 | cerr << "Services2NObjMgr::FillNTFrCFile Error Creation NTLoopExprFunc" << endl;
|
---|
[344] | 823 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 824 | return;
|
---|
| 825 | }
|
---|
| 826 |
|
---|
| 827 | bool fgnnt = false;
|
---|
| 828 | NTuple* nt = NULL;
|
---|
| 829 | if (nomnt.length() > 0) {
|
---|
| 830 | AnyDataObj* oh = NULL;
|
---|
| 831 | oh=mOmg->GetObj(nomnt);
|
---|
| 832 | if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
|
---|
| 833 | nt = (NTuple*)oh;
|
---|
| 834 | if (nt->NVar() > 10) {
|
---|
[449] | 835 | cout << "Services2NObjMgr::FillNTFrCFile() Warning , Max 10 var in NTuple -> new NTuple" << endl;
|
---|
[333] | 836 | nt = NULL;
|
---|
| 837 | }
|
---|
| 838 | }
|
---|
| 839 | if (nt == NULL) {
|
---|
| 840 | char* ntn[4]= {"x", "y","z","t"};
|
---|
| 841 | nt = new NTuple(4,ntn); // Creation NTuple
|
---|
| 842 | fgnnt = true;
|
---|
| 843 | }
|
---|
| 844 | }
|
---|
| 845 |
|
---|
| 846 | double xnt[10];
|
---|
| 847 | float fxnt[10];
|
---|
| 848 |
|
---|
| 849 | int i,k;
|
---|
| 850 | for(i=0; i<10; i++) fxnt[i] = xnt[i] = 0.;
|
---|
| 851 |
|
---|
| 852 |
|
---|
| 853 | // $CHECK$ A virer des que possible - Pb blocage application quand trop d'impression
|
---|
| 854 | // redirige - On redirige la sortie sur le terminal
|
---|
| 855 | bool red = mImgapp->HasRedirectedStdOutErr();
|
---|
| 856 | mImgapp->RedirectStdOutErr(false);
|
---|
| 857 |
|
---|
[357] | 858 | int k1,k2,dk;
|
---|
| 859 | k1 = 0; k2 = objnt->NbLines(); dk = 1;
|
---|
| 860 | DecodeLoopParameters(loop, k1, k2, dk);
|
---|
| 861 | if (k1 < 0) k1 = 0;
|
---|
| 862 | if (k2 < 0) k2 = objnt->NbLines();
|
---|
| 863 | if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
|
---|
| 864 | if (dk <= 0) dk = 1;
|
---|
| 865 |
|
---|
[333] | 866 | TRY {
|
---|
| 867 | double* xn;
|
---|
[357] | 868 | int kmax = k2;
|
---|
| 869 | for(k=k1; k<kmax; k+=dk) {
|
---|
[333] | 870 | xn = objnt->GetLineD(k);
|
---|
| 871 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
|
---|
| 872 | if (nt) {
|
---|
| 873 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
| 874 | nt->Fill(fxnt);
|
---|
| 875 | }
|
---|
| 876 | }
|
---|
| 877 | }
|
---|
| 878 | }
|
---|
| 879 | CATCH(merr) {
|
---|
| 880 | fflush(stdout);
|
---|
| 881 | cout << endl;
|
---|
| 882 | cerr << endl;
|
---|
| 883 | string es = PeidaExc(merr);
|
---|
| 884 | cerr << "Services2NObjMgr::FillNTFrCFile() Exception :" << merr << es;
|
---|
| 885 | } ENDTRY;
|
---|
[344] | 886 |
|
---|
| 887 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 888 | CloseDLL();
|
---|
| 889 |
|
---|
| 890 | // $CHECK$ A virer des que possible On redirige la sortie sur la fenetre PIConsole
|
---|
| 891 | mImgapp->RedirectStdOutErr(red);
|
---|
| 892 |
|
---|
| 893 | if (fgnnt) mOmg->AddObj(nt, nomnt);
|
---|
| 894 | return;
|
---|
| 895 | }
|
---|
| 896 |
|
---|
| 897 | /* --Methode-- */
|
---|
| 898 | void Services2NObjMgr::PrepareNTExpressionCFile(string & nom, string const & fname,
|
---|
| 899 | string const & funcname)
|
---|
| 900 | {
|
---|
| 901 | NObjMgrAdapter* obja=NULL;
|
---|
| 902 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 903 | if (obja == NULL) {
|
---|
| 904 | cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom << "...) No such object" <<endl;
|
---|
| 905 | return;
|
---|
| 906 | }
|
---|
[344] | 907 | bool adel = true;
|
---|
| 908 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
[333] | 909 | if (objnt == NULL) {
|
---|
| 910 | cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom
|
---|
| 911 | << "...) No NTupleInterface !" <<endl;
|
---|
| 912 | return;
|
---|
| 913 | }
|
---|
| 914 | string vardec = objnt->VarList_C("_xnti_");
|
---|
| 915 |
|
---|
| 916 | FILE *fip;
|
---|
| 917 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 918 | cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl;
|
---|
[344] | 919 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 920 | return;
|
---|
| 921 | }
|
---|
[344] | 922 |
|
---|
[333] | 923 | // constitution du fichier des decalarations des variables de l'interface NTuple
|
---|
| 924 | fputs("#include <stdlib.h> \n", fip);
|
---|
| 925 | fputs("#include <stdio.h> \n", fip);
|
---|
| 926 | fputs("#include <math.h> \n\n", fip);
|
---|
[344] | 927 |
|
---|
| 928 | fputs("/* ------ Some random number generators --------- */ \n", fip);
|
---|
| 929 | fputs("#define frand01() ( (float) drand48() ) \n", fip);
|
---|
| 930 | fputs("#define drand01() drand48() \n", fip);
|
---|
| 931 | fputs("#define rand01() drand48() \n", fip);
|
---|
| 932 | fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
|
---|
| 933 | fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
| 934 | fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
| 935 | fputs("double NorRand(void) \n", fip);
|
---|
| 936 | fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
|
---|
| 937 | fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
|
---|
[345] | 938 | fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
|
---|
[344] | 939 | fputs(" return(x); \n } \n", fip);
|
---|
| 940 | fputs("#define GauRand() NorRand() \n", fip);
|
---|
| 941 | fputs("#define gaurand() NorRand() \n\n", fip);
|
---|
| 942 |
|
---|
[333] | 943 | fputs("/* NTupleInterface Variable declaration - Generated by piapp \n", fip);
|
---|
| 944 | fputs(" -- Services2NObjMgr::PrepareNTExpressionCFile() -- */ \n\n", fip);
|
---|
| 945 | fprintf(fip,"int %s(double* _xnti_, double* _rx_, double* _ry_, double* _rz_, \n",
|
---|
| 946 | funcname.c_str());
|
---|
| 947 | fprintf(fip," double* _rt_, int _n_, int _nmax_) \n");
|
---|
| 948 | fprintf(fip, "{ \n %s \n", vardec.c_str());
|
---|
| 949 | fputs(" if (!1) { /* Cut Expression failed */ \n", fip);
|
---|
| 950 | fputs(" *_rx_ = *_ry_ = *_rz_ = *_rt_ = 0.; return(0);", fip);
|
---|
| 951 | fputs(" } \n /* Cut expression satisfied */ \n", fip);
|
---|
| 952 | fputs(" *_rx_ = 1.; \n *_ry_ = 1.; \n *_rz_ = 1.; \n *_rt_ = 1.; \n", fip);
|
---|
| 953 | fputs(" return(1); \n} \n", fip);
|
---|
| 954 |
|
---|
| 955 | fclose(fip);
|
---|
[344] | 956 |
|
---|
| 957 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 958 | return;
|
---|
| 959 | }
|
---|
| 960 |
|
---|
| 961 | /* --Methode-- cmv 13/10/98 */
|
---|
| 962 | void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
|
---|
[357] | 963 | string& experr, string& expcut, string& nomgfd, string loop)
|
---|
[333] | 964 | // Pour remplir un ``GeneralFitData'' a partir de divers objets:
|
---|
| 965 | //| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
|
---|
| 966 | //| Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
|
---|
| 967 | //| expx = expression X du GeneralFitData (1er abscisse)
|
---|
| 968 | //| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
|
---|
| 969 | //| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
|
---|
| 970 | //| experr = expression de l'erreur sur l'ordonnee Z
|
---|
| 971 | //| expcut = expression du test de selection
|
---|
| 972 | //| nomgfd = nom du GeneralFitData engendre (optionnel)
|
---|
| 973 | {
|
---|
| 974 | NObjMgrAdapter* obja=NULL;
|
---|
| 975 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 976 | if (obja == NULL) {
|
---|
[449] | 977 | cout << "Services2NObjMgr::FillGFD() Error , No such object "<<nom<<endl;
|
---|
[333] | 978 | return;
|
---|
| 979 | }
|
---|
| 980 | if(!mImgapp) return;
|
---|
| 981 |
|
---|
| 982 | // 2D ou 3D?
|
---|
| 983 | int nvar = 2;
|
---|
| 984 | if(expy.length()<=0) {nvar = 1; expy = "0.";}
|
---|
| 985 |
|
---|
| 986 | // Creation NTuple Buffer
|
---|
| 987 | char* ntn[4]= {"x","y","f","e"};
|
---|
| 988 | NTuple*nt = new NTuple(4,ntn);
|
---|
| 989 |
|
---|
| 990 | // Remplissage NTuple buffer
|
---|
[357] | 991 | ComputeExpressions(obja, expx, expy, expz, experr, expcut, loop, nt, NULL, NULL);
|
---|
[333] | 992 | if(nt->NEntry() < 1)
|
---|
| 993 | {cout<<"Services2NObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl;
|
---|
| 994 | delete nt; return;}
|
---|
| 995 |
|
---|
| 996 | //Remplissage de la structure GeneraFitData
|
---|
| 997 | if (nt->NEntry() <= 0) {
|
---|
| 998 | cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
|
---|
| 999 | delete nt;
|
---|
| 1000 | return;
|
---|
| 1001 | }
|
---|
| 1002 |
|
---|
| 1003 | GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
|
---|
| 1004 | int k;
|
---|
| 1005 | float* xn;
|
---|
| 1006 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 1007 | xn = nt->GetVec(k);
|
---|
| 1008 | gfd->AddData(xn,xn[2],xn[3]);
|
---|
| 1009 | }
|
---|
| 1010 |
|
---|
| 1011 | // Menage et table d'objets
|
---|
| 1012 | delete nt;
|
---|
| 1013 | mOmg->AddObj(gfd, nomgfd);
|
---|
| 1014 | return;
|
---|
| 1015 | }
|
---|
| 1016 |
|
---|
| 1017 |
|
---|
| 1018 | /* --Methode-- */
|
---|
| 1019 | void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx,
|
---|
[357] | 1020 | string& expy, string& expz, string& expt, string& expcut, string& loop,
|
---|
[333] | 1021 | NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
|
---|
| 1022 | {
|
---|
| 1023 | if (obja == NULL) return;
|
---|
[344] | 1024 | bool adel = true;
|
---|
| 1025 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
[333] | 1026 | if (objnt == NULL) return;
|
---|
| 1027 | string vardec = objnt->VarList_C("_zz6qi_");
|
---|
| 1028 |
|
---|
| 1029 | PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
|
---|
| 1030 | if (!f) {
|
---|
| 1031 | cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " << endl;
|
---|
[344] | 1032 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 1033 | return;
|
---|
| 1034 | }
|
---|
| 1035 |
|
---|
| 1036 | double xnt[10];
|
---|
| 1037 | float fxnt[10];
|
---|
| 1038 |
|
---|
| 1039 | int i,k;
|
---|
| 1040 | for(i=0; i<10; i++) xnt[i] = 0.;
|
---|
[357] | 1041 | int k1,k2,dk;
|
---|
| 1042 | k1 = 0; k2 = objnt->NbLines(); dk = 1;
|
---|
| 1043 | DecodeLoopParameters(loop, k1, k2, dk);
|
---|
| 1044 | if (k1 < 0) k1 = 0;
|
---|
| 1045 | if (k2 < 0) k2 = objnt->NbLines();
|
---|
| 1046 | if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
|
---|
| 1047 | if (dk <= 0) dk = 1;
|
---|
[333] | 1048 | TRY {
|
---|
| 1049 | double* xn;
|
---|
[357] | 1050 | for(k=k1; k<k2; k += dk) {
|
---|
[333] | 1051 | xn = objnt->GetLineD(k);
|
---|
| 1052 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
| 1053 | if (nt) {
|
---|
| 1054 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
| 1055 | nt->Fill(fxnt);
|
---|
| 1056 | }
|
---|
| 1057 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
| 1058 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
| 1059 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
| 1060 | }
|
---|
| 1061 | }
|
---|
| 1062 | }
|
---|
| 1063 | CATCH(merr) {
|
---|
| 1064 | fflush(stdout);
|
---|
| 1065 | cout << endl;
|
---|
| 1066 | cerr << endl;
|
---|
| 1067 | string es = PeidaExc(merr);
|
---|
| 1068 | cerr << "Services2NObjMgr::ComputeExpressions() Exception :" << merr << es;
|
---|
| 1069 | } ENDTRY;
|
---|
| 1070 |
|
---|
| 1071 |
|
---|
[344] | 1072 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 1073 | // Fermeture du fichier .so
|
---|
| 1074 | CloseDLL();
|
---|
| 1075 | return;
|
---|
| 1076 | }
|
---|
| 1077 |
|
---|
| 1078 |
|
---|
| 1079 | /* --Methode-- */
|
---|
| 1080 | PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy,
|
---|
| 1081 | string& expz, string& expt, string& cut)
|
---|
| 1082 | {
|
---|
| 1083 | FILE *fip;
|
---|
| 1084 | string fname = TmpDir + "expf_pia_dl.c";
|
---|
| 1085 | string cmd;
|
---|
| 1086 | int rc;
|
---|
| 1087 |
|
---|
| 1088 | cmd = "rm -f " + fname;
|
---|
| 1089 | rc = system(cmd.c_str());
|
---|
| 1090 | //DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 1091 |
|
---|
| 1092 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 1093 | string sn = fname;
|
---|
[449] | 1094 | cout << "Services2NObjMgr/LinkExprFunc_Error: fopen( " << sn << endl;
|
---|
[333] | 1095 | return(NULL);
|
---|
| 1096 | }
|
---|
| 1097 |
|
---|
| 1098 | // constitution du fichier a compiler
|
---|
| 1099 | fputs("#include <stdlib.h> \n", fip);
|
---|
| 1100 | fputs("#include <math.h> \n", fip);
|
---|
[344] | 1101 |
|
---|
| 1102 | fputs("/* ------ Some random number generators --------- */ \n", fip);
|
---|
| 1103 | fputs("#define frand01() ( (float) drand48() ) \n", fip);
|
---|
| 1104 | fputs("#define drand01() drand48() \n", fip);
|
---|
| 1105 | fputs("#define rand01() drand48() \n", fip);
|
---|
| 1106 | fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
|
---|
| 1107 | fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
| 1108 | fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
| 1109 | fputs("double NorRand(void) \n", fip);
|
---|
| 1110 | fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
|
---|
| 1111 | fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
|
---|
[345] | 1112 | fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
|
---|
[344] | 1113 | fputs(" return(x); \n } \n", fip);
|
---|
| 1114 | fputs("#define GauRand() NorRand() \n", fip);
|
---|
| 1115 | fputs("#define gaurand() NorRand() \n\n", fip);
|
---|
| 1116 |
|
---|
[333] | 1117 | fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
|
---|
| 1118 | fprintf(fip,"%s \n", vardec.c_str());
|
---|
| 1119 | fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.; return(0); } \n", cut.c_str());
|
---|
| 1120 | fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
|
---|
| 1121 | fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
|
---|
| 1122 | fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
|
---|
| 1123 | fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
|
---|
| 1124 | fputs("return(1); \n} \n", fip);
|
---|
| 1125 | fclose(fip);
|
---|
| 1126 | string func = "expf_pia_dl_func";
|
---|
| 1127 | return((PlotExprFunc)LinkFunctionFromFile(fname, func));
|
---|
| 1128 | }
|
---|
| 1129 |
|
---|
| 1130 |
|
---|
| 1131 | /* --Methode-- */
|
---|
| 1132 | DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
|
---|
| 1133 | {
|
---|
| 1134 | // Le link dynamique
|
---|
| 1135 | CloseDLL();
|
---|
| 1136 | dynlink = PDynLinkMgr::BuildFromCFile(fname);
|
---|
| 1137 | if (dynlink == NULL) {
|
---|
| 1138 | cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
|
---|
| 1139 | return(NULL);
|
---|
| 1140 | }
|
---|
| 1141 |
|
---|
| 1142 | DlFunction retfunc = dynlink->GetFunction(funcname);
|
---|
| 1143 | if (retfunc == NULL) {
|
---|
| 1144 | string sn = funcname;
|
---|
| 1145 | cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
|
---|
| 1146 | CloseDLL();
|
---|
| 1147 | return(NULL);
|
---|
| 1148 | }
|
---|
| 1149 | else return(retfunc);
|
---|
| 1150 | }
|
---|
| 1151 |
|
---|
| 1152 | /* --Methode-- */
|
---|
| 1153 | void Services2NObjMgr::CloseDLL()
|
---|
| 1154 | {
|
---|
| 1155 | if (dynlink) delete dynlink; dynlink = NULL;
|
---|
| 1156 | }
|
---|
| 1157 |
|
---|
[357] | 1158 | // Fonction static
|
---|
| 1159 | /* --Methode-- */
|
---|
| 1160 | void Services2NObjMgr::DecodeLoopParameters(string& loop, int& i1, int& i2, int& di)
|
---|
| 1161 | {
|
---|
| 1162 | // Decode des paramatres de boucle for(int i=i1; i<i2; i+=di) specifies
|
---|
| 1163 | // sous forme i1[:i2[:di]]
|
---|
| 1164 | // cout << "LoopParam() " << loop << " I1=" << i1 << " I2=" << i2 << " DI=" << di;
|
---|
| 1165 | size_t l = loop.length();
|
---|
| 1166 | if (l < 1) return;
|
---|
| 1167 | size_t p = loop.find(':');
|
---|
| 1168 | if (p >= l) { i1 = atoi(loop.c_str()); return; }
|
---|
| 1169 | i1 = atoi(loop.substr(0, p).c_str());
|
---|
| 1170 | string aa = loop.substr(p+1);
|
---|
| 1171 | p = aa.find(':');
|
---|
| 1172 | if (p < aa.length() ) {
|
---|
| 1173 | i2 = atoi(aa.substr(0,p).c_str());
|
---|
| 1174 | di = atoi(aa.substr(p+1).c_str());
|
---|
| 1175 | }
|
---|
| 1176 | else i2 = atoi(aa.c_str());
|
---|
| 1177 | // cout << "-> I1= " << i1 << " I2= " << i2 << " DI= " << di << endl;
|
---|
| 1178 | return;
|
---|
| 1179 | }
|
---|
[333] | 1180 |
|
---|
| 1181 | /* --Methode-- */
|
---|
[165] | 1182 | string Services2NObjMgr::FileName2Name(string const & fn)
|
---|
| 1183 | {
|
---|
| 1184 |
|
---|
| 1185 | char fsep[2] = {FILESEP, '\0'};
|
---|
| 1186 | char tsep[2] = {'.', '\0'};
|
---|
| 1187 | size_t p = fn.find_last_of(fsep);
|
---|
[194] | 1188 | size_t l = fn.length();
|
---|
| 1189 | if (p >= l) p = 0;
|
---|
| 1190 | else p++;
|
---|
| 1191 | size_t q = fn.find_first_of(tsep,p);
|
---|
| 1192 | if (q < p) q = l;
|
---|
[165] | 1193 | return(fn.substr(p,q-p));
|
---|
| 1194 | }
|
---|
| 1195 |
|
---|
| 1196 |
|
---|
| 1197 | typedef vector<string> GraTok;
|
---|
| 1198 |
|
---|
| 1199 | /* --Methode-- */
|
---|
| 1200 | int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
|
---|
| 1201 | {
|
---|
| 1202 | int ropt = Disp_Next;
|
---|
| 1203 | if (!mImgapp) return(ropt);
|
---|
| 1204 |
|
---|
| 1205 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
|
---|
| 1206 |
|
---|
| 1207 | if (fgsrgr) mImgapp->SaveGraphicAtt();
|
---|
| 1208 |
|
---|
[326] | 1209 | if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini
|
---|
[165] | 1210 | mImgapp->SetColAtt();
|
---|
| 1211 | mImgapp->SetLineAtt();
|
---|
| 1212 | mImgapp->SetFontAtt();
|
---|
| 1213 | mImgapp->SetMarkerAtt();
|
---|
| 1214 | mImgapp->SetColMapId();
|
---|
| 1215 | mImgapp->SetZoomAtt();
|
---|
[331] | 1216 | mImgapp->SetAxesAtt();
|
---|
| 1217 | mImgapp->SetXYLimits();
|
---|
| 1218 | mImgapp->UseXYLimits();
|
---|
[165] | 1219 | return(ropt);
|
---|
| 1220 | }
|
---|
| 1221 |
|
---|
| 1222 | // On separe en mots separes par des virgules
|
---|
| 1223 | gratt = ","+gratt;
|
---|
| 1224 | size_t p = 0;
|
---|
| 1225 | size_t q = 0;
|
---|
| 1226 | size_t l = gratt.length();
|
---|
| 1227 | string token;
|
---|
| 1228 |
|
---|
| 1229 | GraTok grt;
|
---|
| 1230 |
|
---|
| 1231 | while (q < l) {
|
---|
| 1232 | p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
|
---|
| 1233 | if (p>=l) break;
|
---|
| 1234 | q = gratt.find_first_of(" ,",p); // la fin du token;
|
---|
| 1235 | token = gratt.substr(p,q-p);
|
---|
| 1236 | grt.push_back(token);
|
---|
| 1237 | }
|
---|
| 1238 |
|
---|
| 1239 |
|
---|
| 1240 | static GrAttNames::iterator it;
|
---|
| 1241 |
|
---|
| 1242 | int k;
|
---|
| 1243 | bool fgcont = true;
|
---|
| 1244 | fgsrgr = false;
|
---|
| 1245 |
|
---|
| 1246 | for(k=0; k<grt.size(); k++) {
|
---|
| 1247 | // cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
|
---|
| 1248 |
|
---|
| 1249 | // Decodage option affichage (win, next, etc
|
---|
| 1250 | fgcont = true;
|
---|
| 1251 | if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
|
---|
| 1252 | else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
|
---|
| 1253 | else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
|
---|
| 1254 | else fgcont = false;
|
---|
| 1255 | if (fgcont) continue;
|
---|
[331] | 1256 |
|
---|
| 1257 | // Utilisation limites X-Y
|
---|
| 1258 | if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true); fgsrgr = true; continue; }
|
---|
[165] | 1259 | // Si c'est une couleur
|
---|
| 1260 | it = GrAcolors.find(grt[k]);
|
---|
| 1261 | if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 1262 | // Si c'est un attribut de lignes
|
---|
| 1263 | it = GrAlines.find(grt[k]);
|
---|
| 1264 | if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 1265 | // Si c'est un attribut de fontes
|
---|
| 1266 | it = GrAfonts.find(grt[k]);
|
---|
| 1267 | if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
|
---|
| 1268 | fgsrgr = true; continue; }
|
---|
| 1269 | // Si c'est un attribut de markers
|
---|
| 1270 | it = GrAmarkers.find(grt[k]);
|
---|
| 1271 | if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
|
---|
| 1272 | fgsrgr = true; continue; }
|
---|
| 1273 | // Si c'est un colormap
|
---|
| 1274 | it = GrAcmap.find(grt[k]);
|
---|
| 1275 | if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
|
---|
| 1276 | // Si c'est un facteur de zoom
|
---|
| 1277 | it = GrAzoom.find(grt[k]);
|
---|
| 1278 | if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
[203] | 1279 | // Si c'est un attribut d'axe
|
---|
| 1280 | it = GrAaxes.find(grt[k]);
|
---|
| 1281 | if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
[165] | 1282 |
|
---|
| 1283 | }
|
---|
| 1284 |
|
---|
| 1285 | return(ropt);
|
---|
| 1286 | }
|
---|
| 1287 |
|
---|
| 1288 |
|
---|
| 1289 |
|
---|
| 1290 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
| 1291 | // Initialisation des chaines de caracteres designant les attributs graphiques
|
---|
| 1292 |
|
---|
| 1293 | /* --Methode-- */
|
---|
| 1294 | void Services2NObjMgr::InitGrAttNames()
|
---|
| 1295 | {
|
---|
| 1296 | gratt_item gi;
|
---|
| 1297 | // Les couleurs
|
---|
| 1298 | gi.a2 = 0;
|
---|
| 1299 | gi.a1 = PI_NotDefColor;
|
---|
| 1300 | GrAcolors["defcol"] = gi;
|
---|
| 1301 | gi.a1 = PI_Black;
|
---|
| 1302 | GrAcolors["black"] = gi;
|
---|
| 1303 | gi.a1 = PI_White;
|
---|
| 1304 | GrAcolors["white"] = gi;
|
---|
| 1305 | gi.a1 = PI_Grey;
|
---|
| 1306 | GrAcolors["grey"] = gi;
|
---|
| 1307 | gi.a1 = PI_Red;
|
---|
| 1308 | GrAcolors["red"] = gi;
|
---|
| 1309 | gi.a1 = PI_Blue;
|
---|
| 1310 | GrAcolors["blue"] = gi;
|
---|
| 1311 | gi.a1 = PI_Green;
|
---|
| 1312 | GrAcolors["green"] = gi;
|
---|
| 1313 | gi.a1 = PI_Yellow;
|
---|
| 1314 | GrAcolors["yellow"] = gi;
|
---|
| 1315 | gi.a1 = PI_Magenta;
|
---|
| 1316 | GrAcolors["magenta"] = gi;
|
---|
| 1317 |
|
---|
| 1318 | gi.a1 = PI_Cyan;
|
---|
| 1319 | GrAcolors["cyan"] = gi;
|
---|
| 1320 | gi.a1 = PI_Turquoise;
|
---|
| 1321 | GrAcolors["turquoise"] = gi;
|
---|
| 1322 | gi.a1 = PI_NavyBlue;
|
---|
| 1323 | GrAcolors["navyblue"] = gi;
|
---|
| 1324 | gi.a1 = PI_Orange;
|
---|
| 1325 | GrAcolors["orange"] = gi;
|
---|
| 1326 | gi.a1 = PI_SiennaRed;
|
---|
| 1327 | GrAcolors["siennared"] = gi;
|
---|
| 1328 | gi.a1 = PI_Purple;
|
---|
| 1329 | GrAcolors["purple"] = gi;
|
---|
| 1330 | gi.a1 = PI_LimeGreen;
|
---|
| 1331 | GrAcolors["limegreen"] = gi;
|
---|
| 1332 | gi.a1 = PI_Gold;
|
---|
| 1333 | GrAcolors["gold"] = gi;
|
---|
| 1334 |
|
---|
| 1335 | // Les attributs de lignes
|
---|
| 1336 | gi.a2 = 0;
|
---|
| 1337 | gi.a1 = PI_NotDefLineAtt;
|
---|
| 1338 | GrAlines["defline"] = gi;
|
---|
| 1339 | gi.a1 = PI_NormalLine;
|
---|
| 1340 | GrAlines["normalline"] = gi;
|
---|
| 1341 | gi.a1 = PI_ThinLine;
|
---|
| 1342 | GrAlines["thinline"] = gi;
|
---|
| 1343 | gi.a1 = PI_ThickLine;
|
---|
| 1344 | GrAlines["thickline"] = gi;
|
---|
| 1345 | gi.a1 = PI_DashedLine;
|
---|
| 1346 | GrAlines["dashedline"] = gi;
|
---|
| 1347 | gi.a1 = PI_ThinDashedLine;
|
---|
| 1348 | GrAlines["thindashedline"] = gi;
|
---|
| 1349 | gi.a1 = PI_ThickDashedLine;
|
---|
| 1350 | GrAlines["thickdashedline"] = gi;
|
---|
[192] | 1351 | gi.a1 = PI_DottedLine;
|
---|
| 1352 | GrAlines["dottedline"] = gi;
|
---|
| 1353 | gi.a1 = PI_ThinDottedLine;
|
---|
| 1354 | GrAlines["thindottedline"] = gi;
|
---|
| 1355 | gi.a1 = PI_ThickDottedLine;
|
---|
| 1356 | GrAlines["thickdottedline"] = gi;
|
---|
[165] | 1357 |
|
---|
[293] | 1358 | // Les fontes
|
---|
[165] | 1359 | gi.a2 = PI_NotDefFontSize;
|
---|
| 1360 | gi.a1 = PI_NotDefFontAtt;
|
---|
[349] | 1361 | GrAfonts["deffont"] = gi;
|
---|
[165] | 1362 |
|
---|
| 1363 | gi.a2 = PI_NormalSizeFont;
|
---|
| 1364 | gi.a1 = PI_RomanFont;
|
---|
[349] | 1365 | GrAfonts["normalfont"] = gi;
|
---|
[165] | 1366 | gi.a1 = PI_BoldFont;
|
---|
[349] | 1367 | GrAfonts["boldfont"] = gi;
|
---|
[165] | 1368 | gi.a1 = PI_ItalicFont;
|
---|
[349] | 1369 | GrAfonts["italicfont"] = gi;
|
---|
[165] | 1370 | gi.a2 = PI_SmallSizeFont;
|
---|
| 1371 | gi.a1 = PI_RomanFont;
|
---|
[349] | 1372 | GrAfonts["smallfont"] = gi;
|
---|
[165] | 1373 | gi.a1 = PI_BoldFont;
|
---|
[349] | 1374 | GrAfonts["smallboldfont"] = gi;
|
---|
[165] | 1375 | gi.a1 = PI_ItalicFont;
|
---|
[349] | 1376 | GrAfonts["smallitalicfont"] = gi;
|
---|
[165] | 1377 | gi.a2 = PI_BigSizeFont;
|
---|
| 1378 | gi.a1 = PI_RomanFont;
|
---|
[349] | 1379 | GrAfonts["bigfont"] = gi;
|
---|
[165] | 1380 | gi.a1 = PI_BoldFont;
|
---|
[349] | 1381 | GrAfonts["bigboldfont"] = gi;
|
---|
[165] | 1382 | gi.a1 = PI_ItalicFont;
|
---|
[349] | 1383 | GrAfonts["bigitalicfont"] = gi;
|
---|
[192] | 1384 | gi.a2 = PI_HugeSizeFont;
|
---|
| 1385 | gi.a1 = PI_RomanFont;
|
---|
[349] | 1386 | GrAfonts["hugefont"] = gi;
|
---|
[192] | 1387 | gi.a1 = PI_BoldFont;
|
---|
[349] | 1388 | GrAfonts["hugeboldfont"] = gi;
|
---|
[192] | 1389 | gi.a1 = PI_ItalicFont;
|
---|
[349] | 1390 | GrAfonts["hugeitalicfont"] = gi;
|
---|
[165] | 1391 |
|
---|
| 1392 |
|
---|
| 1393 | // Les markers
|
---|
[176] | 1394 | const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
|
---|
| 1395 | "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
|
---|
| 1396 | "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
|
---|
[165] | 1397 | PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
|
---|
| 1398 | PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
|
---|
| 1399 | PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
|
---|
| 1400 |
|
---|
| 1401 | gi.a2 = 0;
|
---|
| 1402 | gi.a1 = PI_NotDefMarker;
|
---|
| 1403 | GrAmarkers["defmarker"] = gi;
|
---|
| 1404 |
|
---|
| 1405 | for(int j=0; j<11; j++) {
|
---|
| 1406 | string smrk;
|
---|
| 1407 | char buff[16];
|
---|
| 1408 | for(int m=1; m<10; m+=2) {
|
---|
| 1409 | sprintf(buff,"%d",m);
|
---|
| 1410 | smrk = (string)mrkn[j] + (string)buff;
|
---|
| 1411 | gi.a1 = mrk[j]; gi.a2 = m;
|
---|
| 1412 | GrAmarkers[smrk] = gi;
|
---|
| 1413 | }
|
---|
| 1414 | }
|
---|
| 1415 |
|
---|
| 1416 | // Les tables de couleurs
|
---|
| 1417 | gi.a2 = 0;
|
---|
| 1418 | gi.a1 = CMAP_OTHER;
|
---|
| 1419 | GrAcmap["defcmap"] = gi;
|
---|
| 1420 | gi.a1 = CMAP_GREY32;
|
---|
| 1421 | GrAcmap["grey32"] = gi;
|
---|
| 1422 | gi.a1 = CMAP_GREYINV32;
|
---|
| 1423 | GrAcmap["greyinv32"] = gi;
|
---|
| 1424 | gi.a1 = CMAP_COLRJ32;
|
---|
| 1425 | GrAcmap["colrj32"] = gi;
|
---|
| 1426 | gi.a1 = CMAP_COLBR32;
|
---|
| 1427 | GrAcmap["colbr32"] = gi;
|
---|
| 1428 | gi.a1 = CMAP_GREY128;
|
---|
| 1429 | GrAcmap["grey128"] = gi;
|
---|
| 1430 | gi.a1 = CMAP_GREYINV128;
|
---|
| 1431 | GrAcmap["greyinv128"] = gi;
|
---|
| 1432 | gi.a1 = CMAP_COLRJ128;
|
---|
| 1433 | GrAcmap["colrj128"] = gi;
|
---|
| 1434 | gi.a1 = CMAP_COLBR128;
|
---|
| 1435 | GrAcmap["colbr128"] = gi;
|
---|
| 1436 |
|
---|
[203] | 1437 | // La valeur de zoom
|
---|
[165] | 1438 | gi.a2 = 0;
|
---|
| 1439 | gi.a1 = 0;
|
---|
| 1440 | GrAzoom["defzoom"] = gi;
|
---|
| 1441 | gi.a1 = 1;
|
---|
| 1442 | GrAzoom["zoomx1"] = gi;
|
---|
| 1443 | gi.a1 = 2;
|
---|
| 1444 | GrAzoom["zoomx2"] = gi;
|
---|
| 1445 | gi.a1 = 3;
|
---|
| 1446 | GrAzoom["zoomx3"] = gi;
|
---|
| 1447 | gi.a1 = 4;
|
---|
| 1448 | GrAzoom["zoomx4"] = gi;
|
---|
| 1449 | gi.a1 = 5;
|
---|
| 1450 | GrAzoom["zoomx5"] = gi;
|
---|
| 1451 | gi.a1 = -2;
|
---|
| 1452 | GrAzoom["zoom/2"] = gi;
|
---|
| 1453 | gi.a1 = -3;
|
---|
| 1454 | GrAzoom["zoom/3"] = gi;
|
---|
| 1455 | gi.a1 = -4;
|
---|
| 1456 | GrAzoom["zoom/4"] = gi;
|
---|
| 1457 | gi.a1 = -5;
|
---|
| 1458 | GrAzoom["zoom/5"] = gi;
|
---|
[203] | 1459 |
|
---|
| 1460 | // Attributs d'axes
|
---|
| 1461 | gi.a2 = 0;
|
---|
| 1462 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
|
---|
| 1463 | GrAaxes["stdaxes"] = gi;
|
---|
| 1464 | GrAaxes["defaxes"] = gi;
|
---|
| 1465 | GrAaxes["boxaxes"] = gi;
|
---|
| 1466 | gi.a1 = (int)kAxesDflt;
|
---|
| 1467 | GrAaxes["simpleaxes"] = gi;
|
---|
| 1468 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
|
---|
| 1469 | GrAaxes["boxaxesgrid"] = gi;
|
---|
| 1470 |
|
---|
| 1471 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
|
---|
| 1472 | GrAaxes["fineaxes"] = gi;
|
---|
| 1473 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
|
---|
| 1474 | GrAaxes["grid"] = gi;
|
---|
| 1475 | GrAaxes["fineaxesgrid"] = gi;
|
---|
| 1476 |
|
---|
[165] | 1477 | }
|
---|
[333] | 1478 |
|
---|
| 1479 |
|
---|
| 1480 | // SANS_EVOLPLANCK Attention !
|
---|
| 1481 | #include "pclassids.h"
|
---|
| 1482 |
|
---|
| 1483 | /* --Methode-- */
|
---|
| 1484 | char* Services2NObjMgr::PClassIdToClassName(int cid)
|
---|
| 1485 | {
|
---|
| 1486 | switch (cid) {
|
---|
| 1487 | case ClassId_Poly1 :
|
---|
| 1488 | return("Poly1");
|
---|
| 1489 | case ClassId_Poly2 :
|
---|
| 1490 | return("Poly2");
|
---|
| 1491 | case ClassId_Matrix :
|
---|
| 1492 | return("Matrix");
|
---|
| 1493 | case ClassId_Vector :
|
---|
| 1494 | return("Vector");
|
---|
| 1495 |
|
---|
| 1496 | case ClassId_DVList :
|
---|
| 1497 | return("DVList");
|
---|
| 1498 |
|
---|
| 1499 | case ClassId_Histo1D :
|
---|
| 1500 | return("Histo1D");
|
---|
| 1501 | case ClassId_Histo2D :
|
---|
| 1502 | return("Histo2D");
|
---|
| 1503 | case ClassId_HProf :
|
---|
| 1504 | return("HProf");
|
---|
| 1505 | case ClassId_NTuple :
|
---|
| 1506 | return("NTuple");
|
---|
[361] | 1507 | case ClassId_XNTuple :
|
---|
| 1508 | return("XNTuple");
|
---|
[333] | 1509 | case ClassId_GeneralFitData :
|
---|
| 1510 | return("GeneralFitData");
|
---|
| 1511 |
|
---|
| 1512 | case ClassId_Image :
|
---|
| 1513 | return("RzImage");
|
---|
| 1514 | case ClassId_Image + kuint_1 :
|
---|
| 1515 | return("ImageU1");
|
---|
| 1516 | case ClassId_Image + kint_1 :
|
---|
| 1517 | return("ImageI1");
|
---|
| 1518 | case ClassId_Image + kuint_2 :
|
---|
| 1519 | return("ImageU2");
|
---|
| 1520 | case ClassId_Image + kint_2 :
|
---|
| 1521 | return("ImageI2");
|
---|
| 1522 | case ClassId_Image + kuint_4 :
|
---|
| 1523 | return("ImageU4");
|
---|
| 1524 | case ClassId_Image + kint_4 :
|
---|
| 1525 | return("ImageI4");
|
---|
| 1526 | case ClassId_Image + kr_4 :
|
---|
| 1527 | return("ImageR4");
|
---|
| 1528 | case ClassId_Image + kr_8 :
|
---|
| 1529 | return("ImageR8");
|
---|
| 1530 |
|
---|
| 1531 | case ClassId_ZFidu :
|
---|
| 1532 | return("ZFidu");
|
---|
| 1533 |
|
---|
| 1534 | case ClassId_StarList :
|
---|
| 1535 | return("StarList");
|
---|
| 1536 | case ClassId_Transfo :
|
---|
| 1537 | return("Transfo");
|
---|
| 1538 | case ClassId_PSF :
|
---|
| 1539 | return("PSF");
|
---|
| 1540 |
|
---|
| 1541 |
|
---|
| 1542 | // - Ajout objet PPF
|
---|
| 1543 | default:
|
---|
| 1544 | return("AnyDataObj");
|
---|
| 1545 | }
|
---|
| 1546 | }
|
---|
| 1547 |
|
---|