[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;
|
---|
[333] | 96 | cout << "Services2NObjMgr/PlotFunc_Erreur: Pb. Ouverture " << 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;
|
---|
[333] | 131 | cout << "Services2NObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << 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) {
|
---|
| 289 | cout << "Services2NObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 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) {
|
---|
| 332 | cout << "Services2NObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 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) {
|
---|
| 374 | cout << "Services2NObjMgr::DisplayPoints2DW() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 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) {
|
---|
| 410 | cout << "Services2NObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 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) {
|
---|
| 459 | cout << "Services2NObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 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) {
|
---|
| 520 | cout << "Services2NObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 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) {
|
---|
| 672 | cout << "Services2NObjMgr::ExpressionToVector() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 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;
|
---|
| 725 | cout<<"CMV -> Reza tu dois mofidier FillFromASCIIFile"<<endl;
|
---|
| 726 | cout<<"CMV -> Reza pour permettre une valeur par defaut"<<endl;
|
---|
| 727 | cout<<"CMV -> Reza n oublie AUSSI pas l arg par def dans servnobj.h"<<endl;
|
---|
| 728 | cout<<"CMV -> Reza > nt->FillFromASCIIFile(filename,def_val);"<<endl;
|
---|
| 729 | nt->FillFromASCIIFile(filename);
|
---|
| 730 | return;
|
---|
| 731 | }
|
---|
| 732 |
|
---|
| 733 | /* --Methode-- */
|
---|
[333] | 734 | void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz,
|
---|
[357] | 735 | string& expt, string& expcut, string& nomnt, string loop)
|
---|
[333] | 736 | {
|
---|
| 737 | NObjMgrAdapter* obja=NULL;
|
---|
| 738 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 739 | if (obja == NULL) {
|
---|
| 740 | cout << "Services2NObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl;
|
---|
| 741 | return;
|
---|
| 742 | }
|
---|
| 743 | if (!mImgapp) return;
|
---|
| 744 |
|
---|
| 745 | bool fgnnt = false;
|
---|
| 746 | NTuple* nt = NULL;
|
---|
| 747 | AnyDataObj* oh = NULL;
|
---|
| 748 | if (nomnt.length() > 0) oh=mOmg->GetObj(nomnt);
|
---|
| 749 | else nomnt = "/tmp/fillnt";
|
---|
| 750 | if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
|
---|
| 751 | nt = (NTuple*)oh;
|
---|
| 752 | if (nt->NVar() > 10) {
|
---|
| 753 | cout << "Services2NObjMgr::FillNT() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
|
---|
| 754 | nt = NULL;
|
---|
| 755 | }
|
---|
| 756 | }
|
---|
| 757 | if (nt == NULL) {
|
---|
| 758 | char* ntn[4]= {"x", "y","z","t"};
|
---|
| 759 | nt = new NTuple(4,ntn); // Creation NTuple
|
---|
| 760 | fgnnt = true;
|
---|
| 761 | }
|
---|
| 762 |
|
---|
[357] | 763 | ComputeExpressions(obja, expx, expy, expz, expt, expcut, loop, nt, NULL, NULL);
|
---|
[333] | 764 |
|
---|
| 765 | if (fgnnt) mOmg->AddObj(nt, nomnt);
|
---|
| 766 | return;
|
---|
| 767 |
|
---|
| 768 | }
|
---|
| 769 |
|
---|
| 770 | /* --Methode-- */
|
---|
| 771 | void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname,
|
---|
[357] | 772 | string const & funcname, string & nomnt, string loop)
|
---|
[333] | 773 | {
|
---|
| 774 | if (!mImgapp) return;
|
---|
| 775 |
|
---|
| 776 | NObjMgrAdapter* obja=NULL;
|
---|
| 777 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 778 | if (obja == NULL) {
|
---|
| 779 | cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No such object" <<endl;
|
---|
| 780 | return;
|
---|
| 781 | }
|
---|
[344] | 782 | bool adel = true;
|
---|
| 783 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
[333] | 784 | if (objnt == NULL) {
|
---|
| 785 | cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No NTupleInterface !" <<endl;
|
---|
| 786 | return;
|
---|
| 787 | }
|
---|
| 788 |
|
---|
| 789 | NTLoopExprFunc f = (NTLoopExprFunc)LinkFunctionFromFile(fname, funcname);
|
---|
| 790 | if (!f) {
|
---|
| 791 | cerr << "Services2NObjMgr::FillNTFrCFile Error Creation NTLoopExprFunc" << endl;
|
---|
[344] | 792 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 793 | return;
|
---|
| 794 | }
|
---|
| 795 |
|
---|
| 796 | bool fgnnt = false;
|
---|
| 797 | NTuple* nt = NULL;
|
---|
| 798 | if (nomnt.length() > 0) {
|
---|
| 799 | AnyDataObj* oh = NULL;
|
---|
| 800 | oh=mOmg->GetObj(nomnt);
|
---|
| 801 | if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
|
---|
| 802 | nt = (NTuple*)oh;
|
---|
| 803 | if (nt->NVar() > 10) {
|
---|
| 804 | cout << "Services2NObjMgr::FillNTFrCFile() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
|
---|
| 805 | nt = NULL;
|
---|
| 806 | }
|
---|
| 807 | }
|
---|
| 808 | if (nt == NULL) {
|
---|
| 809 | char* ntn[4]= {"x", "y","z","t"};
|
---|
| 810 | nt = new NTuple(4,ntn); // Creation NTuple
|
---|
| 811 | fgnnt = true;
|
---|
| 812 | }
|
---|
| 813 | }
|
---|
| 814 |
|
---|
| 815 | double xnt[10];
|
---|
| 816 | float fxnt[10];
|
---|
| 817 |
|
---|
| 818 | int i,k;
|
---|
| 819 | for(i=0; i<10; i++) fxnt[i] = xnt[i] = 0.;
|
---|
| 820 |
|
---|
| 821 |
|
---|
| 822 | // $CHECK$ A virer des que possible - Pb blocage application quand trop d'impression
|
---|
| 823 | // redirige - On redirige la sortie sur le terminal
|
---|
| 824 | bool red = mImgapp->HasRedirectedStdOutErr();
|
---|
| 825 | mImgapp->RedirectStdOutErr(false);
|
---|
| 826 |
|
---|
[357] | 827 | int k1,k2,dk;
|
---|
| 828 | k1 = 0; k2 = objnt->NbLines(); dk = 1;
|
---|
| 829 | DecodeLoopParameters(loop, k1, k2, dk);
|
---|
| 830 | if (k1 < 0) k1 = 0;
|
---|
| 831 | if (k2 < 0) k2 = objnt->NbLines();
|
---|
| 832 | if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
|
---|
| 833 | if (dk <= 0) dk = 1;
|
---|
| 834 |
|
---|
[333] | 835 | TRY {
|
---|
| 836 | double* xn;
|
---|
[357] | 837 | int kmax = k2;
|
---|
| 838 | for(k=k1; k<kmax; k+=dk) {
|
---|
[333] | 839 | xn = objnt->GetLineD(k);
|
---|
| 840 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
|
---|
| 841 | if (nt) {
|
---|
| 842 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
| 843 | nt->Fill(fxnt);
|
---|
| 844 | }
|
---|
| 845 | }
|
---|
| 846 | }
|
---|
| 847 | }
|
---|
| 848 | CATCH(merr) {
|
---|
| 849 | fflush(stdout);
|
---|
| 850 | cout << endl;
|
---|
| 851 | cerr << endl;
|
---|
| 852 | string es = PeidaExc(merr);
|
---|
| 853 | cerr << "Services2NObjMgr::FillNTFrCFile() Exception :" << merr << es;
|
---|
| 854 | } ENDTRY;
|
---|
[344] | 855 |
|
---|
| 856 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 857 | CloseDLL();
|
---|
| 858 |
|
---|
| 859 | // $CHECK$ A virer des que possible On redirige la sortie sur la fenetre PIConsole
|
---|
| 860 | mImgapp->RedirectStdOutErr(red);
|
---|
| 861 |
|
---|
| 862 | if (fgnnt) mOmg->AddObj(nt, nomnt);
|
---|
| 863 | return;
|
---|
| 864 | }
|
---|
| 865 |
|
---|
| 866 | /* --Methode-- */
|
---|
| 867 | void Services2NObjMgr::PrepareNTExpressionCFile(string & nom, string const & fname,
|
---|
| 868 | string const & funcname)
|
---|
| 869 | {
|
---|
| 870 | NObjMgrAdapter* obja=NULL;
|
---|
| 871 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 872 | if (obja == NULL) {
|
---|
| 873 | cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom << "...) No such object" <<endl;
|
---|
| 874 | return;
|
---|
| 875 | }
|
---|
[344] | 876 | bool adel = true;
|
---|
| 877 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
[333] | 878 | if (objnt == NULL) {
|
---|
| 879 | cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom
|
---|
| 880 | << "...) No NTupleInterface !" <<endl;
|
---|
| 881 | return;
|
---|
| 882 | }
|
---|
| 883 | string vardec = objnt->VarList_C("_xnti_");
|
---|
| 884 |
|
---|
| 885 | FILE *fip;
|
---|
| 886 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 887 | cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl;
|
---|
[344] | 888 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 889 | return;
|
---|
| 890 | }
|
---|
[344] | 891 |
|
---|
[333] | 892 | // constitution du fichier des decalarations des variables de l'interface NTuple
|
---|
| 893 | fputs("#include <stdlib.h> \n", fip);
|
---|
| 894 | fputs("#include <stdio.h> \n", fip);
|
---|
| 895 | fputs("#include <math.h> \n\n", fip);
|
---|
[344] | 896 |
|
---|
| 897 | fputs("/* ------ Some random number generators --------- */ \n", fip);
|
---|
| 898 | fputs("#define frand01() ( (float) drand48() ) \n", fip);
|
---|
| 899 | fputs("#define drand01() drand48() \n", fip);
|
---|
| 900 | fputs("#define rand01() drand48() \n", fip);
|
---|
| 901 | fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
|
---|
| 902 | fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
| 903 | fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
| 904 | fputs("double NorRand(void) \n", fip);
|
---|
| 905 | fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
|
---|
| 906 | fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
|
---|
[345] | 907 | fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
|
---|
[344] | 908 | fputs(" return(x); \n } \n", fip);
|
---|
| 909 | fputs("#define GauRand() NorRand() \n", fip);
|
---|
| 910 | fputs("#define gaurand() NorRand() \n\n", fip);
|
---|
| 911 |
|
---|
[333] | 912 | fputs("/* NTupleInterface Variable declaration - Generated by piapp \n", fip);
|
---|
| 913 | fputs(" -- Services2NObjMgr::PrepareNTExpressionCFile() -- */ \n\n", fip);
|
---|
| 914 | fprintf(fip,"int %s(double* _xnti_, double* _rx_, double* _ry_, double* _rz_, \n",
|
---|
| 915 | funcname.c_str());
|
---|
| 916 | fprintf(fip," double* _rt_, int _n_, int _nmax_) \n");
|
---|
| 917 | fprintf(fip, "{ \n %s \n", vardec.c_str());
|
---|
| 918 | fputs(" if (!1) { /* Cut Expression failed */ \n", fip);
|
---|
| 919 | fputs(" *_rx_ = *_ry_ = *_rz_ = *_rt_ = 0.; return(0);", fip);
|
---|
| 920 | fputs(" } \n /* Cut expression satisfied */ \n", fip);
|
---|
| 921 | fputs(" *_rx_ = 1.; \n *_ry_ = 1.; \n *_rz_ = 1.; \n *_rt_ = 1.; \n", fip);
|
---|
| 922 | fputs(" return(1); \n} \n", fip);
|
---|
| 923 |
|
---|
| 924 | fclose(fip);
|
---|
[344] | 925 |
|
---|
| 926 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 927 | return;
|
---|
| 928 | }
|
---|
| 929 |
|
---|
| 930 |
|
---|
| 931 | /* --Methode-- cmv 13/10/98 */
|
---|
| 932 | void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
|
---|
[357] | 933 | string& experr, string& expcut, string& nomgfd, string loop)
|
---|
[333] | 934 | // Pour remplir un ``GeneralFitData'' a partir de divers objets:
|
---|
| 935 | //| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
|
---|
| 936 | //| Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
|
---|
| 937 | //| expx = expression X du GeneralFitData (1er abscisse)
|
---|
| 938 | //| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
|
---|
| 939 | //| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
|
---|
| 940 | //| experr = expression de l'erreur sur l'ordonnee Z
|
---|
| 941 | //| expcut = expression du test de selection
|
---|
| 942 | //| nomgfd = nom du GeneralFitData engendre (optionnel)
|
---|
| 943 | {
|
---|
| 944 | NObjMgrAdapter* obja=NULL;
|
---|
| 945 | obja = mOmg->GetObjAdapter(nom);
|
---|
| 946 | if (obja == NULL) {
|
---|
| 947 | cout << "Services2NObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
|
---|
| 948 | return;
|
---|
| 949 | }
|
---|
| 950 | if(!mImgapp) return;
|
---|
| 951 |
|
---|
| 952 | // 2D ou 3D?
|
---|
| 953 | int nvar = 2;
|
---|
| 954 | if(expy.length()<=0) {nvar = 1; expy = "0.";}
|
---|
| 955 |
|
---|
| 956 | // Creation NTuple Buffer
|
---|
| 957 | char* ntn[4]= {"x","y","f","e"};
|
---|
| 958 | NTuple*nt = new NTuple(4,ntn);
|
---|
| 959 |
|
---|
| 960 | // Remplissage NTuple buffer
|
---|
[357] | 961 | ComputeExpressions(obja, expx, expy, expz, experr, expcut, loop, nt, NULL, NULL);
|
---|
[333] | 962 | if(nt->NEntry() < 1)
|
---|
| 963 | {cout<<"Services2NObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl;
|
---|
| 964 | delete nt; return;}
|
---|
| 965 |
|
---|
| 966 | //Remplissage de la structure GeneraFitData
|
---|
| 967 | if (nt->NEntry() <= 0) {
|
---|
| 968 | cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
|
---|
| 969 | delete nt;
|
---|
| 970 | return;
|
---|
| 971 | }
|
---|
| 972 |
|
---|
| 973 | GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
|
---|
| 974 | int k;
|
---|
| 975 | float* xn;
|
---|
| 976 | for(k=0; k<nt->NEntry(); k++) {
|
---|
| 977 | xn = nt->GetVec(k);
|
---|
| 978 | gfd->AddData(xn,xn[2],xn[3]);
|
---|
| 979 | }
|
---|
| 980 |
|
---|
| 981 | // Menage et table d'objets
|
---|
| 982 | delete nt;
|
---|
| 983 | mOmg->AddObj(gfd, nomgfd);
|
---|
| 984 | return;
|
---|
| 985 | }
|
---|
| 986 |
|
---|
| 987 |
|
---|
| 988 | /* --Methode-- */
|
---|
| 989 | void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx,
|
---|
[357] | 990 | string& expy, string& expz, string& expt, string& expcut, string& loop,
|
---|
[333] | 991 | NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
|
---|
| 992 | {
|
---|
| 993 | if (obja == NULL) return;
|
---|
[344] | 994 | bool adel = true;
|
---|
| 995 | NTupleInterface* objnt = obja->GetNTupleInterface(adel);
|
---|
[333] | 996 | if (objnt == NULL) return;
|
---|
| 997 | string vardec = objnt->VarList_C("_zz6qi_");
|
---|
| 998 |
|
---|
| 999 | PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
|
---|
| 1000 | if (!f) {
|
---|
| 1001 | cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " << endl;
|
---|
[344] | 1002 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 1003 | return;
|
---|
| 1004 | }
|
---|
| 1005 |
|
---|
| 1006 | double xnt[10];
|
---|
| 1007 | float fxnt[10];
|
---|
| 1008 |
|
---|
| 1009 | int i,k;
|
---|
| 1010 | for(i=0; i<10; i++) xnt[i] = 0.;
|
---|
[357] | 1011 | int k1,k2,dk;
|
---|
| 1012 | k1 = 0; k2 = objnt->NbLines(); dk = 1;
|
---|
| 1013 | DecodeLoopParameters(loop, k1, k2, dk);
|
---|
| 1014 | if (k1 < 0) k1 = 0;
|
---|
| 1015 | if (k2 < 0) k2 = objnt->NbLines();
|
---|
| 1016 | if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
|
---|
| 1017 | if (dk <= 0) dk = 1;
|
---|
[333] | 1018 | TRY {
|
---|
| 1019 | double* xn;
|
---|
[357] | 1020 | for(k=k1; k<k2; k += dk) {
|
---|
[333] | 1021 | xn = objnt->GetLineD(k);
|
---|
| 1022 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
| 1023 | if (nt) {
|
---|
| 1024 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
| 1025 | nt->Fill(fxnt);
|
---|
| 1026 | }
|
---|
| 1027 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
| 1028 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
| 1029 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
| 1030 | }
|
---|
| 1031 | }
|
---|
| 1032 | }
|
---|
| 1033 | CATCH(merr) {
|
---|
| 1034 | fflush(stdout);
|
---|
| 1035 | cout << endl;
|
---|
| 1036 | cerr << endl;
|
---|
| 1037 | string es = PeidaExc(merr);
|
---|
| 1038 | cerr << "Services2NObjMgr::ComputeExpressions() Exception :" << merr << es;
|
---|
| 1039 | } ENDTRY;
|
---|
| 1040 |
|
---|
| 1041 |
|
---|
[344] | 1042 | if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
|
---|
[333] | 1043 | // Fermeture du fichier .so
|
---|
| 1044 | CloseDLL();
|
---|
| 1045 | return;
|
---|
| 1046 | }
|
---|
| 1047 |
|
---|
| 1048 |
|
---|
| 1049 | /* --Methode-- */
|
---|
| 1050 | PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy,
|
---|
| 1051 | string& expz, string& expt, string& cut)
|
---|
| 1052 | {
|
---|
| 1053 | FILE *fip;
|
---|
| 1054 | string fname = TmpDir + "expf_pia_dl.c";
|
---|
| 1055 | string cmd;
|
---|
| 1056 | int rc;
|
---|
| 1057 |
|
---|
| 1058 | cmd = "rm -f " + fname;
|
---|
| 1059 | rc = system(cmd.c_str());
|
---|
| 1060 | //DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 1061 |
|
---|
| 1062 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 1063 | string sn = fname;
|
---|
| 1064 | cout << "Services2NObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl;
|
---|
| 1065 | return(NULL);
|
---|
| 1066 | }
|
---|
| 1067 |
|
---|
| 1068 | // constitution du fichier a compiler
|
---|
| 1069 | fputs("#include <stdlib.h> \n", fip);
|
---|
| 1070 | fputs("#include <math.h> \n", fip);
|
---|
[344] | 1071 |
|
---|
| 1072 | fputs("/* ------ Some random number generators --------- */ \n", fip);
|
---|
| 1073 | fputs("#define frand01() ( (float) drand48() ) \n", fip);
|
---|
| 1074 | fputs("#define drand01() drand48() \n", fip);
|
---|
| 1075 | fputs("#define rand01() drand48() \n", fip);
|
---|
| 1076 | fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
|
---|
| 1077 | fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
| 1078 | fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
|
---|
| 1079 | fputs("double NorRand(void) \n", fip);
|
---|
| 1080 | fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
|
---|
| 1081 | fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
|
---|
[345] | 1082 | fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
|
---|
[344] | 1083 | fputs(" return(x); \n } \n", fip);
|
---|
| 1084 | fputs("#define GauRand() NorRand() \n", fip);
|
---|
| 1085 | fputs("#define gaurand() NorRand() \n\n", fip);
|
---|
| 1086 |
|
---|
[333] | 1087 | fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
|
---|
| 1088 | fprintf(fip,"%s \n", vardec.c_str());
|
---|
| 1089 | fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.; return(0); } \n", cut.c_str());
|
---|
| 1090 | fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
|
---|
| 1091 | fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
|
---|
| 1092 | fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
|
---|
| 1093 | fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
|
---|
| 1094 | fputs("return(1); \n} \n", fip);
|
---|
| 1095 | fclose(fip);
|
---|
| 1096 | string func = "expf_pia_dl_func";
|
---|
| 1097 | return((PlotExprFunc)LinkFunctionFromFile(fname, func));
|
---|
| 1098 | }
|
---|
| 1099 |
|
---|
| 1100 |
|
---|
| 1101 | /* --Methode-- */
|
---|
| 1102 | DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
|
---|
| 1103 | {
|
---|
| 1104 | // Le link dynamique
|
---|
| 1105 | CloseDLL();
|
---|
| 1106 | dynlink = PDynLinkMgr::BuildFromCFile(fname);
|
---|
| 1107 | if (dynlink == NULL) {
|
---|
| 1108 | cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
|
---|
| 1109 | return(NULL);
|
---|
| 1110 | }
|
---|
| 1111 |
|
---|
| 1112 | DlFunction retfunc = dynlink->GetFunction(funcname);
|
---|
| 1113 | if (retfunc == NULL) {
|
---|
| 1114 | string sn = funcname;
|
---|
| 1115 | cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
|
---|
| 1116 | CloseDLL();
|
---|
| 1117 | return(NULL);
|
---|
| 1118 | }
|
---|
| 1119 | else return(retfunc);
|
---|
| 1120 | }
|
---|
| 1121 |
|
---|
| 1122 | /* --Methode-- */
|
---|
| 1123 | void Services2NObjMgr::CloseDLL()
|
---|
| 1124 | {
|
---|
| 1125 | if (dynlink) delete dynlink; dynlink = NULL;
|
---|
| 1126 | }
|
---|
| 1127 |
|
---|
[357] | 1128 | // Fonction static
|
---|
| 1129 | /* --Methode-- */
|
---|
| 1130 | void Services2NObjMgr::DecodeLoopParameters(string& loop, int& i1, int& i2, int& di)
|
---|
| 1131 | {
|
---|
| 1132 | // Decode des paramatres de boucle for(int i=i1; i<i2; i+=di) specifies
|
---|
| 1133 | // sous forme i1[:i2[:di]]
|
---|
| 1134 | // cout << "LoopParam() " << loop << " I1=" << i1 << " I2=" << i2 << " DI=" << di;
|
---|
| 1135 | size_t l = loop.length();
|
---|
| 1136 | if (l < 1) return;
|
---|
| 1137 | size_t p = loop.find(':');
|
---|
| 1138 | if (p >= l) { i1 = atoi(loop.c_str()); return; }
|
---|
| 1139 | i1 = atoi(loop.substr(0, p).c_str());
|
---|
| 1140 | string aa = loop.substr(p+1);
|
---|
| 1141 | p = aa.find(':');
|
---|
| 1142 | if (p < aa.length() ) {
|
---|
| 1143 | i2 = atoi(aa.substr(0,p).c_str());
|
---|
| 1144 | di = atoi(aa.substr(p+1).c_str());
|
---|
| 1145 | }
|
---|
| 1146 | else i2 = atoi(aa.c_str());
|
---|
| 1147 | // cout << "-> I1= " << i1 << " I2= " << i2 << " DI= " << di << endl;
|
---|
| 1148 | return;
|
---|
| 1149 | }
|
---|
[333] | 1150 |
|
---|
| 1151 | /* --Methode-- */
|
---|
[165] | 1152 | string Services2NObjMgr::FileName2Name(string const & fn)
|
---|
| 1153 | {
|
---|
| 1154 |
|
---|
| 1155 | char fsep[2] = {FILESEP, '\0'};
|
---|
| 1156 | char tsep[2] = {'.', '\0'};
|
---|
| 1157 | size_t p = fn.find_last_of(fsep);
|
---|
[194] | 1158 | size_t l = fn.length();
|
---|
| 1159 | if (p >= l) p = 0;
|
---|
| 1160 | else p++;
|
---|
| 1161 | size_t q = fn.find_first_of(tsep,p);
|
---|
| 1162 | if (q < p) q = l;
|
---|
[165] | 1163 | return(fn.substr(p,q-p));
|
---|
| 1164 | }
|
---|
| 1165 |
|
---|
| 1166 |
|
---|
| 1167 | typedef vector<string> GraTok;
|
---|
| 1168 |
|
---|
| 1169 | /* --Methode-- */
|
---|
| 1170 | int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
|
---|
| 1171 | {
|
---|
| 1172 | int ropt = Disp_Next;
|
---|
| 1173 | if (!mImgapp) return(ropt);
|
---|
| 1174 |
|
---|
| 1175 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
|
---|
| 1176 |
|
---|
| 1177 | if (fgsrgr) mImgapp->SaveGraphicAtt();
|
---|
| 1178 |
|
---|
[326] | 1179 | if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini
|
---|
[165] | 1180 | mImgapp->SetColAtt();
|
---|
| 1181 | mImgapp->SetLineAtt();
|
---|
| 1182 | mImgapp->SetFontAtt();
|
---|
| 1183 | mImgapp->SetMarkerAtt();
|
---|
| 1184 | mImgapp->SetColMapId();
|
---|
| 1185 | mImgapp->SetZoomAtt();
|
---|
[331] | 1186 | mImgapp->SetAxesAtt();
|
---|
| 1187 | mImgapp->SetXYLimits();
|
---|
| 1188 | mImgapp->UseXYLimits();
|
---|
[165] | 1189 | return(ropt);
|
---|
| 1190 | }
|
---|
| 1191 |
|
---|
| 1192 | // On separe en mots separes par des virgules
|
---|
| 1193 | gratt = ","+gratt;
|
---|
| 1194 | size_t p = 0;
|
---|
| 1195 | size_t q = 0;
|
---|
| 1196 | size_t l = gratt.length();
|
---|
| 1197 | string token;
|
---|
| 1198 |
|
---|
| 1199 | GraTok grt;
|
---|
| 1200 |
|
---|
| 1201 | while (q < l) {
|
---|
| 1202 | p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
|
---|
| 1203 | if (p>=l) break;
|
---|
| 1204 | q = gratt.find_first_of(" ,",p); // la fin du token;
|
---|
| 1205 | token = gratt.substr(p,q-p);
|
---|
| 1206 | grt.push_back(token);
|
---|
| 1207 | }
|
---|
| 1208 |
|
---|
| 1209 |
|
---|
| 1210 | static GrAttNames::iterator it;
|
---|
| 1211 |
|
---|
| 1212 | int k;
|
---|
| 1213 | bool fgcont = true;
|
---|
| 1214 | fgsrgr = false;
|
---|
| 1215 |
|
---|
| 1216 | for(k=0; k<grt.size(); k++) {
|
---|
| 1217 | // cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
|
---|
| 1218 |
|
---|
| 1219 | // Decodage option affichage (win, next, etc
|
---|
| 1220 | fgcont = true;
|
---|
| 1221 | if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
|
---|
| 1222 | else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
|
---|
| 1223 | else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
|
---|
| 1224 | else fgcont = false;
|
---|
| 1225 | if (fgcont) continue;
|
---|
[331] | 1226 |
|
---|
| 1227 | // Utilisation limites X-Y
|
---|
| 1228 | if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true); fgsrgr = true; continue; }
|
---|
[165] | 1229 | // Si c'est une couleur
|
---|
| 1230 | it = GrAcolors.find(grt[k]);
|
---|
| 1231 | if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 1232 | // Si c'est un attribut de lignes
|
---|
| 1233 | it = GrAlines.find(grt[k]);
|
---|
| 1234 | if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 1235 | // Si c'est un attribut de fontes
|
---|
| 1236 | it = GrAfonts.find(grt[k]);
|
---|
| 1237 | if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
|
---|
| 1238 | fgsrgr = true; continue; }
|
---|
| 1239 | // Si c'est un attribut de markers
|
---|
| 1240 | it = GrAmarkers.find(grt[k]);
|
---|
| 1241 | if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
|
---|
| 1242 | fgsrgr = true; continue; }
|
---|
| 1243 | // Si c'est un colormap
|
---|
| 1244 | it = GrAcmap.find(grt[k]);
|
---|
| 1245 | if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
|
---|
| 1246 | // Si c'est un facteur de zoom
|
---|
| 1247 | it = GrAzoom.find(grt[k]);
|
---|
| 1248 | if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
[203] | 1249 | // Si c'est un attribut d'axe
|
---|
| 1250 | it = GrAaxes.find(grt[k]);
|
---|
| 1251 | if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
[165] | 1252 |
|
---|
| 1253 | }
|
---|
| 1254 |
|
---|
| 1255 | return(ropt);
|
---|
| 1256 | }
|
---|
| 1257 |
|
---|
| 1258 |
|
---|
| 1259 |
|
---|
| 1260 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
| 1261 | // Initialisation des chaines de caracteres designant les attributs graphiques
|
---|
| 1262 |
|
---|
| 1263 | /* --Methode-- */
|
---|
| 1264 | void Services2NObjMgr::InitGrAttNames()
|
---|
| 1265 | {
|
---|
| 1266 | gratt_item gi;
|
---|
| 1267 | // Les couleurs
|
---|
| 1268 | gi.a2 = 0;
|
---|
| 1269 | gi.a1 = PI_NotDefColor;
|
---|
| 1270 | GrAcolors["defcol"] = gi;
|
---|
| 1271 | gi.a1 = PI_Black;
|
---|
| 1272 | GrAcolors["black"] = gi;
|
---|
| 1273 | gi.a1 = PI_White;
|
---|
| 1274 | GrAcolors["white"] = gi;
|
---|
| 1275 | gi.a1 = PI_Grey;
|
---|
| 1276 | GrAcolors["grey"] = gi;
|
---|
| 1277 | gi.a1 = PI_Red;
|
---|
| 1278 | GrAcolors["red"] = gi;
|
---|
| 1279 | gi.a1 = PI_Blue;
|
---|
| 1280 | GrAcolors["blue"] = gi;
|
---|
| 1281 | gi.a1 = PI_Green;
|
---|
| 1282 | GrAcolors["green"] = gi;
|
---|
| 1283 | gi.a1 = PI_Yellow;
|
---|
| 1284 | GrAcolors["yellow"] = gi;
|
---|
| 1285 | gi.a1 = PI_Magenta;
|
---|
| 1286 | GrAcolors["magenta"] = gi;
|
---|
| 1287 |
|
---|
| 1288 | gi.a1 = PI_Cyan;
|
---|
| 1289 | GrAcolors["cyan"] = gi;
|
---|
| 1290 | gi.a1 = PI_Turquoise;
|
---|
| 1291 | GrAcolors["turquoise"] = gi;
|
---|
| 1292 | gi.a1 = PI_NavyBlue;
|
---|
| 1293 | GrAcolors["navyblue"] = gi;
|
---|
| 1294 | gi.a1 = PI_Orange;
|
---|
| 1295 | GrAcolors["orange"] = gi;
|
---|
| 1296 | gi.a1 = PI_SiennaRed;
|
---|
| 1297 | GrAcolors["siennared"] = gi;
|
---|
| 1298 | gi.a1 = PI_Purple;
|
---|
| 1299 | GrAcolors["purple"] = gi;
|
---|
| 1300 | gi.a1 = PI_LimeGreen;
|
---|
| 1301 | GrAcolors["limegreen"] = gi;
|
---|
| 1302 | gi.a1 = PI_Gold;
|
---|
| 1303 | GrAcolors["gold"] = gi;
|
---|
| 1304 |
|
---|
| 1305 | // Les attributs de lignes
|
---|
| 1306 | gi.a2 = 0;
|
---|
| 1307 | gi.a1 = PI_NotDefLineAtt;
|
---|
| 1308 | GrAlines["defline"] = gi;
|
---|
| 1309 | gi.a1 = PI_NormalLine;
|
---|
| 1310 | GrAlines["normalline"] = gi;
|
---|
| 1311 | gi.a1 = PI_ThinLine;
|
---|
| 1312 | GrAlines["thinline"] = gi;
|
---|
| 1313 | gi.a1 = PI_ThickLine;
|
---|
| 1314 | GrAlines["thickline"] = gi;
|
---|
| 1315 | gi.a1 = PI_DashedLine;
|
---|
| 1316 | GrAlines["dashedline"] = gi;
|
---|
| 1317 | gi.a1 = PI_ThinDashedLine;
|
---|
| 1318 | GrAlines["thindashedline"] = gi;
|
---|
| 1319 | gi.a1 = PI_ThickDashedLine;
|
---|
| 1320 | GrAlines["thickdashedline"] = gi;
|
---|
[192] | 1321 | gi.a1 = PI_DottedLine;
|
---|
| 1322 | GrAlines["dottedline"] = gi;
|
---|
| 1323 | gi.a1 = PI_ThinDottedLine;
|
---|
| 1324 | GrAlines["thindottedline"] = gi;
|
---|
| 1325 | gi.a1 = PI_ThickDottedLine;
|
---|
| 1326 | GrAlines["thickdottedline"] = gi;
|
---|
[165] | 1327 |
|
---|
[293] | 1328 | // Les fontes
|
---|
[165] | 1329 | gi.a2 = PI_NotDefFontSize;
|
---|
| 1330 | gi.a1 = PI_NotDefFontAtt;
|
---|
[349] | 1331 | GrAfonts["deffont"] = gi;
|
---|
[165] | 1332 |
|
---|
| 1333 | gi.a2 = PI_NormalSizeFont;
|
---|
| 1334 | gi.a1 = PI_RomanFont;
|
---|
[349] | 1335 | GrAfonts["normalfont"] = gi;
|
---|
[165] | 1336 | gi.a1 = PI_BoldFont;
|
---|
[349] | 1337 | GrAfonts["boldfont"] = gi;
|
---|
[165] | 1338 | gi.a1 = PI_ItalicFont;
|
---|
[349] | 1339 | GrAfonts["italicfont"] = gi;
|
---|
[165] | 1340 | gi.a2 = PI_SmallSizeFont;
|
---|
| 1341 | gi.a1 = PI_RomanFont;
|
---|
[349] | 1342 | GrAfonts["smallfont"] = gi;
|
---|
[165] | 1343 | gi.a1 = PI_BoldFont;
|
---|
[349] | 1344 | GrAfonts["smallboldfont"] = gi;
|
---|
[165] | 1345 | gi.a1 = PI_ItalicFont;
|
---|
[349] | 1346 | GrAfonts["smallitalicfont"] = gi;
|
---|
[165] | 1347 | gi.a2 = PI_BigSizeFont;
|
---|
| 1348 | gi.a1 = PI_RomanFont;
|
---|
[349] | 1349 | GrAfonts["bigfont"] = gi;
|
---|
[165] | 1350 | gi.a1 = PI_BoldFont;
|
---|
[349] | 1351 | GrAfonts["bigboldfont"] = gi;
|
---|
[165] | 1352 | gi.a1 = PI_ItalicFont;
|
---|
[349] | 1353 | GrAfonts["bigitalicfont"] = gi;
|
---|
[192] | 1354 | gi.a2 = PI_HugeSizeFont;
|
---|
| 1355 | gi.a1 = PI_RomanFont;
|
---|
[349] | 1356 | GrAfonts["hugefont"] = gi;
|
---|
[192] | 1357 | gi.a1 = PI_BoldFont;
|
---|
[349] | 1358 | GrAfonts["hugeboldfont"] = gi;
|
---|
[192] | 1359 | gi.a1 = PI_ItalicFont;
|
---|
[349] | 1360 | GrAfonts["hugeitalicfont"] = gi;
|
---|
[165] | 1361 |
|
---|
| 1362 |
|
---|
| 1363 | // Les markers
|
---|
[176] | 1364 | const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
|
---|
| 1365 | "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
|
---|
| 1366 | "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
|
---|
[165] | 1367 | PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
|
---|
| 1368 | PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
|
---|
| 1369 | PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
|
---|
| 1370 |
|
---|
| 1371 | gi.a2 = 0;
|
---|
| 1372 | gi.a1 = PI_NotDefMarker;
|
---|
| 1373 | GrAmarkers["defmarker"] = gi;
|
---|
| 1374 |
|
---|
| 1375 | for(int j=0; j<11; j++) {
|
---|
| 1376 | string smrk;
|
---|
| 1377 | char buff[16];
|
---|
| 1378 | for(int m=1; m<10; m+=2) {
|
---|
| 1379 | sprintf(buff,"%d",m);
|
---|
| 1380 | smrk = (string)mrkn[j] + (string)buff;
|
---|
| 1381 | gi.a1 = mrk[j]; gi.a2 = m;
|
---|
| 1382 | GrAmarkers[smrk] = gi;
|
---|
| 1383 | }
|
---|
| 1384 | }
|
---|
| 1385 |
|
---|
| 1386 | // Les tables de couleurs
|
---|
| 1387 | gi.a2 = 0;
|
---|
| 1388 | gi.a1 = CMAP_OTHER;
|
---|
| 1389 | GrAcmap["defcmap"] = gi;
|
---|
| 1390 | gi.a1 = CMAP_GREY32;
|
---|
| 1391 | GrAcmap["grey32"] = gi;
|
---|
| 1392 | gi.a1 = CMAP_GREYINV32;
|
---|
| 1393 | GrAcmap["greyinv32"] = gi;
|
---|
| 1394 | gi.a1 = CMAP_COLRJ32;
|
---|
| 1395 | GrAcmap["colrj32"] = gi;
|
---|
| 1396 | gi.a1 = CMAP_COLBR32;
|
---|
| 1397 | GrAcmap["colbr32"] = gi;
|
---|
| 1398 | gi.a1 = CMAP_GREY128;
|
---|
| 1399 | GrAcmap["grey128"] = gi;
|
---|
| 1400 | gi.a1 = CMAP_GREYINV128;
|
---|
| 1401 | GrAcmap["greyinv128"] = gi;
|
---|
| 1402 | gi.a1 = CMAP_COLRJ128;
|
---|
| 1403 | GrAcmap["colrj128"] = gi;
|
---|
| 1404 | gi.a1 = CMAP_COLBR128;
|
---|
| 1405 | GrAcmap["colbr128"] = gi;
|
---|
| 1406 |
|
---|
[203] | 1407 | // La valeur de zoom
|
---|
[165] | 1408 | gi.a2 = 0;
|
---|
| 1409 | gi.a1 = 0;
|
---|
| 1410 | GrAzoom["defzoom"] = gi;
|
---|
| 1411 | gi.a1 = 1;
|
---|
| 1412 | GrAzoom["zoomx1"] = gi;
|
---|
| 1413 | gi.a1 = 2;
|
---|
| 1414 | GrAzoom["zoomx2"] = gi;
|
---|
| 1415 | gi.a1 = 3;
|
---|
| 1416 | GrAzoom["zoomx3"] = gi;
|
---|
| 1417 | gi.a1 = 4;
|
---|
| 1418 | GrAzoom["zoomx4"] = gi;
|
---|
| 1419 | gi.a1 = 5;
|
---|
| 1420 | GrAzoom["zoomx5"] = gi;
|
---|
| 1421 | gi.a1 = -2;
|
---|
| 1422 | GrAzoom["zoom/2"] = gi;
|
---|
| 1423 | gi.a1 = -3;
|
---|
| 1424 | GrAzoom["zoom/3"] = gi;
|
---|
| 1425 | gi.a1 = -4;
|
---|
| 1426 | GrAzoom["zoom/4"] = gi;
|
---|
| 1427 | gi.a1 = -5;
|
---|
| 1428 | GrAzoom["zoom/5"] = gi;
|
---|
[203] | 1429 |
|
---|
| 1430 | // Attributs d'axes
|
---|
| 1431 | gi.a2 = 0;
|
---|
| 1432 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
|
---|
| 1433 | GrAaxes["stdaxes"] = gi;
|
---|
| 1434 | GrAaxes["defaxes"] = gi;
|
---|
| 1435 | GrAaxes["boxaxes"] = gi;
|
---|
| 1436 | gi.a1 = (int)kAxesDflt;
|
---|
| 1437 | GrAaxes["simpleaxes"] = gi;
|
---|
| 1438 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
|
---|
| 1439 | GrAaxes["boxaxesgrid"] = gi;
|
---|
| 1440 |
|
---|
| 1441 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
|
---|
| 1442 | GrAaxes["fineaxes"] = gi;
|
---|
| 1443 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
|
---|
| 1444 | GrAaxes["grid"] = gi;
|
---|
| 1445 | GrAaxes["fineaxesgrid"] = gi;
|
---|
| 1446 |
|
---|
[165] | 1447 | }
|
---|
[333] | 1448 |
|
---|
| 1449 |
|
---|
| 1450 | // SANS_EVOLPLANCK Attention !
|
---|
| 1451 | #include "pclassids.h"
|
---|
| 1452 |
|
---|
| 1453 | /* --Methode-- */
|
---|
| 1454 | char* Services2NObjMgr::PClassIdToClassName(int cid)
|
---|
| 1455 | {
|
---|
| 1456 | switch (cid) {
|
---|
| 1457 | case ClassId_Poly1 :
|
---|
| 1458 | return("Poly1");
|
---|
| 1459 | case ClassId_Poly2 :
|
---|
| 1460 | return("Poly2");
|
---|
| 1461 | case ClassId_Matrix :
|
---|
| 1462 | return("Matrix");
|
---|
| 1463 | case ClassId_Vector :
|
---|
| 1464 | return("Vector");
|
---|
| 1465 |
|
---|
| 1466 | case ClassId_DVList :
|
---|
| 1467 | return("DVList");
|
---|
| 1468 |
|
---|
| 1469 | case ClassId_Histo1D :
|
---|
| 1470 | return("Histo1D");
|
---|
| 1471 | case ClassId_Histo2D :
|
---|
| 1472 | return("Histo2D");
|
---|
| 1473 | case ClassId_HProf :
|
---|
| 1474 | return("HProf");
|
---|
| 1475 | case ClassId_NTuple :
|
---|
| 1476 | return("NTuple");
|
---|
[361] | 1477 | case ClassId_XNTuple :
|
---|
| 1478 | return("XNTuple");
|
---|
[333] | 1479 | case ClassId_GeneralFitData :
|
---|
| 1480 | return("GeneralFitData");
|
---|
| 1481 |
|
---|
| 1482 | case ClassId_Image :
|
---|
| 1483 | return("RzImage");
|
---|
| 1484 | case ClassId_Image + kuint_1 :
|
---|
| 1485 | return("ImageU1");
|
---|
| 1486 | case ClassId_Image + kint_1 :
|
---|
| 1487 | return("ImageI1");
|
---|
| 1488 | case ClassId_Image + kuint_2 :
|
---|
| 1489 | return("ImageU2");
|
---|
| 1490 | case ClassId_Image + kint_2 :
|
---|
| 1491 | return("ImageI2");
|
---|
| 1492 | case ClassId_Image + kuint_4 :
|
---|
| 1493 | return("ImageU4");
|
---|
| 1494 | case ClassId_Image + kint_4 :
|
---|
| 1495 | return("ImageI4");
|
---|
| 1496 | case ClassId_Image + kr_4 :
|
---|
| 1497 | return("ImageR4");
|
---|
| 1498 | case ClassId_Image + kr_8 :
|
---|
| 1499 | return("ImageR8");
|
---|
| 1500 |
|
---|
| 1501 | case ClassId_ZFidu :
|
---|
| 1502 | return("ZFidu");
|
---|
| 1503 |
|
---|
| 1504 | case ClassId_StarList :
|
---|
| 1505 | return("StarList");
|
---|
| 1506 | case ClassId_Transfo :
|
---|
| 1507 | return("Transfo");
|
---|
| 1508 | case ClassId_PSF :
|
---|
| 1509 | return("PSF");
|
---|
| 1510 |
|
---|
| 1511 |
|
---|
| 1512 | // - Ajout objet PPF
|
---|
| 1513 | default:
|
---|
| 1514 | return("AnyDataObj");
|
---|
| 1515 | }
|
---|
| 1516 | }
|
---|
| 1517 |
|
---|