| 1 | #include "sopnamsp.h" | 
|---|
| 2 | #include "piacmd.h" | 
|---|
| 3 |  | 
|---|
| 4 | #include <stdio.h> | 
|---|
| 5 | #include <stdlib.h> | 
|---|
| 6 | #include <math.h> | 
|---|
| 7 |  | 
|---|
| 8 | #include "basexecut.h" | 
|---|
| 9 |  | 
|---|
| 10 | #include "pdlmgr.h" | 
|---|
| 11 | #include "ctimer.h" | 
|---|
| 12 | #include "strutilxx.h" | 
|---|
| 13 |  | 
|---|
| 14 | #include "pistdimgapp.h" | 
|---|
| 15 | #include "nobjmgr.h" | 
|---|
| 16 | #include "servnobjm.h" | 
|---|
| 17 | #include "nomgadapter.h" | 
|---|
| 18 |  | 
|---|
| 19 | #include "histos.h" | 
|---|
| 20 | #include "histos2.h" | 
|---|
| 21 | #include "hisprof.h" | 
|---|
| 22 | #include "ntuple.h" | 
|---|
| 23 | #include "generaldata.h" | 
|---|
| 24 | #include "datatable.h" | 
|---|
| 25 |  | 
|---|
| 26 | #ifdef SANS_EVOLPLANCK | 
|---|
| 27 | #include "cvector.h" | 
|---|
| 28 | #else | 
|---|
| 29 | #include "tvector.h" | 
|---|
| 30 | #endif | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | /* --Methode-- */ | 
|---|
| 34 | PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app) | 
|---|
| 35 | { | 
|---|
| 36 | mpiac = piac; | 
|---|
| 37 | mObjMgr = omg; | 
|---|
| 38 | mImgApp = app; | 
|---|
| 39 | dynlink = NULL; | 
|---|
| 40 | dynlink2 = NULL; | 
|---|
| 41 | RegisterCommands(); | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 | PIABaseExecutor::~PIABaseExecutor() | 
|---|
| 45 | { | 
|---|
| 46 | if (dynlink) delete dynlink; | 
|---|
| 47 | if (dynlink2) delete dynlink2; | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 |  | 
|---|
| 52 | /* --Methode-- */ | 
|---|
| 53 | int PIABaseExecutor::Execute(string& kw, vector<string>& tokens, string& toks) | 
|---|
| 54 | { | 
|---|
| 55 | Services2NObjMgr* srvo = mObjMgr->GetServiceObj(); | 
|---|
| 56 | // >>>>> Chargement de modules | 
|---|
| 57 | if (kw == "loadmodule") { | 
|---|
| 58 | if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl;  return(0); } | 
|---|
| 59 | mpiac->LoadModule(tokens[0], tokens[1]); | 
|---|
| 60 | } | 
|---|
| 61 |  | 
|---|
| 62 | // >>>>>>>>>>> Link dynamique de fonctions C++ | 
|---|
| 63 | else if (kw == "link" ) { | 
|---|
| 64 | if (tokens.size() < 2) { cout << "Usage: link fnameso f1 [f2 f3]" << endl;  return(0); } | 
|---|
| 65 | string sph = ""; | 
|---|
| 66 | for(int gg=0; gg<5; gg++)   tokens.push_back(sph); | 
|---|
| 67 | int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]); | 
|---|
| 68 | if (rc == 0)  cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl; | 
|---|
| 69 | } | 
|---|
| 70 | else if (kw == "linkff2" ) { | 
|---|
| 71 | if (tokens.size() < 2) { cout << "Usage: linkff2 fnameso f1 [f2 f3]" << endl;  return(0); } | 
|---|
| 72 | string sph = ""; | 
|---|
| 73 | for(int gg=0; gg<5; gg++)   tokens.push_back(sph); | 
|---|
| 74 | int rc = LinkUserFuncs2(tokens[0], tokens[1], tokens[2], tokens[3]); | 
|---|
| 75 | if (rc == 0)  cout << "PIABaseExecutor: Link2 from " << tokens[0] << " OK " << endl; | 
|---|
| 76 | } | 
|---|
| 77 | else if (kw == "call" ) { | 
|---|
| 78 | if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl;  return(0); } | 
|---|
| 79 | UsFmap::iterator it; | 
|---|
| 80 | UsFmap::iterator it1 = usfmap.find(tokens[0]); | 
|---|
| 81 | UsFmap::iterator it2 = usfmap2.find(tokens[0]); | 
|---|
| 82 | if ((it1 == usfmap.end()) && (it2 == usfmap2.end()) ) { | 
|---|
| 83 | cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl; | 
|---|
| 84 | return(0); | 
|---|
| 85 | } | 
|---|
| 86 | if (it1 == usfmap.end())  it = it2; | 
|---|
| 87 | else it = it1; | 
|---|
| 88 | cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl; | 
|---|
| 89 | // on est oblige de faire un cast  etant donne qu'on | 
|---|
| 90 | // utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++) | 
|---|
| 91 | DlUserProcFunction fuf = (DlUserProcFunction)(*it).second; | 
|---|
| 92 | /*DEL----- Plus besoin en multi-thread ? / Reza 06/01/2004 | 
|---|
| 93 | //   On redirige la sortie sur le terminal | 
|---|
| 94 | bool red = mImgApp->HasRedirectedStdOutErr(); | 
|---|
| 95 | mImgApp->RedirectStdOutErr(false); | 
|---|
| 96 | --------DEL  */ | 
|---|
| 97 | #ifdef SANS_EVOLPLANCK | 
|---|
| 98 | TRY { | 
|---|
| 99 | tokens.erase(tokens.begin()); | 
|---|
| 100 | fuf(tokens); | 
|---|
| 101 | }  CATCH(merr) { | 
|---|
| 102 | fflush(stdout); | 
|---|
| 103 | string es = PeidaExc(merr); | 
|---|
| 104 | cerr << "\n PIABaseExecutor: Call UserFunc  Exception :" << merr << es; | 
|---|
| 105 | cout << endl; | 
|---|
| 106 | } | 
|---|
| 107 | #else | 
|---|
| 108 | try { | 
|---|
| 109 | tokens.erase(tokens.begin()); | 
|---|
| 110 | fuf(tokens); | 
|---|
| 111 | return(0); | 
|---|
| 112 | } | 
|---|
| 113 | catch ( PThrowable & exc ) { | 
|---|
| 114 | cerr << "\n PIABaseExecutor: Call / Catched Exception :" | 
|---|
| 115 | << (string)typeid(exc).name() << " Msg= " | 
|---|
| 116 | << exc.Msg() << endl; | 
|---|
| 117 | return(-77); | 
|---|
| 118 | } | 
|---|
| 119 | catch ( ... ) { | 
|---|
| 120 | cerr << "\n PIABaseExecutor: Call / Catched Exception ... " | 
|---|
| 121 | << endl; | 
|---|
| 122 | return(-79); | 
|---|
| 123 | } | 
|---|
| 124 | #endif | 
|---|
| 125 | /*DEL----- Plus besoin en multi-thread ? / Reza 06/01/2004 | 
|---|
| 126 | mImgApp->RedirectStdOutErr(red); | 
|---|
| 127 | --------DEL    */ | 
|---|
| 128 | } | 
|---|
| 129 |  | 
|---|
| 130 | else if (kw == "openppf" ) { | 
|---|
| 131 | if (tokens.size()<1) {cout<<"Usage: openppf file [objname1 objname2 ...]"<<endl; return(0); } | 
|---|
| 132 | else if (tokens.size()==1) mObjMgr->ReadAll(tokens[0]); | 
|---|
| 133 | else mObjMgr->ReadObj(tokens); | 
|---|
| 134 | } | 
|---|
| 135 | else if ((kw == "saveobjs") || (kw == "saveppf"))  { | 
|---|
| 136 | if (tokens.size() < 2) { cout << "Usage: saveobjs patt filename " << endl; return(0); } | 
|---|
| 137 | mObjMgr->SaveObjects(tokens[0], tokens[1]); | 
|---|
| 138 | } | 
|---|
| 139 | else if (kw == "savelist")  { | 
|---|
| 140 | if (tokens.size() < 2) { | 
|---|
| 141 | cout << "Usage: savelist objname1 [objname2 ...] filename "<<endl; | 
|---|
| 142 | return(0); | 
|---|
| 143 | } | 
|---|
| 144 | mObjMgr->SaveListObjects(tokens); | 
|---|
| 145 | } | 
|---|
| 146 | else if (kw == "saveall" ) { | 
|---|
| 147 | if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); } | 
|---|
| 148 | mObjMgr->SaveAll(tokens[0]); | 
|---|
| 149 | } | 
|---|
| 150 | else if (kw == "print" ) { | 
|---|
| 151 | if (tokens.size() < 1) { cout << "Usage: print nameobj [prtlev]" << endl; return(0); } | 
|---|
| 152 | int lev = 0; | 
|---|
| 153 | if (tokens.size()>1) lev = atoi(tokens[1].c_str()); | 
|---|
| 154 | mObjMgr->PrintObj(tokens[0], lev); | 
|---|
| 155 | } | 
|---|
| 156 | else if ( (kw == "rename" ) || (kw == "mv") )  { | 
|---|
| 157 | if (tokens.size() < 2) { cout << "Usage: rename/mv nameobj namenew" << endl; return(0); } | 
|---|
| 158 | mObjMgr->RenameObj(tokens[0], tokens[1]); | 
|---|
| 159 | } | 
|---|
| 160 | else if ( (kw == "del" ) || (kw == "rm") ) { | 
|---|
| 161 | if (tokens.size() < 1) { cout << "Usage: del nameobj [nameobj2 ...]" << endl; return(0); } | 
|---|
| 162 | if (tokens.size()>0) | 
|---|
| 163 | for(uint_4 i=0;i<tokens.size();i++)  mObjMgr->DelObj(tokens[i]); | 
|---|
| 164 | } | 
|---|
| 165 | else if (kw == "delobjs" ) { | 
|---|
| 166 | if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); } | 
|---|
| 167 | mObjMgr->DelObjects(tokens[0]); | 
|---|
| 168 | } | 
|---|
| 169 | else if ( (kw == "listobjs") || (kw == "ls") )    { | 
|---|
| 170 | if  (tokens.size() < 1)  tokens.push_back("*"); | 
|---|
| 171 | if  (tokens.size() < 2)  mObjMgr->ListObjs(tokens[0]); | 
|---|
| 172 | else { | 
|---|
| 173 | vector<string> olv; | 
|---|
| 174 | mObjMgr->GetObjList(tokens[0], olv); | 
|---|
| 175 | mpiac->SetVar(tokens[1], olv); | 
|---|
| 176 | } | 
|---|
| 177 | } | 
|---|
| 178 |  | 
|---|
| 179 | // Gestion des repertoires | 
|---|
| 180 | else if (kw == "mkdir" ) { | 
|---|
| 181 | if (tokens.size() < 1) { cout << "Usage: mkdir dirname [true]" << endl; return(0); } | 
|---|
| 182 | bool crd = mObjMgr->CreateDir(tokens[0]); | 
|---|
| 183 | if ( crd && (tokens.size() > 1) && (tokens[1] == "true") ) | 
|---|
| 184 | mObjMgr->SetKeepOldDirAtt(tokens[0], true); | 
|---|
| 185 | } | 
|---|
| 186 | else if (kw == "rmdir" ) { | 
|---|
| 187 | if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); } | 
|---|
| 188 | mObjMgr->DeleteDir(tokens[0]); | 
|---|
| 189 | } | 
|---|
| 190 | else if (kw == "setdiratt" ) { | 
|---|
| 191 | if (tokens.size() < 2) { cout << "Usage: setdiratt dirname true/false" << endl; return(0); } | 
|---|
| 192 | if (tokens[1] == "true") mObjMgr->SetKeepOldDirAtt(tokens[0], true); | 
|---|
| 193 | else mObjMgr->SetKeepOldDirAtt(tokens[0], false); | 
|---|
| 194 | } | 
|---|
| 195 | else if (kw == "cd")   { | 
|---|
| 196 | if  (tokens.size() < 1)  tokens.push_back("home"); | 
|---|
| 197 | mObjMgr->SetCurrentDir(tokens[0]); | 
|---|
| 198 | } | 
|---|
| 199 | else if (kw == "pwd") { | 
|---|
| 200 | string dirn; | 
|---|
| 201 | mObjMgr->GetCurrentDir(dirn); | 
|---|
| 202 | cout << "CurrentDirectory: " << dirn << endl; | 
|---|
| 203 | } | 
|---|
| 204 | else if (kw == "listdirs")   { | 
|---|
| 205 | if  (tokens.size() < 1)  tokens.push_back("*"); | 
|---|
| 206 | mObjMgr->ListDirs(tokens[0]); | 
|---|
| 207 | } | 
|---|
| 208 |  | 
|---|
| 209 | // >>>>>>>>>>> Creation d'histos 1D-2D | 
|---|
| 210 | else if (kw == "newh1d") { | 
|---|
| 211 | if (tokens.size() < 4) { cout << "Usage: newh1d name xmin xmax nbin" << endl; return(0); } | 
|---|
| 212 | int_4 nbx = 100; | 
|---|
| 213 | r_8 xmin = 0., xmax = 1.; | 
|---|
| 214 | nbx = atoi(tokens[3].c_str()); | 
|---|
| 215 | xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str()); | 
|---|
| 216 | Histo* h = new Histo(xmin, xmax, nbx); | 
|---|
| 217 | mObjMgr->AddObj(h, tokens[0]); | 
|---|
| 218 | } | 
|---|
| 219 | else if (kw == "newh2d") { | 
|---|
| 220 | if (tokens.size() < 7) { | 
|---|
| 221 | cout << "Usage: newh2d name xmin xmax nbinx ymin ymax nbiny" << endl; | 
|---|
| 222 | return(0); | 
|---|
| 223 | } | 
|---|
| 224 | int_4 nbx = 50, nby = 50; | 
|---|
| 225 | r_8 xmin = 0., xmax = 1.; | 
|---|
| 226 | r_8 ymin = 0., ymax = 1.; | 
|---|
| 227 | nbx = atoi(tokens[3].c_str()); | 
|---|
| 228 | nby = atoi(tokens[6].c_str()); | 
|---|
| 229 | xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str()); | 
|---|
| 230 | ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str()); | 
|---|
| 231 | Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby); | 
|---|
| 232 | mObjMgr->AddObj(h, tokens[0]); | 
|---|
| 233 | } | 
|---|
| 234 | else if (kw == "newprof" || kw == "newprofe") { | 
|---|
| 235 | if (tokens.size() < 4) | 
|---|
| 236 | { cout << "Usage: newprof[e] name xmin xmax nbin [ymin ymax]" << endl; return(0); } | 
|---|
| 237 | int_4 nbx = 100; | 
|---|
| 238 | r_8 xmin = 0., xmax = 1., ymin = 1., ymax = -1.; | 
|---|
| 239 | if(tokens.size() > 5) | 
|---|
| 240 | {ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str());} | 
|---|
| 241 | nbx = atoi(tokens[3].c_str()); | 
|---|
| 242 | xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str()); | 
|---|
| 243 | HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax); | 
|---|
| 244 | if(kw == "newprofe") h->SetErrOpt(false); | 
|---|
| 245 | mObjMgr->AddObj(h, tokens[0]); | 
|---|
| 246 | } | 
|---|
| 247 |  | 
|---|
| 248 | // Creation de NTuple | 
|---|
| 249 | else if (kw == "newnt") { | 
|---|
| 250 | if(tokens.size() < 2) | 
|---|
| 251 | {cout<<"Usage: newnt name v1 v2 ... vn / newnt name nvar"<<endl; return(0);} | 
|---|
| 252 | vector<string> varname; | 
|---|
| 253 | int nvar = 0; | 
|---|
| 254 | const char *c = tokens[1].c_str(); | 
|---|
| 255 | if(isdigit(c[0])) { | 
|---|
| 256 | nvar = atoi(tokens[1].c_str()); | 
|---|
| 257 | if(nvar<=0 || nvar>=10000) | 
|---|
| 258 | {cout<<"newnt name nvar : nvar must be an positive integer<10000"<<endl; | 
|---|
| 259 | return(0);} | 
|---|
| 260 | for(int i=0;i<nvar;i++) { | 
|---|
| 261 | char str[16]; sprintf(str,"%d",i); | 
|---|
| 262 | string dum = "v"; dum += str; | 
|---|
| 263 | varname.push_back(dum.c_str()); | 
|---|
| 264 | } | 
|---|
| 265 | } else if( islower(c[0]) || isupper(c[0]) ) { | 
|---|
| 266 | for(int i=1;i<(int)tokens.size();i++) { | 
|---|
| 267 | varname.push_back(tokens[i].c_str()); | 
|---|
| 268 | nvar++; | 
|---|
| 269 | } | 
|---|
| 270 | } else { | 
|---|
| 271 | cout<<"newnt name v1 v2 ... vn : name vi must begin by a letter"<<endl | 
|---|
| 272 | <<"newnt name nvar : nvar must be an positive integer"<<endl; | 
|---|
| 273 | return(0); | 
|---|
| 274 | } | 
|---|
| 275 | char **noms = new char*[nvar]; | 
|---|
| 276 | for(int i=0;i<nvar;i++) noms[i] = (char *)varname[i].c_str(); | 
|---|
| 277 | NTuple* nt = new NTuple(nvar,noms); | 
|---|
| 278 | delete [] noms; | 
|---|
| 279 | mObjMgr->AddObj(nt,tokens[0]); | 
|---|
| 280 | } | 
|---|
| 281 |  | 
|---|
| 282 | // Creation de DataTable | 
|---|
| 283 | else if (kw == "newdt") { | 
|---|
| 284 | if(tokens.size() < 2) | 
|---|
| 285 | {cout<<"Usage: newdt name v1:t1 v2:t2 ... vn:tn / newdt name nvar"<<endl; return(0);} | 
|---|
| 286 | DataTable* dt = new DataTable(); | 
|---|
| 287 | const char *c = tokens[1].c_str(); | 
|---|
| 288 | if(isdigit(c[0])) { | 
|---|
| 289 | int n = atoi(tokens[1].c_str()); | 
|---|
| 290 | if(n<=0 || n>=10000) { | 
|---|
| 291 | cout<<"newdt name nvar : nvar="<<n<<" must be an positive integer<10000"<<endl; | 
|---|
| 292 | delete dt; return(0); | 
|---|
| 293 | } | 
|---|
| 294 | for(int i=0;i<n;i++) { | 
|---|
| 295 | char str[16]; sprintf(str,"v%d",i); | 
|---|
| 296 | dt->AddDoubleColumn(str); | 
|---|
| 297 | } | 
|---|
| 298 | } else { | 
|---|
| 299 | for(int i=1;i<tokens.size();i++) { | 
|---|
| 300 | string vname = tokens[i]; | 
|---|
| 301 | uint_4 p = tokens[i].find(':'); | 
|---|
| 302 | if(p<tokens[i].size()) vname = vname.substr(0,p); | 
|---|
| 303 | if(vname.size()<1) { | 
|---|
| 304 | cout<<"Zero size name for variable: tokens["<<i<<"]="<<tokens[i]<<endl; | 
|---|
| 305 | delete dt; return(0); | 
|---|
| 306 | } | 
|---|
| 307 | if     (tokens[i].find(":r4")<tokens[i].size()) dt->AddFloatColumn(vname); | 
|---|
| 308 | else if(tokens[i].find(":r8")<tokens[i].size()) dt->AddDoubleColumn(vname); | 
|---|
| 309 | else if(tokens[i].find(":i4")<tokens[i].size()) dt->AddIntegerColumn(vname); | 
|---|
| 310 | else if(tokens[i].find(":i8")<tokens[i].size()) dt->AddLongColumn(vname); | 
|---|
| 311 | else if(tokens[i].find(":s") <tokens[i].size()) dt->AddStringColumn(vname); | 
|---|
| 312 | else                                            dt->AddDoubleColumn(vname); | 
|---|
| 313 | } | 
|---|
| 314 | } | 
|---|
| 315 | mObjMgr->AddObj(dt,tokens[0]); | 
|---|
| 316 | } | 
|---|
| 317 |  | 
|---|
| 318 | // Creation de GeneralFitData | 
|---|
| 319 | else if (kw == "newgfd") { | 
|---|
| 320 | if (tokens.size() < 3) | 
|---|
| 321 | { cout << "Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); } | 
|---|
| 322 | int nvar, nalloc, errx=0; | 
|---|
| 323 | if (tokens.size() > 3) | 
|---|
| 324 | { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;} | 
|---|
| 325 | nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str()); | 
|---|
| 326 | if(nvar>0 && nalloc>0) { | 
|---|
| 327 | GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx); | 
|---|
| 328 | mObjMgr->AddObj(gfd, tokens[0]); | 
|---|
| 329 | } | 
|---|
| 330 | } | 
|---|
| 331 |  | 
|---|
| 332 | // Creation/remplissage de vecteur et de matrice | 
|---|
| 333 | else if (kw == "newvec") { | 
|---|
| 334 | if (tokens.size() < 2) { | 
|---|
| 335 | cout << "Usage: newvec name size [f(i) dopt] " << endl; return(0); | 
|---|
| 336 | } | 
|---|
| 337 | int n = atoi(tokens[1].c_str()); | 
|---|
| 338 | double xmin, xmax; | 
|---|
| 339 | xmin = 0.;  xmax = n; | 
|---|
| 340 | if (tokens.size() < 3)  { | 
|---|
| 341 | Vector* v = new Vector(n); | 
|---|
| 342 | mObjMgr->AddObj(v, tokens[0]); | 
|---|
| 343 | } | 
|---|
| 344 | else { | 
|---|
| 345 | if (tokens.size() < 4)  tokens.push_back(""); | 
|---|
| 346 | mObjMgr->GetServiceObj()->PlotFunc(tokens[2], tokens[0], xmin, xmax, n, tokens[3]); | 
|---|
| 347 | } | 
|---|
| 348 | } | 
|---|
| 349 | else if (kw == "newmtx") { | 
|---|
| 350 | if (tokens.size() < 3) { | 
|---|
| 351 | cout << "Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) dopt] " << endl; return(0); | 
|---|
| 352 | } | 
|---|
| 353 | int nx = atoi(tokens[1].c_str()); | 
|---|
| 354 | int ny = atoi(tokens[2].c_str()); | 
|---|
| 355 | double xmin, xmax, ymin, ymax; | 
|---|
| 356 | xmin = 0.;  xmax = nx; | 
|---|
| 357 | ymin = 0.;  ymax = ny; | 
|---|
| 358 | if (tokens.size() < 4)  { | 
|---|
| 359 | Matrix* mtx = new Matrix(ny,nx); | 
|---|
| 360 | mObjMgr->AddObj(mtx, tokens[0]); | 
|---|
| 361 | } | 
|---|
| 362 | else { | 
|---|
| 363 | if (tokens.size() < 5)  tokens.push_back("next"); | 
|---|
| 364 | mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax, | 
|---|
| 365 | nx, ny, tokens[4]); | 
|---|
| 366 | } | 
|---|
| 367 | } | 
|---|
| 368 | // ----- Vecteur/NTuple <> Lignes/variables interpreteur | 
|---|
| 369 | // Creation de vecteur depuis le contenu de la ligne | 
|---|
| 370 | else if (kw == "line2vec") { | 
|---|
| 371 | if (tokens.size() < 2) { | 
|---|
| 372 | cout << "Usage: line2vec vecname v0 v1 v2 ... " << endl; return(0); | 
|---|
| 373 | } | 
|---|
| 374 | int vsz = tokens.size()-1; | 
|---|
| 375 | Vector* v = new Vector(vsz); | 
|---|
| 376 | for(int kkv=0; kkv<vsz; kkv++)  (*v)(kkv) = atof(tokens[kkv+1].c_str()); | 
|---|
| 377 | mObjMgr->AddObj(v, tokens[0]); | 
|---|
| 378 | } | 
|---|
| 379 | // Remplissage de NTuple depuis la ligne | 
|---|
| 380 | else if (kw == "line2nt") { | 
|---|
| 381 | if (tokens.size() < 2) { | 
|---|
| 382 | cout << "Usage: line2nt ntname col0 col1 ..." << endl; return(0); | 
|---|
| 383 | } | 
|---|
| 384 | AnyDataObj* obj; | 
|---|
| 385 | obj = mObjMgr->GetObj(tokens[0]); | 
|---|
| 386 | if(obj == NULL) { | 
|---|
| 387 | cerr << "line2nt Error , No such object " << tokens[0] << endl; | 
|---|
| 388 | return(0); | 
|---|
| 389 | } | 
|---|
| 390 | NTuple* nt = dynamic_cast<NTuple *>(obj); | 
|---|
| 391 | if(nt == NULL) { | 
|---|
| 392 | cerr << "line2nt Error " << tokens[0] << " not an NTuple ! " << endl; | 
|---|
| 393 | return(0); | 
|---|
| 394 | } | 
|---|
| 395 | if (nt->NbColumns() < 1) { | 
|---|
| 396 | cerr << "line2nt Error: NbColumns  < 1" << endl; | 
|---|
| 397 | return(0); | 
|---|
| 398 | } | 
|---|
| 399 | r_4* xnt = new r_4[ nt->NbColumns() ]; | 
|---|
| 400 | int kkx; | 
|---|
| 401 | for(kkx=0; kkx<nt->NbColumns(); kkx++) { | 
|---|
| 402 | if (kkx < tokens.size()-1)  xnt[kkx] = atof(tokens[kkx+1].c_str()); | 
|---|
| 403 | else xnt[kkx] = 0.; | 
|---|
| 404 | } | 
|---|
| 405 | nt->Fill(xnt); | 
|---|
| 406 | delete[] xnt; | 
|---|
| 407 | } | 
|---|
| 408 | // Contenu du vecteur vers variable interpreteur | 
|---|
| 409 | #define MAXNWORDSO2V 32768 | 
|---|
| 410 | else if (kw == "vec2var") { | 
|---|
| 411 | if (tokens.size() < 2) { | 
|---|
| 412 | cout << "Usage: vec2var vecname varname [loop_param start:end:step] " << endl; return(0); | 
|---|
| 413 | } | 
|---|
| 414 | AnyDataObj* obj; | 
|---|
| 415 | obj = mObjMgr->GetObj(tokens[0]); | 
|---|
| 416 | if(obj == NULL) { | 
|---|
| 417 | cerr << "vec2var Error , No such object " << tokens[0] << endl; | 
|---|
| 418 | return(0); | 
|---|
| 419 | } | 
|---|
| 420 | Vector* v = dynamic_cast<Vector *>(obj); | 
|---|
| 421 | if(v == NULL) { | 
|---|
| 422 | cerr << "vec2var Error " << tokens[0] << " not a Vector ! " << endl; | 
|---|
| 423 | return(0); | 
|---|
| 424 | } | 
|---|
| 425 | int_8 kks = 0; | 
|---|
| 426 | int_8 kke = v->NElts(); | 
|---|
| 427 | int_8 kkp = 1; | 
|---|
| 428 | if (tokens.size() > 2) Services2NObjMgr::DecodeLoopParameters(tokens[2], kks, kke, kkp); | 
|---|
| 429 | if (kks < 0)  kks = 0; | 
|---|
| 430 | if (kke > (int_8)v->NElts()) kke = v->NElts(); | 
|---|
| 431 | if (kkp < 1) kkp = 1; | 
|---|
| 432 | int nelt = (kke-kks-1)/kkp; | 
|---|
| 433 | if (nelt > MAXNWORDSO2V) { | 
|---|
| 434 | nelt = MAXNWORDSO2V; | 
|---|
| 435 | cout << "vec2var Warning:  Only " << nelt | 
|---|
| 436 | << " elements  will be converted to string" << endl; | 
|---|
| 437 | kke = kks+nelt*kkp; | 
|---|
| 438 | } | 
|---|
| 439 | string v2str; | 
|---|
| 440 | char buff[64]; | 
|---|
| 441 | for(int kkv=kks; kkv<kke; kkv+=kkp) { | 
|---|
| 442 | sprintf(buff, "%lg ", (*v)(kkv)); | 
|---|
| 443 | v2str += buff; | 
|---|
| 444 | } | 
|---|
| 445 |  | 
|---|
| 446 | mpiac->SetVar(tokens[1], v2str); | 
|---|
| 447 | } | 
|---|
| 448 | // Une ligne du NTuple/NTupleInterface -> variable interpreteur | 
|---|
| 449 | else if ((kw == "ntline2var") || (kw == "ntcol2var")) { | 
|---|
| 450 | if (tokens.size() < 3) { | 
|---|
| 451 | cout << "Usage: ntline/col2var objname line_number varname" << endl; | 
|---|
| 452 | return(0); | 
|---|
| 453 | } | 
|---|
| 454 | NObjMgrAdapter* oa = mObjMgr->GetObjAdapter(tokens[0]); | 
|---|
| 455 | if(oa == NULL) { | 
|---|
| 456 | cerr << "ntline/col2var Error , No such object " << tokens[0] << endl; | 
|---|
| 457 | return(0); | 
|---|
| 458 | } | 
|---|
| 459 | bool adel = false; | 
|---|
| 460 | NTupleInterface* nti = oa->GetNTupleInterface(adel); | 
|---|
| 461 | if(nti == NULL) { | 
|---|
| 462 | cerr << "ntline/col2var Error: objet" << tokens[0] << " has no NTupleInterface" << endl; | 
|---|
| 463 | return(0); | 
|---|
| 464 | } | 
|---|
| 465 |  | 
|---|
| 466 | if (nti->NbColumns() < 1 || nti->NbLines() < 1) { | 
|---|
| 467 | cerr << "ntline/col2var Error: NbColumns or NbLines < 1" << endl; | 
|---|
| 468 | return(0); | 
|---|
| 469 | } | 
|---|
| 470 | string v2str; | 
|---|
| 471 | char buff[64]; | 
|---|
| 472 | if (kw == "ntline2var") { | 
|---|
| 473 | int numline = atoi(tokens[1].c_str()); | 
|---|
| 474 | if ( (numline >= nti->NbLines()) || (numline < 0) )  { | 
|---|
| 475 | cerr << "ntline2var Error: numline" << tokens[1] << " out of bounds" << endl; | 
|---|
| 476 | return(0); | 
|---|
| 477 | } | 
|---|
| 478 | r_8* dline = nti->GetLineD(numline); | 
|---|
| 479 | for(int kkv=0; kkv<nti->NbColumns(); kkv++) { | 
|---|
| 480 | sprintf(buff, "%lg ", dline[kkv]); | 
|---|
| 481 | v2str += buff; | 
|---|
| 482 | } | 
|---|
| 483 | } | 
|---|
| 484 | else { | 
|---|
| 485 | int numcol = atoi(tokens[1].c_str()); | 
|---|
| 486 | if ( (numcol >= nti->NbColumns()) || (numcol < 0) )  { | 
|---|
| 487 | cerr << "ntcol2var Error: numcol" << tokens[1] << " out of bounds" << endl; | 
|---|
| 488 | return(0); | 
|---|
| 489 | } | 
|---|
| 490 | int_8 kks = 0; | 
|---|
| 491 | int_8 kke = nti->NbLines(); | 
|---|
| 492 | int_8 kkp = 1; | 
|---|
| 493 | if (tokens.size() > 3) Services2NObjMgr::DecodeLoopParameters(tokens[3], kks, kke, kkp); | 
|---|
| 494 | if (kks < 0)  kks = 0; | 
|---|
| 495 | if (kke > (int_8)nti->NbLines()) kke = nti->NbLines(); | 
|---|
| 496 | if (kkp < 1) kkp = 1; | 
|---|
| 497 | int nelt = (kke-kks-1)/kkp; | 
|---|
| 498 | if (nelt > MAXNWORDSO2V) { | 
|---|
| 499 | nelt = MAXNWORDSO2V; | 
|---|
| 500 | cout << "ntcol2var Warning: Only " << nelt | 
|---|
| 501 | << " lines " << " will be converted to string" << endl; | 
|---|
| 502 | kke = kks+nelt*kkp; | 
|---|
| 503 | } | 
|---|
| 504 | r_8* dline; | 
|---|
| 505 | for(int kkl=kks; kkl<kke; kkl+=kkp) { | 
|---|
| 506 | dline = nti->GetLineD(kkl); | 
|---|
| 507 | sprintf(buff, "%lg ", dline[numcol]); | 
|---|
| 508 | v2str += buff; | 
|---|
| 509 | } | 
|---|
| 510 | } | 
|---|
| 511 | mpiac->SetVar(tokens[2], v2str); | 
|---|
| 512 | if (adel) delete nti; | 
|---|
| 513 | } | 
|---|
| 514 | // Operation sur objets a travers l'adaptateur NObjMgrAdapter::PerformOperation() | 
|---|
| 515 | else if (kw == "objaoper") { | 
|---|
| 516 | if (tokens.size() < 2) { | 
|---|
| 517 | cout << "Usage: objaoper objname operation [args ...]" << endl; | 
|---|
| 518 | return(0); | 
|---|
| 519 | } | 
|---|
| 520 | NObjMgrAdapter* oa = mObjMgr->GetObjAdapter(tokens[0]); | 
|---|
| 521 | if(oa == NULL) { | 
|---|
| 522 | cerr << "objaoper Error , No such object " << tokens[0] << endl; | 
|---|
| 523 | return(0); | 
|---|
| 524 | } | 
|---|
| 525 | tokens.erase(tokens.begin()); | 
|---|
| 526 | return oa->PerformOperation(tokens); | 
|---|
| 527 | } | 
|---|
| 528 |  | 
|---|
| 529 | // ------------------------------------------------------- | 
|---|
| 530 | // Copie d'objets | 
|---|
| 531 | else if ( (kw == "copy") || (kw == "cp") ) { | 
|---|
| 532 | if(tokens.size()<2) { | 
|---|
| 533 | cout<<"Usage: copy name_from  name_to"<<endl;return(0); | 
|---|
| 534 | } | 
|---|
| 535 | mObjMgr->CopyObj(tokens[0],tokens[1]); | 
|---|
| 536 | } | 
|---|
| 537 |  | 
|---|
| 538 |  | 
|---|
| 539 | // >>>>>>>>>>>  Trace de fonctions | 
|---|
| 540 | else if ( (kw == "func") ) { | 
|---|
| 541 | if(tokens.size()<3) {cout<<"Usage: func f(x) xmin xmax [npt opt]"<<endl; return(0);} | 
|---|
| 542 | int np = 100; | 
|---|
| 543 | double xmin=0., xmax=1.; | 
|---|
| 544 | string opt = "", nom = ""; | 
|---|
| 545 | xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str()); | 
|---|
| 546 | if (tokens.size() > 3)  np = atoi(tokens[3].c_str()); | 
|---|
| 547 | if (tokens.size() > 4)  opt = tokens[4]; | 
|---|
| 548 | mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt); | 
|---|
| 549 | } | 
|---|
| 550 | else if ( (kw == "funcff") ) { | 
|---|
| 551 | if (tokens.size()<4) {cout<<"Usage: funcff C-filename f(x)-name xmin xmax [npt opt]"<<endl; return(0);} | 
|---|
| 552 | int np = 100; | 
|---|
| 553 | double xmin=0., xmax=1.; | 
|---|
| 554 | string opt = "", nom = ""; | 
|---|
| 555 | xmin = atof(tokens[2].c_str());  xmax = atof(tokens[3].c_str()); | 
|---|
| 556 | if(tokens.size()>4)  np = atoi(tokens[4].c_str()); | 
|---|
| 557 | if(tokens.size()>5)  opt = tokens[5]; | 
|---|
| 558 | mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt); | 
|---|
| 559 | } | 
|---|
| 560 | else if ( (kw == "func2d") ) { | 
|---|
| 561 | if (tokens.size() < 7) { | 
|---|
| 562 | cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [opt]" << endl; | 
|---|
| 563 | return(0); | 
|---|
| 564 | } | 
|---|
| 565 | int npx, npy; | 
|---|
| 566 | double xmin, xmax; | 
|---|
| 567 | double ymin, ymax; | 
|---|
| 568 | npx = npy = 50; | 
|---|
| 569 | xmin = 0.;  xmax = 1.; | 
|---|
| 570 | ymin = 0.;  ymax = 1.; | 
|---|
| 571 | npx = atoi(tokens[3].c_str()); | 
|---|
| 572 | npy = atoi(tokens[6].c_str()); | 
|---|
| 573 | xmin = atof(tokens[1].c_str());   xmax = atof(tokens[2].c_str()); | 
|---|
| 574 | ymin = atof(tokens[4].c_str());   ymax = atof(tokens[5].c_str()); | 
|---|
| 575 | string opt = ""; | 
|---|
| 576 | if (tokens.size() > 7)  opt = tokens[7]; | 
|---|
| 577 | string nom = ""; | 
|---|
| 578 | mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt); | 
|---|
| 579 | } | 
|---|
| 580 | else if ( (kw == "func2dff") ) { | 
|---|
| 581 | if (tokens.size() < 8) { | 
|---|
| 582 | cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty [opt]" << endl; | 
|---|
| 583 | return(0); | 
|---|
| 584 | } | 
|---|
| 585 | int npx, npy; | 
|---|
| 586 | double xmin, xmax; | 
|---|
| 587 | double ymin, ymax; | 
|---|
| 588 | npx = npy = 50; | 
|---|
| 589 | xmin = 0.;  xmax = 1.; | 
|---|
| 590 | ymin = 0.;  ymax = 1.; | 
|---|
| 591 | npx = atoi(tokens[4].c_str()); | 
|---|
| 592 | npy = atoi(tokens[7].c_str()); | 
|---|
| 593 | xmin = atof(tokens[2].c_str());   xmax = atof(tokens[3].c_str()); | 
|---|
| 594 | ymin = atof(tokens[5].c_str());   ymax = atof(tokens[6].c_str()); | 
|---|
| 595 | string opt = ""; | 
|---|
| 596 | if (tokens.size() > 8)  opt = tokens[8]; | 
|---|
| 597 | string nom = ""; | 
|---|
| 598 | mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt); | 
|---|
| 599 | } | 
|---|
| 600 |  | 
|---|
| 601 | // >>>>>>>>>>>  Trace d'expressions de N_Tuple, StarList, etc ... | 
|---|
| 602 | else if (kw == "plot2d" ) { | 
|---|
| 603 | if (tokens.size() < 3) { | 
|---|
| 604 | cout << "Usage: plot2d nameobj expx expy [expcut opt loop_par]" << endl; | 
|---|
| 605 | return(0); | 
|---|
| 606 | } | 
|---|
| 607 | string errx = ""; string erry = ""; | 
|---|
| 608 | if (tokens.size() < 4) tokens.push_back("1"); | 
|---|
| 609 | while (tokens.size() < 6) tokens.push_back(""); | 
|---|
| 610 | srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,tokens[3],tokens[4],tokens[5]); | 
|---|
| 611 | } | 
|---|
| 612 |  | 
|---|
| 613 | else if (kw == "plot2de" ) {  // Plot2D avec les erreurs | 
|---|
| 614 | if (tokens.size() < 5) { | 
|---|
| 615 | cout << "Usage: plot2de nameobj expx expy experrx experry [expcut opt loop_par]" << endl; | 
|---|
| 616 | return(0); | 
|---|
| 617 | } | 
|---|
| 618 | if (tokens.size() < 6) tokens.push_back("1"); | 
|---|
| 619 | while (tokens.size() < 8) tokens.push_back(""); | 
|---|
| 620 | srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4], | 
|---|
| 621 | tokens[5],tokens[6],tokens[7]); | 
|---|
| 622 | } | 
|---|
| 623 |  | 
|---|
| 624 | else if (kw == "plot2dw" ) {   // Plot2d avec poids | 
|---|
| 625 | if (tokens.size() < 4) { | 
|---|
| 626 | cout << "Usage: plot2dw nomobj expx expy expwt [expcut opt loop_par]" << endl; | 
|---|
| 627 | return(0); | 
|---|
| 628 | } | 
|---|
| 629 | if (tokens.size() < 5) tokens.push_back("1"); | 
|---|
| 630 | while (tokens.size() < 7) tokens.push_back(""); | 
|---|
| 631 | srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]); | 
|---|
| 632 | } | 
|---|
| 633 | else if (kw == "plot3d" ) { | 
|---|
| 634 | if (tokens.size() < 4) { | 
|---|
| 635 | cout << "Usage: plot3d nomobj expx expy expz [expcut opt loop_par]" << endl; | 
|---|
| 636 | return(0); | 
|---|
| 637 | } | 
|---|
| 638 | if (tokens.size() < 5) tokens.push_back("1"); | 
|---|
| 639 | while (tokens.size() < 7) tokens.push_back(""); | 
|---|
| 640 | srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]); | 
|---|
| 641 | } | 
|---|
| 642 | else if (kw == "plot3dw" ) { | 
|---|
| 643 | if (tokens.size() < 5) { | 
|---|
| 644 | cout << "Usage: plot3dw nomobj expx expy expz expwt [expcut opt loop_par]" << endl; | 
|---|
| 645 | return(0); | 
|---|
| 646 | } | 
|---|
| 647 | if (tokens.size() < 6) tokens.push_back("1"); | 
|---|
| 648 | while (tokens.size() < 8) tokens.push_back(""); | 
|---|
| 649 | srvo->DisplayPoints3DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], | 
|---|
| 650 | tokens[6], tokens[7]); | 
|---|
| 651 | } | 
|---|
| 652 |  | 
|---|
| 653 | else if (kw == "projh1d" ) { | 
|---|
| 654 | if (tokens.size() < 3) { | 
|---|
| 655 | cout << "Usage: projh1d nomh1 nomobj expx [expwt expcut opt loop_par]" << endl; | 
|---|
| 656 | return(0); | 
|---|
| 657 | } | 
|---|
| 658 | if (tokens.size() < 4) tokens.push_back("1."); | 
|---|
| 659 | if (tokens.size() < 5) tokens.push_back("1"); | 
|---|
| 660 | while (tokens.size() < 7) tokens.push_back(""); | 
|---|
| 661 | srvo->ProjectH1(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] ); | 
|---|
| 662 | } | 
|---|
| 663 |  | 
|---|
| 664 |  | 
|---|
| 665 | // Projection dans histogrammes | 
|---|
| 666 | else if (kw == "projh2d" ) { | 
|---|
| 667 | if (tokens.size() < 4) { | 
|---|
| 668 | cout << "Usage: projh2d nomh2 nomobj expx expy [expwt expcut opt loop_par]" << endl; | 
|---|
| 669 | return(0); | 
|---|
| 670 | } | 
|---|
| 671 | if (tokens.size() < 5) tokens.push_back("1."); | 
|---|
| 672 | if (tokens.size() < 6) tokens.push_back("1"); | 
|---|
| 673 | while (tokens.size() < 8) tokens.push_back(""); | 
|---|
| 674 | srvo->ProjectH2(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0], | 
|---|
| 675 | tokens[6], tokens[7] ); | 
|---|
| 676 | } | 
|---|
| 677 |  | 
|---|
| 678 | else if (kw == "projprof" ) { | 
|---|
| 679 | if (tokens.size() < 4) { | 
|---|
| 680 | cout << "Usage: projprof nomprof nomobj expx expy [expwt expcut opt loop_par]" << endl; | 
|---|
| 681 | return(0); | 
|---|
| 682 | } | 
|---|
| 683 | if (tokens.size() < 5) tokens.push_back("1."); | 
|---|
| 684 | if (tokens.size() < 6) tokens.push_back("1"); | 
|---|
| 685 | while (tokens.size() < 8) tokens.push_back(""); | 
|---|
| 686 | srvo->ProjectHProf(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0], | 
|---|
| 687 | tokens[6], tokens[7] ); | 
|---|
| 688 | } | 
|---|
| 689 |  | 
|---|
| 690 | // Projection dans vector/matrix | 
|---|
| 691 | else if (kw == "fillvec" ) { | 
|---|
| 692 | if (tokens.size() < 4) { | 
|---|
| 693 | cout << "Usage: fillvec nomvec nomobj expx expv [expcut opt loop_par]" << endl; | 
|---|
| 694 | return(0); | 
|---|
| 695 | } | 
|---|
| 696 | if (tokens.size() < 5) tokens.push_back("1"); | 
|---|
| 697 | while (tokens.size() < 7) tokens.push_back(""); | 
|---|
| 698 | srvo->FillVect(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] ); | 
|---|
| 699 | } | 
|---|
| 700 |  | 
|---|
| 701 | else if (kw == "fillmtx" ) { | 
|---|
| 702 | if (tokens.size() < 5) { | 
|---|
| 703 | cout << "Usage: fillmtx nommtx nomobj expx expy expv [expcut opt loop_par]" << endl; | 
|---|
| 704 | return(0); | 
|---|
| 705 | } | 
|---|
| 706 | if (tokens.size() < 6) tokens.push_back("1"); | 
|---|
| 707 | while (tokens.size() < 8) tokens.push_back(""); | 
|---|
| 708 | srvo->FillMatx(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0], | 
|---|
| 709 | tokens[6], tokens[7] ); | 
|---|
| 710 | } | 
|---|
| 711 |  | 
|---|
| 712 | // Remplissage NTuple,Vecteurs, ... , boucle de NTuple | 
|---|
| 713 | else if (kw == "ntfrascii" ) { | 
|---|
| 714 | if(tokens.size() < 2) { | 
|---|
| 715 | cout<<"Usage: ntfrascii nt_name file_name [def_init_val]"<<endl; | 
|---|
| 716 | return(0); | 
|---|
| 717 | } | 
|---|
| 718 | double def_val = 0.; | 
|---|
| 719 | if(tokens.size()>=3) def_val = atof(tokens[2].c_str()); | 
|---|
| 720 | srvo->NtFromASCIIFile(tokens[0],tokens[1],def_val); | 
|---|
| 721 | } | 
|---|
| 722 |  | 
|---|
| 723 | #ifndef SANS_EVOLPLANCK | 
|---|
| 724 | /* Lecture matrice/vecteur depuis fichier ASCII  */ | 
|---|
| 725 | else if ((kw == "mtxfrascii") || (kw == "vecfrascii") ) { | 
|---|
| 726 | if(tokens.size() < 2) { | 
|---|
| 727 | cout<<"Usage: mtxfrascii/vecfrascii mtx/vec_name file_name [CommLine Separator]"<<endl; | 
|---|
| 728 | return(0); | 
|---|
| 729 | } | 
|---|
| 730 | TMatrix<r_8> mtx; | 
|---|
| 731 | TVector<r_8> vec; | 
|---|
| 732 | FILE* fip = fopen(tokens[1].c_str(), "r"); | 
|---|
| 733 | if (fip == NULL) { | 
|---|
| 734 | cout << "vec/mtxfrascii: can not open file " << tokens[1] << endl; | 
|---|
| 735 | return(0); | 
|---|
| 736 | } | 
|---|
| 737 | fclose(fip); | 
|---|
| 738 | ifstream is(tokens[1].c_str()); | 
|---|
| 739 | sa_size_t nr, nc; | 
|---|
| 740 | char clm = '#'; | 
|---|
| 741 | string sep = " \t"; | 
|---|
| 742 | if (tokens.size()>2) clm = tokens[2][0]; | 
|---|
| 743 | if (tokens.size()>3) sep = tokens[3]; | 
|---|
| 744 | if (kw == "mtxfrascii") { | 
|---|
| 745 | mtx.ReadASCII(is, nr, nc, clm, sep.c_str()); | 
|---|
| 746 | mObjMgr->AddObj(mtx, tokens[0]); | 
|---|
| 747 | cout << "mtxfrascii: TMatrix<r_8> " << tokens[0] << " read from file " | 
|---|
| 748 | << tokens[1] << endl; | 
|---|
| 749 | } | 
|---|
| 750 | else { | 
|---|
| 751 | vec.ReadASCII(is, nr, nc, clm, sep.c_str()); | 
|---|
| 752 | mObjMgr->AddObj(vec, tokens[0]); | 
|---|
| 753 | cout << "vecfrascii: TVector<r_8> " << tokens[0] << " read from file " | 
|---|
| 754 | << tokens[1] << endl; | 
|---|
| 755 | } | 
|---|
| 756 | } | 
|---|
| 757 | else if (kw == "arrtoascii")  { | 
|---|
| 758 | if(tokens.size() < 2) { | 
|---|
| 759 | cout<<"Usage: arrtoascii array_name file_name "<<endl; | 
|---|
| 760 | return(0); | 
|---|
| 761 | } | 
|---|
| 762 |  | 
|---|
| 763 | AnyDataObj* obj; | 
|---|
| 764 | obj = mObjMgr->GetObj(tokens[0]); | 
|---|
| 765 | if(obj == NULL) { | 
|---|
| 766 | cerr << "arrtoascii Error , No such object " << tokens[0] << endl; | 
|---|
| 767 | return(0); | 
|---|
| 768 | } | 
|---|
| 769 | BaseArray* ba = dynamic_cast<BaseArray *>(obj); | 
|---|
| 770 | if(ba == NULL) { | 
|---|
| 771 | cerr << "arrtoascii Error " << tokens[0] << " not a BaseArray ! " << endl; | 
|---|
| 772 | return(0); | 
|---|
| 773 | } | 
|---|
| 774 | ofstream os(tokens[1].c_str()); | 
|---|
| 775 | ba->WriteASCII(os); | 
|---|
| 776 | cout << "arrtoascii: Array " << tokens[0] << " written to file " << tokens[1] << endl; | 
|---|
| 777 | } | 
|---|
| 778 |  | 
|---|
| 779 | #endif | 
|---|
| 780 |  | 
|---|
| 781 | else if (kw == "fillnt" ) { | 
|---|
| 782 | if (tokens.size() < 5) { | 
|---|
| 783 | cout << "Usage: fillnt nameobj expx expy expz expt [expcut ntname loop_par]" << endl; | 
|---|
| 784 | return(0); | 
|---|
| 785 | } | 
|---|
| 786 | while (tokens.size() < 8) tokens.push_back(""); | 
|---|
| 787 | srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], tokens[7] ); | 
|---|
| 788 | } | 
|---|
| 789 |  | 
|---|
| 790 | else if (kw == "ntloop" ) { | 
|---|
| 791 | if (tokens.size() < 3) { | 
|---|
| 792 | cout << "Usage: ntloop nameobj fname funcname [ntname loop_par ]" << endl; | 
|---|
| 793 | return(0); | 
|---|
| 794 | } | 
|---|
| 795 | while (tokens.size() < 5) tokens.push_back(""); | 
|---|
| 796 | srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], tokens[4]); | 
|---|
| 797 | } | 
|---|
| 798 |  | 
|---|
| 799 | else if (kw == "ntexpcfile" ) { | 
|---|
| 800 | if (tokens.size() < 3) { | 
|---|
| 801 | cout << "Usage: ntexpcfile nameobj fname funcname" << endl; | 
|---|
| 802 | return(0); | 
|---|
| 803 | } | 
|---|
| 804 | srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]); | 
|---|
| 805 | } | 
|---|
| 806 |  | 
|---|
| 807 | else if (kw == "expmeansig" ) { | 
|---|
| 808 | if (tokens.size() < 2) { | 
|---|
| 809 | cout << "Usage: expmeansig nameobj expx [expcut loop_par]" << endl; | 
|---|
| 810 | return(0); | 
|---|
| 811 | } | 
|---|
| 812 | while (tokens.size() < 4) tokens.push_back(""); | 
|---|
| 813 | string dummy = ""; | 
|---|
| 814 | cout << " expmeansig: computing mean/sigma + min/max for " << tokens[0] | 
|---|
| 815 | << "." << tokens[1] << endl; | 
|---|
| 816 | srvo->ExpressionToVector(tokens[0],tokens[1],tokens[2],dummy,dummy,tokens[3]); | 
|---|
| 817 | } | 
|---|
| 818 |  | 
|---|
| 819 | else if (kw == "exptovec" ) { | 
|---|
| 820 | if (tokens.size() < 3) { | 
|---|
| 821 | cout << "Usage: exptovec nomvec nameobj expx [expcut opt loop_par]" << endl; | 
|---|
| 822 | return(0); | 
|---|
| 823 | } | 
|---|
| 824 | while (tokens.size() < 6) tokens.push_back(""); | 
|---|
| 825 | srvo->ExpressionToVector(tokens[1],tokens[2],tokens[3],tokens[0],tokens[4],tokens[5]); | 
|---|
| 826 | } | 
|---|
| 827 |  | 
|---|
| 828 | else if (kw == "fillgd1" ) { | 
|---|
| 829 | if (tokens.size() < 5) { | 
|---|
| 830 | cout << "Usage: fillgd1 nomgfd nomobj expx expy experry [expcut loop_par] " << endl; | 
|---|
| 831 | return(0); | 
|---|
| 832 | } | 
|---|
| 833 | if (tokens.size() < 6) tokens.push_back("1"); | 
|---|
| 834 | if (tokens.size() < 7) tokens.push_back(""); | 
|---|
| 835 | string expy = ""; | 
|---|
| 836 | srvo->FillGFD(tokens[1],tokens[2], expy, tokens[3], tokens[4], tokens[5], tokens[0]); | 
|---|
| 837 | } | 
|---|
| 838 |  | 
|---|
| 839 | else if (kw == "fillgd2" ) { | 
|---|
| 840 | if (tokens.size() < 6) { | 
|---|
| 841 | cout << "Usage: fillgd2 nomgfd nomobj expx expy expz experrz [expcut loop_par]" << endl; | 
|---|
| 842 | return(0); | 
|---|
| 843 | } | 
|---|
| 844 | if (tokens.size() < 7) tokens.push_back("1"); | 
|---|
| 845 | if (tokens.size() < 8) tokens.push_back(""); | 
|---|
| 846 | srvo->FillGFD(tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6], tokens[0], tokens[7]); | 
|---|
| 847 | } | 
|---|
| 848 |  | 
|---|
| 849 | else if (kw == "gdfrvec" ) { | 
|---|
| 850 | if(tokens.size()<3) { | 
|---|
| 851 | cout<<"Usage: gdfrvec namegfd X Y\n" | 
|---|
| 852 | <<"       gdfrvec namegfd X Y" | 
|---|
| 853 | <<"       gdfrvec namegfd X Y ! EY\n" | 
|---|
| 854 | <<"       gdfrvec namegfd X Y Z\n" | 
|---|
| 855 | <<"       gdfrvec namegfd X Y Z EZ"<<endl; | 
|---|
| 856 | return(0); | 
|---|
| 857 | } | 
|---|
| 858 | while(tokens.size()<5) tokens.push_back("!"); | 
|---|
| 859 | srvo->FillGFDfrVec(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4]); | 
|---|
| 860 | } | 
|---|
| 861 |  | 
|---|
| 862 | // >>>>>>>>>>>  Calcul d'expression arithmetique | 
|---|
| 863 | else if ( (kw == "eval") ) { | 
|---|
| 864 | if(tokens.size()<2) | 
|---|
| 865 | {cout<<"Usage: eval resultvarname arithmetic expression...."<<endl; return(0);} | 
|---|
| 866 | string expval = ""; | 
|---|
| 867 | for(unsigned int i=1;i<tokens.size();i++) expval+=tokens[i]; | 
|---|
| 868 | string resultvarname = ""; | 
|---|
| 869 | if(isalpha(tokens[0][0])) resultvarname=tokens[0]; | 
|---|
| 870 | mObjMgr->GetServiceObj()->ExpVal(expval,resultvarname); | 
|---|
| 871 | } | 
|---|
| 872 |  | 
|---|
| 873 | else  { | 
|---|
| 874 | cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl; | 
|---|
| 875 | return(-1); | 
|---|
| 876 | } | 
|---|
| 877 |  | 
|---|
| 878 | return(0); | 
|---|
| 879 | } | 
|---|
| 880 |  | 
|---|
| 881 | /* --Methode-- */ | 
|---|
| 882 | bool PIABaseExecutor::IsThreadable(string const & keyw) | 
|---|
| 883 | { | 
|---|
| 884 | if ( (keyw == "fillvec") || (keyw == "fillmtx") || | 
|---|
| 885 | (keyw == "fillnt") || (keyw == "ntloop") )  return true; | 
|---|
| 886 | else if (keyw.substr(0,4) == "func")  return true; | 
|---|
| 887 | else { | 
|---|
| 888 | string skw = keyw.substr(0,5); | 
|---|
| 889 | if ( (skw == "plot2") || (skw == "plot3") || (skw == "projh") )  return true; | 
|---|
| 890 | } | 
|---|
| 891 | return false; | 
|---|
| 892 | } | 
|---|
| 893 |  | 
|---|
| 894 |  | 
|---|
| 895 | /* --Methode-- */ | 
|---|
| 896 | void PIABaseExecutor::RegisterCommands() | 
|---|
| 897 | { | 
|---|
| 898 | string kw, usage, grp; | 
|---|
| 899 | //--------- Commandes du groupe modules externes | 
|---|
| 900 | grp = "External Modules"; | 
|---|
| 901 | string gdesc = "Dynamic load (shared object modules) management command group"; | 
|---|
| 902 | mpiac->AddHelpGroup(grp, gdesc); | 
|---|
| 903 | kw = "loadmodule"; | 
|---|
| 904 | usage = "To load and initialize modules \n  Usage: loadmodule fnameso modulename"; | 
|---|
| 905 | usage += "\n  Related commands: link"; | 
|---|
| 906 | mpiac->RegisterCommand(kw, usage, this, grp); | 
|---|
| 907 | kw = "link"; | 
|---|
| 908 | usage = "Dynamic linking of compiled user functions \n  Usage: link fnameso f1 [f2 f3]"; | 
|---|
| 909 | usage += "\n  fnameso: Shared-object file name, f1,f2,f3 : User function names "; | 
|---|
| 910 | usage += "\n  Related commands: call loadmodule linkff2"; | 
|---|
| 911 | mpiac->RegisterCommand(kw, usage, this, grp); | 
|---|
| 912 | kw = "linkff2"; | 
|---|
| 913 | usage = "Dynamic linking of compiled user functions (Set 2)\n  Usage: linkff2 fnameso f1 [f2 f3]"; | 
|---|
| 914 | usage += "\n  fnameso: Shared-object file name, f1,f2,f3 : User function names "; | 
|---|
| 915 | usage += "\n  Related commands: call link loadmodule"; | 
|---|
| 916 | mpiac->RegisterCommand(kw, usage, this, grp); | 
|---|
| 917 | kw = "call"; | 
|---|
| 918 | usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]"; | 
|---|
| 919 | usage += "\n  User function : f(vector<string>& args)"; | 
|---|
| 920 | usage += "\n  Related commands: link"; | 
|---|
| 921 | mpiac->RegisterCommand(kw, usage, this, grp); | 
|---|
| 922 |  | 
|---|
| 923 | kw = "openppf"; | 
|---|
| 924 | usage = "Reads all or some objects from a PPF file \n Usage: openppf filename [objname1 objname2 ...]"; | 
|---|
| 925 | usage += "\n  Related commands: saveall "; | 
|---|
| 926 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 927 | kw = "saveppf"; | 
|---|
| 928 | usage = "Saves objects with names matching a pattern into a\n"; | 
|---|
| 929 | usage += "  PPF file (pattern: x?y*) - Alias saveppf\n"; | 
|---|
| 930 | usage += "Usage: saveppf nameobjpattern filename"; | 
|---|
| 931 | usage += "\n  Related commands: saveobjs savelist saveall openppf"; | 
|---|
| 932 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 933 | kw = "saveobjs"; | 
|---|
| 934 | usage = "Saves objects with names matching a pattern into a\n"; | 
|---|
| 935 | usage += "  PPF file (pattern: x?y*) - Alias saveppf\n"; | 
|---|
| 936 | usage += "Usage: saveobjs nameobjpattern filename"; | 
|---|
| 937 | usage += "\n  Related commands: saveppf savelist saveall openppf "; | 
|---|
| 938 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 939 | kw = "saveall"; | 
|---|
| 940 | usage = "Saves all objects into a PPF file \n Usage: saveall filename"; | 
|---|
| 941 | usage += "\n  Related commands: saveobj savelist openppf"; | 
|---|
| 942 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 943 | kw = "savelist"; | 
|---|
| 944 | usage = "Saves a list of objects into a PPF file"; | 
|---|
| 945 | usage = "\n Usage: savelist objname1 [objname2 ...] filename"; | 
|---|
| 946 | usage += "\n  Related commands: saveobj openppf"; | 
|---|
| 947 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 948 | kw = "ntfrascii"; | 
|---|
| 949 | usage = "Fills an existing NTuple or DataTable from ASCII table file"; | 
|---|
| 950 | usage += "\n Usage: ntfrascii nt_name file_name [def_init_val]"; | 
|---|
| 951 | usage += "\n  Related commands: ntloop fillnt "; | 
|---|
| 952 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 953 | #ifndef SANS_EVOLPLANCK | 
|---|
| 954 | kw = "mtxfrascii"; | 
|---|
| 955 | usage = "Reads a matrix from an ASCII file (TMatrix<r_8>)"; | 
|---|
| 956 | usage += "\n Usage: mtxfrascii mtx_name file_name [CommChar Separator]"; | 
|---|
| 957 | usage += "\n  Related commands: arrtoascii vecfrascii ntfrascii "; | 
|---|
| 958 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 959 | kw = "vecfrascii"; | 
|---|
| 960 | usage = "Reads a vector from an ASCII file (TVector<r_8>)"; | 
|---|
| 961 | usage += "\n Usage: vecfrascii vec_name file_name"; | 
|---|
| 962 | usage += "\n  Related commands: arrtoascii mtxfrascii ntfrascii [CommChar Separator]"; | 
|---|
| 963 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 964 | kw = "arrtoascii"; | 
|---|
| 965 | usage = "Writes an array (TArray<T>) to an ASCII file "; | 
|---|
| 966 | usage += "\n Usage: arrtoascii array_name file_name"; | 
|---|
| 967 | usage += "\n  Related commands:  mtxfrascii vecfrascii ntfrascii "; | 
|---|
| 968 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 969 | #endif | 
|---|
| 970 |  | 
|---|
| 971 | kw = "print"; | 
|---|
| 972 | usage = "Prints an object \n Usage: print nameobj [prtlev]"; | 
|---|
| 973 | usage += "\n prtlev = 0,1,2...  default: prtlev=0"; | 
|---|
| 974 | mpiac->RegisterCommand(kw, usage, this, "FileIO"); | 
|---|
| 975 |  | 
|---|
| 976 | //------- Commandes gestion de repertoires et d'objets | 
|---|
| 977 | kw = "mkdir"; | 
|---|
| 978 | usage = "Create a directory"; | 
|---|
| 979 | usage += "\n Usage: mkdir dirname [true]"; | 
|---|
| 980 | usage += "\n if second argument==true, the directory's KeepOld attribute is set to true"; | 
|---|
| 981 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 982 | kw = "rmdir"; | 
|---|
| 983 | usage = "Removes an empty directory"; | 
|---|
| 984 | usage += "\n Usage: remove dirname"; | 
|---|
| 985 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 986 | kw = "setdiratt"; | 
|---|
| 987 | usage = "Sets directory attributes"; | 
|---|
| 988 | usage += "\n Usage: setdiratt dirname KeepOldFlag(=true/false)"; | 
|---|
| 989 | usage += "\n   KeepOldFlag=true Object with the same name is moved to old"; | 
|---|
| 990 | usage += "\n   when adding objects"; | 
|---|
| 991 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 992 | kw = "cd"; | 
|---|
| 993 | usage = "Change current directory"; | 
|---|
| 994 | usage += "\n Usage: cd [dirname]"; | 
|---|
| 995 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 996 | kw = "pwd"; | 
|---|
| 997 | usage = "Prints current directory"; | 
|---|
| 998 | usage += "\n Usage: pwd"; | 
|---|
| 999 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1000 | kw = "listdirs"; | 
|---|
| 1001 | usage = "Prints the list of directories"; | 
|---|
| 1002 | usage += "\n Usage: listdirs [patt=*] \n patt : * , ? "; | 
|---|
| 1003 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1004 | kw = "listobjs"; | 
|---|
| 1005 | usage = "Prints the list of objects (Alias: ls)"; | 
|---|
| 1006 | usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... "; | 
|---|
| 1007 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1008 | kw = "rename"; | 
|---|
| 1009 | usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew"; | 
|---|
| 1010 | usage += "\n  Related commands: mv del delobjs"; | 
|---|
| 1011 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1012 | kw = "mv"; | 
|---|
| 1013 | usage = "Rename an object (Alias: rename) \n Usage: mv nameobj namenew"; | 
|---|
| 1014 | usage += "\n  Related commands: rename del delobjs"; | 
|---|
| 1015 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1016 | kw = "copy"; | 
|---|
| 1017 | usage = "Copy objects (Alias cp) \n"; | 
|---|
| 1018 | usage +="  Usage: copy name_from name_to"; | 
|---|
| 1019 | usage += "\n  Related commands: cp new..."; | 
|---|
| 1020 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1021 | kw = "cp"; | 
|---|
| 1022 | usage = "Copy objects (Alias copy) \n"; | 
|---|
| 1023 | usage +="  Usage: cp name_from name_to"; | 
|---|
| 1024 | usage += "\n  Related commands: copy new..."; | 
|---|
| 1025 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1026 | kw = "del"; | 
|---|
| 1027 | usage = "Deletes an object (Alias: rm) \n Usage: del nameobj [nameobj2 ...]"; | 
|---|
| 1028 | usage += "\n  Related commands: rm delobjs rename"; | 
|---|
| 1029 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1030 | kw = "rm"; | 
|---|
| 1031 | usage = "Deletes an object (Alias: del) \n Usage: rm nameobj [nameobj2 ...]"; | 
|---|
| 1032 | usage += "\n  Related commands: del delobjs rename"; | 
|---|
| 1033 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1034 | kw = "delobjs"; | 
|---|
| 1035 | usage = "Delete a set of objects with names matching a pattern (x?y*)"; | 
|---|
| 1036 | usage += "\n Usage: delobjs nameobjpattern \n"; | 
|---|
| 1037 | usage += "\n  Related commands: del rename"; | 
|---|
| 1038 | mpiac->RegisterCommand(kw, usage, this, "Object Management"); | 
|---|
| 1039 |  | 
|---|
| 1040 | //------- Commandes creation/manipulation d'objets | 
|---|
| 1041 | kw = "newh1d"; | 
|---|
| 1042 | usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin"; | 
|---|
| 1043 | usage += "\n  Related commands: newh2d  newprof[e] newdt newnt  newgfd "; | 
|---|
| 1044 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1045 | kw = "newh2d"; | 
|---|
| 1046 | usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny"; | 
|---|
| 1047 | usage += "\n  Related commands: newh1d  newprof[e] newdt newnt  newgfd "; | 
|---|
| 1048 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1049 | kw = "newprof"; | 
|---|
| 1050 | usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]"; | 
|---|
| 1051 | usage += "\n  Errors represent the data spread in the X bin "; | 
|---|
| 1052 | usage += "\n  Related commands: newh1d  newh2d newprofe newdt newnt newgfd "; | 
|---|
| 1053 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1054 | kw = "newprofe"; | 
|---|
| 1055 | usage = "Creates a profile histogramm \n Usage: newprofe name xmin xmax nbin [ymin ymax]"; | 
|---|
| 1056 | usage += "\n  Errors represent the error on the data mean in the X bin "; | 
|---|
| 1057 | usage += "\n  Related commands: newh1d  newh2d newprof newdt newnt newgfd "; | 
|---|
| 1058 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1059 | kw = "newnt"; | 
|---|
| 1060 | usage = "Creates a ntuple \n Usage: newnt name v1 v2 v3 .. vn"; | 
|---|
| 1061 | usage += "\n        newnt name nvar"; | 
|---|
| 1062 | usage += "\n  Related commands: newdt newh1d  newh2d newprof[e] newgfd "; | 
|---|
| 1063 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1064 | kw = "newdt"; | 
|---|
| 1065 | usage = "Creates a datatable \n Usage: newdt name v1:t1 v2:t2 v3:t3 .. vn:tn"; | 
|---|
| 1066 | usage += "\n        newdt name nvar"; | 
|---|
| 1067 | usage += "\n    vi : variable name"; | 
|---|
| 1068 | usage += "\n    ti : variable type"; | 
|---|
| 1069 | usage += "\n         r8,r4 for 8 and 4 bytes float"; | 
|---|
| 1070 | usage += "\n         i8,i4 for 8 and 4 bytes signed integer"; | 
|---|
| 1071 | usage += "\n         s for string"; | 
|---|
| 1072 | usage += "\n  Related commands: newnt newh1d  newh2d newprof[e] newgfd"; | 
|---|
| 1073 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1074 | kw = "newgfd"; | 
|---|
| 1075 | usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]"; | 
|---|
| 1076 | usage += "\n  Related commands: newh1d  newh2d  newprof[e] newdt newnt "; | 
|---|
| 1077 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1078 | kw = "newvec"; | 
|---|
| 1079 | usage = "Creates (and optionaly fills) a vector \n Usage: newvec name size [f(i) [dopt] ] "; | 
|---|
| 1080 | usage += "\n  Related commands: newmtx line2vec"; | 
|---|
| 1081 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1082 | kw = "newmtx"; | 
|---|
| 1083 | usage = "Creates (and optionaly fills) a matrix \n"; | 
|---|
| 1084 | usage +="  Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) [dopt] ] "; | 
|---|
| 1085 | usage += "\n  Related commands: newvec"; | 
|---|
| 1086 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1087 | kw = "line2vec"; | 
|---|
| 1088 | usage = "Creates a vector from the line \n"; | 
|---|
| 1089 | usage += "  Usage: line2vec vecname v0 v1 v2 ... \n"; | 
|---|
| 1090 | usage += "  Related commands: newvec line2nt"; | 
|---|
| 1091 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1092 | kw = "line2nt"; | 
|---|
| 1093 | usage = "Fills (append) an NTuple from the line content \n"; | 
|---|
| 1094 | usage += "  Usage: line2nt ntname col0 col1 ... \n"; | 
|---|
| 1095 | usage += "  Related commands: newnt line2vec ntline2var ntcol2var"; | 
|---|
| 1096 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1097 | kw = "vec2var"; | 
|---|
| 1098 | usage = "Vector content to an interpreter variable varname = 'v0 v1 v2 ...' \n"; | 
|---|
| 1099 | usage += "  Usage: line2vec vecname varname [LoopParam start:end[:step] ]\n"; | 
|---|
| 1100 | usage += "  Related commands: line2vec ntline2var"; | 
|---|
| 1101 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1102 | kw = "ntline2var"; | 
|---|
| 1103 | usage = "Object NTupleInterface line to an interpreter variable \n"; | 
|---|
| 1104 | usage += "  Usage: ntline2var objname line_number varname \n"; | 
|---|
| 1105 | usage += "  Related commands: vec2var ntcol2var"; | 
|---|
| 1106 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1107 | kw = "ntcol2var"; | 
|---|
| 1108 | usage = "Object NTupleInterface column to an interpreter variable \n"; | 
|---|
| 1109 | usage += "  Usage: ntline2var objname column_number varname [LoopParam start:end[:step] ] \n"; | 
|---|
| 1110 | usage += "  Related commands: vec2var ntline2var"; | 
|---|
| 1111 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1112 | kw = "objaoper"; | 
|---|
| 1113 | usage = "Perform an operation through the object adapter NObjMgrAdapter::PerformOperation()\n"; | 
|---|
| 1114 | usage += "  Usage: objaoper objname operation [arg1 ...] \n"; | 
|---|
| 1115 | usage += "  Examples of defined operations : \n"; | 
|---|
| 1116 | usage += "  Matrices: row indx_row , col indx_col \n"; | 
|---|
| 1117 | usage += "  Arrays: slicexy indx_Z , slicexz indx_Y, sliceyz indxX \n"; | 
|---|
| 1118 | mpiac->RegisterCommand(kw, usage, this, "Objects"); | 
|---|
| 1119 |  | 
|---|
| 1120 | //------- Commandes trace de fonctions | 
|---|
| 1121 | kw = "func"; | 
|---|
| 1122 | usage = "Displays a function y=f(x) (Fills a vector with function values)"; | 
|---|
| 1123 | usage += "\n Usage: func f(x) xmin xmax [npt graphic_attributes]"; | 
|---|
| 1124 | usage += "\n  Related commands: funcff func2d func2dff "; | 
|---|
| 1125 | mpiac->RegisterCommand(kw, usage, this, "Func Plot"); | 
|---|
| 1126 | kw = "funcff"; | 
|---|
| 1127 | usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)"; | 
|---|
| 1128 | usage += "\n Usage: funcff C-FileName FunctionName xmin xmax [npt graphic_attributes]"; | 
|---|
| 1129 | usage += "\n  Related commands: func func2d func2dff "; | 
|---|
| 1130 | mpiac->RegisterCommand(kw, usage, this, "Func Plot"); | 
|---|
| 1131 | kw = "func2d"; | 
|---|
| 1132 | usage = "Displays a function z=f(x,y) (Fills a matrix with function values)"; | 
|---|
| 1133 | usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]"; | 
|---|
| 1134 | usage += "\n  Related commands: func"; | 
|---|
| 1135 | mpiac->RegisterCommand(kw, usage, this, "Func Plot"); | 
|---|
| 1136 | kw = "func2dff"; | 
|---|
| 1137 | usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)"; | 
|---|
| 1138 | usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]"; | 
|---|
| 1139 | usage += "\n  Related commands: func funcff func2d "; | 
|---|
| 1140 | mpiac->RegisterCommand(kw, usage, this, "Func Plot"); | 
|---|
| 1141 |  | 
|---|
| 1142 | //------ Commandes trace d'expression | 
|---|
| 1143 | kw = "ObjectExpressions"; | 
|---|
| 1144 | usage = "Any mathematical expression (math.h) with object variables can be used"; | 
|---|
| 1145 | usage += "\n  ------ Object Variable names (double) -------- "; | 
|---|
| 1146 | usage += "\n  (_nl is the table line number or the sequential index)"; | 
|---|
| 1147 | usage += "\n- NTuple: ntuple variable names,_nl"; | 
|---|
| 1148 | usage += "\n- Histo1D/HProf/HistoErr: i,x,val,err,nb,_nl"; | 
|---|
| 1149 | usage += "\n- Histo2D: i,j,x,y,val,err,_nl"; | 
|---|
| 1150 | usage += "\n- Vector/Matrix: n,r,c,val,real,imag,mod,phas,_nl"; | 
|---|
| 1151 | usage += "\n- TArray: n,x,y,z,t,u,val,real,imag,mod,phas,_nl"; | 
|---|
| 1152 | usage += "\n- Image: i,j,x,y,val(=pix),_nl"; | 
|---|
| 1153 | usage += "\n- GeneralFitData: x0,ex0 x1,ex1 ...  xn,exn   y,ey   ok  ,_nl"; | 
|---|
| 1154 | usage += "\n- LocalMap/SphereThetaPhi/SphereHEALPix: "; | 
|---|
| 1155 | usage += "\n-         i,k,val,real,imag,mod,phas,teta,phi,_nl"; | 
|---|
| 1156 | usage += "\n- FITS Binary/ASCII table: fits column names,_nl"; | 
|---|
| 1157 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1158 | usage += "\n  ------ Eros Variable names (double) -------- "; | 
|---|
| 1159 | usage += "\n- StarList: x,y,flux,fond,pixmax,flags,"; | 
|---|
| 1160 | usage += "\n-           xref,yref,fluxref,fondref,pixmaxref,_nl"; | 
|---|
| 1161 | #endif | 
|---|
| 1162 | usage += "\n  ------ Other parameters -------- "; | 
|---|
| 1163 | usage += "\nLoop parameters can be specified as I1[:I2[:DI]] for(int i=I1; i<I2; i+=DI)"; | 
|---|
| 1164 | usage += "\nThe default Cut() expression in true (=1) for all"; | 
|---|
| 1165 | usage += "\n\n Related commands: plot2d plot2de plot2dw plot3d plot3dw"; | 
|---|
| 1166 | usage += "\n         projh1d projh2d  projprof fillvec fillmtx "; | 
|---|
| 1167 | usage += "\n         fillnt fillgd1 fillgd2 ntloop exptovec ... "; | 
|---|
| 1168 | grp = "Expr. Plotting"; | 
|---|
| 1169 | mpiac->RegisterHelp(kw, usage, grp); | 
|---|
| 1170 | kw = "plot2d"; | 
|---|
| 1171 | usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :"; | 
|---|
| 1172 | usage += "\n Usage: plot2d nameobj f_X() g_Y() [f_Cut() graphic_attributes loop_param]"; | 
|---|
| 1173 | usage += "\n  Related commands: plot2de plot2dw plot3d plot3dw ObjectExpressions ..."; | 
|---|
| 1174 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1175 | kw = "plot2de"; | 
|---|
| 1176 | usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with error bars eX/Y=f_ErrX/Y(Object) "; | 
|---|
| 1177 | usage += "\n Usage: plot2de nameobj f_X() g_Y() f_ErrX() f_ErrY() [f_Cut() graphic_attributes loop_param]"; | 
|---|
| 1178 | usage += "\n  Related commands: plot2d plot2dw plot3d ObjectExpressions ..."; | 
|---|
| 1179 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1180 | kw = "plot2dw"; | 
|---|
| 1181 | usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) "; | 
|---|
| 1182 | usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() [Cut() graphic_attributes loop_param]"; | 
|---|
| 1183 | usage += "\n  Related commands: plot2d plot2dw plot3d ObjectExpressions ..."; | 
|---|
| 1184 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1185 | kw = "plot3d"; | 
|---|
| 1186 | usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object)"; | 
|---|
| 1187 | usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() [Cut() graphic_attributes loop_param]"; | 
|---|
| 1188 | usage += "\n  Related commands: plot2d plot2de plot3dw ObjectExpressions ..."; | 
|---|
| 1189 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1190 | kw = "plot3dw"; | 
|---|
| 1191 | usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) with Weight W=k(Object)  "; | 
|---|
| 1192 | usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() k_Wt() [Cut() graphic_attributes loop_param]"; | 
|---|
| 1193 | usage += "\n  Related commands: plot2d plot2dw plot3d ObjectExpressions ..."; | 
|---|
| 1194 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1195 |  | 
|---|
| 1196 | kw = "projh1d"; | 
|---|
| 1197 | usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram "; | 
|---|
| 1198 | usage += "\n Usage: projh1d nameh1d nameobj f_X() [h_WT()=1. Cut() graphic_attributes loop_param]"; | 
|---|
| 1199 | usage += "\n   Histo1D nameh1d is created if necessary "; | 
|---|
| 1200 | usage += "\n  Related commands: projh2d projprof ObjectExpressions ..."; | 
|---|
| 1201 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1202 | kw = "projh2d"; | 
|---|
| 1203 | usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram "; | 
|---|
| 1204 | usage += "\n Usage: projh2d nameh2d nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]"; | 
|---|
| 1205 | usage += "\n   Histo2D nameh2d is created if necessary "; | 
|---|
| 1206 | usage += "\n  Related commands: projh1d projprof ObjectExpressions ..."; | 
|---|
| 1207 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1208 | kw = "projprof"; | 
|---|
| 1209 | usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram "; | 
|---|
| 1210 | usage += "\n Usage: projprof nameprof nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]"; | 
|---|
| 1211 | usage += "\n   HProf nameprof is created if necessary "; | 
|---|
| 1212 | usage += "\n  Related commands: projh1d projh2d ObjectExpressions ..."; | 
|---|
| 1213 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1214 | kw = "fillvec"; | 
|---|
| 1215 | usage = "Fills a Vector V((int)(f_X(Object)+0.5)) =  h_V(Object) "; | 
|---|
| 1216 | usage += "\n Usage: fillvec namevec nameobj f_X() h_V() [Cut() graphic_attributes loop_param]"; | 
|---|
| 1217 | usage += "\n  Related commands: fillmtx fillnt ObjectExpressions ..."; | 
|---|
| 1218 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1219 | kw = "fillmtx"; | 
|---|
| 1220 | usage = "Fills a Matrix M(Line=g_Y(Object)+0.5, Col=f_X(Object)+0.5)) =  h_V(Object) "; | 
|---|
| 1221 | usage += "\n Usage: fillvec namevec nameobj f_X() g_Y() h_V() [Cut() graphic_attributes loop_param]"; | 
|---|
| 1222 | usage += "\n  Related commands: fillvec fillnt ObjectExpressions ..."; | 
|---|
| 1223 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1224 |  | 
|---|
| 1225 | kw = "fillnt"; | 
|---|
| 1226 | usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))"; | 
|---|
| 1227 | usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() [Cut() nameNt loop_param]"; | 
|---|
| 1228 | usage += "\n  Related commands: ntloop plot2d projh1d projh2d projprof "; | 
|---|
| 1229 | usage += "\n  Related commands: fillvec fillmtx ntloop exptovec fillgd1 fillgd2 ObjectExpressions ..."; | 
|---|
| 1230 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1231 |  | 
|---|
| 1232 | kw = "ntloop"; | 
|---|
| 1233 | usage = "Loops over an Object NTupleInterface calling a function from a C-file \n"; | 
|---|
| 1234 | usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))"; | 
|---|
| 1235 | usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName loop_param]"; | 
|---|
| 1236 | usage += "\n  Related commands: fillvec fillmtx fillnt fillgd1 fillgd2 exptovec ObjectExpressions ..."; | 
|---|
| 1237 | usage += "\n  Related commands: ntexpcfile fillnt"; | 
|---|
| 1238 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1239 |  | 
|---|
| 1240 | kw = "ntexpcfile"; | 
|---|
| 1241 | usage = "Creates a C-File with declarations suitable to be used for ntloop"; | 
|---|
| 1242 | usage += "\n Usage: ntexpcfile nameobj CFileName FuncName "; | 
|---|
| 1243 | usage += "\n  Related commands: ntloop"; | 
|---|
| 1244 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1245 |  | 
|---|
| 1246 | kw = "expmeansig"; | 
|---|
| 1247 | usage = "Computes Mean/Sigma (+Min/Max) for an expression X=f(Object)"; | 
|---|
| 1248 | usage += "\n Usage: expmeansig nameobj f_X() [Cut() loop_param]"; | 
|---|
| 1249 | usage += "\n  Related commands: exptovec ntloop fillnt ObjectExpressions ..."; | 
|---|
| 1250 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1251 |  | 
|---|
| 1252 | kw = "exptovec"; | 
|---|
| 1253 | usage = "Creates and Fills a Vector with X=f(Object)"; | 
|---|
| 1254 | usage += "\n Usage: exptovec namevec nameobj f_X() [Cut() graphic_attributes loop_param]"; | 
|---|
| 1255 | usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; | 
|---|
| 1256 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1257 |  | 
|---|
| 1258 | kw = "fillgd1"; | 
|---|
| 1259 | usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))"; | 
|---|
| 1260 | usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_ErrY() [Cut() loop_param]"; | 
|---|
| 1261 | usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; | 
|---|
| 1262 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1263 | kw = "fillgd2"; | 
|---|
| 1264 | usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)"; | 
|---|
| 1265 | usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_Z() k_ErrZ() [Cut() loop_param]"; | 
|---|
| 1266 | usage += "\n  Related commands: ntloop fillnt ObjectExpressions ..."; | 
|---|
| 1267 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1268 | kw = "gdfrvec"; | 
|---|
| 1269 | usage = "Fills a GeneralFitData with vectors X,Y,Z,EZ"; | 
|---|
| 1270 | usage += "\n Usage: gdfrvec namegfd X Y"; | 
|---|
| 1271 | usage += "\n Usage: gdfrvec namegfd X Y ! EY"; | 
|---|
| 1272 | usage += "\n Usage: gdfrvec namegfd X Y Z"; | 
|---|
| 1273 | usage += "\n Usage: gdfrvec namegfd X Y Z EZ"; | 
|---|
| 1274 | usage += "\n  Related commands: fillgd1 fillgd2 ..."; | 
|---|
| 1275 | mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting"); | 
|---|
| 1276 |  | 
|---|
| 1277 |  | 
|---|
| 1278 | kw = "eval"; | 
|---|
| 1279 | usage = "Compute arithmetic expression\n"; | 
|---|
| 1280 | usage += "\n Usage: eval resultvarname arithmetic expression...."; | 
|---|
| 1281 | usage += "\n  resultvarname: store result in variable resultvarname"; | 
|---|
| 1282 | usage += "\n    - If first character is not alphabetic, just print result"; | 
|---|
| 1283 | usage += "\n  arithmetic expression:"; | 
|---|
| 1284 | usage += "\n      ex: x + sqrt(y)+z +3.14    (x,y,z are variables)"; | 
|---|
| 1285 | usage += "\n      ex: $x + sqrt($y)+$z +3.14 (x,y,z are variables)"; | 
|---|
| 1286 | usage += "\n      ex: 360 * M_PI / 180."; | 
|---|
| 1287 | mpiac->RegisterCommand(kw, usage, this, "Expr. Arithmetic"); | 
|---|
| 1288 |  | 
|---|
| 1289 | } | 
|---|
| 1290 |  | 
|---|
| 1291 | /* --Methode-- */ | 
|---|
| 1292 | int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3) | 
|---|
| 1293 | //                          string& func4, string& func5) | 
|---|
| 1294 | { | 
|---|
| 1295 | string cmd; | 
|---|
| 1296 |  | 
|---|
| 1297 | if (dynlink) delete dynlink;    dynlink = NULL; | 
|---|
| 1298 | usfmap.clear(); | 
|---|
| 1299 |  | 
|---|
| 1300 | dynlink = new PDynLinkMgr(fnameso, true); | 
|---|
| 1301 | if (dynlink == NULL) { | 
|---|
| 1302 | string sn = fnameso; | 
|---|
| 1303 | cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl; | 
|---|
| 1304 | return(2); | 
|---|
| 1305 | } | 
|---|
| 1306 |  | 
|---|
| 1307 | int nok=0; | 
|---|
| 1308 | // on utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++) | 
|---|
| 1309 | // DlUserProcFunction f = NULL; | 
|---|
| 1310 | DlFunction f = NULL; | 
|---|
| 1311 | if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") )  goto fin; | 
|---|
| 1312 | // f = (DlUserProcFunction)  dlsym(dlhandle, func1.c_str()); | 
|---|
| 1313 | f = dynlink->GetFunction(func1); | 
|---|
| 1314 | if (f) { nok++;  usfmap[func1] = f; } | 
|---|
| 1315 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl; | 
|---|
| 1316 |  | 
|---|
| 1317 | if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin; | 
|---|
| 1318 | // f = (DlUserProcFunction)  dlsym(dlhandle, func2.c_str()); | 
|---|
| 1319 | f = dynlink->GetFunction(func2); | 
|---|
| 1320 | if (f) { nok++;  usfmap[func2] = f; } | 
|---|
| 1321 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl; | 
|---|
| 1322 |  | 
|---|
| 1323 | if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin; | 
|---|
| 1324 | // f = (DlUserProcFunction)  dlsym(dlhandle, func3.c_str()); | 
|---|
| 1325 | f = dynlink->GetFunction(func3); | 
|---|
| 1326 | if (f) { nok++;  usfmap[func3] = f; } | 
|---|
| 1327 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl; | 
|---|
| 1328 |  | 
|---|
| 1329 | /*  Pb compile g++ 2.7.2 | 
|---|
| 1330 | if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") )  goto fin; | 
|---|
| 1331 | // f = (DlUserProcFunction)  dlsym(dlhandle, func4.c_str()); | 
|---|
| 1332 | f = dynlink->GetFunction(func4); | 
|---|
| 1333 | if (f) { nok++;  usfmap[func4] = f; } | 
|---|
| 1334 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl; | 
|---|
| 1335 |  | 
|---|
| 1336 | if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") )  goto fin; | 
|---|
| 1337 | // f = (DlUserProcFunction)  dlsym(dlhandle, func5.c_str()); | 
|---|
| 1338 | f = dynlink->GetFunction(func5); | 
|---|
| 1339 | if (f) { nok++;  usfmap[func5] = f; } | 
|---|
| 1340 | else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl; | 
|---|
| 1341 | */ | 
|---|
| 1342 | fin: | 
|---|
| 1343 | if (nok < 1) { if (dynlink) delete dynlink;    dynlink = NULL;  return(3); } | 
|---|
| 1344 | else return(0); | 
|---|
| 1345 | } | 
|---|
| 1346 |  | 
|---|
| 1347 | /* --Methode-- */ | 
|---|
| 1348 | int PIABaseExecutor::LinkUserFuncs2(string& fnameso, string& func1, string& func2, string& func3) | 
|---|
| 1349 | { | 
|---|
| 1350 | string cmd; | 
|---|
| 1351 |  | 
|---|
| 1352 | if (dynlink2) delete dynlink2;    dynlink2 = NULL; | 
|---|
| 1353 | usfmap2.clear(); | 
|---|
| 1354 |  | 
|---|
| 1355 | dynlink2 = new PDynLinkMgr(fnameso, true); | 
|---|
| 1356 | if (dynlink2 == NULL) { | 
|---|
| 1357 | string sn = fnameso; | 
|---|
| 1358 | cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur ouverture SO " << sn << endl; | 
|---|
| 1359 | return(2); | 
|---|
| 1360 | } | 
|---|
| 1361 |  | 
|---|
| 1362 | int nok=0; | 
|---|
| 1363 | // on utilise donc des DlFunction  (Reza 20/08/98)  voir commentaire ds .h (pb g++) | 
|---|
| 1364 | // DlUserProcFunction f = NULL; | 
|---|
| 1365 | DlFunction f = NULL; | 
|---|
| 1366 | if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") )  goto fin; | 
|---|
| 1367 | f = dynlink2->GetFunction(func1); | 
|---|
| 1368 | if (f) { nok++;  usfmap2[func1] = f; } | 
|---|
| 1369 | else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func1 << endl; | 
|---|
| 1370 |  | 
|---|
| 1371 | if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") )  goto fin; | 
|---|
| 1372 | f = dynlink2->GetFunction(func2); | 
|---|
| 1373 | if (f) { nok++;  usfmap2[func2] = f; } | 
|---|
| 1374 | else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func2 << endl; | 
|---|
| 1375 |  | 
|---|
| 1376 | if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") )  goto fin; | 
|---|
| 1377 | f = dynlink2->GetFunction(func3); | 
|---|
| 1378 | if (f) { nok++;  usfmap2[func3] = f; } | 
|---|
| 1379 | else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func3 << endl; | 
|---|
| 1380 |  | 
|---|
| 1381 | fin: | 
|---|
| 1382 | if (nok < 1) { if (dynlink2) delete dynlink2;    dynlink2 = NULL;  return(3); } | 
|---|
| 1383 | else return(0); | 
|---|
| 1384 | } | 
|---|
| 1385 |  | 
|---|