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