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