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