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