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