| [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 | 
|---|
| [815] | 147 | if(typeid(*mobj)==typeid(Vector))       {Vector*  ob=(Vector*) mobj; (*ob) = 0.; } | 
|---|
|  | 148 | // ob->DataBlock().Reset(0.);} | 
|---|
|  | 149 | else if(typeid(*mobj)==typeid(Matrix))   {Matrix*  ob=(Matrix*) mobj; (*ob) = 0.; } | 
|---|
|  | 150 | //ob->DataBlock().Reset(0.);} | 
|---|
| [545] | 151 | #endif | 
|---|
| [466] | 152 | else if(typeid(*mobj)==typeid(Histo))   {Histo*   ob=(Histo*)  mobj; ob->Zero();} | 
|---|
|  | 153 | else if(typeid(*mobj)==typeid(HProf))   {HProf*   ob=(HProf*)  mobj; ob->Zero();} | 
|---|
|  | 154 | else if(typeid(*mobj)==typeid(Histo2D)) {Histo2D* ob=(Histo2D*)mobj; ob->Zero();} | 
|---|
|  | 155 | else { | 
|---|
|  | 156 | cout<<"PAWExecutor::reset Error , No reset possible on "<<ctyp<<endl; | 
|---|
|  | 157 | return; | 
|---|
|  | 158 | } | 
|---|
|  | 159 |  | 
|---|
|  | 160 | return; | 
|---|
|  | 161 | } | 
|---|
|  | 162 |  | 
|---|
|  | 163 | /* methode */ | 
|---|
|  | 164 | void PAWExecutor::n_plot(vector<string>& tokens) | 
|---|
|  | 165 | // Equivalent n/plot de paw | 
|---|
|  | 166 | // Plot 1D | 
|---|
|  | 167 | //   n/plot nameobj.x_exp [cut] [w_exp] [gratt] | 
|---|
|  | 168 | // Plot 2D (plot2dw) | 
|---|
|  | 169 | //   n/plot nameobj.y_exp%x_exp [cut] [w_exp] [gratt] | 
|---|
|  | 170 | // Plot 3D (plot3d) | 
|---|
|  | 171 | //   n/plot nameobj.z_exp%y_exp%x_exp [cut] [gratt] | 
|---|
|  | 172 | { | 
|---|
|  | 173 | if(tokens.size() < 1) { | 
|---|
|  | 174 | cout | 
|---|
| [469] | 175 | <<"Usage: n/plot nameobj.x_exp [cut] [w_exp] [loop] [gratt]"<<endl | 
|---|
|  | 176 | <<"       n/plot nameobj.y_exp%x_exp [cut] [loop] [gratt]"<<endl | 
|---|
|  | 177 | <<"       n/plot nameobj.z_exp%y_exp%x_exp [cut] [loop] [gratt]"<<endl | 
|---|
|  | 178 | <<"              for default use ! , loop=i1[:i2[:di]]"<<endl; | 
|---|
| [466] | 179 | return; | 
|---|
|  | 180 | } | 
|---|
|  | 181 | string nameobj,expx,expy,expz; | 
|---|
|  | 182 | int nvar = decodepawstring(tokens[0],nameobj,expx,expy,expz); | 
|---|
| [469] | 183 | string expcut = "1"; string expwt = "1."; string loop = ""; string dopt = ""; | 
|---|
|  | 184 | if(tokens.size()>=2) expcut = tokens[1]; if(expcut=="!") expcut="1"; | 
|---|
| [466] | 185 |  | 
|---|
|  | 186 | NamedObjMgr omg; | 
|---|
|  | 187 | Services2NObjMgr* srvo = omg.GetServiceObj(); | 
|---|
|  | 188 |  | 
|---|
|  | 189 | if(nvar<=0) { | 
|---|
|  | 190 | cout<<"PAWExecutor::n_plot Error: bad coding "<<tokens[0]<<endl; | 
|---|
|  | 191 | } else if(nvar==1) { // c'est un plot 1D | 
|---|
| [469] | 192 | if(tokens.size()>=3) expwt = tokens[2]; if(expwt=="!") expwt="1."; | 
|---|
|  | 193 | if(tokens.size()>=4) loop  = tokens[3]; if(loop=="!") loop=""; | 
|---|
|  | 194 | if(tokens.size()>=5) dopt  = tokens[4]; | 
|---|
| [466] | 195 | string nameproj = "/autoc/paw_n_plot1D"; | 
|---|
|  | 196 | AnyDataObj* mobj = omg.GetObj(nameproj); | 
|---|
| [685] | 197 | //  if(mobj!=NULL) omg.DelObj(nameproj);  $CHECK$ Reza 12/12/99 - clean auto | 
|---|
| [466] | 198 | srvo->ProjectH1(nameobj,expx,expwt,expcut,nameproj,dopt,loop); | 
|---|
|  | 199 | } else if(nvar==2) { // c'est un plot 2D | 
|---|
| [469] | 200 | if(tokens.size()>=3) loop = tokens[2]; if(loop=="!") loop=""; | 
|---|
|  | 201 | if(tokens.size()>=4) dopt = tokens[3]; | 
|---|
|  | 202 | string err = ""; | 
|---|
|  | 203 | srvo->DisplayPoints2D(nameobj,expx,expy,err,err,expcut,dopt,loop); | 
|---|
| [466] | 204 | } else {             // c'est un plot 3D | 
|---|
| [469] | 205 | if(tokens.size()>=3) loop = tokens[2]; if(loop=="!") loop=""; | 
|---|
|  | 206 | if(tokens.size()>=4) dopt = tokens[3]; | 
|---|
| [466] | 207 | srvo->DisplayPoints3D(nameobj,expx,expy,expz,expcut,dopt,loop); | 
|---|
|  | 208 | } | 
|---|
|  | 209 |  | 
|---|
|  | 210 | return; | 
|---|
|  | 211 | } | 
|---|
|  | 212 |  | 
|---|
|  | 213 | /* methode */ | 
|---|
|  | 214 | void PAWExecutor::n_proj(vector<string>& tokens) | 
|---|
|  | 215 | // Equivalent n/proj de paw | 
|---|
|  | 216 | // Project NTuple in histogram a la paw | 
|---|
|  | 217 | // Dans un Histo 1D | 
|---|
|  | 218 | //   n/proj nameproj nameobj.x_exp [cut] [w_exp] [gratt] | 
|---|
|  | 219 | // Dans un Histo 2D ou un HProf (dans ce cas nameproj doit etre cree). | 
|---|
|  | 220 | //   n/proj nameproj nameobj.y_exp%x_exp [cut] [w_exp] [gratt] | 
|---|
|  | 221 | { | 
|---|
|  | 222 | if(tokens.size()<2) | 
|---|
| [469] | 223 | {cout<<"Usage: n/proj nameproj nameobj.[y_exp%]x_exp [cut] [w_exp] [loop] [gratt]"<<endl | 
|---|
|  | 224 | <<"              for default use ! , loop=i1[:i2[:di]]"<<endl; return;} | 
|---|
| [466] | 225 | string nameproj = tokens[0]; | 
|---|
|  | 226 | string nameobj,expx,expy,expz; | 
|---|
|  | 227 | int nvar = decodepawstring(tokens[1],nameobj,expx,expy,expz); | 
|---|
| [469] | 228 | string expcut = "1"; string expwt = "1."; string loop = ""; string dopt = ""; | 
|---|
|  | 229 | if(tokens.size()>=3) expcut = tokens[2]; if(expcut=="!") expcut="1"; | 
|---|
|  | 230 | if(tokens.size()>=4) expwt  = tokens[3]; if(expwt=="!") expwt="1."; | 
|---|
|  | 231 | if(tokens.size()>=5) loop   = tokens[4]; if(loop=="!") loop=""; | 
|---|
|  | 232 | if(tokens.size()>=6) dopt   = tokens[5]; | 
|---|
| [466] | 233 |  | 
|---|
|  | 234 | NamedObjMgr omg; | 
|---|
|  | 235 | Services2NObjMgr* srvo = omg.GetServiceObj(); | 
|---|
|  | 236 |  | 
|---|
|  | 237 | if(nvar<=0) { | 
|---|
|  | 238 | cout<<"PAWExecutor::n_proj Error: bad coding "<<tokens[1]<<endl; | 
|---|
|  | 239 | } else if(nvar==1) { | 
|---|
|  | 240 | // c'est une projection dans un histo 1D | 
|---|
|  | 241 | srvo->ProjectH1(nameobj,expx,expwt,expcut,nameproj,dopt,loop); | 
|---|
|  | 242 | } else { | 
|---|
|  | 243 | // c'est une projection dans un histo2D | 
|---|
|  | 244 | // OU un HProf si nameproj est HProf un deja defini | 
|---|
|  | 245 | AnyDataObj* mobj = omg.GetObj(nameproj); | 
|---|
|  | 246 | if(mobj==NULL) | 
|---|
|  | 247 | srvo->ProjectH2(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); | 
|---|
|  | 248 | else if(dynamic_cast<HProf*>(mobj)) | 
|---|
|  | 249 | srvo->ProjectHProf(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); | 
|---|
|  | 250 | else | 
|---|
|  | 251 | srvo->ProjectH2(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); | 
|---|
|  | 252 | } | 
|---|
|  | 253 |  | 
|---|
|  | 254 | return; | 
|---|
|  | 255 | } | 
|---|
|  | 256 |  | 
|---|
|  | 257 | /* methode */ | 
|---|
|  | 258 | void PAWExecutor::h_integ(vector<string>& tokens) | 
|---|
|  | 259 | // Pour remplacer le contenu d'un histo 1D par son integrale | 
|---|
|  | 260 | { | 
|---|
|  | 261 | if(tokens.size()<1) | 
|---|
|  | 262 | {cout<<"Usage: h/integ nameh1d [norm]"<<endl; return;} | 
|---|
|  | 263 | NamedObjMgr omg; | 
|---|
|  | 264 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
|  | 265 | if(mobj==NULL) | 
|---|
|  | 266 | {cout<<"PAWExecutor::h_integ Error: unknow object"<<tokens[0]<<endl; | 
|---|
|  | 267 | return;} | 
|---|
|  | 268 | double norm = 1.; | 
|---|
|  | 269 | if(tokens.size()>=2) norm = atof(tokens[1].c_str()); | 
|---|
|  | 270 | Histo* h1 = dynamic_cast<Histo*>(mobj); | 
|---|
|  | 271 | // Le HProf se fait tout seul avec Histo: dynamic_cast<Histo*>(HProf)=Vrai! | 
|---|
|  | 272 | //HProf* hp = dynamic_cast<HProf*>(mobj); | 
|---|
|  | 273 | if(h1)      h1->HInteg(norm); | 
|---|
|  | 274 | //else if(hp) hp->HInteg(norm); | 
|---|
|  | 275 | else cout<<"PAWExecutor::h_integ Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; | 
|---|
|  | 276 | } | 
|---|
|  | 277 |  | 
|---|
|  | 278 | /* methode */ | 
|---|
|  | 279 | void PAWExecutor::h_deriv(vector<string>& tokens) | 
|---|
|  | 280 | // Pour remplacer le contenu d'un histo 1D par sa derivee | 
|---|
|  | 281 | { | 
|---|
|  | 282 | if(tokens.size()<1) | 
|---|
|  | 283 | {cout<<"Usage: h/deriv nameh1d"<<endl; return;} | 
|---|
|  | 284 | NamedObjMgr omg; | 
|---|
|  | 285 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
|  | 286 | if(mobj==NULL) | 
|---|
|  | 287 | {cout<<"PAWExecutor::h_deriv Error: unknow object"<<tokens[0]<<endl; | 
|---|
|  | 288 | return;} | 
|---|
|  | 289 | Histo* h1 = dynamic_cast<Histo*>(mobj); | 
|---|
|  | 290 | //HProf* hp = dynamic_cast<HProf*>(mobj); | 
|---|
|  | 291 | if(h1)      h1->HDeriv(); | 
|---|
|  | 292 | //else if(hp) hp->HDeriv(); | 
|---|
|  | 293 | else cout<<"PAWExecutor::h_deriv Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; | 
|---|
|  | 294 | } | 
|---|
|  | 295 |  | 
|---|
|  | 296 | /* methode */ | 
|---|
|  | 297 | void PAWExecutor::h_rebin(vector<string>& tokens) | 
|---|
|  | 298 | // Pour re-binner un histogramme 1D | 
|---|
|  | 299 | { | 
|---|
|  | 300 | if(tokens.size()<2) | 
|---|
|  | 301 | {cout<<"Usage: h/rebin nameh1d nbin"<<endl; return;} | 
|---|
|  | 302 | NamedObjMgr omg; | 
|---|
|  | 303 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
|  | 304 | if(mobj==NULL) | 
|---|
|  | 305 | {cout<<"PAWExecutor::h_rebin Error: unknow object"<<tokens[0]<<endl; | 
|---|
|  | 306 | return;} | 
|---|
|  | 307 | int nbin = atoi(tokens[1].c_str()); | 
|---|
|  | 308 | Histo* h1 = dynamic_cast<Histo*>(mobj); | 
|---|
|  | 309 | //HProf* hp = dynamic_cast<HProf*>(mobj); | 
|---|
|  | 310 | if(h1)      h1->HRebin(nbin); | 
|---|
|  | 311 | //else if(hp) hp->HRebin(nbin); | 
|---|
|  | 312 | else cout<<"PAWExecutor::h_rebin Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; | 
|---|
|  | 313 | } | 
|---|
|  | 314 |  | 
|---|
|  | 315 | /* methode */ | 
|---|
|  | 316 | void PAWExecutor::h_cadd(vector<string>& tokens) | 
|---|
|  | 317 | // Additionne une constante a un histogramme | 
|---|
|  | 318 | { | 
|---|
|  | 319 | if(tokens.size()<2) | 
|---|
|  | 320 | {cout<<"Usage: h/cadd nameh1d val"<<endl; return;} | 
|---|
|  | 321 | NamedObjMgr omg; | 
|---|
|  | 322 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
|  | 323 | if(mobj==NULL) | 
|---|
|  | 324 | {cout<<"PAWExecutor::h_cadd Error: unknow object"<<tokens[0]<<endl; | 
|---|
|  | 325 | return;} | 
|---|
|  | 326 | double val = atof(tokens[1].c_str()); | 
|---|
|  | 327 | Histo*   h1 = dynamic_cast<Histo*>(mobj); | 
|---|
|  | 328 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); | 
|---|
|  | 329 | if(h1)      *h1 += val; | 
|---|
|  | 330 | else if(h2) *h2 += val; | 
|---|
|  | 331 | else cout<<"PAWExecutor::h_cadd Error: "<<tokens[0]<<" not an Histo/HProf/Histo2D"<<endl; | 
|---|
|  | 332 | } | 
|---|
|  | 333 |  | 
|---|
|  | 334 | /* methode */ | 
|---|
|  | 335 | void PAWExecutor::h_cmult(vector<string>& tokens) | 
|---|
|  | 336 | // Multiplie un histogramme par une constante | 
|---|
|  | 337 | { | 
|---|
|  | 338 | if(tokens.size()<2) | 
|---|
|  | 339 | {cout<<"Usage: h/cmult nameh1d val"<<endl; return;} | 
|---|
|  | 340 | NamedObjMgr omg; | 
|---|
|  | 341 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
|  | 342 | if(mobj==NULL) | 
|---|
|  | 343 | {cout<<"PAWExecutor::h_cmult Error: unknow object"<<tokens[0]<<endl; | 
|---|
|  | 344 | return;} | 
|---|
|  | 345 | double val = atof(tokens[1].c_str()); | 
|---|
|  | 346 | Histo*   h1 = dynamic_cast<Histo*>(mobj); | 
|---|
|  | 347 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); | 
|---|
|  | 348 | if(h1)      *h1 *= val; | 
|---|
|  | 349 | else if(h2) *h2 *= val; | 
|---|
|  | 350 | else cout<<"PAWExecutor::h_cmult Error: "<<tokens[0] | 
|---|
|  | 351 | <<" not an Histo/HProf/Histo2D"<<endl; | 
|---|
|  | 352 | } | 
|---|
|  | 353 |  | 
|---|
|  | 354 | /* methode */ | 
|---|
|  | 355 | void PAWExecutor::h_plot_2d(vector<string>& tokens) | 
|---|
|  | 356 | // plot for 2D histogramme: plot histo, bandx/y, slicex/y or projx/y | 
|---|
|  | 357 | { | 
|---|
|  | 358 | if(tokens.size()<2) | 
|---|
|  | 359 | {cout<<"Usage: h/plot/2d nameh2d to_plot [n/s] [dopt]"<<endl; return;} | 
|---|
|  | 360 | NamedObjMgr omg; | 
|---|
|  | 361 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
|  | 362 | if(mobj==NULL) | 
|---|
|  | 363 | {cout<<"PAWExecutor::h_plot_2d Error: unknow object"<<tokens[0]<<endl; | 
|---|
|  | 364 | return;} | 
|---|
|  | 365 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); | 
|---|
|  | 366 | if(!h2) | 
|---|
|  | 367 | {cout<<"PAWExecutor::h_plot_2d Error: "<<tokens[0]<<" not an Histo2D"<<endl; | 
|---|
|  | 368 | return;} | 
|---|
|  | 369 |  | 
|---|
|  | 370 | Histo* h1p = NULL; string nametoplot = "/autoc/h_plot_2d_h1"; | 
|---|
|  | 371 | AnyDataObj* mobjh1 = omg.GetObj(nametoplot); | 
|---|
| [685] | 372 | // if(mobjh1!=NULL) omg.DelObj(nametoplot);  $CHECK$ Reza 12/12/99 - Ne pas faire - autoclean | 
|---|
| [466] | 373 |  | 
|---|
|  | 374 | string dopt = ""; if(tokens.size()>=3) dopt = tokens[2]; | 
|---|
|  | 375 | if(tokens[1] == "show") { | 
|---|
|  | 376 | h2->ShowProj(); | 
|---|
|  | 377 | h2->ShowBand(2); | 
|---|
|  | 378 | h2->ShowSli(2); | 
|---|
|  | 379 | return; | 
|---|
|  | 380 | } else if(tokens[1] == "h") { | 
|---|
|  | 381 | nametoplot = tokens[0]; | 
|---|
|  | 382 | } else if(tokens[1] == "px") { | 
|---|
|  | 383 | if((h1p=h2->HProjX())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
|  | 384 | else {h2->ShowProj(); return;} | 
|---|
|  | 385 | } else if(tokens[1] == "py") { | 
|---|
|  | 386 | if((h1p=h2->HProjY())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
|  | 387 | else {h2->ShowProj(); return;} | 
|---|
|  | 388 | } else { | 
|---|
|  | 389 | if(tokens.size()<3) | 
|---|
|  | 390 | {cout<<"Usage: h/plot/2d nameh2d bx/by/sx/sy n [dopt]"<<endl; return;} | 
|---|
|  | 391 | int n = atoi(tokens[2].c_str()); | 
|---|
|  | 392 | dopt = ""; if(tokens.size()>=4) dopt = tokens[3]; | 
|---|
|  | 393 | if(tokens[1] == "bx") { | 
|---|
|  | 394 | if((h1p=h2->HBandX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
|  | 395 | else {h2->ShowBand(); return;} | 
|---|
|  | 396 | } else if(tokens[1] == "by") { | 
|---|
|  | 397 | if((h1p=h2->HBandY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
|  | 398 | else {h2->ShowBand(); return;} | 
|---|
|  | 399 | } else if(tokens[1] == "sx") { | 
|---|
|  | 400 | if((h1p=h2->HSliX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
|  | 401 | else {h2->ShowSli(); return;} | 
|---|
|  | 402 | } else if(tokens[1] == "sy") { | 
|---|
|  | 403 | if((h1p=h2->HSliY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
|  | 404 | else {h2->ShowSli(); return;} | 
|---|
| [463] | 405 | } | 
|---|
|  | 406 | } | 
|---|
| [466] | 407 |  | 
|---|
|  | 408 | omg.DisplayObj(nametoplot,dopt); | 
|---|
|  | 409 | } | 
|---|
|  | 410 |  | 
|---|
|  | 411 | /* methode */ | 
|---|
|  | 412 | int PAWExecutor::decodepawstring(string tokens,string& nameobj | 
|---|
|  | 413 | ,string& xexp,string& yexp,string& zexp) | 
|---|
|  | 414 | // Decodage general de "nameobj.xexp" | 
|---|
|  | 415 | //                     "nameobj.yexp%xexp" | 
|---|
|  | 416 | //                     "nameobj.zexp%yexp%xexp" | 
|---|
|  | 417 | // Return: nombre de variables trouvees, -1 si probleme | 
|---|
|  | 418 | { | 
|---|
|  | 419 | nameobj = ""; xexp= ""; yexp= ""; zexp= ""; | 
|---|
|  | 420 |  | 
|---|
|  | 421 | int lt = (int) tokens.length(); | 
|---|
|  | 422 | if(lt<=0) return -1; | 
|---|
|  | 423 |  | 
|---|
|  | 424 | // decodage de la chaine de type PAW. | 
|---|
|  | 425 | char *str = new char[lt+2]; | 
|---|
|  | 426 | strcpy(str,tokens.c_str()); strip(str,'B',' '); lt = strlen(str); | 
|---|
|  | 427 | //cout<<"chaine1["<<lt<<"] :"<<str<<":"<<endl; | 
|---|
|  | 428 | char *c[3] = {NULL,NULL,NULL}; | 
|---|
|  | 429 | int i, np=0; bool namefound = false; | 
|---|
| [562] | 430 | for(i=0;i<lt;i++) { | 
|---|
| [466] | 431 | if(!namefound && str[i]=='.') { | 
|---|
|  | 432 | str[i]='\0'; | 
|---|
|  | 433 | namefound=true; | 
|---|
|  | 434 | c[np] = str+i+1; np++; | 
|---|
|  | 435 | } | 
|---|
|  | 436 | if( namefound && str[i]=='%') { | 
|---|
|  | 437 | str[i]='\0'; | 
|---|
|  | 438 | if(np<3) {c[np] = str+i+1; np++;} | 
|---|
|  | 439 | } | 
|---|
|  | 440 | } | 
|---|
|  | 441 | //cout<<"chaine2 :"; for(i=0;i<lt;i++) cout<<str[i]; cout<<":"<<endl; | 
|---|
|  | 442 |  | 
|---|
|  | 443 | // Remplissage du nom et des variables | 
|---|
|  | 444 | nameobj = str; | 
|---|
|  | 445 | if(np==1)  xexp=c[0]; | 
|---|
|  | 446 | if(np==2) {yexp=c[0]; xexp=c[1];} | 
|---|
|  | 447 | if(np==3) {zexp=c[0]; yexp=c[1]; xexp=c[2];} | 
|---|
|  | 448 | //cout<<"pawstring str,c[0-2] "<<str<<" "<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl; | 
|---|
|  | 449 | delete [] str; | 
|---|
|  | 450 |  | 
|---|
|  | 451 | // Comptage des variables | 
|---|
|  | 452 | np = -1; | 
|---|
|  | 453 | if(nameobj.length()>0) | 
|---|
|  | 454 | {np = 0; if(xexp.length()>0) | 
|---|
|  | 455 | {np++; if(yexp.length()>0) | 
|---|
|  | 456 | {np++; if(zexp.length()>0) np++;}}} | 
|---|
|  | 457 | cout<<"pawstring["<<np<<"] name="<<nameobj | 
|---|
|  | 458 | <<" xexp="<<xexp<<" yexp="<<yexp<<" zexp="<<zexp<<endl; | 
|---|
|  | 459 | return np; | 
|---|
|  | 460 | } | 
|---|