[463] | 1 | #include <stdio.h>
|
---|
| 2 | #include <stdlib.h>
|
---|
| 3 | #include <ctype.h>
|
---|
| 4 | #include <iostream.h>
|
---|
| 5 | #include <typeinfo>
|
---|
| 6 |
|
---|
[466] | 7 | #include "strutil.h"
|
---|
[463] | 8 | #include "histos.h"
|
---|
[466] | 9 | #include "histos.h"
|
---|
[463] | 10 | #include "histos2.h"
|
---|
[466] | 11 | #include "hisprof.h"
|
---|
[463] | 12 | #include "ntuple.h"
|
---|
| 13 |
|
---|
| 14 | #include "pawexecut.h"
|
---|
| 15 | #include "nobjmgr.h"
|
---|
[466] | 16 | #include "servnobjm.h"
|
---|
[463] | 17 | #include "pistdimgapp.h"
|
---|
| 18 |
|
---|
[544] | 19 | #ifdef SANS_EVOLPLANCK
|
---|
| 20 | #include "cvector.h"
|
---|
| 21 | #include "matrix.h"
|
---|
| 22 | #else
|
---|
| 23 | #include "tmatrix.h"
|
---|
| 24 | #include "tvector.h"
|
---|
| 25 | #endif
|
---|
| 26 |
|
---|
[466] | 27 | /* Reza + cmv 13/10/99 */
|
---|
| 28 |
|
---|
| 29 | /* methode */
|
---|
[463] | 30 | PAWExecutor::PAWExecutor(PIACmd *piac, PIStdImgApp* app)
|
---|
[466] | 31 | : mApp(app)
|
---|
[463] | 32 | {
|
---|
| 33 | string kw, usage;
|
---|
| 34 | string hgrp = "pawCmd";
|
---|
[466] | 35 |
|
---|
| 36 | kw = "reset";
|
---|
| 37 | usage = "Reset histograms vectors or matrix";
|
---|
| 38 | usage += "\n reset nameobj";
|
---|
[463] | 39 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
[466] | 40 |
|
---|
| 41 | kw = "n/plot";
|
---|
[469] | 42 | usage = "Plot NTuple variables a la paw";
|
---|
| 43 | usage += "\n n/plot nameobj.x_exp [cut] [w_exp] [loop] [gratt]";
|
---|
| 44 | usage += "\n n/plot nameobj.y_exp%x_exp [cut] [loop] [gratt]";
|
---|
| 45 | usage += "\n n/plot nameobj.z_exp%y_exp%x_exp [cut] [loop] [gratt]";
|
---|
| 46 | usage += "\n for default use ! , loop=i1[:i2[:di]]";
|
---|
[466] | 47 | usage += "\n Related commands: plot2dw plot3d";
|
---|
| 48 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
| 49 |
|
---|
| 50 | kw = "n/proj";
|
---|
| 51 | usage = "Project NTuple in histogram (1D or 2D) a la paw";
|
---|
[469] | 52 | usage += "\n n/proj nameproj nameobj.x_exp [cut] [w_exp] [loop] [gratt]";
|
---|
| 53 | usage += "\n n/proj nameproj nameobj.y_exp%x_exp [cut] [w_exp] [loop] [gratt]";
|
---|
| 54 | usage += "\n for default use ! , loop=i1[:i2[:di]]";
|
---|
[466] | 55 | usage += "\n Related commands: projh1d projh2d projprof";
|
---|
| 56 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
| 57 |
|
---|
| 58 | kw = "h/integ";
|
---|
| 59 | usage = "Integrate a 1D histogram or profile";
|
---|
| 60 | usage += "\n h/integ nameh1d [norm]";
|
---|
| 61 | usage += "\n Related commands: h/deriv";
|
---|
| 62 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
| 63 |
|
---|
| 64 | kw = "h/deriv";
|
---|
| 65 | usage = "Derivate a 1D histogram or profile";
|
---|
| 66 | usage += "\n h/deriv nameh1d";
|
---|
| 67 | usage += "\n Related commands: h/integ";
|
---|
| 68 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
| 69 |
|
---|
| 70 | kw = "h/rebin";
|
---|
| 71 | usage = "Rebin a 1D histogram or profile";
|
---|
| 72 | usage += "\n h/rebin nbin";
|
---|
| 73 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
| 74 |
|
---|
| 75 | kw = "h/cadd";
|
---|
| 76 | usage = "Add a constant to an histogramme";
|
---|
| 77 | usage += "\n h/cadd val";
|
---|
| 78 | usage += "\n Related commands: h/cmult";
|
---|
| 79 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
| 80 |
|
---|
| 81 | kw = "h/cmult";
|
---|
| 82 | usage = "Multiply an histogramme by a constant";
|
---|
| 83 | usage += "\n h/cmult val";
|
---|
| 84 | usage += "\n Related commands: h/cadd";
|
---|
| 85 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
| 86 |
|
---|
| 87 | kw = "h/plot/2d";
|
---|
| 88 | usage = "Specific plot for 2D histogrammes";
|
---|
| 89 | usage += "\n h/plot/2d nameh2d show : infos on 2D histogramme";
|
---|
| 90 | usage += "\n h/plot/2d nameh2d h [dopt] : plot 2D histogramme";
|
---|
| 91 | usage += "\n h/plot/2d nameh2d px [dopt] : plot X projection";
|
---|
| 92 | usage += "\n h/plot/2d nameh2d py [dopt] : plot Y projection";
|
---|
| 93 | usage += "\n h/plot/2d nameh2d bx n [dopt] : plot X band number n";
|
---|
| 94 | usage += "\n h/plot/2d nameh2d by n [dopt] : plot Y band number n";
|
---|
| 95 | usage += "\n h/plot/2d nameh2d sx n [dopt] : plot X slice number n";
|
---|
| 96 | usage += "\n h/plot/2d nameh2d sy n [dopt] : plot Y slice number n";
|
---|
| 97 | usage += "\n n < 0 means Show Info";
|
---|
| 98 | piac->RegisterCommand(kw,usage,this,hgrp);
|
---|
[463] | 99 | }
|
---|
| 100 |
|
---|
[466] | 101 | /* methode */
|
---|
[463] | 102 | PAWExecutor::~PAWExecutor()
|
---|
| 103 | {
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[466] | 106 | /* methode */
|
---|
[463] | 107 | int PAWExecutor::Execute(string& kw, vector<string>& tokens)
|
---|
| 108 | {
|
---|
[466] | 109 | if(kw == "reset") {
|
---|
| 110 | reset(tokens); return(0);
|
---|
| 111 | } else if(kw == "n/plot") {
|
---|
| 112 | n_plot(tokens); return(0);
|
---|
| 113 | } else if(kw == "n/proj") {
|
---|
| 114 | n_proj(tokens); return(0);
|
---|
| 115 | } else if(kw == "h/integ") {
|
---|
| 116 | h_integ(tokens); return(0);
|
---|
| 117 | } else if(kw == "h/deriv") {
|
---|
| 118 | h_deriv(tokens); return(0);
|
---|
| 119 | } else if(kw == "h/rebin") {
|
---|
| 120 | h_rebin(tokens); return(0);
|
---|
| 121 | } else if(kw == "h/cadd") {
|
---|
| 122 | h_cadd(tokens); return(0);
|
---|
| 123 | } else if(kw == "h/cmult") {
|
---|
| 124 | h_cmult(tokens); return(0);
|
---|
| 125 | } else if(kw == "h/plot/2d") {
|
---|
| 126 | h_plot_2d(tokens); return(0);
|
---|
| 127 | } else return(1);
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | /* methode */
|
---|
| 131 | void PAWExecutor::reset(vector<string>& tokens)
|
---|
| 132 | // Reset d'histogrammes, vecteurs et matrices
|
---|
| 133 | {
|
---|
| 134 | if(tokens.size() < 1)
|
---|
[469] | 135 | {cout<<"Usage: reset nameobj"<<endl; return;}
|
---|
[466] | 136 | NamedObjMgr omg;
|
---|
| 137 | AnyDataObj* mobj = omg.GetObj(tokens[0]);
|
---|
| 138 | if(mobj == NULL)
|
---|
| 139 | {cout<<"PAWExecutor::reset Error , Pas d'objet de nom "<<tokens[0]<<endl;
|
---|
| 140 | return;}
|
---|
| 141 | string ctyp = typeid(*mobj).name();
|
---|
| 142 |
|
---|
[545] | 143 | #ifdef SANS_EVOLPLANCK
|
---|
[466] | 144 | if(typeid(*mobj)==typeid(Vector)) {Vector* ob=(Vector*) mobj; ob->Zero();}
|
---|
| 145 | else if(typeid(*mobj)==typeid(Matrix)) {Matrix* ob=(Matrix*) mobj; ob->Zero();}
|
---|
[545] | 146 | #else
|
---|
| 147 | if(typeid(*mobj)==typeid(Vector)) {Vector* ob=(Vector*) mobj; ob->Reset(0.);}
|
---|
| 148 | else if(typeid(*mobj)==typeid(Matrix)) {Matrix* ob=(Matrix*) mobj; ob->Reset(0.);}
|
---|
| 149 | #endif
|
---|
[466] | 150 | else if(typeid(*mobj)==typeid(Histo)) {Histo* ob=(Histo*) mobj; ob->Zero();}
|
---|
| 151 | else if(typeid(*mobj)==typeid(HProf)) {HProf* ob=(HProf*) mobj; ob->Zero();}
|
---|
| 152 | else if(typeid(*mobj)==typeid(Histo2D)) {Histo2D* ob=(Histo2D*)mobj; ob->Zero();}
|
---|
| 153 | else {
|
---|
| 154 | cout<<"PAWExecutor::reset Error , No reset possible on "<<ctyp<<endl;
|
---|
| 155 | return;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | return;
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | /* methode */
|
---|
| 162 | void PAWExecutor::n_plot(vector<string>& tokens)
|
---|
| 163 | // Equivalent n/plot de paw
|
---|
| 164 | // Plot 1D
|
---|
| 165 | // n/plot nameobj.x_exp [cut] [w_exp] [gratt]
|
---|
| 166 | // Plot 2D (plot2dw)
|
---|
| 167 | // n/plot nameobj.y_exp%x_exp [cut] [w_exp] [gratt]
|
---|
| 168 | // Plot 3D (plot3d)
|
---|
| 169 | // n/plot nameobj.z_exp%y_exp%x_exp [cut] [gratt]
|
---|
| 170 | {
|
---|
| 171 | if(tokens.size() < 1) {
|
---|
| 172 | cout
|
---|
[469] | 173 | <<"Usage: n/plot nameobj.x_exp [cut] [w_exp] [loop] [gratt]"<<endl
|
---|
| 174 | <<" n/plot nameobj.y_exp%x_exp [cut] [loop] [gratt]"<<endl
|
---|
| 175 | <<" n/plot nameobj.z_exp%y_exp%x_exp [cut] [loop] [gratt]"<<endl
|
---|
| 176 | <<" for default use ! , loop=i1[:i2[:di]]"<<endl;
|
---|
[466] | 177 | return;
|
---|
| 178 | }
|
---|
| 179 | string nameobj,expx,expy,expz;
|
---|
| 180 | int nvar = decodepawstring(tokens[0],nameobj,expx,expy,expz);
|
---|
[469] | 181 | string expcut = "1"; string expwt = "1."; string loop = ""; string dopt = "";
|
---|
| 182 | if(tokens.size()>=2) expcut = tokens[1]; if(expcut=="!") expcut="1";
|
---|
[466] | 183 |
|
---|
| 184 | NamedObjMgr omg;
|
---|
| 185 | Services2NObjMgr* srvo = omg.GetServiceObj();
|
---|
| 186 |
|
---|
| 187 | if(nvar<=0) {
|
---|
| 188 | cout<<"PAWExecutor::n_plot Error: bad coding "<<tokens[0]<<endl;
|
---|
| 189 | } else if(nvar==1) { // c'est un plot 1D
|
---|
[469] | 190 | if(tokens.size()>=3) expwt = tokens[2]; if(expwt=="!") expwt="1.";
|
---|
| 191 | if(tokens.size()>=4) loop = tokens[3]; if(loop=="!") loop="";
|
---|
| 192 | if(tokens.size()>=5) dopt = tokens[4];
|
---|
[466] | 193 | string nameproj = "/autoc/paw_n_plot1D";
|
---|
| 194 | AnyDataObj* mobj = omg.GetObj(nameproj);
|
---|
| 195 | if(mobj!=NULL) omg.DelObj(nameproj);
|
---|
| 196 | srvo->ProjectH1(nameobj,expx,expwt,expcut,nameproj,dopt,loop);
|
---|
| 197 | } else if(nvar==2) { // c'est un plot 2D
|
---|
[469] | 198 | if(tokens.size()>=3) loop = tokens[2]; if(loop=="!") loop="";
|
---|
| 199 | if(tokens.size()>=4) dopt = tokens[3];
|
---|
| 200 | string err = "";
|
---|
| 201 | srvo->DisplayPoints2D(nameobj,expx,expy,err,err,expcut,dopt,loop);
|
---|
[466] | 202 | } else { // c'est un plot 3D
|
---|
[469] | 203 | if(tokens.size()>=3) loop = tokens[2]; if(loop=="!") loop="";
|
---|
| 204 | if(tokens.size()>=4) dopt = tokens[3];
|
---|
[466] | 205 | srvo->DisplayPoints3D(nameobj,expx,expy,expz,expcut,dopt,loop);
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | return;
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | /* methode */
|
---|
| 212 | void PAWExecutor::n_proj(vector<string>& tokens)
|
---|
| 213 | // Equivalent n/proj de paw
|
---|
| 214 | // Project NTuple in histogram a la paw
|
---|
| 215 | // Dans un Histo 1D
|
---|
| 216 | // n/proj nameproj nameobj.x_exp [cut] [w_exp] [gratt]
|
---|
| 217 | // Dans un Histo 2D ou un HProf (dans ce cas nameproj doit etre cree).
|
---|
| 218 | // n/proj nameproj nameobj.y_exp%x_exp [cut] [w_exp] [gratt]
|
---|
| 219 | {
|
---|
| 220 | if(tokens.size()<2)
|
---|
[469] | 221 | {cout<<"Usage: n/proj nameproj nameobj.[y_exp%]x_exp [cut] [w_exp] [loop] [gratt]"<<endl
|
---|
| 222 | <<" for default use ! , loop=i1[:i2[:di]]"<<endl; return;}
|
---|
[466] | 223 | string nameproj = tokens[0];
|
---|
| 224 | string nameobj,expx,expy,expz;
|
---|
| 225 | int nvar = decodepawstring(tokens[1],nameobj,expx,expy,expz);
|
---|
[469] | 226 | string expcut = "1"; string expwt = "1."; string loop = ""; string dopt = "";
|
---|
| 227 | if(tokens.size()>=3) expcut = tokens[2]; if(expcut=="!") expcut="1";
|
---|
| 228 | if(tokens.size()>=4) expwt = tokens[3]; if(expwt=="!") expwt="1.";
|
---|
| 229 | if(tokens.size()>=5) loop = tokens[4]; if(loop=="!") loop="";
|
---|
| 230 | if(tokens.size()>=6) dopt = tokens[5];
|
---|
[466] | 231 |
|
---|
| 232 | NamedObjMgr omg;
|
---|
| 233 | Services2NObjMgr* srvo = omg.GetServiceObj();
|
---|
| 234 |
|
---|
| 235 | if(nvar<=0) {
|
---|
| 236 | cout<<"PAWExecutor::n_proj Error: bad coding "<<tokens[1]<<endl;
|
---|
| 237 | } else if(nvar==1) {
|
---|
| 238 | // c'est une projection dans un histo 1D
|
---|
| 239 | srvo->ProjectH1(nameobj,expx,expwt,expcut,nameproj,dopt,loop);
|
---|
| 240 | } else {
|
---|
| 241 | // c'est une projection dans un histo2D
|
---|
| 242 | // OU un HProf si nameproj est HProf un deja defini
|
---|
| 243 | AnyDataObj* mobj = omg.GetObj(nameproj);
|
---|
| 244 | if(mobj==NULL)
|
---|
| 245 | srvo->ProjectH2(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop);
|
---|
| 246 | else if(dynamic_cast<HProf*>(mobj))
|
---|
| 247 | srvo->ProjectHProf(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop);
|
---|
| 248 | else
|
---|
| 249 | srvo->ProjectH2(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop);
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | return;
|
---|
| 253 | }
|
---|
| 254 |
|
---|
| 255 | /* methode */
|
---|
| 256 | void PAWExecutor::h_integ(vector<string>& tokens)
|
---|
| 257 | // Pour remplacer le contenu d'un histo 1D par son integrale
|
---|
| 258 | {
|
---|
| 259 | if(tokens.size()<1)
|
---|
| 260 | {cout<<"Usage: h/integ nameh1d [norm]"<<endl; return;}
|
---|
| 261 | NamedObjMgr omg;
|
---|
| 262 | AnyDataObj* mobj = omg.GetObj(tokens[0]);
|
---|
| 263 | if(mobj==NULL)
|
---|
| 264 | {cout<<"PAWExecutor::h_integ Error: unknow object"<<tokens[0]<<endl;
|
---|
| 265 | return;}
|
---|
| 266 | double norm = 1.;
|
---|
| 267 | if(tokens.size()>=2) norm = atof(tokens[1].c_str());
|
---|
| 268 | Histo* h1 = dynamic_cast<Histo*>(mobj);
|
---|
| 269 | // Le HProf se fait tout seul avec Histo: dynamic_cast<Histo*>(HProf)=Vrai!
|
---|
| 270 | //HProf* hp = dynamic_cast<HProf*>(mobj);
|
---|
| 271 | if(h1) h1->HInteg(norm);
|
---|
| 272 | //else if(hp) hp->HInteg(norm);
|
---|
| 273 | else cout<<"PAWExecutor::h_integ Error: "<<tokens[0]<<" not an Histo/HProf"<<endl;
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | /* methode */
|
---|
| 277 | void PAWExecutor::h_deriv(vector<string>& tokens)
|
---|
| 278 | // Pour remplacer le contenu d'un histo 1D par sa derivee
|
---|
| 279 | {
|
---|
| 280 | if(tokens.size()<1)
|
---|
| 281 | {cout<<"Usage: h/deriv nameh1d"<<endl; return;}
|
---|
| 282 | NamedObjMgr omg;
|
---|
| 283 | AnyDataObj* mobj = omg.GetObj(tokens[0]);
|
---|
| 284 | if(mobj==NULL)
|
---|
| 285 | {cout<<"PAWExecutor::h_deriv Error: unknow object"<<tokens[0]<<endl;
|
---|
| 286 | return;}
|
---|
| 287 | Histo* h1 = dynamic_cast<Histo*>(mobj);
|
---|
| 288 | //HProf* hp = dynamic_cast<HProf*>(mobj);
|
---|
| 289 | if(h1) h1->HDeriv();
|
---|
| 290 | //else if(hp) hp->HDeriv();
|
---|
| 291 | else cout<<"PAWExecutor::h_deriv Error: "<<tokens[0]<<" not an Histo/HProf"<<endl;
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | /* methode */
|
---|
| 295 | void PAWExecutor::h_rebin(vector<string>& tokens)
|
---|
| 296 | // Pour re-binner un histogramme 1D
|
---|
| 297 | {
|
---|
| 298 | if(tokens.size()<2)
|
---|
| 299 | {cout<<"Usage: h/rebin nameh1d nbin"<<endl; return;}
|
---|
| 300 | NamedObjMgr omg;
|
---|
| 301 | AnyDataObj* mobj = omg.GetObj(tokens[0]);
|
---|
| 302 | if(mobj==NULL)
|
---|
| 303 | {cout<<"PAWExecutor::h_rebin Error: unknow object"<<tokens[0]<<endl;
|
---|
| 304 | return;}
|
---|
| 305 | int nbin = atoi(tokens[1].c_str());
|
---|
| 306 | Histo* h1 = dynamic_cast<Histo*>(mobj);
|
---|
| 307 | //HProf* hp = dynamic_cast<HProf*>(mobj);
|
---|
| 308 | if(h1) h1->HRebin(nbin);
|
---|
| 309 | //else if(hp) hp->HRebin(nbin);
|
---|
| 310 | else cout<<"PAWExecutor::h_rebin Error: "<<tokens[0]<<" not an Histo/HProf"<<endl;
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | /* methode */
|
---|
| 314 | void PAWExecutor::h_cadd(vector<string>& tokens)
|
---|
| 315 | // Additionne une constante a un histogramme
|
---|
| 316 | {
|
---|
| 317 | if(tokens.size()<2)
|
---|
| 318 | {cout<<"Usage: h/cadd nameh1d val"<<endl; return;}
|
---|
| 319 | NamedObjMgr omg;
|
---|
| 320 | AnyDataObj* mobj = omg.GetObj(tokens[0]);
|
---|
| 321 | if(mobj==NULL)
|
---|
| 322 | {cout<<"PAWExecutor::h_cadd Error: unknow object"<<tokens[0]<<endl;
|
---|
| 323 | return;}
|
---|
| 324 | double val = atof(tokens[1].c_str());
|
---|
| 325 | Histo* h1 = dynamic_cast<Histo*>(mobj);
|
---|
| 326 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj);
|
---|
| 327 | if(h1) *h1 += val;
|
---|
| 328 | else if(h2) *h2 += val;
|
---|
| 329 | else cout<<"PAWExecutor::h_cadd Error: "<<tokens[0]<<" not an Histo/HProf/Histo2D"<<endl;
|
---|
| 330 | }
|
---|
| 331 |
|
---|
| 332 | /* methode */
|
---|
| 333 | void PAWExecutor::h_cmult(vector<string>& tokens)
|
---|
| 334 | // Multiplie un histogramme par une constante
|
---|
| 335 | {
|
---|
| 336 | if(tokens.size()<2)
|
---|
| 337 | {cout<<"Usage: h/cmult nameh1d val"<<endl; return;}
|
---|
| 338 | NamedObjMgr omg;
|
---|
| 339 | AnyDataObj* mobj = omg.GetObj(tokens[0]);
|
---|
| 340 | if(mobj==NULL)
|
---|
| 341 | {cout<<"PAWExecutor::h_cmult Error: unknow object"<<tokens[0]<<endl;
|
---|
| 342 | return;}
|
---|
| 343 | double val = atof(tokens[1].c_str());
|
---|
| 344 | Histo* h1 = dynamic_cast<Histo*>(mobj);
|
---|
| 345 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj);
|
---|
| 346 | if(h1) *h1 *= val;
|
---|
| 347 | else if(h2) *h2 *= val;
|
---|
| 348 | else cout<<"PAWExecutor::h_cmult Error: "<<tokens[0]
|
---|
| 349 | <<" not an Histo/HProf/Histo2D"<<endl;
|
---|
| 350 | }
|
---|
| 351 |
|
---|
| 352 | /* methode */
|
---|
| 353 | void PAWExecutor::h_plot_2d(vector<string>& tokens)
|
---|
| 354 | // plot for 2D histogramme: plot histo, bandx/y, slicex/y or projx/y
|
---|
| 355 | {
|
---|
| 356 | if(tokens.size()<2)
|
---|
| 357 | {cout<<"Usage: h/plot/2d nameh2d to_plot [n/s] [dopt]"<<endl; return;}
|
---|
| 358 | NamedObjMgr omg;
|
---|
| 359 | AnyDataObj* mobj = omg.GetObj(tokens[0]);
|
---|
| 360 | if(mobj==NULL)
|
---|
| 361 | {cout<<"PAWExecutor::h_plot_2d Error: unknow object"<<tokens[0]<<endl;
|
---|
| 362 | return;}
|
---|
| 363 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj);
|
---|
| 364 | if(!h2)
|
---|
| 365 | {cout<<"PAWExecutor::h_plot_2d Error: "<<tokens[0]<<" not an Histo2D"<<endl;
|
---|
| 366 | return;}
|
---|
| 367 |
|
---|
| 368 | Histo* h1p = NULL; string nametoplot = "/autoc/h_plot_2d_h1";
|
---|
| 369 | AnyDataObj* mobjh1 = omg.GetObj(nametoplot);
|
---|
| 370 | if(mobjh1!=NULL) omg.DelObj(nametoplot);
|
---|
| 371 |
|
---|
| 372 | string dopt = ""; if(tokens.size()>=3) dopt = tokens[2];
|
---|
| 373 | if(tokens[1] == "show") {
|
---|
| 374 | h2->ShowProj();
|
---|
| 375 | h2->ShowBand(2);
|
---|
| 376 | h2->ShowSli(2);
|
---|
| 377 | return;
|
---|
| 378 | } else if(tokens[1] == "h") {
|
---|
| 379 | nametoplot = tokens[0];
|
---|
| 380 | } else if(tokens[1] == "px") {
|
---|
| 381 | if((h1p=h2->HProjX())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
|
---|
| 382 | else {h2->ShowProj(); return;}
|
---|
| 383 | } else if(tokens[1] == "py") {
|
---|
| 384 | if((h1p=h2->HProjY())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
|
---|
| 385 | else {h2->ShowProj(); return;}
|
---|
| 386 | } else {
|
---|
| 387 | if(tokens.size()<3)
|
---|
| 388 | {cout<<"Usage: h/plot/2d nameh2d bx/by/sx/sy n [dopt]"<<endl; return;}
|
---|
| 389 | int n = atoi(tokens[2].c_str());
|
---|
| 390 | dopt = ""; if(tokens.size()>=4) dopt = tokens[3];
|
---|
| 391 | if(tokens[1] == "bx") {
|
---|
| 392 | if((h1p=h2->HBandX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
|
---|
| 393 | else {h2->ShowBand(); return;}
|
---|
| 394 | } else if(tokens[1] == "by") {
|
---|
| 395 | if((h1p=h2->HBandY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
|
---|
| 396 | else {h2->ShowBand(); return;}
|
---|
| 397 | } else if(tokens[1] == "sx") {
|
---|
| 398 | if((h1p=h2->HSliX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
|
---|
| 399 | else {h2->ShowSli(); return;}
|
---|
| 400 | } else if(tokens[1] == "sy") {
|
---|
| 401 | if((h1p=h2->HSliY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);}
|
---|
| 402 | else {h2->ShowSli(); return;}
|
---|
[463] | 403 | }
|
---|
| 404 | }
|
---|
[466] | 405 |
|
---|
| 406 | omg.DisplayObj(nametoplot,dopt);
|
---|
| 407 | }
|
---|
| 408 |
|
---|
| 409 | /* methode */
|
---|
| 410 | int PAWExecutor::decodepawstring(string tokens,string& nameobj
|
---|
| 411 | ,string& xexp,string& yexp,string& zexp)
|
---|
| 412 | // Decodage general de "nameobj.xexp"
|
---|
| 413 | // "nameobj.yexp%xexp"
|
---|
| 414 | // "nameobj.zexp%yexp%xexp"
|
---|
| 415 | // Return: nombre de variables trouvees, -1 si probleme
|
---|
| 416 | {
|
---|
| 417 | nameobj = ""; xexp= ""; yexp= ""; zexp= "";
|
---|
| 418 |
|
---|
| 419 | int lt = (int) tokens.length();
|
---|
| 420 | if(lt<=0) return -1;
|
---|
| 421 |
|
---|
| 422 | // decodage de la chaine de type PAW.
|
---|
| 423 | char *str = new char[lt+2];
|
---|
| 424 | strcpy(str,tokens.c_str()); strip(str,'B',' '); lt = strlen(str);
|
---|
| 425 | //cout<<"chaine1["<<lt<<"] :"<<str<<":"<<endl;
|
---|
| 426 | char *c[3] = {NULL,NULL,NULL};
|
---|
| 427 | int i, np=0; bool namefound = false;
|
---|
| 428 | for(int i=0;i<lt;i++) {
|
---|
| 429 | if(!namefound && str[i]=='.') {
|
---|
| 430 | str[i]='\0';
|
---|
| 431 | namefound=true;
|
---|
| 432 | c[np] = str+i+1; np++;
|
---|
| 433 | }
|
---|
| 434 | if( namefound && str[i]=='%') {
|
---|
| 435 | str[i]='\0';
|
---|
| 436 | if(np<3) {c[np] = str+i+1; np++;}
|
---|
| 437 | }
|
---|
| 438 | }
|
---|
| 439 | //cout<<"chaine2 :"; for(i=0;i<lt;i++) cout<<str[i]; cout<<":"<<endl;
|
---|
| 440 |
|
---|
| 441 | // Remplissage du nom et des variables
|
---|
| 442 | nameobj = str;
|
---|
| 443 | if(np==1) xexp=c[0];
|
---|
| 444 | if(np==2) {yexp=c[0]; xexp=c[1];}
|
---|
| 445 | if(np==3) {zexp=c[0]; yexp=c[1]; xexp=c[2];}
|
---|
| 446 | //cout<<"pawstring str,c[0-2] "<<str<<" "<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl;
|
---|
| 447 | delete [] str;
|
---|
| 448 |
|
---|
| 449 | // Comptage des variables
|
---|
| 450 | np = -1;
|
---|
| 451 | if(nameobj.length()>0)
|
---|
| 452 | {np = 0; if(xexp.length()>0)
|
---|
| 453 | {np++; if(yexp.length()>0)
|
---|
| 454 | {np++; if(zexp.length()>0) np++;}}}
|
---|
| 455 | cout<<"pawstring["<<np<<"] name="<<nameobj
|
---|
| 456 | <<" xexp="<<xexp<<" yexp="<<yexp<<" zexp="<<zexp<<endl;
|
---|
| 457 | return np;
|
---|
| 458 | }
|
---|