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