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