- Timestamp:
- Oct 14, 1999, 7:01:58 PM (26 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/nobjmgr.cc
r463 r466 119 119 CreateDir(dirn); 120 120 SetKeepOldDirAtt(dirn, false); 121 dirn = " func";121 dirn = "autoc"; 122 122 CreateDir(dirn); 123 123 SetKeepOldDirAtt(dirn, false); … … 420 420 } 421 421 422 // Si c'est le repertoire / func, on nettoie423 if (nrep == " func") {422 // Si c'est le repertoire /autoc, on nettoie 423 if (nrep == "autoc") { 424 424 CleanDir(nrep); 425 425 } … … 439 439 it = myObjs->find(nom); 440 440 if (it != myObjs->end()) { // l'objet existe deja 441 if (nrep == " func") { // Dans /func , on garde les objets affiches, donc del. par Clean441 if (nrep == "autoc") { // Dans /autoc , on garde les objets affiches, donc del. par Clean 442 442 sprintf(buff, "%d", (*it).second.oid); 443 string nomnew = "/ func/" + nobj + buff;443 string nomnew = "/autoc/" + nobj + buff; 444 444 RenameObj(nom, nomnew); 445 445 } -
trunk/SophyaPI/PIext/pawexecut.cc
r463 r466 5 5 #include <typeinfo> 6 6 7 #include "strutil.h" 8 #include "cvector.h" 9 #include "matrix.h" 10 #include "histos.h" 7 11 #include "histos.h" 8 12 #include "histos2.h" 13 #include "hisprof.h" 9 14 #include "ntuple.h" 10 15 11 16 #include "pawexecut.h" 12 17 #include "nobjmgr.h" 18 #include "servnobjm.h" 13 19 #include "pistdimgapp.h" 14 20 21 /* Reza + cmv 13/10/99 */ 22 23 /* methode */ 15 24 PAWExecutor::PAWExecutor(PIACmd *piac, PIStdImgApp* app) 16 25 : mApp(app) 17 26 { 18 27 string kw, usage; 19 28 string hgrp = "pawCmd"; 20 kw = "h/op/res"; 21 usage = "Reset histogram - " ; 22 piac->RegisterCommand(kw,usage,this,hgrp); 23 } 24 29 30 kw = "reset"; 31 usage = "Reset histograms vectors or matrix"; 32 usage += "\n reset nameobj"; 33 piac->RegisterCommand(kw,usage,this,hgrp); 34 35 kw = "n/plot"; 36 usage = "Plot NTuple variable a la paw"; 37 usage += "\n n/plot nameobj.x_exp [cut] [w_exp] [gratt]"; 38 usage += "\n n/plot nameobj.y_exp%x_exp [cut] [w_exp] [gratt]"; 39 usage += "\n n/plot nameobj.z_exp%y_exp%x_exp [cut] [gratt]"; 40 usage += "\n Related commands: plot2dw plot3d"; 41 piac->RegisterCommand(kw,usage,this,hgrp); 42 43 kw = "n/proj"; 44 usage = "Project NTuple in histogram (1D or 2D) a la paw"; 45 usage += "\n n/proj nameproj nameobj.x_exp [cut] [w_exp] [gratt]"; 46 usage += "\n n/proj nameproj nameobj.y_exp%x_exp [cut] [w_exp] [gratt]"; 47 usage += "\n Related commands: projh1d projh2d projprof"; 48 piac->RegisterCommand(kw,usage,this,hgrp); 49 50 kw = "h/integ"; 51 usage = "Integrate a 1D histogram or profile"; 52 usage += "\n h/integ nameh1d [norm]"; 53 usage += "\n Related commands: h/deriv"; 54 piac->RegisterCommand(kw,usage,this,hgrp); 55 56 kw = "h/deriv"; 57 usage = "Derivate a 1D histogram or profile"; 58 usage += "\n h/deriv nameh1d"; 59 usage += "\n Related commands: h/integ"; 60 piac->RegisterCommand(kw,usage,this,hgrp); 61 62 kw = "h/rebin"; 63 usage = "Rebin a 1D histogram or profile"; 64 usage += "\n h/rebin nbin"; 65 piac->RegisterCommand(kw,usage,this,hgrp); 66 67 kw = "h/cadd"; 68 usage = "Add a constant to an histogramme"; 69 usage += "\n h/cadd val"; 70 usage += "\n Related commands: h/cmult"; 71 piac->RegisterCommand(kw,usage,this,hgrp); 72 73 kw = "h/cmult"; 74 usage = "Multiply an histogramme by a constant"; 75 usage += "\n h/cmult val"; 76 usage += "\n Related commands: h/cadd"; 77 piac->RegisterCommand(kw,usage,this,hgrp); 78 79 kw = "h/plot/2d"; 80 usage = "Specific plot for 2D histogrammes"; 81 usage += "\n h/plot/2d nameh2d show : infos on 2D histogramme"; 82 usage += "\n h/plot/2d nameh2d h [dopt] : plot 2D histogramme"; 83 usage += "\n h/plot/2d nameh2d px [dopt] : plot X projection"; 84 usage += "\n h/plot/2d nameh2d py [dopt] : plot Y projection"; 85 usage += "\n h/plot/2d nameh2d bx n [dopt] : plot X band number n"; 86 usage += "\n h/plot/2d nameh2d by n [dopt] : plot Y band number n"; 87 usage += "\n h/plot/2d nameh2d sx n [dopt] : plot X slice number n"; 88 usage += "\n h/plot/2d nameh2d sy n [dopt] : plot Y slice number n"; 89 usage += "\n n < 0 means Show Info"; 90 piac->RegisterCommand(kw,usage,this,hgrp); 91 } 92 93 /* methode */ 25 94 PAWExecutor::~PAWExecutor() 26 95 { 27 96 } 28 97 98 /* methode */ 29 99 int PAWExecutor::Execute(string& kw, vector<string>& tokens) 30 100 { 31 if(kw == "h/op/res") { 32 cout << " CMV-A faire - h/op/res pas implemente " << endl; 33 return(0); 101 if(kw == "reset") { 102 reset(tokens); return(0); 103 } else if(kw == "n/plot") { 104 n_plot(tokens); return(0); 105 } else if(kw == "n/proj") { 106 n_proj(tokens); return(0); 107 } else if(kw == "h/integ") { 108 h_integ(tokens); return(0); 109 } else if(kw == "h/deriv") { 110 h_deriv(tokens); return(0); 111 } else if(kw == "h/rebin") { 112 h_rebin(tokens); return(0); 113 } else if(kw == "h/cadd") { 114 h_cadd(tokens); return(0); 115 } else if(kw == "h/cmult") { 116 h_cmult(tokens); return(0); 117 } else if(kw == "h/plot/2d") { 118 h_plot_2d(tokens); return(0); 119 } else return(1); 120 } 121 122 /* methode */ 123 void PAWExecutor::reset(vector<string>& tokens) 124 // Reset d'histogrammes, vecteurs et matrices 125 { 126 if(tokens.size() < 1) 127 {cout<<"Usage: reset nameobj"<<endl; 128 return;} 129 NamedObjMgr omg; 130 AnyDataObj* mobj = omg.GetObj(tokens[0]); 131 if(mobj == NULL) 132 {cout<<"PAWExecutor::reset Error , Pas d'objet de nom "<<tokens[0]<<endl; 133 return;} 134 string ctyp = typeid(*mobj).name(); 135 136 if(typeid(*mobj)==typeid(Vector)) {Vector* ob=(Vector*) mobj; ob->Zero();} 137 else if(typeid(*mobj)==typeid(Matrix)) {Matrix* ob=(Matrix*) mobj; ob->Zero();} 138 else if(typeid(*mobj)==typeid(Histo)) {Histo* ob=(Histo*) mobj; ob->Zero();} 139 else if(typeid(*mobj)==typeid(HProf)) {HProf* ob=(HProf*) mobj; ob->Zero();} 140 else if(typeid(*mobj)==typeid(Histo2D)) {Histo2D* ob=(Histo2D*)mobj; ob->Zero();} 141 else { 142 cout<<"PAWExecutor::reset Error , No reset possible on "<<ctyp<<endl; 143 return; 144 } 145 146 return; 147 } 148 149 /* methode */ 150 void PAWExecutor::n_plot(vector<string>& tokens) 151 // Equivalent n/plot de paw 152 // Plot 1D 153 // n/plot nameobj.x_exp [cut] [w_exp] [gratt] 154 // Plot 2D (plot2dw) 155 // n/plot nameobj.y_exp%x_exp [cut] [w_exp] [gratt] 156 // Plot 3D (plot3d) 157 // n/plot nameobj.z_exp%y_exp%x_exp [cut] [gratt] 158 { 159 if(tokens.size() < 1) { 160 cout 161 <<"Usage: n/plot nameobj.[z_exp%y_exp%]x_exp [cut] [w_exp] [gratt]"<<endl 162 <<" n/plot nameobj.z_exp%y_exp%x_exp [cut] [gratt]"<<endl; 163 return; 164 } 165 string nameobj,expx,expy,expz; 166 int nvar = decodepawstring(tokens[0],nameobj,expx,expy,expz); 167 string expcut = "1"; 168 string expwt = "1."; 169 string dopt = ""; 170 string loop = ""; 171 if(tokens.size()>=2) expcut = tokens[1]; 172 if(tokens.size()>=3) expwt = tokens[2]; 173 if(tokens.size()>=4) dopt = tokens[3]; 174 175 176 NamedObjMgr omg; 177 Services2NObjMgr* srvo = omg.GetServiceObj(); 178 179 if(nvar<=0) { 180 cout<<"PAWExecutor::n_plot Error: bad coding "<<tokens[0]<<endl; 181 } else if(nvar==1) { // c'est un plot 1D 182 string nameproj = "/autoc/paw_n_plot1D"; 183 AnyDataObj* mobj = omg.GetObj(nameproj); 184 if(mobj!=NULL) omg.DelObj(nameproj); 185 srvo->ProjectH1(nameobj,expx,expwt,expcut,nameproj,dopt,loop); 186 } else if(nvar==2) { // c'est un plot 2D 187 srvo->DisplayPoints2DW(nameobj,expx,expy,expwt,expcut,dopt,loop); 188 } else { // c'est un plot 3D 189 srvo->DisplayPoints3D(nameobj,expx,expy,expz,expcut,dopt,loop); 190 } 191 192 return; 193 } 194 195 /* methode */ 196 void PAWExecutor::n_proj(vector<string>& tokens) 197 // Equivalent n/proj de paw 198 // Project NTuple in histogram a la paw 199 // Dans un Histo 1D 200 // n/proj nameproj nameobj.x_exp [cut] [w_exp] [gratt] 201 // Dans un Histo 2D ou un HProf (dans ce cas nameproj doit etre cree). 202 // n/proj nameproj nameobj.y_exp%x_exp [cut] [w_exp] [gratt] 203 { 204 if(tokens.size()<2) 205 {cout<<"Usage: n/proj nameproj nameobj.[y_exp%]x_exp [cut] [w_exp] [gratt]"<<endl; 206 return;} 207 string nameproj = tokens[0]; 208 string nameobj,expx,expy,expz; 209 int nvar = decodepawstring(tokens[1],nameobj,expx,expy,expz); 210 string expcut = "1"; 211 string expwt = "1."; 212 string dopt = ""; 213 string loop = ""; 214 if(tokens.size()>=3) expcut = tokens[2]; 215 if(tokens.size()>=4) expwt = tokens[3]; 216 if(tokens.size()>=5) dopt = tokens[4]; 217 218 NamedObjMgr omg; 219 Services2NObjMgr* srvo = omg.GetServiceObj(); 220 221 if(nvar<=0) { 222 cout<<"PAWExecutor::n_proj Error: bad coding "<<tokens[1]<<endl; 223 } else if(nvar==1) { 224 // c'est une projection dans un histo 1D 225 srvo->ProjectH1(nameobj,expx,expwt,expcut,nameproj,dopt,loop); 226 } else { 227 // c'est une projection dans un histo2D 228 // OU un HProf si nameproj est HProf un deja defini 229 AnyDataObj* mobj = omg.GetObj(nameproj); 230 if(mobj==NULL) 231 srvo->ProjectH2(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); 232 else if(dynamic_cast<HProf*>(mobj)) 233 srvo->ProjectHProf(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); 234 else 235 srvo->ProjectH2(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); 236 } 237 238 return; 239 } 240 241 /* methode */ 242 void PAWExecutor::h_integ(vector<string>& tokens) 243 // Pour remplacer le contenu d'un histo 1D par son integrale 244 { 245 if(tokens.size()<1) 246 {cout<<"Usage: h/integ nameh1d [norm]"<<endl; return;} 247 NamedObjMgr omg; 248 AnyDataObj* mobj = omg.GetObj(tokens[0]); 249 if(mobj==NULL) 250 {cout<<"PAWExecutor::h_integ Error: unknow object"<<tokens[0]<<endl; 251 return;} 252 double norm = 1.; 253 if(tokens.size()>=2) norm = atof(tokens[1].c_str()); 254 Histo* h1 = dynamic_cast<Histo*>(mobj); 255 // Le HProf se fait tout seul avec Histo: dynamic_cast<Histo*>(HProf)=Vrai! 256 //HProf* hp = dynamic_cast<HProf*>(mobj); 257 if(h1) h1->HInteg(norm); 258 //else if(hp) hp->HInteg(norm); 259 else cout<<"PAWExecutor::h_integ Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; 260 } 261 262 /* methode */ 263 void PAWExecutor::h_deriv(vector<string>& tokens) 264 // Pour remplacer le contenu d'un histo 1D par sa derivee 265 { 266 if(tokens.size()<1) 267 {cout<<"Usage: h/deriv nameh1d"<<endl; return;} 268 NamedObjMgr omg; 269 AnyDataObj* mobj = omg.GetObj(tokens[0]); 270 if(mobj==NULL) 271 {cout<<"PAWExecutor::h_deriv Error: unknow object"<<tokens[0]<<endl; 272 return;} 273 Histo* h1 = dynamic_cast<Histo*>(mobj); 274 //HProf* hp = dynamic_cast<HProf*>(mobj); 275 if(h1) h1->HDeriv(); 276 //else if(hp) hp->HDeriv(); 277 else cout<<"PAWExecutor::h_deriv Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; 278 } 279 280 /* methode */ 281 void PAWExecutor::h_rebin(vector<string>& tokens) 282 // Pour re-binner un histogramme 1D 283 { 284 if(tokens.size()<2) 285 {cout<<"Usage: h/rebin nameh1d nbin"<<endl; return;} 286 NamedObjMgr omg; 287 AnyDataObj* mobj = omg.GetObj(tokens[0]); 288 if(mobj==NULL) 289 {cout<<"PAWExecutor::h_rebin Error: unknow object"<<tokens[0]<<endl; 290 return;} 291 int nbin = atoi(tokens[1].c_str()); 292 Histo* h1 = dynamic_cast<Histo*>(mobj); 293 //HProf* hp = dynamic_cast<HProf*>(mobj); 294 if(h1) h1->HRebin(nbin); 295 //else if(hp) hp->HRebin(nbin); 296 else cout<<"PAWExecutor::h_rebin Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; 297 } 298 299 /* methode */ 300 void PAWExecutor::h_cadd(vector<string>& tokens) 301 // Additionne une constante a un histogramme 302 { 303 if(tokens.size()<2) 304 {cout<<"Usage: h/cadd nameh1d val"<<endl; return;} 305 NamedObjMgr omg; 306 AnyDataObj* mobj = omg.GetObj(tokens[0]); 307 if(mobj==NULL) 308 {cout<<"PAWExecutor::h_cadd Error: unknow object"<<tokens[0]<<endl; 309 return;} 310 double val = atof(tokens[1].c_str()); 311 Histo* h1 = dynamic_cast<Histo*>(mobj); 312 Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); 313 if(h1) *h1 += val; 314 else if(h2) *h2 += val; 315 else cout<<"PAWExecutor::h_cadd Error: "<<tokens[0]<<" not an Histo/HProf/Histo2D"<<endl; 316 } 317 318 /* methode */ 319 void PAWExecutor::h_cmult(vector<string>& tokens) 320 // Multiplie un histogramme par une constante 321 { 322 if(tokens.size()<2) 323 {cout<<"Usage: h/cmult nameh1d val"<<endl; return;} 324 NamedObjMgr omg; 325 AnyDataObj* mobj = omg.GetObj(tokens[0]); 326 if(mobj==NULL) 327 {cout<<"PAWExecutor::h_cmult Error: unknow object"<<tokens[0]<<endl; 328 return;} 329 double val = atof(tokens[1].c_str()); 330 Histo* h1 = dynamic_cast<Histo*>(mobj); 331 Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); 332 if(h1) *h1 *= val; 333 else if(h2) *h2 *= val; 334 else cout<<"PAWExecutor::h_cmult Error: "<<tokens[0] 335 <<" not an Histo/HProf/Histo2D"<<endl; 336 } 337 338 /* methode */ 339 void PAWExecutor::h_plot_2d(vector<string>& tokens) 340 // plot for 2D histogramme: plot histo, bandx/y, slicex/y or projx/y 341 { 342 if(tokens.size()<2) 343 {cout<<"Usage: h/plot/2d nameh2d to_plot [n/s] [dopt]"<<endl; return;} 344 NamedObjMgr omg; 345 AnyDataObj* mobj = omg.GetObj(tokens[0]); 346 if(mobj==NULL) 347 {cout<<"PAWExecutor::h_plot_2d Error: unknow object"<<tokens[0]<<endl; 348 return;} 349 Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); 350 if(!h2) 351 {cout<<"PAWExecutor::h_plot_2d Error: "<<tokens[0]<<" not an Histo2D"<<endl; 352 return;} 353 354 Histo* h1p = NULL; string nametoplot = "/autoc/h_plot_2d_h1"; 355 AnyDataObj* mobjh1 = omg.GetObj(nametoplot); 356 if(mobjh1!=NULL) omg.DelObj(nametoplot); 357 358 string dopt = ""; if(tokens.size()>=3) dopt = tokens[2]; 359 if(tokens[1] == "show") { 360 h2->ShowProj(); 361 h2->ShowBand(2); 362 h2->ShowSli(2); 363 return; 364 } else if(tokens[1] == "h") { 365 nametoplot = tokens[0]; 366 } else if(tokens[1] == "px") { 367 if((h1p=h2->HProjX())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} 368 else {h2->ShowProj(); return;} 369 } else if(tokens[1] == "py") { 370 if((h1p=h2->HProjY())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} 371 else {h2->ShowProj(); return;} 372 } else { 373 if(tokens.size()<3) 374 {cout<<"Usage: h/plot/2d nameh2d bx/by/sx/sy n [dopt]"<<endl; return;} 375 int n = atoi(tokens[2].c_str()); 376 dopt = ""; if(tokens.size()>=4) dopt = tokens[3]; 377 if(tokens[1] == "bx") { 378 if((h1p=h2->HBandX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} 379 else {h2->ShowBand(); return;} 380 } else if(tokens[1] == "by") { 381 if((h1p=h2->HBandY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} 382 else {h2->ShowBand(); return;} 383 } else if(tokens[1] == "sx") { 384 if((h1p=h2->HSliX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} 385 else {h2->ShowSli(); return;} 386 } else if(tokens[1] == "sy") { 387 if((h1p=h2->HSliY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} 388 else {h2->ShowSli(); return;} 34 389 } 35 else return(1); 36 } 390 } 391 392 omg.DisplayObj(nametoplot,dopt); 393 } 394 395 /* methode */ 396 int PAWExecutor::decodepawstring(string tokens,string& nameobj 397 ,string& xexp,string& yexp,string& zexp) 398 // Decodage general de "nameobj.xexp" 399 // "nameobj.yexp%xexp" 400 // "nameobj.zexp%yexp%xexp" 401 // Return: nombre de variables trouvees, -1 si probleme 402 { 403 nameobj = ""; xexp= ""; yexp= ""; zexp= ""; 404 405 int lt = (int) tokens.length(); 406 if(lt<=0) return -1; 407 408 // decodage de la chaine de type PAW. 409 char *str = new char[lt+2]; 410 strcpy(str,tokens.c_str()); strip(str,'B',' '); lt = strlen(str); 411 //cout<<"chaine1["<<lt<<"] :"<<str<<":"<<endl; 412 char *c[3] = {NULL,NULL,NULL}; 413 int i, np=0; bool namefound = false; 414 for(int i=0;i<lt;i++) { 415 if(!namefound && str[i]=='.') { 416 str[i]='\0'; 417 namefound=true; 418 c[np] = str+i+1; np++; 419 } 420 if( namefound && str[i]=='%') { 421 str[i]='\0'; 422 if(np<3) {c[np] = str+i+1; np++;} 423 } 424 } 425 //cout<<"chaine2 :"; for(i=0;i<lt;i++) cout<<str[i]; cout<<":"<<endl; 426 427 // Remplissage du nom et des variables 428 nameobj = str; 429 if(np==1) xexp=c[0]; 430 if(np==2) {yexp=c[0]; xexp=c[1];} 431 if(np==3) {zexp=c[0]; yexp=c[1]; xexp=c[2];} 432 //cout<<"pawstring str,c[0-2] "<<str<<" "<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl; 433 delete [] str; 434 435 // Comptage des variables 436 np = -1; 437 if(nameobj.length()>0) 438 {np = 0; if(xexp.length()>0) 439 {np++; if(yexp.length()>0) 440 {np++; if(zexp.length()>0) np++;}}} 441 cout<<"pawstring["<<np<<"] name="<<nameobj 442 <<" xexp="<<xexp<<" yexp="<<yexp<<" zexp="<<zexp<<endl; 443 return np; 444 } -
trunk/SophyaPI/PIext/pawexecut.h
r463 r466 20 20 virtual int Execute(string& keyw, vector<string>& args); 21 21 protected: 22 void reset(vector<string>& tokens); 23 void n_plot(vector<string>& tokens); 24 void n_proj(vector<string>& tokens); 25 void h_integ(vector<string>& tokens); 26 void h_deriv(vector<string>& tokens); 27 void h_rebin(vector<string>& tokens); 28 void h_cadd(vector<string>& tokens); 29 void h_cmult(vector<string>& tokens); 30 void h_plot_2d(vector<string>& tokens); 31 int decodepawstring(string tokens,string& nameobj 32 ,string& xexp,string& yexp,string& zexp); 22 33 PIStdImgApp* mApp; 23 34 }; 24 35 25 36 #endif 26 -
trunk/SophyaPI/PIext/piafitting.cc
r392 r466 54 54 55 55 //////////////////////////////////////////////////////////////////////// 56 // --- Generation automatique du "usage" pour helpfit: 57 // 1-/ copier le texte ci-dessous de piafitting.cc dans toto 58 // 2-/ cat toto | sed 's?^//?usage+="\\n?' | sed 's?$? ";?' 59 // NE PAS EFFACER LA SUITE: c'est elle qui doit etre modifiee, 60 // le usage du helpfit sera regenere a l'aide des commandes ci-dessus. 61 //////////////////////////////////////////////////////////////////////// 56 62 //| --------------- Fit Lineaire a 1 et 2 dimensions --------------- 57 63 //| Syntaxe: 58 64 //| fitlin nom pnn [o:.aa,bb,cc, o;dd,ee,ff o:gg,hh,jj,kk etc...] 59 65 //| avec: 60 //| nom : cf commentaire ordre "fit"66 //| nom : cf commentaire ordre ''fit'' 61 67 //| pnn : fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D 62 //| o:aa,...,bb : cf commentaires ordre "fit"68 //| o:aa,...,bb : cf commentaires ordre ''fit'' 63 69 //| 64 70 //////////////////////////////////////////////////////////////////////// … … 69 75 //| [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn] 70 76 //| [o:.aa,bb,cc, o;dd,ee,ff o:gg,hh,jj,kk etc...] 71 //| cf commentaire ordre "fit"77 //| cf commentaire ordre ''fit'' 72 78 //| 73 79 //////////////////////////////////////////////////////////////////////// … … 109 115 //| 110 116 //|----- OPTIONS ----- 111 //| o : options "o:Eaa.b,eaa.b,f,r,caa.b,Xaa.b"117 //| o : options ''o:Eaa.b,eaa.b,f,r,caa.b,Xaa.b'' 112 118 //| F : initialisation a partir des resultats et de l'etat du fit precedent 113 119 //| (option non prioritaire sur les definitions p:,s:,m:,M:,f:o:) 114 120 //| a : initialisation automatique des parametres du fit (si disponible) 115 121 //| (option non prioritaire sur les definitions p:,s:,m:,M:,f:o: 116 //| et sur l'initialisation pa l'option "F")122 //| et sur l'initialisation pa l'option ''F'') 117 123 //| f : generation d'un Objet identique contenant la fonction fittee 118 124 //| r : generation d'un Objet identique contenant les residus 119 125 //| Xaa.b : aa.b valeur du DXi2 d'arret (def=1.e-3) 120 126 //| Naa : aa nombre maximum d'iterations (def=100) 121 //| la : niveau "a"de print: a=niveau de print Fit1/2D122 //| da : niveau "a"de debug: a=niveau de GeneralFit127 //| la : niveau ''a'' de print: a=niveau de print Fit1/2D 128 //| da : niveau ''a'' de debug: a=niveau de GeneralFit 123 129 //| Ii1/i2 : numeros des bins X de l'histos utilises pour le fit [i1,i2] 124 130 //|2D Jj1/j2 : numeros des bins Y de l'histos utilises pour le fit [j1,j2] … … 137 143 //| Actif pour exp+poly 1D, poly 1D 138 144 //| Pour gauss+poly 1D, xc est le centre de la gaussienne. 139 //|2D yaa.b et y : idem "xaa.b et x"mais pour y145 //|2D yaa.b et y : idem ''xaa.b et x'' mais pour y 140 146 //| 141 147 //////////////////////////////////////////////////////////////////////// … … 156 162 //| double gauss2_der(double const* x,double const* p,double* dp) 157 163 //| ou dp[i] = dF(x[];p[])/dp[i] 158 //| Par convention, cette fonction a le meme nom suivi de "_der"164 //| Par convention, cette fonction a le meme nom suivi de ''_der'' 159 165 //| > crfitfun nom_fichier nom_fonction nvar npar 160 //| Permet de compiler le fichier "nom_fichier"et de linker161 //| la fonction "nom_fonction"166 //| Permet de compiler le fichier ''nom_fichier'' et de linker 167 //| la fonction ''nom_fonction'' 162 168 //| - Un meme fichier peut contenir plusieurs fonctions a fitter 163 169 //| … … 184 190 185 191 // enregistrement des ordres de fit 186 string kw, usage; 192 string kw, usage, grp = "Fitting"; 193 194 kw = "helpfit"; 195 usage=""; 196 usage+="\n////////////////////////////////////////////////////////////////////// "; 197 usage+="\n| --------------- Fit Lineaire a 1 et 2 dimensions --------------- "; 198 usage+="\n| Syntaxe: "; 199 usage+="\n| fitlin nom pnn [o:.aa,bb,cc, o;dd,ee,ff o:gg,hh,jj,kk etc...] "; 200 usage+="\n| avec: "; 201 usage+="\n| nom : cf commentaire ordre ''fit'' "; 202 usage+="\n| pnn : fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D "; 203 usage+="\n| o:aa,...,bb : cf commentaires ordre ''fit'' "; 204 usage+="\n| "; 205 usage+="\n////////////////////////////////////////////////////////////////////// "; 206 usage+="\n| --------------- Fit d'objets a 1 et 2 dimensions --------------- "; 207 usage+="\n| avec interface d'aide graphique "; 208 usage+="\n| Syntaxe: "; 209 usage+="\n| fitw nom func "; 210 usage+="\n| [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn] "; 211 usage+="\n| [o:.aa,bb,cc, o;dd,ee,ff o:gg,hh,jj,kk etc...] "; 212 usage+="\n| cf commentaire ordre ''fit'' "; 213 usage+="\n| "; 214 usage+="\n////////////////////////////////////////////////////////////////////// "; 215 usage+="\n| --------------- Fit d'objets a 1 et 2 dimensions --------------- "; 216 usage+="\n| Syntaxe: "; 217 usage+="\n| fit nom func "; 218 usage+="\n| [p:p1,p2,...,pn s:s1,s2,...,sn m:m1,m2,...,mn M:M1,mM2,...,Mn f:f1,...,fn] "; 219 usage+="\n| [o:.aa,bb,cc, o;dd,ee,ff o:gg,hh,jj,kk etc...] "; 220 usage+="\n|----- OBJET ----- "; 221 usage+="\n| nom : nom de l'objet qui peut etre: "; 222 usage+="\n| fit-1D: Vector,Histo1D,HProf ou GeneraFitData(1D) "; 223 usage+="\n| fit-2D: Matrix,Histo2D,Image<T> ou GeneraFitData(2D) "; 224 usage+="\n| "; 225 usage+="\n|----- FUNCTION ----- "; 226 usage+="\n| func : pnn : fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D "; 227 usage+="\n| : gnn : fit gaussienne (hauteur) + polynome de degre nn 1D "; 228 usage+="\n| : g : fit gaussienne (hauteur) 1D "; 229 usage+="\n| : enn : fit exponentielle + polynome de degre nn 1D "; 230 usage+="\n| : e : fit exponentielle 1D "; 231 usage+="\n| : Gnn : fit gaussienne (volume) + polynome de degre nn 1D "; 232 usage+="\n| : G : fit gaussienne (volume) 1D "; 233 usage+="\n| : : fit gaussienne+fond (volume) 2D "; 234 usage+="\n| : Gi : fit gaussienne+fond integree (volume) 2D "; 235 usage+="\n| : d : fit DL de gaussienne+fond (volume) 2D "; 236 usage+="\n| : di : fit DL de gaussienne+fond integree (volume) 2D "; 237 usage+="\n| : D : fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D "; 238 usage+="\n| : Di : fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D "; 239 usage+="\n| : M : fit Moffat+fond (expos=p6) (volume) 2D "; 240 usage+="\n| : Mi : fit Moffat+fond integree (expos=p6) (volume) 2D "; 241 usage+="\n| : Autre : fonction definie par l'utilisateur (cf commentaires ci apres) "; 242 usage+="\n| "; 243 usage+="\n|----- INIT PARAMETRES ET ETAT DU FIT ----- "; 244 usage+="\n| p : p1,...,pn : valeur d'initialisation des parametres (def=0) "; 245 usage+="\n| s : s1,...,sn : valeur des steps de depart (def=1) "; 246 usage+="\n| m : m1,...,mn : valeur des minima (def=1) "; 247 usage+="\n| M : M1,...,Mn : valeur des maxima (def=-1) (max<=min : pas de limite) "; 248 usage+="\n| f : f1,...,fn : si >=1 parametre fixe sinon libre (def=0) "; 249 usage+="\n| - Remarque: si pi,si,mi ou Mi = '!' la valeur correspondante n'est pas changee "; 250 usage+="\n| "; 251 usage+="\n|----- OPTIONS ----- "; 252 usage+="\n| o : options ''o:Eaa.b,eaa.b,f,r,caa.b,Xaa.b'' "; 253 usage+="\n| F : initialisation a partir des resultats et de l'etat du fit precedent "; 254 usage+="\n| (option non prioritaire sur les definitions p:,s:,m:,M:,f:o:) "; 255 usage+="\n| a : initialisation automatique des parametres du fit (si disponible) "; 256 usage+="\n| (option non prioritaire sur les definitions p:,s:,m:,M:,f:o: "; 257 usage+="\n| et sur l'initialisation pa l'option ''F'') "; 258 usage+="\n| f : generation d'un Objet identique contenant la fonction fittee "; 259 usage+="\n| r : generation d'un Objet identique contenant les residus "; 260 usage+="\n| Xaa.b : aa.b valeur du DXi2 d'arret (def=1.e-3) "; 261 usage+="\n| Naa : aa nombre maximum d'iterations (def=100) "; 262 usage+="\n| la : niveau ''a'' de print: a=niveau de print Fit1/2D "; 263 usage+="\n| da : niveau ''a'' de debug: a=niveau de GeneralFit "; 264 usage+="\n| Ii1/i2 : numeros des bins X de l'histos utilises pour le fit [i1,i2] "; 265 usage+="\n|2D Jj1/j2 : numeros des bins Y de l'histos utilises pour le fit [j1,j2] "; 266 usage+="\n| - L'erreur est celle associee a l'objet (si elle existe), "; 267 usage+="\n| elle est mise a 1 sinon, sauf si E... ou e... est precise: "; 268 usage+="\n| Eaa.b : si |val|>=1 erreur = aa.b*sqrt(|val|) "; 269 usage+="\n| si |val|<1 erreur = aa.b "; 270 usage+="\n| si aa.b <=0 alors aa.b=1.0 "; 271 usage+="\n| E seul est equivalent a E1.0 "; 272 usage+="\n| eaa.b : erreur = aa.b "; 273 usage+="\n| si aa.b <=0 alors aa.b=1.0 "; 274 usage+="\n| e seul est equivalent a e1.0 "; 275 usage+="\n| xaa.b : demande de centrage: on fit x-aa.b au lieu de x) "; 276 usage+="\n| x : demande de centrage: on fit x-xc au lieu de x "; 277 usage+="\n| avec xc=abscisse du milieu de l'histogramme "; 278 usage+="\n| Actif pour exp+poly 1D, poly 1D "; 279 usage+="\n| Pour gauss+poly 1D, xc est le centre de la gaussienne. "; 280 usage+="\n|2D yaa.b et y : idem ''xaa.b et x'' mais pour y "; 281 usage+="\n| "; 282 usage+="\n////////////////////////////////////////////////////////////////////// "; 283 usage+="\n| --------------- Def des fcts de fit par l'utilisateur --------------- "; 284 usage+="\n| Pour definir une fonction parametree utilisateur: "; 285 usage+="\n| Un exemple de fichier contenant des fonctions a fitter: PIext/userfitfunex.c "; 286 usage+="\n| > crfitfil nom_fichier nom_fonction nvar npar "; 287 usage+="\n| pour creer un squelette de fichier C contenant la fonction a fitter "; 288 usage+="\n| nom_fichier : nom du fichier ou est le code de la fonction "; 289 usage+="\n| c'est un fichier C de nom blabla.c "; 290 usage+="\n| nom_fonction : nom de la fonction ex: gauss2 "; 291 usage+="\n| nvar : nombre de variables x[] (1D=1, 2D=2, etc...) "; 292 usage+="\n| npar : nombre de parametre p[] "; 293 usage+="\n| - La fonction est donc F(x[];p[]), soit par ex: "; 294 usage+="\n| double gauss2(double const* x,double const* p) "; 295 usage+="\n| - L'utilisateur a la possibilite de donner egalement la fonction "; 296 usage+="\n| retournant les derivees de la fonction par rapport aux parametres "; 297 usage+="\n| double gauss2_der(double const* x,double const* p,double* dp) "; 298 usage+="\n| ou dp[i] = dF(x[];p[])/dp[i] "; 299 usage+="\n| Par convention, cette fonction a le meme nom suivi de ''_der'' "; 300 usage+="\n| > crfitfun nom_fichier nom_fonction nvar npar "; 301 usage+="\n| Permet de compiler le fichier ''nom_fichier'' et de linker "; 302 usage+="\n| la fonction ''nom_fonction'' "; 303 usage+="\n| - Un meme fichier peut contenir plusieurs fonctions a fitter "; 304 usage+="\n| "; 305 usage+="\n////////////////////////////////////////////////////////////////////// "; 306 piac->RegisterHelp(kw,usage,grp); 187 307 188 308 kw = "fit"; … … 190 310 usage += "\n Usage: fit nomobj func [Options]"; 191 311 usage += "\n [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]"; 192 piac->RegisterCommand(kw,usage,this,"Fitting"); 312 usage += "\n Related commands: fitw fitlin crfitfun crfitfil"; 313 piac->RegisterCommand(kw,usage,this,grp); 193 314 194 315 kw = "fitw"; … … 196 317 usage += "\n Usage: fitw nomobj func [Options]"; 197 318 usage += "\n [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]"; 198 piac->RegisterCommand(kw,usage,this,"Fitting"); 319 usage += "\n Related commands: fit fitlin crfitfun crfitfil"; 320 piac->RegisterCommand(kw,usage,this,grp); 199 321 200 322 kw = "fitlin"; 201 323 usage = "Linear Fitting of Polynoms to DataObjects"; 202 324 usage += "\n Usage: fitlin nomobj func [o:... o:...]"; 203 piac->RegisterCommand(kw,usage,this,"Fitting"); 325 usage += "\n Related commands: fit fitw crfitfun crfitfil"; 326 piac->RegisterCommand(kw,usage,this,grp); 204 327 205 328 kw = "crfitfun"; 206 329 usage = "Creation et link de function utilisateur pour le fit"; 207 330 usage += "\n Usage: crfitfun file func nvar npar"; 208 piac->RegisterCommand(kw,usage,this,"Fitting"); 331 usage += "\n Related commands: fit fitw fitlin crfitfil"; 332 piac->RegisterCommand(kw,usage,this,grp); 209 333 210 334 kw = "crfitfil"; 211 335 usage = "Creation de fichier C pour function utilisateur du fit"; 212 336 usage += "\n Usage: crfitfil file func nvar npar"; 213 piac->RegisterCommand(kw,usage,this,"Fitting"); 337 usage += "\n Related commands: fit fitw fitlin crfitfun"; 338 piac->RegisterCommand(kw,usage,this,grp); 214 339 } 215 340 -
trunk/SophyaPI/PIext/servnobjm.cc
r463 r466 199 199 if (nom.length() < 1) { 200 200 titre = "Function f(x)"; 201 nom = "/ func/f_x";201 nom = "/autoc/f_x"; 202 202 } 203 203 else titre = nom; … … 261 261 if (nom.length() < 1) { 262 262 titre = "Function f(x,y)"; 263 nom = "/ func/f2d_xy";263 nom = "/autoc/f2d_xy"; 264 264 } 265 265 else titre = nom; … … 485 485 double xmin, xmax, ymin, ymax; 486 486 nt->GetMinMax(0, xmin, xmax); 487 nt->GetMinMax( 0, ymin, ymax);487 nt->GetMinMax(1, ymin, ymax); 488 488 h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50); 489 489 int k;
Note:
See TracChangeset
for help on using the changeset viewer.