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