| 1 | #include <stdio.h> | 
|---|
| 2 | #include <stdlib.h> | 
|---|
| 3 | #include <ctype.h> | 
|---|
| 4 | #include <iostream> | 
|---|
| 5 | #include <typeinfo> | 
|---|
| 6 |  | 
|---|
| 7 | #include "sopnamsp.h" | 
|---|
| 8 | #include "strutil.h" | 
|---|
| 9 | #include "strutilxx.h" | 
|---|
| 10 | #include "histos.h" | 
|---|
| 11 | #include "histos2.h" | 
|---|
| 12 | #include "hisprof.h" | 
|---|
| 13 | #include "histerr.h" | 
|---|
| 14 | #include "ntuple.h" | 
|---|
| 15 | #include "datatable.h" | 
|---|
| 16 |  | 
|---|
| 17 | #include "pawexecut.h" | 
|---|
| 18 | #include "nobjmgr.h" | 
|---|
| 19 | #include "servnobjm.h" | 
|---|
| 20 | #include "nomgadapter.h" | 
|---|
| 21 | #include "pistdimgapp.h" | 
|---|
| 22 | #include "pihisto.h" | 
|---|
| 23 |  | 
|---|
| 24 | #ifdef SANS_EVOLPLANCK | 
|---|
| 25 | #include "cvector.h" | 
|---|
| 26 | #include "matrix.h" | 
|---|
| 27 | #else | 
|---|
| 28 | #include "tmatrix.h" | 
|---|
| 29 | #include "tvector.h" | 
|---|
| 30 | #endif | 
|---|
| 31 |  | 
|---|
| 32 | /* Reza + cmv  13/10/99 */ | 
|---|
| 33 |  | 
|---|
| 34 | inline bool __vector_sort_up_r8(r_8 x1,r_8 x2) {return x1<x2;} | 
|---|
| 35 | inline bool __vector_sort_down_r8(r_8 x1,r_8 x2) {return x1>x2;} | 
|---|
| 36 | inline bool __vector_sort_up_r4(r_4 x1,r_4 x2) {return x1<x2;} | 
|---|
| 37 | inline bool __vector_sort_down_r4(r_4 x1,r_4 x2) {return x1>x2;} | 
|---|
| 38 | inline bool __vector_sort_up_i4(int_4 x1,int_4 x2) {return x1<x2;} | 
|---|
| 39 | inline bool __vector_sort_down_i4(int_4 x1,int_4 x2) {return x1>x2;} | 
|---|
| 40 | inline bool __vector_sort_up_u8(uint_8 x1,uint_8 x2) {return x1<x2;} | 
|---|
| 41 | inline bool __vector_sort_down_u8(uint_8 x1,uint_8 x2) {return x1>x2;} | 
|---|
| 42 |  | 
|---|
| 43 | uint_4 PAWExecutor::autoc_counter_ = 0; | 
|---|
| 44 |  | 
|---|
| 45 | /* methode */ | 
|---|
| 46 | PAWExecutor::PAWExecutor(PIACmd *piac, PIStdImgApp* app) | 
|---|
| 47 | : mApp(app) | 
|---|
| 48 | { | 
|---|
| 49 | string kw, usage; | 
|---|
| 50 | string hgrp = "pawCmd"; | 
|---|
| 51 |  | 
|---|
| 52 | kw = "reset"; | 
|---|
| 53 | usage = "Reset histograms vectors or matrix"; | 
|---|
| 54 | usage += "\n reset nameobj"; | 
|---|
| 55 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 56 |  | 
|---|
| 57 | kw = "n/plot"; | 
|---|
| 58 | usage = "Plot NTuple variables \"a la paw\" (alias n/pl)"; | 
|---|
| 59 | usage += "\n n/plot nameobj.x_exp [cut] [w_exp] [loop] [gratt]"; | 
|---|
| 60 | usage += "\n n/plot nameobj.y_exp%x_exp [cut] [loop] [gratt]"; | 
|---|
| 61 | usage += "\n n/plot nameobj.z_exp%y_exp%x_exp [cut] [loop] [gratt]"; | 
|---|
| 62 | usage += "\n        for default use ! , loop=i1[:i2[:di]]"; | 
|---|
| 63 | usage += "\n for 1 dimensional (1D) projection:"; | 
|---|
| 64 | usage += "\n   use graphic option \"keepbin\" to keep previous"; | 
|---|
| 65 | usage += "\n   plot binning for 1D distribution"; | 
|---|
| 66 | usage += "\n  Related commands: plot2dw plot3d"; | 
|---|
| 67 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 68 |  | 
|---|
| 69 | kw = "n/pl"; | 
|---|
| 70 | usage = "alias to n/plot (see n/plot)"; | 
|---|
| 71 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 72 |  | 
|---|
| 73 | kw = "n/proj"; | 
|---|
| 74 | usage = "Project NTuple in histogram (1D or 2D) a la paw"; | 
|---|
| 75 | usage += "\n n/proj nameproj nameobj.x_exp [cut] [w_exp] [loop] [gratt]"; | 
|---|
| 76 | usage += "\n n/proj nameproj nameobj.y_exp%x_exp [cut] [w_exp] [loop] [gratt]"; | 
|---|
| 77 | usage += "\n        for default use ! , loop=i1[:i2[:di]]"; | 
|---|
| 78 | usage += "\n for 1 dimensional (1D) projection:"; | 
|---|
| 79 | usage += "\n   no display is performed if \"nameproj\" is an existing histogram"; | 
|---|
| 80 | usage += "\n   unless a graphic option \"gratt\" is given"; | 
|---|
| 81 | usage += "\n  Related commands: projh1d projh2d projprof exptovec"; | 
|---|
| 82 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 83 |  | 
|---|
| 84 | kw = "n/scan"; | 
|---|
| 85 | usage = "Scan NTuple a la paw"; | 
|---|
| 86 | usage += "\n n/scan nameobj[.exp1%exp2%exp3] cut loop"; | 
|---|
| 87 | usage += "\n               [-f:filename] [list_of_variables]"; | 
|---|
| 88 | usage += "\n  loop : iev1[:iev2[:diev]] or !"; | 
|---|
| 89 | usage += "\n  cut  : cut expression or 1. or !"; | 
|---|
| 90 | usage += "\n  list_of_variables : default is all variables"; | 
|---|
| 91 | usage += "\n                    : var1 var2 var3 ... varn"; | 
|---|
| 92 | usage += "\n                    : var1 : var2   (from var1 to var2)"; | 
|---|
| 93 | usage += "\n                    :  : var2   (from first variable to var2)"; | 
|---|
| 94 | usage += "\n                    : var1 :    (from var1 to last variable)"; | 
|---|
| 95 | usage += "\n                  ex: \"v1 : v3 v7 v4 : v6 v2 v9 :\""; | 
|---|
| 96 | usage += "\n exp1%exp2%exp3 :"; | 
|---|
| 97 | usage += "\n           if given add exp1,exp2,exp3 to the variable list"; | 
|---|
| 98 | usage += "\n -f:filename : write into \"filename\", Default is to stdout"; | 
|---|
| 99 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 100 |  | 
|---|
| 101 | kw = "n/read"; | 
|---|
| 102 | usage = "Read columns in an ASCII file and fill a NTuple or a DataTable"; | 
|---|
| 103 | usage += "\n n/read nt fascii [options] var_1,c_1 var_2,c_2 ... var_n,c_n "; | 
|---|
| 104 | usage += "\n nt : NTuple or DataTable (see options) name"; | 
|---|
| 105 | usage += "\n var_i,c_i : variable name, associated column in ASCII file [0,n["; | 
|---|
| 106 | usage += "\n where [options] are:"; | 
|---|
| 107 | usage += "\n   \"-dt\": create a DataTable of double instead of a NTuple"; | 
|---|
| 108 | usage += "\n   \"=s\": separator character is \'s\' (could be \"\t\")"; | 
|---|
| 109 | usage += "\n   \"-^abcd\": do not read lines beginning with string \"abcd\" "; | 
|---|
| 110 | usage += "\n   \"+^abcd\": read only lines beginning with string \"abcd\" "; | 
|---|
| 111 | usage += "\n   \"-abcd\": do not read lines which contain string \"abcd\" "; | 
|---|
| 112 | usage += "\n   \"+abcd\": read only lines which contain string \"abcd\" "; | 
|---|
| 113 | usage += "\n these options may be repeated (ex: \"-^abcd\" \"-^xyz\") "; | 
|---|
| 114 | usage += "\n   - in case of \"do not read\" options are added with logical AND "; | 
|---|
| 115 | usage += "\n   - in case of \"read only\" options are added with logical OR "; | 
|---|
| 116 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 117 |  | 
|---|
| 118 | kw = "n/merge"; | 
|---|
| 119 | usage = "Merge ntuples (by adding lines)"; | 
|---|
| 120 | usage += "\n n/merge nt nt_1 nt_2 ... nt_n"; | 
|---|
| 121 | usage += "\n Merge ntuples nt_i lines into ntuple nt"; | 
|---|
| 122 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 123 |  | 
|---|
| 124 | kw = "n/merge/col"; | 
|---|
| 125 | usage = "Merge ntuples (by adding columns for each line)"; | 
|---|
| 126 | usage += "\n n/merge/col nt nt_1[,ext] nt_2[,ext] ... nt_n[,ext]"; | 
|---|
| 127 | usage += "\n Merge ntuples nt_i columns into ntuple nt"; | 
|---|
| 128 | usage += "\n ext : character string to add at the end of the ntuple variable names"; | 
|---|
| 129 | usage += "\n   if \"ext\"=\"!\" no extension is added"; | 
|---|
| 130 | usage += "\n   if no \"ext\" is given, automatic extension \"_0\" \"_1\" \"_2\" ..."; | 
|---|
| 131 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 132 |  | 
|---|
| 133 | kw = "n/assoc/col"; | 
|---|
| 134 | usage = "Merge ntuples columns with an association index"; | 
|---|
| 135 | usage += "\n n/assoc/col ntass[,u/i] nt_1[,ext] nt_2[,ext] nt_assoc[,icass]"; | 
|---|
| 136 | usage += "\n Merge ntuples nt_1 and nt_2 columns into ntuple ntass"; | 
|---|
| 137 | usage += "\n   with line association number given by ntuple nt_assoc"; | 
|---|
| 138 | usage += "\n ---"; | 
|---|
| 139 | usage += "\n icass: association number given by column \"icass\" of nt_assoc (def=0)"; | 
|---|
| 140 | usage += "\n ---"; | 
|---|
| 141 | usage += "\n ext : character string to add at the end of the ntuple variable names"; | 
|---|
| 142 | usage += "\n   if \"ext\"=\"!\" no extension is added"; | 
|---|
| 143 | usage += "\n   if no \"ext\" is given, automatic extension \"_0\" \"_1\" \"_2\" ..."; | 
|---|
| 144 | usage += "\n ---"; | 
|---|
| 145 | usage += "\n u   : do the union of all the lines of nt_1 and nt_2"; | 
|---|
| 146 | usage += "\n       (all ssociated and un-associated lines of nt_1 and nt_2)"; | 
|---|
| 147 | usage += "\n i   : do the intersection of all the lines of nt_1 and nt_2"; | 
|---|
| 148 | usage += "\n       (only associated lines of nt_1 and nt_2)"; | 
|---|
| 149 | usage += "\n def : write all lines of nt_1 with possible associated line of nt_2"; | 
|---|
| 150 | usage += "\n       (number of entries of ntass = number of entries of nt_1)"; | 
|---|
| 151 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 152 |  | 
|---|
| 153 | kw = "n/copy"; | 
|---|
| 154 | usage = "Copy all or some variables of a ntuple into another new ntuple"; | 
|---|
| 155 | usage += "\n n/merge ntnew nt [vname1 vname2 vname3 ...]"; | 
|---|
| 156 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 157 |  | 
|---|
| 158 | kw = "h/integ"; | 
|---|
| 159 | usage = "Integrate a 1D histogram"; | 
|---|
| 160 | usage += "\n h/integ nameh1d [norm]"; | 
|---|
| 161 | usage += "\n norm<=0 means no normalisation (def norm=1)"; | 
|---|
| 162 | usage += "\n  Related commands: h/deriv v/integ v/deriv"; | 
|---|
| 163 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 164 |  | 
|---|
| 165 | kw = "v/integ"; | 
|---|
| 166 | usage = "Integrate a TVector / vector"; | 
|---|
| 167 | usage += "\n v/integ namevec [norm]"; | 
|---|
| 168 | usage += "\n norm<=0 means no normalisation (def norm=0)"; | 
|---|
| 169 | usage += "\n  Related commands: h/integ h/deriv v/deriv"; | 
|---|
| 170 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 171 |  | 
|---|
| 172 | kw = "v/sort"; | 
|---|
| 173 | usage = "Sort a vector into itself"; | 
|---|
| 174 | usage += "\n v/sort namevec [+1/-1]"; | 
|---|
| 175 | usage += "\n \"+1\" means increasing order, \"-1\" decreasing order"; | 
|---|
| 176 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 177 |  | 
|---|
| 178 | kw = "h/deriv"; | 
|---|
| 179 | usage = "Derivate a 1D histogram"; | 
|---|
| 180 | usage += "\n h/deriv nameh1d"; | 
|---|
| 181 | usage += "\n  Related commands: h/integ v/integ v/deriv"; | 
|---|
| 182 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 183 |  | 
|---|
| 184 | kw = "v/deriv"; | 
|---|
| 185 | usage = "Derivate a TVector / vector"; | 
|---|
| 186 | usage += "\n v/deriv namevec [deriv_option]"; | 
|---|
| 187 | usage += "\n deriv_option -1 replace v[i] with v[i]-v[i-1]"; | 
|---|
| 188 | usage += "\n               0 replace v[i] with (v[i+1]-v[i-1])/2 (default)"; | 
|---|
| 189 | usage += "\n              +1 replace v[i] with v[i+1]-v[i]"; | 
|---|
| 190 | usage += "\n  Related commands: h/integ h/deriv v/integ"; | 
|---|
| 191 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 192 |  | 
|---|
| 193 | kw = "h/rebin"; | 
|---|
| 194 | usage = "Rebin a 1D histogram or profile"; | 
|---|
| 195 | usage += "\n h/rebin nameh1d nbin"; | 
|---|
| 196 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 197 |  | 
|---|
| 198 | kw = "h/cadd"; | 
|---|
| 199 | usage = "Add a constant to an histogram, a vector or a matrix"; | 
|---|
| 200 | usage += "\n h/cadd namehisto val"; | 
|---|
| 201 | usage += "\n  Related commands: h/cmult h/oper"; | 
|---|
| 202 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 203 |  | 
|---|
| 204 | kw = "h/cmult"; | 
|---|
| 205 | usage = "Multiply an histogram, a vector or a matrix by a constant"; | 
|---|
| 206 | usage += "\n h/cmult namehisto val"; | 
|---|
| 207 | usage += "\n  Related commands: h/cadd h/oper"; | 
|---|
| 208 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 209 |  | 
|---|
| 210 | kw = "h/oper"; | 
|---|
| 211 | usage = "Operation on histograms vectors or matrices"; | 
|---|
| 212 | usage += "\n h/oper @ h1 h2 hres"; | 
|---|
| 213 | usage += "\n        hres = h1 @ h2   with @ = (+,-,*,/)"; | 
|---|
| 214 | usage += "\n For vectors and matrices, operations are elements by elements"; | 
|---|
| 215 | usage += "\n  Related commands: h/cadd h/cmult"; | 
|---|
| 216 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 217 |  | 
|---|
| 218 | kw = "h/plot/2d"; | 
|---|
| 219 | usage = "Specific plot for 2D histogrammes"; | 
|---|
| 220 | usage += "\n h/plot/2d nameh2d show        : infos on 2D histogramme"; | 
|---|
| 221 | usage += "\n h/plot/2d nameh2d h    [dopt] : plot 2D histogramme"; | 
|---|
| 222 | usage += "\n h/plot/2d nameh2d px   [dopt] : plot X projection"; | 
|---|
| 223 | usage += "\n h/plot/2d nameh2d py   [dopt] : plot Y projection"; | 
|---|
| 224 | usage += "\n h/plot/2d nameh2d bx n [dopt] : plot X band number n"; | 
|---|
| 225 | usage += "\n h/plot/2d nameh2d by n [dopt] : plot Y band number n"; | 
|---|
| 226 | usage += "\n h/plot/2d nameh2d sx n [dopt] : plot X slice number n"; | 
|---|
| 227 | usage += "\n h/plot/2d nameh2d sy n [dopt] : plot Y slice number n"; | 
|---|
| 228 | usage += "\n                      n < 0 means Show Info"; | 
|---|
| 229 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 230 |  | 
|---|
| 231 | kw = "h/put_vec"; | 
|---|
| 232 | usage = "Put content of vector (matrix) into content of histogram 1D or 2D"; | 
|---|
| 233 | usage += "\n h/put_vec nameh1d namevector [cont,err2]"; | 
|---|
| 234 | usage += "\n h/put_vec nameh2d namematrix [cont,err2]"; | 
|---|
| 235 | usage += "\n     cont : put into histogramme content"; | 
|---|
| 236 | usage += "\n     err2 : put into histogramme error^2"; | 
|---|
| 237 | usage += "\n  Related commands: h/get_vec"; | 
|---|
| 238 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 239 |  | 
|---|
| 240 | kw = "h/get_vec"; | 
|---|
| 241 | usage = "Get content of histogram 1D profile or 2D into vector (matrix)"; | 
|---|
| 242 | usage += "\n h/get_vec nameh1d namevector [cont,err2,absc] [proj]"; | 
|---|
| 243 | usage += "\n h/get_vec nameh2d namematrix [cont,err2,absc]"; | 
|---|
| 244 | usage += "\n   cont : get histogramme content"; | 
|---|
| 245 | usage += "\n   err2 : get histogramme error^2"; | 
|---|
| 246 | usage += "\n   absc : get histogramme low bin abscissa (1D only)"; | 
|---|
| 247 | usage += "\n     proj :"; | 
|---|
| 248 | usage += "\n            show  : show available projections for Histo2D"; | 
|---|
| 249 | usage += "\n            px    : get X projection"; | 
|---|
| 250 | usage += "\n            py    : get Y projection"; | 
|---|
| 251 | usage += "\n            bx n  : get X band number n"; | 
|---|
| 252 | usage += "\n            by n  : get Y band number n"; | 
|---|
| 253 | usage += "\n            sx n  : get X slice number n"; | 
|---|
| 254 | usage += "\n            sy n  : get Y slice number n"; | 
|---|
| 255 | usage += "\n  Related commands: h/put_vec"; | 
|---|
| 256 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 257 |  | 
|---|
| 258 | kw = "h/copy"; | 
|---|
| 259 | usage = "Copy content of object1 into object2"; | 
|---|
| 260 | usage += "\n objects are Vector,Matrix,Histo,Histo2D"; | 
|---|
| 261 | usage += "\n h/copy namefrom nametocopy [i1[:i2]] [j1[:j2]] [ic1[:jc1]]"; | 
|---|
| 262 | usage += "\n   copy obj1Dfrom(i1->i2) into obj1Dto(ic1->)"; | 
|---|
| 263 | usage += "\n   copy obj2Dfrom(i1,j1->i2,j2) into obj2Dto(ic1,jc1->)"; | 
|---|
| 264 | usage += "\n Warning: elements from i1 to i2 included are copied"; | 
|---|
| 265 | usage += "\n If obj1Dto does not exist, is is created with size i2-i1+1"; | 
|---|
| 266 | usage += "\n    or obj2Dto with size i2-i1+1,j2-j1+1"; | 
|---|
| 267 | usage += "\n The adressed content of obj?Dfrom is overwritten"; | 
|---|
| 268 | usage += "\n The non-adressed content of obj?Dfrom is left unchanged"; | 
|---|
| 269 | usage += "\n  Related commands: copy"; | 
|---|
| 270 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 271 |  | 
|---|
| 272 | kw = "h/set/err"; | 
|---|
| 273 | usage = "Set Histo,Histo2D errors for range of bins or range of values"; | 
|---|
| 274 | usage += "\n h/set/err namehisto setvalue i1[:i2]  [j1[:j2]]"; | 
|---|
| 275 | usage += "\n     set error to setvalue for bin range i1:i2  j1:j2"; | 
|---|
| 276 | usage += "\n h/set/err namehisto setvalue v v1:v2"; | 
|---|
| 277 | usage += "\n     set error to setvalue for content values range v1:v2"; | 
|---|
| 278 | usage += "\n h/set/err namehisto setvalue e e1:e2"; | 
|---|
| 279 | usage += "\n     set error to setvalue for error values range v1:v2"; | 
|---|
| 280 | usage += "\n  Related commands: h/set/cont"; | 
|---|
| 281 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 282 |  | 
|---|
| 283 | kw = "h/set/cont"; | 
|---|
| 284 | usage = "Set Histo,Histo2D content for range of bins or range of values"; | 
|---|
| 285 | usage += "\n h/set/cont namehisto setvalue i1[:i2]  [j1[:j2]]"; | 
|---|
| 286 | usage += "\n     set content to setvalue for bin range i1:i2  j1:j2"; | 
|---|
| 287 | usage += "\n h/set/cont namehisto setvalue v v1:v2"; | 
|---|
| 288 | usage += "\n     set content to setvalue for content values range v1:v2"; | 
|---|
| 289 | usage += "\n h/set/cont namehisto setvalue e e1:e2"; | 
|---|
| 290 | usage += "\n     set content to setvalue for error values range v1:v2"; | 
|---|
| 291 | usage += "\n  Related commands: h/set/err"; | 
|---|
| 292 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 293 |  | 
|---|
| 294 | kw = "h/err"; | 
|---|
| 295 | usage = "Set Histo,Histo2D error to function of bin content value"; | 
|---|
| 296 | usage += "\n h/err namehisto expr_func"; | 
|---|
| 297 | usage += "\n  Related commands: h/set/err"; | 
|---|
| 298 | piac->RegisterCommand(kw,usage,this,hgrp); | 
|---|
| 299 |  | 
|---|
| 300 | } | 
|---|
| 301 |  | 
|---|
| 302 | /* methode */ | 
|---|
| 303 | PAWExecutor::~PAWExecutor() | 
|---|
| 304 | { | 
|---|
| 305 | } | 
|---|
| 306 |  | 
|---|
| 307 | /* methode */ | 
|---|
| 308 | int PAWExecutor::Execute(string& kw, vector<string>& tokens, string& toks) | 
|---|
| 309 | { | 
|---|
| 310 | if(kw == "reset") { | 
|---|
| 311 | reset(tokens); return(0); | 
|---|
| 312 | } else if(kw == "n/plot" || kw == "n/pl") { | 
|---|
| 313 | n_plot(tokens); return(0); | 
|---|
| 314 | } else if(kw == "n/proj") { | 
|---|
| 315 | n_proj(tokens); return(0); | 
|---|
| 316 | } else if(kw == "n/scan") { | 
|---|
| 317 | n_scan(tokens); return(0); | 
|---|
| 318 | } else if(kw == "n/read") { | 
|---|
| 319 | n_read(tokens); return(0); | 
|---|
| 320 | } else if(kw == "n/merge") { | 
|---|
| 321 | n_merge(tokens); return(0); | 
|---|
| 322 | } else if(kw == "n/merge/col") { | 
|---|
| 323 | n_merge_col(tokens); return(0); | 
|---|
| 324 | } else if(kw == "n/assoc/col") { | 
|---|
| 325 | n_assoc_col(tokens); return(0); | 
|---|
| 326 | } else if(kw == "n/copy") { | 
|---|
| 327 | n_copy(tokens); return(0); | 
|---|
| 328 | } else if(kw == "h/integ") { | 
|---|
| 329 | h_integ(tokens); return(0); | 
|---|
| 330 | } else if(kw == "v/integ") { | 
|---|
| 331 | v_integ(tokens); return(0); | 
|---|
| 332 | } else if(kw == "v/sort") { | 
|---|
| 333 | v_sort(tokens); return(0); | 
|---|
| 334 | } else if(kw == "h/deriv") { | 
|---|
| 335 | h_deriv(tokens); return(0); | 
|---|
| 336 | } else if(kw == "v/deriv") { | 
|---|
| 337 | v_deriv(tokens); return(0); | 
|---|
| 338 | } else if(kw == "h/rebin") { | 
|---|
| 339 | h_rebin(tokens); return(0); | 
|---|
| 340 | } else if(kw == "h/cadd") { | 
|---|
| 341 | h_cadd(tokens); return(0); | 
|---|
| 342 | } else if(kw == "h/cmult") { | 
|---|
| 343 | h_cmult(tokens); return(0); | 
|---|
| 344 | } else if(kw == "h/oper") { | 
|---|
| 345 | h_oper(tokens); return(0); | 
|---|
| 346 | } else if(kw == "h/plot/2d") { | 
|---|
| 347 | h_plot_2d(tokens); return(0); | 
|---|
| 348 | } else if(kw == "h/put_vec") { | 
|---|
| 349 | h_put_vec(tokens); return(0); | 
|---|
| 350 | } else if(kw == "h/get_vec") { | 
|---|
| 351 | h_get_vec(tokens); return(0); | 
|---|
| 352 | } else if(kw == "h/copy") { | 
|---|
| 353 | h_copy(tokens); return(0); | 
|---|
| 354 | } else if(kw == "h/set/err") { | 
|---|
| 355 | string dum = "err"; | 
|---|
| 356 | h_set(dum,tokens); return(0); | 
|---|
| 357 | } else if(kw == "h/set/cont") { | 
|---|
| 358 | string dum = "cont"; | 
|---|
| 359 | h_set(dum,tokens); return(0); | 
|---|
| 360 | } else if(kw == "h/err") { | 
|---|
| 361 | h_err(tokens); return(0); | 
|---|
| 362 | } else return(1); | 
|---|
| 363 | } | 
|---|
| 364 |  | 
|---|
| 365 | /* methode */ | 
|---|
| 366 | bool PAWExecutor::IsThreadable(string const & keyw) | 
|---|
| 367 | { | 
|---|
| 368 | if ( (keyw == "n/plot")  || (keyw == "n/pl") || | 
|---|
| 369 | (keyw == "n/proj") )  return true; | 
|---|
| 370 | else return false; | 
|---|
| 371 | } | 
|---|
| 372 |  | 
|---|
| 373 |  | 
|---|
| 374 | /* methode */ | 
|---|
| 375 | void PAWExecutor::reset(vector<string>& tokens) | 
|---|
| 376 | // Reset d'histogrammes, vecteurs et matrices | 
|---|
| 377 | { | 
|---|
| 378 | if(tokens.size() < 1) | 
|---|
| 379 | {cout<<"Usage: reset nameobj"<<endl; return;} | 
|---|
| 380 | NamedObjMgr omg; | 
|---|
| 381 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 382 | if(mobj == NULL) | 
|---|
| 383 | {cout<<"PAWExecutor::reset Error , Pas d'objet de nom "<<tokens[0]<<endl; | 
|---|
| 384 | return;} | 
|---|
| 385 | string ctyp = typeid(*mobj).name(); | 
|---|
| 386 |  | 
|---|
| 387 | #ifdef SANS_EVOLPLANCK | 
|---|
| 388 | if(typeid(*mobj)==typeid(Vector))       {Vector*  ob=(Vector*) mobj; ob->Zero();} | 
|---|
| 389 | else if(typeid(*mobj)==typeid(Matrix))  {Matrix*  ob=(Matrix*) mobj; ob->Zero();} | 
|---|
| 390 | #else | 
|---|
| 391 | if(typeid(*mobj)==typeid(Vector))       {Vector*  ob=(Vector*) mobj; (*ob) = 0.; } | 
|---|
| 392 | // ob->DataBlock().Reset(0.);} | 
|---|
| 393 | else if(typeid(*mobj)==typeid(Matrix))   {Matrix*  ob=(Matrix*) mobj; (*ob) = 0.; } | 
|---|
| 394 | //ob->DataBlock().Reset(0.);} | 
|---|
| 395 | #endif | 
|---|
| 396 | else if(typeid(*mobj)==typeid(Histo))    {Histo* ob=(Histo*)  mobj; ob->Zero();} | 
|---|
| 397 | else if(typeid(*mobj)==typeid(HProf))    {HProf* ob=(HProf*)  mobj; ob->Zero();} | 
|---|
| 398 | else if(typeid(*mobj)==typeid(HistoErr)) {HistoErr* ob=(HistoErr*)  mobj; ob->Zero();} | 
|---|
| 399 | else if(typeid(*mobj)==typeid(Histo2D))  {Histo2D* ob=(Histo2D*)mobj; ob->Zero();} | 
|---|
| 400 | else { | 
|---|
| 401 | cout<<"PAWExecutor::reset Error , No reset possible on "<<ctyp<<endl; | 
|---|
| 402 | return; | 
|---|
| 403 | } | 
|---|
| 404 |  | 
|---|
| 405 | return; | 
|---|
| 406 | } | 
|---|
| 407 |  | 
|---|
| 408 | /* methode */ | 
|---|
| 409 | void PAWExecutor::n_plot(vector<string>& tokens) | 
|---|
| 410 | // Equivalent n/plot de paw | 
|---|
| 411 | // Plot 1D | 
|---|
| 412 | //   n/plot nameobj.x_exp [cut] [w_exp] [gratt] | 
|---|
| 413 | // Plot 2D (plot2dw) | 
|---|
| 414 | //   n/plot nameobj.y_exp%x_exp [cut] [w_exp] [gratt] | 
|---|
| 415 | // Plot 3D (plot3d) | 
|---|
| 416 | //   n/plot nameobj.z_exp%y_exp%x_exp [cut] [gratt] | 
|---|
| 417 | { | 
|---|
| 418 | if(tokens.size() < 1) { | 
|---|
| 419 | cout | 
|---|
| 420 | <<"Usage: n/plot nameobj.x_exp [cut] [w_exp] [loop] [gratt] [nomh1]"<<endl | 
|---|
| 421 | <<"       n/plot nameobj.y_exp%x_exp [cut] [loop] [gratt]"<<endl | 
|---|
| 422 | <<"       n/plot nameobj.z_exp%y_exp%x_exp [cut] [loop] [gratt]"<<endl | 
|---|
| 423 | <<"              for default use ! , loop=i1[:i2[:di]]"<<endl; | 
|---|
| 424 | return; | 
|---|
| 425 | } | 
|---|
| 426 | string nameobj,expx,expy,expz; | 
|---|
| 427 | int_4 nvar = decodepawstring(tokens[0],nameobj,expx,expy,expz); | 
|---|
| 428 | string expcut = "1"; string expwt = "1."; string loop = ""; | 
|---|
| 429 | string dopt = ""; string nameproj=""; | 
|---|
| 430 | if(tokens.size()>=2) expcut = tokens[1]; if(expcut=="!") expcut="1"; | 
|---|
| 431 |  | 
|---|
| 432 | NamedObjMgr omg; | 
|---|
| 433 | Services2NObjMgr* srvo = omg.GetServiceObj(); | 
|---|
| 434 |  | 
|---|
| 435 | if(nvar<=0) { | 
|---|
| 436 | cout<<"PAWExecutor::n_plot Error: bad coding "<<tokens[0]<<endl; | 
|---|
| 437 | } else if(nvar==1) { // c'est un plot 1D | 
|---|
| 438 | if(tokens.size()>=3) expwt    = tokens[2]; if(expwt=="!") expwt="1."; | 
|---|
| 439 | if(tokens.size()>=4) loop     = tokens[3]; if(loop=="!") loop=""; | 
|---|
| 440 | if(tokens.size()>=5) dopt     = tokens[4]; if(dopt=="!") dopt=""; | 
|---|
| 441 | if(tokens.size()>=6) nameproj = tokens[5]; | 
|---|
| 442 | if(nameproj.length()<=0 || nameproj=="!") { | 
|---|
| 443 | nameproj = "/autoc/paw_n_plot1D_"; | 
|---|
| 444 | AnyDataObj* mobj = omg.GetObj(nameproj); | 
|---|
| 445 | if(mobj!=NULL) { | 
|---|
| 446 | char buff[16]; autoc_counter_++; sprintf(buff,"%d",autoc_counter_); | 
|---|
| 447 | nameproj += buff; | 
|---|
| 448 | } | 
|---|
| 449 | // --- Si option "keepbin" on projete avec le meme binning que l'histo 1D precedent | 
|---|
| 450 | if(dopt.find("keepbin")<dopt.size()) { | 
|---|
| 451 | PIStdImgApp* piimapp = omg.GetImgApp(); | 
|---|
| 452 | if(piimapp) { | 
|---|
| 453 | PIBaseWdg* pibwdg = piimapp->CurrentBaseWdg(); | 
|---|
| 454 | if(pibwdg) { | 
|---|
| 455 | int nbdrw = pibwdg->NbDrawers(); | 
|---|
| 456 | if(nbdrw>0) { | 
|---|
| 457 | for(int i=nbdrw-1;i>=0;i--) { | 
|---|
| 458 | PIDrawer* pidwr = pibwdg->GetDrawer(i); | 
|---|
| 459 | PIHisto* pih = NULL; | 
|---|
| 460 | if( (pih = dynamic_cast<PIHisto *>(pidwr))==NULL ) continue; | 
|---|
| 461 | Histo* h = pih->Histogram(); | 
|---|
| 462 | if(h==NULL) continue; | 
|---|
| 463 | if(h->NBins()<1) continue; | 
|---|
| 464 | Histo* hsame = new Histo(h->XMin(),h->XMax(),h->NBins()); | 
|---|
| 465 | omg.AddObj(hsame,nameproj); | 
|---|
| 466 | break; | 
|---|
| 467 | } | 
|---|
| 468 | } | 
|---|
| 469 | } | 
|---|
| 470 | } | 
|---|
| 471 | } | 
|---|
| 472 | // --- | 
|---|
| 473 | } | 
|---|
| 474 | srvo->ProjectH1(nameobj,expx,expwt,expcut,nameproj,dopt,loop); | 
|---|
| 475 | } else if(nvar==2) { // c'est un plot 2D | 
|---|
| 476 | if(tokens.size()>=3) loop = tokens[2]; if(loop=="!") loop=""; | 
|---|
| 477 | if(tokens.size()>=4) dopt = tokens[3]; | 
|---|
| 478 | string err = ""; | 
|---|
| 479 | srvo->DisplayPoints2D(nameobj,expx,expy,err,err,expcut,dopt,loop); | 
|---|
| 480 | } else {             // c'est un plot 3D | 
|---|
| 481 | if(tokens.size()>=3) loop = tokens[2]; if(loop=="!") loop=""; | 
|---|
| 482 | if(tokens.size()>=4) dopt = tokens[3]; | 
|---|
| 483 | srvo->DisplayPoints3D(nameobj,expx,expy,expz,expcut,dopt,loop); | 
|---|
| 484 | } | 
|---|
| 485 |  | 
|---|
| 486 | return; | 
|---|
| 487 | } | 
|---|
| 488 |  | 
|---|
| 489 |  | 
|---|
| 490 | /* methode */ | 
|---|
| 491 | void PAWExecutor::n_proj(vector<string>& tokens) | 
|---|
| 492 | // Equivalent n/proj de paw | 
|---|
| 493 | // Project NTuple in histogram a la paw | 
|---|
| 494 | // Dans un Histo 1D | 
|---|
| 495 | //   n/proj nameproj nameobj.x_exp [cut] [w_exp] [gratt] | 
|---|
| 496 | // Dans un Histo 2D ou un HProf (dans ce cas nameproj doit etre cree). | 
|---|
| 497 | //   n/proj nameproj nameobj.y_exp%x_exp [cut] [w_exp] [gratt] | 
|---|
| 498 | { | 
|---|
| 499 | if(tokens.size()<2) | 
|---|
| 500 | {cout<<"Usage: n/proj nameproj nameobj.[y_exp%]x_exp [cut] [w_exp] [loop] [gratt]"<<endl | 
|---|
| 501 | <<"              for default use ! , loop=i1[:i2[:di]]"<<endl; return;} | 
|---|
| 502 | string nameproj = tokens[0]; | 
|---|
| 503 | string nameobj,expx,expy,expz; | 
|---|
| 504 | int_4 nvar = decodepawstring(tokens[1],nameobj,expx,expy,expz); | 
|---|
| 505 | string expcut = "1"; string expwt = "1."; string loop = ""; string dopt = ""; | 
|---|
| 506 | if(tokens.size()>=3) expcut = tokens[2]; if(expcut=="!") expcut="1"; | 
|---|
| 507 | if(tokens.size()>=4) expwt  = tokens[3]; if(expwt=="!") expwt="1."; | 
|---|
| 508 | if(tokens.size()>=5) loop   = tokens[4]; if(loop=="!") loop=""; | 
|---|
| 509 | if(tokens.size()>=6) dopt   = tokens[5]; | 
|---|
| 510 |  | 
|---|
| 511 | NamedObjMgr omg; | 
|---|
| 512 | Services2NObjMgr* srvo = omg.GetServiceObj(); | 
|---|
| 513 |  | 
|---|
| 514 | if(nvar==1) { | 
|---|
| 515 | // c'est une projection dans un histo 1D | 
|---|
| 516 | srvo->ProjectH1(nameobj,expx,expwt,expcut,nameproj,dopt,loop); | 
|---|
| 517 | } else if(nvar==2) { | 
|---|
| 518 | // c'est une projection dans un histo2D | 
|---|
| 519 | // OU un HProf si nameproj est un HProf un deja defini | 
|---|
| 520 | AnyDataObj* mobj = omg.GetObj(nameproj); | 
|---|
| 521 | if(mobj==NULL) | 
|---|
| 522 | srvo->ProjectH2(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); | 
|---|
| 523 | else if(dynamic_cast<HProf*>(mobj)) | 
|---|
| 524 | srvo->ProjectHProf(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); | 
|---|
| 525 | else | 
|---|
| 526 | srvo->ProjectH2(nameobj,expx,expy,expwt,expcut,nameproj,dopt,loop); | 
|---|
| 527 | } else { | 
|---|
| 528 | cout<<"PAWExecutor::n_proj Error: bad coding "<<tokens[1]<<" nvar="<<nvar<<endl; | 
|---|
| 529 | } | 
|---|
| 530 |  | 
|---|
| 531 | return; | 
|---|
| 532 | } | 
|---|
| 533 |  | 
|---|
| 534 | /* methode */ | 
|---|
| 535 | void PAWExecutor::n_scan(vector<string>& tokens) | 
|---|
| 536 | { | 
|---|
| 537 | if(tokens.size()<3) | 
|---|
| 538 | {cerr<<"Usage: n/scan nameobj[.exp1%exp2%exp3] cut loop\n" | 
|---|
| 539 | <<"       [-f:filename] [list_of_variables]"<<endl; return;} | 
|---|
| 540 |  | 
|---|
| 541 | // decodage des premiers arguments | 
|---|
| 542 | string nameobj,expr[4]; | 
|---|
| 543 | int_4 nexpr = decodepawstring(tokens[0],nameobj,expr[0],expr[1],expr[2]); | 
|---|
| 544 | if(nexpr<4) {for(int_4 i=nexpr;i<4;i++) expr[i]="1.";} | 
|---|
| 545 | string expcut = tokens[1]; if(expcut=="!") expcut="1"; | 
|---|
| 546 | string loop   = tokens[2]; if(loop=="!") loop=""; | 
|---|
| 547 | FILE* fout = NULL; | 
|---|
| 548 | uint_4 ldebvar = 3; | 
|---|
| 549 | if(tokens.size()>3) { | 
|---|
| 550 | if(tokens[3].find("-f:") == 0) { | 
|---|
| 551 | string filename = tokens[3].substr(3); | 
|---|
| 552 | if(filename.size()>0) { | 
|---|
| 553 | fout = fopen(filename.c_str(),"w"); | 
|---|
| 554 | if(fout==NULL) | 
|---|
| 555 | {cerr<<"PAWExecutor::n_scan Error, file "<<filename | 
|---|
| 556 | <<" not opened"<<endl; return;} | 
|---|
| 557 | } | 
|---|
| 558 | ldebvar++; | 
|---|
| 559 | } | 
|---|
| 560 | } | 
|---|
| 561 |  | 
|---|
| 562 | // ntuple adaptateur | 
|---|
| 563 | NamedObjMgr omg; | 
|---|
| 564 | Services2NObjMgr& srvo = *omg.GetServiceObj(); | 
|---|
| 565 | NObjMgrAdapter* obja = omg.GetObjAdapter(nameobj); // Ne pas deleter | 
|---|
| 566 | if(obja == NULL) | 
|---|
| 567 | {cerr<<"PAWExecutor::n_scan Error, ObjAdapter==NULL for " | 
|---|
| 568 | <<nameobj<<endl; return;} | 
|---|
| 569 | bool adel = true; | 
|---|
| 570 | NTupleInterface* objnt = obja->GetNTupleInterface(adel); | 
|---|
| 571 | if(objnt == NULL) | 
|---|
| 572 | {cerr<<"PAWExecutor::n_scan Error, NTupleInterface==NULL for " | 
|---|
| 573 | <<nameobj<<endl; return;} | 
|---|
| 574 |  | 
|---|
| 575 | // function pour le choix | 
|---|
| 576 | string  vardec = objnt->VarList_C("_zz6qi_"); | 
|---|
| 577 | PlotExprFunc f = srvo.LinkExprFunc(vardec,expr[0],expr[1],expr[2],expr[3],expcut); | 
|---|
| 578 | if(!f) | 
|---|
| 579 | {cerr<<"PAWExecutor::n_scan Error, Creation PlotExprFunc"<<endl; | 
|---|
| 580 | if(adel) delete objnt; if(fout) fclose(fout); return;} | 
|---|
| 581 |  | 
|---|
| 582 | // variables a imprimer | 
|---|
| 583 | // "rien"          --> de 0 a ncol-1 (toutes les variables) | 
|---|
| 584 | // : v1            --> de 0 a v1 | 
|---|
| 585 | // v1 :            --> de v1 a ncol-1 | 
|---|
| 586 | // v1 : v2         --> de v1 a v2 (si v2 apres v1) | 
|---|
| 587 | //                     v1 et v2   (si v2 avant v1) | 
|---|
| 588 | // v1 v2 v3 v4     --> v1 v2 v3 v4 (ordre indifferent) | 
|---|
| 589 | // et toute combinaison : "v1 : v3 v7 v4 : v6 v2 v9 :" | 
|---|
| 590 | //        --> v1 v2 v3  v7  v4 v5 v6  v2  v9 v10...v(ncol-1) | 
|---|
| 591 | int_4 ncol = objnt->NbColumns(); | 
|---|
| 592 | if(ncol<=0) | 
|---|
| 593 | {cerr<<"PAWExecutor::n_scan Error, no columns for NTuple"<<endl; | 
|---|
| 594 | return;} | 
|---|
| 595 | vector<int_4> varnum; | 
|---|
| 596 | if(ldebvar>=tokens.size()) {   // Toutes les variables | 
|---|
| 597 | for(int_4 i=0;i<ncol;i++) varnum.push_back(i); | 
|---|
| 598 | } else {   // Choix de certaines variables | 
|---|
| 599 | int_4 k,klast,kk; bool frlast=false; | 
|---|
| 600 | if(tokens[ldebvar]==":") {varnum.push_back(0); frlast=true;} | 
|---|
| 601 | else {k = objnt->ColumnIndex(tokens[ldebvar]); varnum.push_back(k);} | 
|---|
| 602 | ldebvar++; | 
|---|
| 603 | if(ldebvar<tokens.size()) for(uint_4 i=ldebvar;i<tokens.size();i++) { | 
|---|
| 604 | if(tokens[i]!=":") {  // pas un separateur | 
|---|
| 605 | k = klast = objnt->ColumnIndex(tokens[i]); | 
|---|
| 606 | if(frlast) klast = varnum[varnum.size()-1] + 1; | 
|---|
| 607 | if(klast>k) klast=k; | 
|---|
| 608 | for(kk=klast;kk<=k;kk++) varnum.push_back(kk); | 
|---|
| 609 | frlast=false; | 
|---|
| 610 | } else if(i==tokens.size()-1) {  // separateur a la fin | 
|---|
| 611 | k = ncol-1; | 
|---|
| 612 | klast = varnum[varnum.size()-1] + 1; | 
|---|
| 613 | if(klast>k) klast=k; | 
|---|
| 614 | for(kk=klast;kk<=k;kk++) varnum.push_back(kk); | 
|---|
| 615 | } else frlast=true;  // separateur pas a la fin | 
|---|
| 616 | } | 
|---|
| 617 | } | 
|---|
| 618 |  | 
|---|
| 619 | vector<string> varname; | 
|---|
| 620 | if(varnum.size()>0) for(int_4 i=0;i<(int)varnum.size();i++) { | 
|---|
| 621 | if(varnum[i]<0 || varnum[i]>=ncol) | 
|---|
| 622 | {cerr<<"PAWExecutor::n_scan Error, bad variable name at pos " | 
|---|
| 623 | <<i<<endl; if(adel) delete objnt; if(fout) fclose(fout); return;} | 
|---|
| 624 | string dum = objnt->ColumnName(varnum[i]); | 
|---|
| 625 | varname.push_back(dum); | 
|---|
| 626 | } | 
|---|
| 627 |  | 
|---|
| 628 | // evenements a utiliser | 
|---|
| 629 | int_8 k1=0, k2=objnt->NbLines(), dk=1; | 
|---|
| 630 | srvo.DecodeLoopParameters(loop,k1,k2,dk); | 
|---|
| 631 | if (k1<0) k1=0; | 
|---|
| 632 | if (k2<0) k2=objnt->NbLines(); | 
|---|
| 633 | if (k2>(int_8)objnt->NbLines()) k2=objnt->NbLines(); | 
|---|
| 634 | if (dk<=0) dk=1; | 
|---|
| 635 |  | 
|---|
| 636 | // boucle sur les evenements et print | 
|---|
| 637 | try  { | 
|---|
| 638 | int_4 i; | 
|---|
| 639 | if(fout) fprintf(fout,"#ev "); else printf("#ev "); | 
|---|
| 640 | for(i=0;i<(int)varname.size();i++) | 
|---|
| 641 | if(fout) fprintf(fout,"%s ",varname[i].c_str()); | 
|---|
| 642 | else      printf(     "%s ",varname[i].c_str()); | 
|---|
| 643 | if(nexpr>0) for(i=0;i<nexpr;i++) | 
|---|
| 644 | if(fout) fprintf(fout,"%s ",expr[i].c_str()); | 
|---|
| 645 | else      printf(     "%s ",expr[i].c_str()); | 
|---|
| 646 | if(fout) fprintf(fout,"\n"); else printf("\n"); | 
|---|
| 647 |  | 
|---|
| 648 | double xnt[5]={0,0,0,0,0}; | 
|---|
| 649 | double* xn; | 
|---|
| 650 | for(int_8 k=k1; k<k2; k += dk)    { | 
|---|
| 651 | xn = objnt->GetLineD(k); | 
|---|
| 652 | if(f((int_8_exprf)k,xn,xnt,xnt+1,xnt+2,xnt+3) != 0) { | 
|---|
| 653 | if(fout) fprintf(fout,"%ld ",(long)k); else printf("%ld ",(long)k); | 
|---|
| 654 | for(i=0;i<(int)varnum.size();i++) { | 
|---|
| 655 | if(fout) fprintf(fout,"%g ",*(xn+varnum[i])); | 
|---|
| 656 | else      printf(     "%g ",*(xn+varnum[i])); | 
|---|
| 657 | } | 
|---|
| 658 | if(nexpr>0) for(i=0;i<nexpr;i++) { | 
|---|
| 659 | if(fout) fprintf(fout,"%g ",*(xnt+i)); | 
|---|
| 660 | else      printf(     "%g ",*(xnt+i)); | 
|---|
| 661 | } | 
|---|
| 662 | if(fout) fprintf(fout,"\n"); else printf("\n"); | 
|---|
| 663 | } | 
|---|
| 664 | } | 
|---|
| 665 | }   // fin du try | 
|---|
| 666 | #ifdef SANS_EVOLPLANCK | 
|---|
| 667 | CATCH(merr) { | 
|---|
| 668 | fflush(stdout); cout<<endl; cerr<<endl; | 
|---|
| 669 | string es = PeidaExc(merr); | 
|---|
| 670 | cerr<<"Services2NObjMgr::ComputeExpressions()  Exception :"<<merr<<es; | 
|---|
| 671 | } ENDTRY; | 
|---|
| 672 | #else | 
|---|
| 673 | catch ( PException exc ) { | 
|---|
| 674 | fflush(stdout); cout<<endl; cerr<<endl; | 
|---|
| 675 | cerr<<"Services2NObjMgr::ComputeExpressions()  Exception :"<<exc.Msg()<<endl; | 
|---|
| 676 | } | 
|---|
| 677 | #endif | 
|---|
| 678 |  | 
|---|
| 679 | if(adel) delete objnt; | 
|---|
| 680 | if(fout) fclose(fout); | 
|---|
| 681 | srvo.CloseDLL(); // Fermeture du fichier .so | 
|---|
| 682 | return; | 
|---|
| 683 | } | 
|---|
| 684 |  | 
|---|
| 685 |  | 
|---|
| 686 | /* methode */ | 
|---|
| 687 | #define __LENLINE_N_READ__ 8192 | 
|---|
| 688 | void PAWExecutor::n_read(vector<string>& tokens) | 
|---|
| 689 | { | 
|---|
| 690 | int lp=1; | 
|---|
| 691 |  | 
|---|
| 692 | if(tokens.size()<3) { | 
|---|
| 693 | cerr<<"Usage: n/read nt fascii [options] var_1,c_1 ... var_n,c_n"<<endl; | 
|---|
| 694 | return; | 
|---|
| 695 | } | 
|---|
| 696 |  | 
|---|
| 697 | // decodage des arguments | 
|---|
| 698 | string nament = tokens[0]; | 
|---|
| 699 | string nameascii = tokens[1]; | 
|---|
| 700 | bool create_datatable = false; | 
|---|
| 701 | vector<string> donotreadbeg; | 
|---|
| 702 | vector<string> donotreadin; | 
|---|
| 703 | vector<string> onlyreadbeg; | 
|---|
| 704 | vector<string> onlyreadin; | 
|---|
| 705 | vector<string> varname; | 
|---|
| 706 | vector<int> colnum; | 
|---|
| 707 | char separator = ' '; | 
|---|
| 708 | int numcolmaxi=-1; | 
|---|
| 709 |  | 
|---|
| 710 | for(int i=2;i<(int_4)tokens.size();i++) { | 
|---|
| 711 | int lc = tokens[i].size(); | 
|---|
| 712 | if(lc<2) continue; | 
|---|
| 713 | if(tokens[i].find("-dt")==0) { // create DataTable instead of NTuple | 
|---|
| 714 | create_datatable = true; | 
|---|
| 715 | continue; | 
|---|
| 716 | } | 
|---|
| 717 | const char *c = tokens[i].c_str(); | 
|---|
| 718 | if(c[0]=='=') { // Separator | 
|---|
| 719 | separator = c[1]; | 
|---|
| 720 | if(lc==3) if(c[1]=='\\' && c[2]=='t') separator = '\t'; | 
|---|
| 721 | continue; | 
|---|
| 722 | } | 
|---|
| 723 | if(c[0]=='+') { // Selection des lignes a lire | 
|---|
| 724 | if(c[1]!='^') onlyreadin.push_back(&c[1]); | 
|---|
| 725 | else if(lc>2) onlyreadbeg.push_back(&c[2]); | 
|---|
| 726 | continue; | 
|---|
| 727 | } | 
|---|
| 728 | if(c[0]=='-') { // Selection des lignes commentaire | 
|---|
| 729 | if(c[1]!='^') donotreadin.push_back(&c[1]); | 
|---|
| 730 | else if(lc>2) donotreadbeg.push_back(&c[2]); | 
|---|
| 731 | continue; | 
|---|
| 732 | } | 
|---|
| 733 | // decodage des noms de variables et des colonnes associees | 
|---|
| 734 | int p = tokens[i].find(','); | 
|---|
| 735 | if(p<1 || p>=lc-1) continue; | 
|---|
| 736 | string vn = tokens[i].substr(0,p); | 
|---|
| 737 | string cn = tokens[i].substr(p+1,lc-p-1); | 
|---|
| 738 | int ic = atoi(cn.c_str()); | 
|---|
| 739 | if(ic<0) continue; | 
|---|
| 740 | if( !isalpha(vn[0]) ) continue; | 
|---|
| 741 | if(ic>numcolmaxi) numcolmaxi = ic; | 
|---|
| 742 | varname.push_back(vn); | 
|---|
| 743 | colnum.push_back(ic); | 
|---|
| 744 | } | 
|---|
| 745 |  | 
|---|
| 746 | int nvar = varname.size(); | 
|---|
| 747 | if(nvar<=0) { | 
|---|
| 748 | cerr<<"n_read: no variables to be read"<<endl; | 
|---|
| 749 | return; | 
|---|
| 750 | } | 
|---|
| 751 |  | 
|---|
| 752 | // Print what has to be done | 
|---|
| 753 | if(lp) { | 
|---|
| 754 | if(onlyreadin.size()>0) { | 
|---|
| 755 | cout<<"n_read Only read line containing ["<<onlyreadin.size()<<"]:"; | 
|---|
| 756 | for(int i=0;i<(int_4)onlyreadin.size();i++) cout<<" \'"<<onlyreadin[i]<<"\'"; | 
|---|
| 757 | cout<<endl; | 
|---|
| 758 | } | 
|---|
| 759 | if(onlyreadbeg.size()>0) { | 
|---|
| 760 | cout<<"n_read Only read line begining with ["<<onlyreadbeg.size()<<"]:"; | 
|---|
| 761 | for(int i=0;i<(int_4)onlyreadbeg.size();i++) cout<<" \'"<<onlyreadbeg[i]<<"\'"; | 
|---|
| 762 | cout<<endl; | 
|---|
| 763 | } | 
|---|
| 764 | if(donotreadin.size()>0) { | 
|---|
| 765 | cout<<"n_read Do not read line containing ["<<donotreadin.size()<<"]:"; | 
|---|
| 766 | for(int i=0;i<(int_4)donotreadin.size();i++) cout<<" \'"<<donotreadin[i]<<"\'"; | 
|---|
| 767 | cout<<endl; | 
|---|
| 768 | } | 
|---|
| 769 | if(donotreadbeg.size()>0) { | 
|---|
| 770 | cout<<"n_read Do not read line begining with ["<<donotreadbeg.size()<<"]:"; | 
|---|
| 771 | for(int i=0;i<(int_4)donotreadbeg.size();i++) cout<<" \'"<<donotreadbeg[i]<<"\'"; | 
|---|
| 772 | cout<<endl; | 
|---|
| 773 | } | 
|---|
| 774 | if(nvar>0) { | 
|---|
| 775 | cout<<"n_read Number of variables to be read: "<<nvar<<endl; | 
|---|
| 776 | for(int i=0;i<nvar;i++) cout<<" \'"<<varname[i].c_str()<<","<<colnum[i]<<"\'"; | 
|---|
| 777 | cout<<endl; | 
|---|
| 778 | } | 
|---|
| 779 | if(separator!=' ') cout<<"n_read Separator is: \'"<<separator<<"\'"<<endl; | 
|---|
| 780 | } | 
|---|
| 781 |  | 
|---|
| 782 | // Open ASCII file | 
|---|
| 783 | FILE * fascii = fopen(nameascii.c_str(),"r"); | 
|---|
| 784 | if(fascii==NULL) { | 
|---|
| 785 | cerr<<"n_read: cannot open file "<<nameascii<<endl; | 
|---|
| 786 | return; | 
|---|
| 787 | } | 
|---|
| 788 |  | 
|---|
| 789 | // Creation du NTuple ou de la DataTable | 
|---|
| 790 | NTuple *nt = NULL; | 
|---|
| 791 | DataTable *dt = NULL; | 
|---|
| 792 | if(!create_datatable) { //create NTuple | 
|---|
| 793 | char** ntvn = new char*[nvar]; | 
|---|
| 794 | for(int i=0;i<nvar;i++) ntvn[i] = const_cast<char *>(varname[i].c_str()); | 
|---|
| 795 | nt = new NTuple(nvar,ntvn); | 
|---|
| 796 | delete [] ntvn; | 
|---|
| 797 | } else { //create DataTable | 
|---|
| 798 | dt = new DataTable(); | 
|---|
| 799 | for(int i=0;i<nvar;i++) dt->AddDoubleColumn(varname[i]); | 
|---|
| 800 | } | 
|---|
| 801 | r_8 *xnt = new r_8[nvar]; | 
|---|
| 802 |  | 
|---|
| 803 | // Read file | 
|---|
| 804 | char *line = new char[__LENLINE_N_READ__]; | 
|---|
| 805 | int nline=0, nlinecom=0; | 
|---|
| 806 | while(fgets(line,__LENLINE_N_READ__,fascii) != NULL ) { | 
|---|
| 807 | nline++; | 
|---|
| 808 | uint_4 lc = strlen(line); if(lc<1) continue; | 
|---|
| 809 | // Pour enlever le \n final | 
|---|
| 810 | if(line[lc-1]=='\n' || line[lc-1]=='\r') | 
|---|
| 811 | {line[lc-1]='\0'; lc = strlen(line); if(lc<1) continue;} | 
|---|
| 812 |  | 
|---|
| 813 | string const sline(line); | 
|---|
| 814 | //cout<<"\'"<<sline<<"\'  lc="<<lc<<endl; | 
|---|
| 815 |  | 
|---|
| 816 | // Faut t'il lire cette ligne ? | 
|---|
| 817 | bool read_line_1 = true; | 
|---|
| 818 | if(onlyreadin.size()>0 || onlyreadbeg.size()>0) read_line_1 = false; | 
|---|
| 819 | if(onlyreadin.size()>0) { | 
|---|
| 820 | for(int i=0;i<(int_4)onlyreadin.size();i++) { | 
|---|
| 821 | uint_4 p = sline.find(onlyreadin[i].c_str()); | 
|---|
| 822 | if(p>=lc) continue; | 
|---|
| 823 | read_line_1 = true; | 
|---|
| 824 | break; | 
|---|
| 825 | } | 
|---|
| 826 | } | 
|---|
| 827 | if(onlyreadbeg.size()>0) { | 
|---|
| 828 | for(int i=0;i<(int_4)onlyreadbeg.size();i++) { | 
|---|
| 829 | uint_4 p = sline.find(onlyreadbeg[i].c_str()); | 
|---|
| 830 | if(p!=0) continue; | 
|---|
| 831 | read_line_1 = true; | 
|---|
| 832 | break; | 
|---|
| 833 | } | 
|---|
| 834 | } | 
|---|
| 835 |  | 
|---|
| 836 | // Faut t'il ne pas lire cette ligne ? | 
|---|
| 837 | bool read_line_2 = true; | 
|---|
| 838 | if(donotreadin.size()>0) { | 
|---|
| 839 | for(int i=0;i<(int_4)donotreadin.size();i++) { | 
|---|
| 840 | uint_4 p = sline.find(donotreadin[i].c_str()); | 
|---|
| 841 | if(p>=lc) continue; | 
|---|
| 842 | read_line_2 = false; | 
|---|
| 843 | break; | 
|---|
| 844 | } | 
|---|
| 845 | } | 
|---|
| 846 | if(donotreadbeg.size()>0) { | 
|---|
| 847 | for(int i=0;i<(int_4)donotreadbeg.size();i++) { | 
|---|
| 848 | uint_4 p = sline.find(donotreadbeg[i].c_str()); | 
|---|
| 849 | if(p!=0) continue; | 
|---|
| 850 | read_line_2 = false; | 
|---|
| 851 | break; | 
|---|
| 852 | } | 
|---|
| 853 | } | 
|---|
| 854 | if(!read_line_2) nlinecom++; | 
|---|
| 855 |  | 
|---|
| 856 | if(!read_line_1 || !read_line_2) continue; | 
|---|
| 857 |  | 
|---|
| 858 | // Decodage de la ligne | 
|---|
| 859 | vector<string> vs; | 
|---|
| 860 | //FillVStringFrString(sline,vs,separator); | 
|---|
| 861 | SplitStringToVString(sline,vs,separator); | 
|---|
| 862 | int lvs = vs.size(); | 
|---|
| 863 | //for(int i=0;i<lvs;i++) cout<<"|"<<vs[i]<<"| "; cout<<endl; | 
|---|
| 864 | if(lvs<numcolmaxi) continue; // Pas assez de champs decodes, mauvaise ligne | 
|---|
| 865 |  | 
|---|
| 866 | // Remplissage du NTuple ou de la DataTable | 
|---|
| 867 | for(int i=0;i<nvar;i++) { | 
|---|
| 868 | xnt[i] = 0.; | 
|---|
| 869 | int ic = colnum[i]; | 
|---|
| 870 | if(ic>=lvs) continue; | 
|---|
| 871 | xnt[i] = atof(vs[ic].c_str()); | 
|---|
| 872 | } | 
|---|
| 873 | if(nt)      nt->Fill(xnt); | 
|---|
| 874 | else if(dt) dt->Fill(xnt); | 
|---|
| 875 | //cout<<"...xnt"; for(int i=0;i<nvar;i++) cout<<" "<<xnt[i]; cout<<endl; | 
|---|
| 876 |  | 
|---|
| 877 | } | 
|---|
| 878 | int_4 nentries = (nt)? nt->NEntry(): dt->NEntry(); | 
|---|
| 879 | cout<<"n_read: "<<nline<<" lines in file, " | 
|---|
| 880 | <<nlinecom<<" commentary, " | 
|---|
| 881 | <<nentries<<" object entries"<<endl; | 
|---|
| 882 |  | 
|---|
| 883 | // On sauve le NTuple/DataTable si besoin, on ferme et detruit ce qu'il faut | 
|---|
| 884 | NamedObjMgr omg; | 
|---|
| 885 | if(nentries>0) { | 
|---|
| 886 | if(nt) omg.AddObj(nt,nament); | 
|---|
| 887 | if(dt) omg.AddObj(dt,nament); | 
|---|
| 888 | } else { | 
|---|
| 889 | if(nt) delete nt; | 
|---|
| 890 | if(dt) delete dt; | 
|---|
| 891 | } | 
|---|
| 892 | delete [] xnt; | 
|---|
| 893 | delete [] line; | 
|---|
| 894 | fclose(fascii); | 
|---|
| 895 |  | 
|---|
| 896 | return; | 
|---|
| 897 | } | 
|---|
| 898 | #undef __LENLINE_N_READ__ | 
|---|
| 899 |  | 
|---|
| 900 | /* methode */ | 
|---|
| 901 | void PAWExecutor::n_merge(vector<string>& tokens) | 
|---|
| 902 | { | 
|---|
| 903 | if(tokens.size()<2) { | 
|---|
| 904 | cerr<<"Usage: n/merge nt nt_1 nt_2 ... nt_n"<<endl; | 
|---|
| 905 | return; | 
|---|
| 906 | } | 
|---|
| 907 |  | 
|---|
| 908 | NamedObjMgr omg; | 
|---|
| 909 |  | 
|---|
| 910 | // decodage des arguments | 
|---|
| 911 | string nament = tokens[0]; | 
|---|
| 912 |  | 
|---|
| 913 | // boucle sur les ntuples | 
|---|
| 914 | NTuple * nt = NULL; | 
|---|
| 915 | int nvar=0, nfill=0; | 
|---|
| 916 | r_8 *xnt=NULL; | 
|---|
| 917 |  | 
|---|
| 918 | for(int i=1;i<(int_4)tokens.size();i++) { | 
|---|
| 919 |  | 
|---|
| 920 | AnyDataObj* mobj = omg.GetObj(tokens[i]); | 
|---|
| 921 | if(mobj==NULL) { | 
|---|
| 922 | cout<<"n_merge Error: unknow object"<<tokens[i]<<endl; | 
|---|
| 923 | continue; | 
|---|
| 924 | } | 
|---|
| 925 | NTuple* nt1 = dynamic_cast<NTuple*>(mobj); | 
|---|
| 926 | if(nt1==NULL) { | 
|---|
| 927 | cout<<"n_merge Error: "<<tokens[i]<<" not a NTuple"<<endl; | 
|---|
| 928 | continue; | 
|---|
| 929 | } | 
|---|
| 930 | if(nt1->NEntry()==0) { | 
|---|
| 931 | cout<<"n_merge Error: "<<tokens[i]<<" is empty"<<endl; | 
|---|
| 932 | continue; | 
|---|
| 933 | } | 
|---|
| 934 | if(nt1->NVar()==0) { | 
|---|
| 935 | cout<<"n_merge Error: "<<tokens[i]<<" has no variable"<<endl; | 
|---|
| 936 | continue; | 
|---|
| 937 | } | 
|---|
| 938 |  | 
|---|
| 939 | // create receiving ntuple if first pass | 
|---|
| 940 | if(nt==NULL) { | 
|---|
| 941 | nvar = nt1->NVar(); | 
|---|
| 942 | vector<string> sntvn; | 
|---|
| 943 | for(int iv=0;iv<nvar;iv++) sntvn.push_back(nt1->ColumnName(iv)); | 
|---|
| 944 | char **ntvn = new char*[nvar]; | 
|---|
| 945 | for(int iv=0;iv<nvar;iv++) ntvn[iv] = const_cast<char *>(sntvn[iv].c_str()); | 
|---|
| 946 | nt = new NTuple(nvar,ntvn); | 
|---|
| 947 | delete [] ntvn; | 
|---|
| 948 | } | 
|---|
| 949 |  | 
|---|
| 950 | // filling with current ntuple | 
|---|
| 951 | int nvar1 = nt1->NVar(); | 
|---|
| 952 | int n = (nvar1>nvar)? nvar1: nvar; | 
|---|
| 953 | r_8 *xnt1 = new r_8[n]; | 
|---|
| 954 | for(int iev=0;iev<n;iev++) xnt1[iev]=0.; | 
|---|
| 955 | for(uint_4 iev=0;iev<(uint_4)nt1->NEntry();iev++) { | 
|---|
| 956 | nt1->GetVecD(iev,xnt1); | 
|---|
| 957 | nt->Fill(xnt1); | 
|---|
| 958 | } | 
|---|
| 959 | nfill++; | 
|---|
| 960 | delete [] xnt1; | 
|---|
| 961 |  | 
|---|
| 962 | } | 
|---|
| 963 |  | 
|---|
| 964 | if(xnt!=NULL) delete [] xnt; | 
|---|
| 965 | if(nt!=NULL) { | 
|---|
| 966 | cout<<"n_merge: ntuple filled with "<<nfill | 
|---|
| 967 | <<" ntuples, "<<nt->NEntry()<<" entries"<<endl; | 
|---|
| 968 | if(nt->NEntry()>0) omg.AddObj(nt,nament); else delete nt; | 
|---|
| 969 | } | 
|---|
| 970 | return; | 
|---|
| 971 | } | 
|---|
| 972 |  | 
|---|
| 973 | /* methode */ | 
|---|
| 974 | void PAWExecutor::n_merge_col(vector<string>& tokens) | 
|---|
| 975 | { | 
|---|
| 976 | if(tokens.size()<2) { | 
|---|
| 977 | cerr<<"Usage: n/merge/col nt nt_1[,ext] nt_2[,ext] ... nt_n[,ext]"<<endl; | 
|---|
| 978 | return; | 
|---|
| 979 | } | 
|---|
| 980 |  | 
|---|
| 981 | NamedObjMgr omg; | 
|---|
| 982 |  | 
|---|
| 983 | // decodage des arguments | 
|---|
| 984 | string nament = tokens[0]; | 
|---|
| 985 |  | 
|---|
| 986 | // boucle sur les ntuples | 
|---|
| 987 | uint_4 numnt=0, nentmax=0, ipos=0; | 
|---|
| 988 | vector<string> varname; | 
|---|
| 989 | vector<string> ntname; | 
|---|
| 990 | vector<int> posfirst; | 
|---|
| 991 | for(int i=1;i<(int_4)tokens.size();i++) { | 
|---|
| 992 |  | 
|---|
| 993 | // Decode NTuple name and extension | 
|---|
| 994 | int_4 lc = tokens[i].size(); | 
|---|
| 995 | string ntn = tokens[i]; | 
|---|
| 996 | string ext = ""; | 
|---|
| 997 | int p = ntn.find(','); | 
|---|
| 998 | if(p>=0 && p<lc) { | 
|---|
| 999 | if(p<lc-1) ext = ntn.substr(p+1,lc-p-1); | 
|---|
| 1000 | if(p>0) ntn = ntn.substr(0,p); else ntn = ""; | 
|---|
| 1001 | } | 
|---|
| 1002 | // choose the extentsion: given,automatic,none | 
|---|
| 1003 | if(ext.size()<1) { | 
|---|
| 1004 | char str[8]; sprintf(str,"_%d",numnt); | 
|---|
| 1005 | ext = str; | 
|---|
| 1006 | } else if(ext[0] == '!') { | 
|---|
| 1007 | ext = ""; | 
|---|
| 1008 | } | 
|---|
| 1009 |  | 
|---|
| 1010 | AnyDataObj* mobj = omg.GetObj(ntn); | 
|---|
| 1011 | if(mobj==NULL) { | 
|---|
| 1012 | cout<<"n_merge_col Error: unknow object "<<ntn<<" ("<<tokens[i]<<")"<<endl; | 
|---|
| 1013 | continue; | 
|---|
| 1014 | } | 
|---|
| 1015 | NTuple* nt1 = dynamic_cast<NTuple*>(mobj); | 
|---|
| 1016 | if(nt1==NULL) { | 
|---|
| 1017 | cout<<"n_merge_col Error: "<<ntn<<" not a NTuple"<<endl; | 
|---|
| 1018 | continue; | 
|---|
| 1019 | } | 
|---|
| 1020 | if(nt1->NEntry()==0) { | 
|---|
| 1021 | cout<<"n_merge_col Error: "<<ntn<<" is empty"<<endl; | 
|---|
| 1022 | continue; | 
|---|
| 1023 | } | 
|---|
| 1024 | if(nt1->NVar()==0) { | 
|---|
| 1025 | cout<<"n_merge_col Error: "<<ntn<<" has no variable"<<endl; | 
|---|
| 1026 | continue; | 
|---|
| 1027 | } | 
|---|
| 1028 |  | 
|---|
| 1029 | ntname.push_back(ntn); | 
|---|
| 1030 | posfirst.push_back(ipos); | 
|---|
| 1031 | if(nt1->NEntry()>(int_4)nentmax) nentmax = nt1->NEntry(); | 
|---|
| 1032 | for(int iv=0;iv<nt1->NVar();iv++) { | 
|---|
| 1033 | string str = nt1->ColumnName(iv) + ext; | 
|---|
| 1034 | varname.push_back(str); | 
|---|
| 1035 | } | 
|---|
| 1036 | numnt++; | 
|---|
| 1037 | ipos += nt1->NVar(); | 
|---|
| 1038 | } | 
|---|
| 1039 |  | 
|---|
| 1040 | if(ntname.size()==0) { | 
|---|
| 1041 | cout<<"n_merge_col Error: no ntuple found in argument list"<<endl; | 
|---|
| 1042 | return; | 
|---|
| 1043 | } else cout<<"Number of NTuple found "<<ntname.size() | 
|---|
| 1044 | <<", Number of variables "<<varname.size() | 
|---|
| 1045 | <<", Max_entries "<<nentmax<<endl; | 
|---|
| 1046 |  | 
|---|
| 1047 | // create receiving ntuple | 
|---|
| 1048 | int nvar = varname.size(); | 
|---|
| 1049 | char **ntvn = new char*[nvar]; | 
|---|
| 1050 | for(int iv=0;iv<nvar;iv++) ntvn[iv] = const_cast<char *>(varname[iv].c_str()); | 
|---|
| 1051 | NTuple * nt = new NTuple(nvar,ntvn); | 
|---|
| 1052 | //for(int i=0;i<(int_4)ntname.size();i++) cout<<ntname[i]<<" , p="<<posfirst[i]<<endl; | 
|---|
| 1053 | delete [] ntvn; | 
|---|
| 1054 |  | 
|---|
| 1055 | // filling with current ntuple | 
|---|
| 1056 | r_8 *xnt = new r_8[nvar]; | 
|---|
| 1057 | for(int iev=0;iev<(int_4)nentmax;iev++) { | 
|---|
| 1058 | for(int i=0;i<nvar;i++) xnt[i]=0.; | 
|---|
| 1059 | for(int i=0;i<(int_4)ntname.size();i++) { | 
|---|
| 1060 | AnyDataObj* mobj = omg.GetObj(ntname[i]); | 
|---|
| 1061 | NTuple* nt1 = dynamic_cast<NTuple*>(mobj); | 
|---|
| 1062 | if(iev < nt1->NEntry())  nt1->GetVecD(iev,&xnt[posfirst[i]]); | 
|---|
| 1063 | } | 
|---|
| 1064 | nt->Fill(xnt); | 
|---|
| 1065 | } | 
|---|
| 1066 |  | 
|---|
| 1067 | // Ending and saving merging ntuple columns | 
|---|
| 1068 | delete [] xnt; | 
|---|
| 1069 | cout<<"n_merge_col: ntuple filled with "<<ntname.size() | 
|---|
| 1070 | <<" ntuples, "<<nt->NEntry()<<" entries"<<endl; | 
|---|
| 1071 | if(nt->NEntry()>0) omg.AddObj(nt,nament); else delete nt; | 
|---|
| 1072 |  | 
|---|
| 1073 | return; | 
|---|
| 1074 | } | 
|---|
| 1075 |  | 
|---|
| 1076 | /* methode */ | 
|---|
| 1077 | void PAWExecutor::n_assoc_col(vector<string>& tokens) | 
|---|
| 1078 | { | 
|---|
| 1079 | if(tokens.size()<4) { | 
|---|
| 1080 | cerr<<"Usage: n/assoc/col ntass[,u] nt_1[,ext] nt_2[,ext] nt_assoc[,icass]"<<endl; | 
|---|
| 1081 | return; | 
|---|
| 1082 | } | 
|---|
| 1083 |  | 
|---|
| 1084 | NamedObjMgr omg; | 
|---|
| 1085 |  | 
|---|
| 1086 | // decodage du nom du ntuple final associe | 
|---|
| 1087 | // do_merge = 0  :  on remplit toutes les lignes de nt_1 associees ou non | 
|---|
| 1088 | //                  lignes associees + non-associees de nt_1 | 
|---|
| 1089 | //                  -> ntass.NEntry == nt_1.NEntry | 
|---|
| 1090 | //          = 1  :  on remplit uniquement les lignes associees | 
|---|
| 1091 | //                  lignes associees uniquement | 
|---|
| 1092 | //                  -> ntass.NEntry <= min(nt_1.NEntry,nt_2.NEntry) | 
|---|
| 1093 | //          = 2  :  on remplit l'union des lignes | 
|---|
| 1094 | //                  lignes associees + non-associees de nt_1 + non-associees de nt_2 | 
|---|
| 1095 | //                  -> ntass.NEntry >= max(nt_1.NEntry,nt_2.NEntry) | 
|---|
| 1096 | uint_2 do_merge=0; | 
|---|
| 1097 | string ntmerge = tokens[0]; | 
|---|
| 1098 | int lc = tokens[0].size(); | 
|---|
| 1099 | int p = tokens[0].find(','); | 
|---|
| 1100 | if(p>=0 && p<lc) { | 
|---|
| 1101 | ntmerge = ntmerge.substr(0,p); | 
|---|
| 1102 | p = tokens[0].find(",u"); | 
|---|
| 1103 | if(p>=0 && p<lc) do_merge = 2; | 
|---|
| 1104 | p = tokens[0].find(",i"); | 
|---|
| 1105 | if(p>=0 && p<lc) do_merge = 1; | 
|---|
| 1106 | } | 
|---|
| 1107 | cout<<"n_assoc_col: final ntuple "<<ntmerge<<", do_merge="<<do_merge<<endl; | 
|---|
| 1108 |  | 
|---|
| 1109 | // boucle pour decoder et valider les 3 ntuples | 
|---|
| 1110 | NTuple *nt[3]; | 
|---|
| 1111 | string ntname; | 
|---|
| 1112 | vector<string> varname; | 
|---|
| 1113 | int icass = 0; | 
|---|
| 1114 |  | 
|---|
| 1115 | for(int i=0;i<3;i++) { | 
|---|
| 1116 |  | 
|---|
| 1117 | // Decode NTuple name and extension | 
|---|
| 1118 | ntname = tokens[i+1]; | 
|---|
| 1119 | int_4 lc = ntname.size(); | 
|---|
| 1120 | string ext = ""; | 
|---|
| 1121 | int p = ntname.find(','); | 
|---|
| 1122 | if(p>=0 && p<lc) { | 
|---|
| 1123 | if(p<lc-1) ext = ntname.substr(p+1,lc-p-1); | 
|---|
| 1124 | if(p>0) ntname = ntname.substr(0,p); else ntname = ""; | 
|---|
| 1125 | } | 
|---|
| 1126 | // choose the extension: given,automatic,none | 
|---|
| 1127 | if(i==2) {  // numero de colonne avec l'index d'association | 
|---|
| 1128 | if(ext[0] == '!') ext = ""; | 
|---|
| 1129 | if(ext.size()>0) icass = atoi(ext.c_str()); | 
|---|
| 1130 | } else { | 
|---|
| 1131 | if(ext.size()<1) { | 
|---|
| 1132 | char str[8]; sprintf(str,"_%d",i); | 
|---|
| 1133 | ext = str; | 
|---|
| 1134 | } else if(ext[0] == '!') { | 
|---|
| 1135 | ext = ""; | 
|---|
| 1136 | } | 
|---|
| 1137 | } | 
|---|
| 1138 |  | 
|---|
| 1139 | AnyDataObj* mobj = omg.GetObj(ntname); | 
|---|
| 1140 | if(mobj==NULL) { | 
|---|
| 1141 | cout<<"n_assoc_col Error: unknow object "<<ntname<<" ("<<tokens[i]<<")"<<endl; | 
|---|
| 1142 | return; | 
|---|
| 1143 | } | 
|---|
| 1144 | nt[i] = dynamic_cast<NTuple*>(mobj); | 
|---|
| 1145 | if(nt[i]==NULL) { | 
|---|
| 1146 | cout<<"n_assoc_col Error: "<<ntname<<" not a NTuple"<<endl; | 
|---|
| 1147 | return; | 
|---|
| 1148 | } | 
|---|
| 1149 | if(nt[i]->NEntry()==0) { | 
|---|
| 1150 | cout<<"n_assoc_col Error: "<<ntname<<" is empty"<<endl; | 
|---|
| 1151 | return; | 
|---|
| 1152 | } | 
|---|
| 1153 | if(nt[i]->NVar()==0) { | 
|---|
| 1154 | cout<<"n_assoc_col Error: "<<ntname<<" has no variable"<<endl; | 
|---|
| 1155 | return; | 
|---|
| 1156 | } | 
|---|
| 1157 |  | 
|---|
| 1158 | if(i<2) | 
|---|
| 1159 | for(int iv=0;iv<nt[i]->NVar();iv++) { | 
|---|
| 1160 | string str = nt[i]->ColumnName(iv) + ext; | 
|---|
| 1161 | varname.push_back(str); | 
|---|
| 1162 | } | 
|---|
| 1163 |  | 
|---|
| 1164 | } | 
|---|
| 1165 |  | 
|---|
| 1166 | // Checking size of associated ntuple | 
|---|
| 1167 | if(nt[0]->NEntry() != nt[2]->NEntry()) { | 
|---|
| 1168 | cout<<"n_assoc_col Error: nentries mismatch " | 
|---|
| 1169 | <<" first ntuple"<<"="<<nt[0]->NEntry() | 
|---|
| 1170 | <<", assoc ntuple"<<"="<<nt[2]->NEntry()<<endl; | 
|---|
| 1171 | return; | 
|---|
| 1172 | } | 
|---|
| 1173 | if(icass<0 || icass>=nt[2]->NVar()) { | 
|---|
| 1174 | cout<<"n_assoc_col Error: bad association column number " | 
|---|
| 1175 | <<icass<<" / "<<nt[2]->NVar()<<endl; | 
|---|
| 1176 | return; | 
|---|
| 1177 | } | 
|---|
| 1178 |  | 
|---|
| 1179 | // create receiving ntuple | 
|---|
| 1180 | int nvar = varname.size(); | 
|---|
| 1181 | char **ntvn = new char*[nvar]; | 
|---|
| 1182 | for(int iv=0;iv<nvar;iv++) ntvn[iv] = const_cast<char *>(varname[iv].c_str()); | 
|---|
| 1183 | NTuple * ntass = new NTuple(nvar,ntvn); | 
|---|
| 1184 | delete [] ntvn; | 
|---|
| 1185 |  | 
|---|
| 1186 | // Filling with current ntuple | 
|---|
| 1187 | // the first column gives the associated line in nt[1] | 
|---|
| 1188 | int_4 nfill[2]={0,0}; | 
|---|
| 1189 | r_8 *xass = new r_8[nt[2]->NVar()]; | 
|---|
| 1190 | r_8 *xnt = new r_8[nvar]; | 
|---|
| 1191 | uint_2 *use2 = NULL; | 
|---|
| 1192 | if(do_merge==2) { | 
|---|
| 1193 | use2 = new uint_2[nt[1]->NEntry()]; | 
|---|
| 1194 | for(int i=0;i<nt[1]->NEntry();i++) use2[i] = 0; | 
|---|
| 1195 | } | 
|---|
| 1196 | for(int iev=0;iev<nt[0]->NEntry();iev++) { | 
|---|
| 1197 | nt[2]->GetVecD(iev,xass); | 
|---|
| 1198 | int iass = (xass[icass]<0.) ? -1: int(xass[icass]+0.5); | 
|---|
| 1199 | bool okass = (iass>=0 && iass<nt[1]->NEntry()); | 
|---|
| 1200 | if(do_merge==1 && !okass) continue; // pas d'assoc et intersection demandee | 
|---|
| 1201 | for(int iv=0;iv<nvar;iv++) xnt[iv]=0.; | 
|---|
| 1202 | nt[0]->GetVecD(iev,xnt); | 
|---|
| 1203 | if(okass) { | 
|---|
| 1204 | nt[1]->GetVecD(iass,&xnt[nt[0]->NVar()]); | 
|---|
| 1205 | if(do_merge==2) use2[iass] = 1; | 
|---|
| 1206 | } else nfill[0]++; | 
|---|
| 1207 | ntass->Fill(xnt); | 
|---|
| 1208 | } | 
|---|
| 1209 | // Filling with remaining unassociated in nt[1] if requested | 
|---|
| 1210 | if(do_merge==2) { | 
|---|
| 1211 | for(int iev=0;iev<nt[1]->NEntry();iev++) { | 
|---|
| 1212 | if(use2[iev]!=0) continue; // deja rempli | 
|---|
| 1213 | for(int iv=0;iv<nvar;iv++) xnt[iv]=0.; | 
|---|
| 1214 | nt[1]->GetVecD(iev,&xnt[nt[0]->NVar()]); | 
|---|
| 1215 | ntass->Fill(xnt); | 
|---|
| 1216 | nfill[1]++; | 
|---|
| 1217 | } | 
|---|
| 1218 | } | 
|---|
| 1219 |  | 
|---|
| 1220 | // Ending and saving merged ntuple | 
|---|
| 1221 | delete [] xnt; delete [] xass; | 
|---|
| 1222 | if(use2) delete [] use2; | 
|---|
| 1223 | cout<<"n_assoc_col: ntuple "<<ntmerge | 
|---|
| 1224 | <<" filled with "<<ntass->NEntry()<<" entries" | 
|---|
| 1225 | <<", unassoc in nt_1="<<nfill[0] | 
|---|
| 1226 | <<", unassoc in nt_2="<<nfill[1]<<endl; | 
|---|
| 1227 | omg.AddObj(ntass,ntmerge); | 
|---|
| 1228 |  | 
|---|
| 1229 | return; | 
|---|
| 1230 | } | 
|---|
| 1231 |  | 
|---|
| 1232 | /* methode */ | 
|---|
| 1233 | void PAWExecutor::n_copy(vector<string>& tokens) | 
|---|
| 1234 | { | 
|---|
| 1235 | if(tokens.size()<2) { | 
|---|
| 1236 | cerr<<"Usage: n/copy ntnew nt [vname1 vname2 vname3 ...]"<<endl; | 
|---|
| 1237 | return; | 
|---|
| 1238 | } | 
|---|
| 1239 |  | 
|---|
| 1240 | NamedObjMgr omg; | 
|---|
| 1241 |  | 
|---|
| 1242 | // Le NTuple de depart | 
|---|
| 1243 | AnyDataObj* mobj = omg.GetObj(tokens[1]); | 
|---|
| 1244 | if(mobj==NULL) { | 
|---|
| 1245 | cout<<"n_copy Error: unknow object"<<tokens[1]<<endl; | 
|---|
| 1246 | return; | 
|---|
| 1247 | } | 
|---|
| 1248 | NTuple* nt = dynamic_cast<NTuple*>(mobj); | 
|---|
| 1249 | if(nt==NULL) { | 
|---|
| 1250 | cout<<"n_copy Error: "<<tokens[1]<<" not a NTuple"<<endl; | 
|---|
| 1251 | return; | 
|---|
| 1252 | } | 
|---|
| 1253 | if(nt->NEntry()==0) { | 
|---|
| 1254 | cout<<"n_copy Error: "<<tokens[1]<<" is empty"<<endl; | 
|---|
| 1255 | return; | 
|---|
| 1256 | } | 
|---|
| 1257 | if(nt->NVar()==0) { | 
|---|
| 1258 | cout<<"n_copy Error: "<<tokens[1]<<" has no variable"<<endl; | 
|---|
| 1259 | return; | 
|---|
| 1260 | } | 
|---|
| 1261 |  | 
|---|
| 1262 | // Les variables a copier | 
|---|
| 1263 | int nvar; vector<string> varname; vector<int> ivar; | 
|---|
| 1264 | if(tokens.size()==2) { | 
|---|
| 1265 | nvar = nt->NVar(); | 
|---|
| 1266 | for(int i=0;i<nvar;i++) { | 
|---|
| 1267 | ivar.push_back(i); | 
|---|
| 1268 | varname.push_back(nt->NomIndex(i)); | 
|---|
| 1269 | } | 
|---|
| 1270 | } else { | 
|---|
| 1271 | nvar = tokens.size()-2; | 
|---|
| 1272 | for(int i=0;i<nvar;i++) { | 
|---|
| 1273 | int iv = nt->IndexNom(tokens[i+2].c_str()); | 
|---|
| 1274 | if(iv<0) { | 
|---|
| 1275 | cout<<"n_copy Error: unkown variable "<<tokens[i+2].c_str()<<endl; | 
|---|
| 1276 | return; | 
|---|
| 1277 | } | 
|---|
| 1278 | ivar.push_back(iv); | 
|---|
| 1279 | varname.push_back(tokens[i+2]); | 
|---|
| 1280 | } | 
|---|
| 1281 | } | 
|---|
| 1282 | cout<<"coping variables: "; | 
|---|
| 1283 | for(int i=0;i<nvar;i++) cout<<" "<<varname[i]; | 
|---|
| 1284 | cout<<endl; | 
|---|
| 1285 |  | 
|---|
| 1286 | // Creation du nouveau NTuple | 
|---|
| 1287 | char **ntvn = new char*[nvar]; | 
|---|
| 1288 | for(int i=0;i<nvar;i++) ntvn[i] = const_cast<char *>(varname[i].c_str()); | 
|---|
| 1289 | NTuple ntnew(nvar,ntvn); | 
|---|
| 1290 | delete [] ntvn; | 
|---|
| 1291 |  | 
|---|
| 1292 | // Copie du NTuple | 
|---|
| 1293 | r_8 *xnt = new r_8[nt->NVar()]; | 
|---|
| 1294 | r_8 *xntnew = new r_8[nvar]; | 
|---|
| 1295 | for(int iev=0;iev<nt->NEntry();iev++) { | 
|---|
| 1296 | nt->GetVecD(iev,xnt); | 
|---|
| 1297 | for(int i=0;i<nvar;i++) xntnew[i] = xnt[ivar[i]]; | 
|---|
| 1298 | ntnew.Fill(xntnew); | 
|---|
| 1299 | } | 
|---|
| 1300 | delete [] xnt; delete [] xntnew; | 
|---|
| 1301 |  | 
|---|
| 1302 | // Adding new NTuple | 
|---|
| 1303 | omg.AddObj(ntnew,tokens[0]); | 
|---|
| 1304 |  | 
|---|
| 1305 | return; | 
|---|
| 1306 | } | 
|---|
| 1307 |  | 
|---|
| 1308 | /* methode */ | 
|---|
| 1309 | void PAWExecutor::h_integ(vector<string>& tokens) | 
|---|
| 1310 | // Pour remplacer le contenu d'un histo 1D par son integrale | 
|---|
| 1311 | { | 
|---|
| 1312 | if(tokens.size()<1) | 
|---|
| 1313 | {cout<<"Usage: h/integ nameh1d [norm]"<<endl; return;} | 
|---|
| 1314 | NamedObjMgr omg; | 
|---|
| 1315 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1316 | if(mobj==NULL) | 
|---|
| 1317 | {cout<<"PAWExecutor::h_integ Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1318 | return;} | 
|---|
| 1319 | r_8 norm = 1.; | 
|---|
| 1320 | if(tokens.size()>=2) norm = atof(tokens[1].c_str()); | 
|---|
| 1321 | // attention: dynamic_cast<Histo*>(HProf)=Vrai! | 
|---|
| 1322 | Histo* h1 = dynamic_cast<Histo*>(mobj); | 
|---|
| 1323 | HProf* hp = dynamic_cast<HProf*>(mobj); | 
|---|
| 1324 | if(hp || !h1) | 
|---|
| 1325 | {cout<<"PAWExecutor::h_integ Error: "<<tokens[0]<<" not an Histo"<<endl; | 
|---|
| 1326 | return;} | 
|---|
| 1327 | h1->HInteg(norm); | 
|---|
| 1328 | } | 
|---|
| 1329 |  | 
|---|
| 1330 | /* methode */ | 
|---|
| 1331 | void PAWExecutor::v_integ(vector<string>& tokens) | 
|---|
| 1332 | // Pour remplacer le contenu d'un TVector<r_8> par son integrale | 
|---|
| 1333 | //   normalisee a norm: | 
|---|
| 1334 | // Si norm <= 0 : pas de normalisation, integration seule | 
|---|
| 1335 | { | 
|---|
| 1336 | if(tokens.size()<1) | 
|---|
| 1337 | {cout<<"Usage: v/integ namevec [norm]"<<endl; return;} | 
|---|
| 1338 | NamedObjMgr omg; | 
|---|
| 1339 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1340 | if(mobj==NULL) | 
|---|
| 1341 | {cout<<"PAWExecutor::v_integ Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1342 | return;} | 
|---|
| 1343 | r_8 norm=-1.; | 
|---|
| 1344 | if(tokens.size()>=2) norm = atof(tokens[1].c_str()); | 
|---|
| 1345 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1346 | Vector* v = dynamic_cast<Vector*>(mobj); | 
|---|
| 1347 | #else | 
|---|
| 1348 | TVector<r_8>* v = dynamic_cast<TVector<r_8>*>(mobj); | 
|---|
| 1349 | #endif | 
|---|
| 1350 |  | 
|---|
| 1351 | if(!v) | 
|---|
| 1352 | {cout<<"PAWExecutor::v_integ Error: "<<tokens[0]<<" not a TVector/Vector"<<endl; | 
|---|
| 1353 | return;} | 
|---|
| 1354 |  | 
|---|
| 1355 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1356 | uint_4 n = v->NElts(); | 
|---|
| 1357 | #else | 
|---|
| 1358 | uint_4 n = v->Size(); | 
|---|
| 1359 | #endif | 
|---|
| 1360 |  | 
|---|
| 1361 | if(n==0) | 
|---|
| 1362 | {cout<<"PAWExecutor::v_integ Error: "<<tokens[0]<<" is an empty vector"<<endl; | 
|---|
| 1363 | return;} | 
|---|
| 1364 | if(n>1) for(uint_4 i=1;i<n;i++) (*v)(i)+=(*v)(i-1); | 
|---|
| 1365 | if(norm<=0. || (*v)(n-1)==0.) return; | 
|---|
| 1366 | norm /= (*v)(n-1); | 
|---|
| 1367 | for(uint_4 i=0;i<n;i++) (*v)(i) *= norm; | 
|---|
| 1368 | } | 
|---|
| 1369 |  | 
|---|
| 1370 | /* methode */ | 
|---|
| 1371 | void PAWExecutor::v_sort(vector<string>& tokens) | 
|---|
| 1372 | // Pour sort in-place d'un vecteur ascendant ou descendant | 
|---|
| 1373 | { | 
|---|
| 1374 | if(tokens.size()<1) | 
|---|
| 1375 | {cout<<"Usage: v/sort namevec [+1/-1]"<<endl; return;} | 
|---|
| 1376 | NamedObjMgr omg; | 
|---|
| 1377 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1378 | if(mobj==NULL) | 
|---|
| 1379 | {cout<<"PAWExecutor::v_sort Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1380 | return;} | 
|---|
| 1381 |  | 
|---|
| 1382 | bool up = true; | 
|---|
| 1383 | if(tokens.size()>=2) if(atoi(tokens[1].c_str())<0) up=false; | 
|---|
| 1384 |  | 
|---|
| 1385 | { | 
|---|
| 1386 | TVector<r_8>* v = dynamic_cast<TVector<r_8>*>(mobj); | 
|---|
| 1387 | if(v) { | 
|---|
| 1388 | if(v->Size()==0) return; | 
|---|
| 1389 | if(up) stable_sort(v->Data(), v->Data()+v->Size(), __vector_sort_up_r8); | 
|---|
| 1390 | else stable_sort(v->Data(), v->Data()+v->Size(), __vector_sort_down_r8); | 
|---|
| 1391 | cout<<"median is: "<<0.5*((*v)(v->Size()/2)+(*v)((v->Size()-1)/2))<<endl; | 
|---|
| 1392 | return; | 
|---|
| 1393 | } | 
|---|
| 1394 | } | 
|---|
| 1395 |  | 
|---|
| 1396 | { | 
|---|
| 1397 | TVector<r_4>* v = dynamic_cast<TVector<r_4>*>(mobj); | 
|---|
| 1398 | if(v) { | 
|---|
| 1399 | if(v->Size()==0) return; | 
|---|
| 1400 | if(up) stable_sort(v->Data(), v->Data()+v->Size(), __vector_sort_up_r4); | 
|---|
| 1401 | else stable_sort(v->Data(), v->Data()+v->Size(), __vector_sort_down_r4); | 
|---|
| 1402 | cout<<"median is: "<<0.5*((*v)(v->Size()/2)+(*v)((v->Size()-1)/2))<<endl; | 
|---|
| 1403 | return; | 
|---|
| 1404 | } | 
|---|
| 1405 | } | 
|---|
| 1406 |  | 
|---|
| 1407 | { | 
|---|
| 1408 | TVector<int_4>* v = dynamic_cast<TVector<int_4>*>(mobj); | 
|---|
| 1409 | if(v) { | 
|---|
| 1410 | if(v->Size()==0) return; | 
|---|
| 1411 | if(up) stable_sort(v->Data(), v->Data()+v->Size(), __vector_sort_up_i4); | 
|---|
| 1412 | else stable_sort(v->Data(), v->Data()+v->Size(), __vector_sort_down_i4); | 
|---|
| 1413 | cout<<"median is: "<<0.5*((*v)(v->Size()/2)+(*v)((v->Size()-1)/2))<<endl; | 
|---|
| 1414 | return; | 
|---|
| 1415 | } | 
|---|
| 1416 | } | 
|---|
| 1417 |  | 
|---|
| 1418 | { | 
|---|
| 1419 | TVector<uint_8>* v = dynamic_cast<TVector<uint_8>*>(mobj); | 
|---|
| 1420 | if(v) { | 
|---|
| 1421 | if(v->Size()==0) return; | 
|---|
| 1422 | if(up) stable_sort(v->Data(), v->Data()+v->Size(), __vector_sort_up_u8); | 
|---|
| 1423 | else stable_sort(v->Data(), v->Data()+v->Size(), __vector_sort_down_u8); | 
|---|
| 1424 | cout<<"median is: "<<0.5*((*v)(v->Size()/2)+(*v)((v->Size()-1)/2))<<endl; | 
|---|
| 1425 | return; | 
|---|
| 1426 | } | 
|---|
| 1427 | } | 
|---|
| 1428 |  | 
|---|
| 1429 | cout<<"PAWExecutor::v_sort Error: "<<tokens[0] | 
|---|
| 1430 | <<" not a TVector or not a supported TVector<TYPE>"<<endl; | 
|---|
| 1431 | return; | 
|---|
| 1432 |  | 
|---|
| 1433 | } | 
|---|
| 1434 |  | 
|---|
| 1435 | /* methode */ | 
|---|
| 1436 | void PAWExecutor::h_deriv(vector<string>& tokens) | 
|---|
| 1437 | // Pour remplacer le contenu d'un histo 1D par sa derivee | 
|---|
| 1438 | { | 
|---|
| 1439 | if(tokens.size()<1) | 
|---|
| 1440 | {cout<<"Usage: h/deriv nameh1d"<<endl; return;} | 
|---|
| 1441 | NamedObjMgr omg; | 
|---|
| 1442 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1443 | if(mobj==NULL) | 
|---|
| 1444 | {cout<<"PAWExecutor::h_deriv Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1445 | return;} | 
|---|
| 1446 | // attention: dynamic_cast<Histo*>(HProf)=Vrai! | 
|---|
| 1447 | Histo* h1 = dynamic_cast<Histo*>(mobj); | 
|---|
| 1448 | HProf* hp = dynamic_cast<HProf*>(mobj); | 
|---|
| 1449 | if(hp || !h1) | 
|---|
| 1450 | {cout<<"PAWExecutor::h_deriv Error: "<<tokens[0]<<" not an Histo"<<endl; | 
|---|
| 1451 | return;} | 
|---|
| 1452 | h1->HDeriv(); | 
|---|
| 1453 | } | 
|---|
| 1454 |  | 
|---|
| 1455 | /* methode */ | 
|---|
| 1456 | void PAWExecutor::v_deriv(vector<string>& tokens) | 
|---|
| 1457 | // Pour remplacer le contenu d'un TVector<r_8> par sa derivee | 
|---|
| 1458 | // deriv_option = -1 replace v[i] with v[i]-v[i-1] | 
|---|
| 1459 | //              =  0 replace v[i] with (v[i+1]-v[i-1])/2 (default) | 
|---|
| 1460 | //              = +1 replace v[i] with v[i+1]-v[i] | 
|---|
| 1461 | { | 
|---|
| 1462 | if(tokens.size()<1) | 
|---|
| 1463 | {cout<<"Usage: v/deriv namevec [deriv_option(-1,0,+1)]"<<endl; return;} | 
|---|
| 1464 | NamedObjMgr omg; | 
|---|
| 1465 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1466 | if(mobj==NULL) | 
|---|
| 1467 | {cout<<"PAWExecutor::v_deriv Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1468 | return;} | 
|---|
| 1469 | int_4 deriv_option = 0; | 
|---|
| 1470 | if(tokens.size()>=2) deriv_option = atoi(tokens[1].c_str()); | 
|---|
| 1471 |  | 
|---|
| 1472 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1473 | Vector* v = dynamic_cast<Vector*>(mobj); | 
|---|
| 1474 | #else | 
|---|
| 1475 | TVector<r_8>* v = dynamic_cast<TVector<r_8>*>(mobj); | 
|---|
| 1476 | #endif | 
|---|
| 1477 |  | 
|---|
| 1478 | if(!v) | 
|---|
| 1479 | {cout<<"PAWExecutor::v_deriv Error: "<<tokens[0]<<" not a TVector/Vector"<<endl; | 
|---|
| 1480 | return;} | 
|---|
| 1481 |  | 
|---|
| 1482 |  | 
|---|
| 1483 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1484 | uint_4 n = v->NElts(); | 
|---|
| 1485 | #else | 
|---|
| 1486 | uint_4 n = v->Size(); | 
|---|
| 1487 | #endif | 
|---|
| 1488 |  | 
|---|
| 1489 | if(n==0) | 
|---|
| 1490 | {cout<<"PAWExecutor::v_deriv Error: "<<tokens[0]<<" is an empty vector"<<endl; | 
|---|
| 1491 | return;} | 
|---|
| 1492 | if(n<=1) return; | 
|---|
| 1493 |  | 
|---|
| 1494 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1495 | Vector vsave(*v); | 
|---|
| 1496 | #else | 
|---|
| 1497 | TVector<r_8> vsave(*v,false); | 
|---|
| 1498 | #endif | 
|---|
| 1499 |  | 
|---|
| 1500 | if(deriv_option<0) { | 
|---|
| 1501 | for(uint_4 i=1;i<n;i++) (*v)(i) = vsave(i)-vsave(i-1); | 
|---|
| 1502 | (*v)(0) = (*v)(1); | 
|---|
| 1503 | } else if(deriv_option>0) { | 
|---|
| 1504 | for(uint_4 i=0;i<n-1;i++) (*v)(i) = vsave(i+1)-vsave(i); | 
|---|
| 1505 | (*v)(n-1) = (*v)(n-2); | 
|---|
| 1506 | } else { | 
|---|
| 1507 | for(uint_4 i=1;i<n-1;i++) (*v)(i) = (vsave(i+1)-vsave(i-1))/2.; | 
|---|
| 1508 | (*v)(0)   = vsave(1)-vsave(0); | 
|---|
| 1509 | (*v)(n-1) = vsave(n-1)-vsave(n-2); | 
|---|
| 1510 | } | 
|---|
| 1511 | } | 
|---|
| 1512 |  | 
|---|
| 1513 |  | 
|---|
| 1514 | /* methode */ | 
|---|
| 1515 | void PAWExecutor::h_rebin(vector<string>& tokens) | 
|---|
| 1516 | // Pour re-binner un histogramme 1D | 
|---|
| 1517 | { | 
|---|
| 1518 | if(tokens.size()<2) | 
|---|
| 1519 | {cout<<"Usage: h/rebin nameh1d nbin"<<endl; return;} | 
|---|
| 1520 | NamedObjMgr omg; | 
|---|
| 1521 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1522 | if(mobj==NULL) | 
|---|
| 1523 | {cout<<"PAWExecutor::h_rebin Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1524 | return;} | 
|---|
| 1525 | int_4 nbin = atoi(tokens[1].c_str()); | 
|---|
| 1526 | Histo* h1 = dynamic_cast<Histo*>(mobj); | 
|---|
| 1527 | // Ca marche aussi pour les HProf, HRebin a ete passe virtuel | 
|---|
| 1528 | //HProf* hp = dynamic_cast<HProf*>(mobj); if(hp || !h1) | 
|---|
| 1529 | if(!h1) | 
|---|
| 1530 | {cout<<"PAWExecutor::h_rebin Error: "<<tokens[0]<<" not an Histo/HProf"<<endl; | 
|---|
| 1531 | return;} | 
|---|
| 1532 | h1->HRebin(nbin); | 
|---|
| 1533 | } | 
|---|
| 1534 |  | 
|---|
| 1535 | /* methode */ | 
|---|
| 1536 | void PAWExecutor::h_cadd(vector<string>& tokens) | 
|---|
| 1537 | // Additionne une constante a un histogramme | 
|---|
| 1538 | { | 
|---|
| 1539 | if(tokens.size()<2) | 
|---|
| 1540 | {cout<<"Usage: h/cadd nameh1d val"<<endl; return;} | 
|---|
| 1541 | NamedObjMgr omg; | 
|---|
| 1542 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1543 | if(mobj==NULL) | 
|---|
| 1544 | {cout<<"PAWExecutor::h_cadd Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1545 | return;} | 
|---|
| 1546 | r_8 val = atof(tokens[1].c_str()); | 
|---|
| 1547 | Histo*   h1 = dynamic_cast<Histo*>(mobj); | 
|---|
| 1548 | HProf*   hp = dynamic_cast<HProf*>(mobj); | 
|---|
| 1549 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); | 
|---|
| 1550 | Vector*  v  = dynamic_cast<Vector*>(mobj); | 
|---|
| 1551 | Matrix*  m  = dynamic_cast<Matrix*>(mobj); | 
|---|
| 1552 | if(h1 && !hp) *h1 += val; | 
|---|
| 1553 | else if(h2)   *h2 += val; | 
|---|
| 1554 | else if(v)    *v  += val; | 
|---|
| 1555 | else if(m)    *m  += val; | 
|---|
| 1556 | else cout<<"PAWExecutor::h_cadd Error: not implemented for "<<typeid(*mobj).name()<<endl; | 
|---|
| 1557 | } | 
|---|
| 1558 |  | 
|---|
| 1559 | /* methode */ | 
|---|
| 1560 | void PAWExecutor::h_cmult(vector<string>& tokens) | 
|---|
| 1561 | // Multiplie un histogramme par une constante | 
|---|
| 1562 | { | 
|---|
| 1563 | if(tokens.size()<2) | 
|---|
| 1564 | {cout<<"Usage: h/cmult nameh1d val"<<endl; return;} | 
|---|
| 1565 | NamedObjMgr omg; | 
|---|
| 1566 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1567 | if(mobj==NULL) | 
|---|
| 1568 | {cout<<"PAWExecutor::h_cmult Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1569 | return;} | 
|---|
| 1570 | r_8 val = atof(tokens[1].c_str()); | 
|---|
| 1571 | Histo*   h1 = dynamic_cast<Histo*>(mobj); | 
|---|
| 1572 | HProf*   hp = dynamic_cast<HProf*>(mobj); | 
|---|
| 1573 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); | 
|---|
| 1574 | Vector*  v  = dynamic_cast<Vector*>(mobj); | 
|---|
| 1575 | Matrix*  m  = dynamic_cast<Matrix*>(mobj); | 
|---|
| 1576 | if(h1 && !hp) *h1 *= val; | 
|---|
| 1577 | else if(h2)   *h2 *= val; | 
|---|
| 1578 | else if(v)    *v  += val; | 
|---|
| 1579 | else if(m)    *m  += val; | 
|---|
| 1580 | else cout<<"PAWExecutor::h_mult Error: not implemented for "<<typeid(*mobj).name()<<endl; | 
|---|
| 1581 | } | 
|---|
| 1582 |  | 
|---|
| 1583 | /* methode */ | 
|---|
| 1584 | void PAWExecutor::h_oper(vector<string>& tokens) | 
|---|
| 1585 | // Equivalent h/oper/add sub,mul,div de paw | 
|---|
| 1586 | // Operation entre 2 histogrammes ou 2 vecteurs ou 2 matrices | 
|---|
| 1587 | // h/oper @ h1 h2 hres | 
|---|
| 1588 | // hres = h1 @ h2    with @ = (+,-,*,/) | 
|---|
| 1589 | // Pour les vecteurs et les matrices, il sagit d'operations elements a elements | 
|---|
| 1590 | { | 
|---|
| 1591 | if(tokens.size()<4) | 
|---|
| 1592 | {cout<<"Usage: n/oper @ h1 h2 hres with @=(+,-,*,/,@)"<<endl; | 
|---|
| 1593 | return;} | 
|---|
| 1594 |  | 
|---|
| 1595 | // Decode arguments | 
|---|
| 1596 | const char * oper = tokens[0].c_str(); | 
|---|
| 1597 | if( oper[0]!='+' && oper[0]!='-' && oper[0]!='*' && oper[0]!='/' ) | 
|---|
| 1598 | {cout<<"PAWExecutor::h_oper Error: unknow operation "<<oper<<endl; | 
|---|
| 1599 | return;} | 
|---|
| 1600 | string h1name = tokens[1]; | 
|---|
| 1601 | string h2name = tokens[2]; | 
|---|
| 1602 | string h3name = tokens[3]; | 
|---|
| 1603 |  | 
|---|
| 1604 | // Get objects | 
|---|
| 1605 | NamedObjMgr omg; | 
|---|
| 1606 | AnyDataObj* mobjh1 = omg.GetObj(h1name); | 
|---|
| 1607 | AnyDataObj* mobjh2 = omg.GetObj(h2name); | 
|---|
| 1608 | if( mobjh1==NULL || mobjh2==NULL ) | 
|---|
| 1609 | {cout<<"PAWExecutor::h_oper Error: unknow object(s) "<<h1name<<" or "<<h2name<<endl; | 
|---|
| 1610 | return;} | 
|---|
| 1611 | AnyDataObj* mobjh3 = omg.GetObj(h3name); | 
|---|
| 1612 |  | 
|---|
| 1613 | // Operations on HProf, only + is working | 
|---|
| 1614 | if( dynamic_cast<HProf*>(mobjh1) != NULL ) { | 
|---|
| 1615 | if( oper[0]!='+' ) | 
|---|
| 1616 | { cout<<"PAWExecutor::h_oper Error: operation "<<oper | 
|---|
| 1617 | <<" not implemented for HProf"<<endl; return;} | 
|---|
| 1618 | if( dynamic_cast<HProf*>(mobjh2) == NULL ) | 
|---|
| 1619 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2\n" | 
|---|
| 1620 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl; | 
|---|
| 1621 | return;} | 
|---|
| 1622 | HProf* h1 =(HProf*) mobjh1; | 
|---|
| 1623 | HProf* h2 =(HProf*) mobjh2; | 
|---|
| 1624 | if( h1->NBins() != h2->NBins() ) | 
|---|
| 1625 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h2 " | 
|---|
| 1626 | <<h1->NBins()<<" "<<h2->NBins()<<endl; return;} | 
|---|
| 1627 | HProf* h3 = NULL; | 
|---|
| 1628 | if( mobjh3 == NULL ) // l'objet n'existe pas, on le cree | 
|---|
| 1629 | {h3 = new HProf(*h1); h3->Zero(); omg.AddObj(h3,h3name); mobjh3 = omg.GetObj(h3name);} | 
|---|
| 1630 | h3 = dynamic_cast<HProf*>(mobjh3); | 
|---|
| 1631 | if(h3 == NULL)  // ce n'est pas un HProf | 
|---|
| 1632 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3\n" | 
|---|
| 1633 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl; return;} | 
|---|
| 1634 | if(h1->NBins() != h3->NBins()) | 
|---|
| 1635 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 " | 
|---|
| 1636 | <<h1->NBins()<<" "<<h3->NBins()<<endl; return;} | 
|---|
| 1637 | *h3 = *h1 + *h2; | 
|---|
| 1638 | h3->UpdateHisto(); | 
|---|
| 1639 |  | 
|---|
| 1640 | // Operations on Histo | 
|---|
| 1641 | } else if( dynamic_cast<Histo*>(mobjh1) != NULL ) { | 
|---|
| 1642 | if( dynamic_cast<Histo*>(mobjh2) == NULL ) | 
|---|
| 1643 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2\n" | 
|---|
| 1644 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl; | 
|---|
| 1645 | return;} | 
|---|
| 1646 | Histo* h1 =(Histo*) mobjh1; | 
|---|
| 1647 | Histo* h2 =(Histo*) mobjh2; | 
|---|
| 1648 | if( h1->NBins() != h2->NBins() ) | 
|---|
| 1649 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h2 " | 
|---|
| 1650 | <<h1->NBins()<<" "<<h2->NBins()<<endl; return;} | 
|---|
| 1651 | Histo* h3 = NULL; | 
|---|
| 1652 | if( mobjh3 == NULL ) // l'objet n'existe pas, on le cree | 
|---|
| 1653 | {h3 = new Histo(*h1); h3->Zero(); omg.AddObj(h3,h3name); mobjh3 = omg.GetObj(h3name);} | 
|---|
| 1654 | h3 = dynamic_cast<Histo*>(mobjh3); | 
|---|
| 1655 | if(h3 == NULL)  // ce n'est pas un Histo | 
|---|
| 1656 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3\n" | 
|---|
| 1657 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl; return;} | 
|---|
| 1658 | if(h1->NBins() != h3->NBins()) | 
|---|
| 1659 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 " | 
|---|
| 1660 | <<h1->NBins()<<" "<<h3->NBins()<<endl; return;} | 
|---|
| 1661 | if( oper[0]=='+')      *h3 = *h1 + *h2; | 
|---|
| 1662 | else if( oper[0]=='-') *h3 = *h1 - *h2; | 
|---|
| 1663 | else if( oper[0]=='*') *h3 = *h1 * *h2; | 
|---|
| 1664 | else if( oper[0]=='/') *h3 = *h1 / *h2; | 
|---|
| 1665 |  | 
|---|
| 1666 | // Operations on Histo2D | 
|---|
| 1667 | } else if( dynamic_cast<Histo2D*>(mobjh1) != NULL ) { | 
|---|
| 1668 | if( dynamic_cast<Histo2D*>(mobjh2) == NULL ) | 
|---|
| 1669 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2\n" | 
|---|
| 1670 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl; | 
|---|
| 1671 | return;} | 
|---|
| 1672 | Histo2D* h1 =(Histo2D*) mobjh1; | 
|---|
| 1673 | Histo2D* h2 =(Histo2D*) mobjh2; | 
|---|
| 1674 | if( h1->NBinX() != h2->NBinX() || h1->NBinY() != h2->NBinY() ) | 
|---|
| 1675 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h2 " | 
|---|
| 1676 | <<h1->NBinX()<<","<<h1->NBinY()<<"   " | 
|---|
| 1677 | <<h2->NBinX()<<","<<h2->NBinY()<<endl; return;} | 
|---|
| 1678 | Histo2D* h3 = NULL; | 
|---|
| 1679 | if( mobjh3 == NULL ) // l'objet n'existe pas, on le cree | 
|---|
| 1680 | {h3 = new Histo2D(*h1); h3->Zero(); omg.AddObj(h3,h3name); mobjh3 = omg.GetObj(h3name);} | 
|---|
| 1681 | h3 = dynamic_cast<Histo2D*>(mobjh3); | 
|---|
| 1682 | if(h3 == NULL)  // ce n'est pas un Histo2D | 
|---|
| 1683 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3\n" | 
|---|
| 1684 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl; return;} | 
|---|
| 1685 | if( h1->NBinX() != h3->NBinX() || h1->NBinY() != h3->NBinY() ) | 
|---|
| 1686 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 " | 
|---|
| 1687 | <<h1->NBinX()<<","<<h1->NBinY()<<"   " | 
|---|
| 1688 | <<h3->NBinX()<<","<<h3->NBinY()<<endl; return;} | 
|---|
| 1689 | if( oper[0]=='+')      *h3 = *h1 + *h2; | 
|---|
| 1690 | else if( oper[0]=='-') *h3 = *h1 - *h2; | 
|---|
| 1691 | else if( oper[0]=='*') *h3 = *h1 * *h2; | 
|---|
| 1692 | else if( oper[0]=='/') *h3 = *h1 / *h2; | 
|---|
| 1693 |  | 
|---|
| 1694 | // Operations on Vector | 
|---|
| 1695 | } else if( dynamic_cast<Vector*>(mobjh1) != NULL ) { | 
|---|
| 1696 | if( dynamic_cast<Vector*>(mobjh2) == NULL ) | 
|---|
| 1697 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2\n" | 
|---|
| 1698 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl; | 
|---|
| 1699 | return;} | 
|---|
| 1700 | Vector* h1 =(Vector*) mobjh1; | 
|---|
| 1701 | Vector* h2 =(Vector*) mobjh2; | 
|---|
| 1702 | if( h1->NElts() != h2->NElts() ) | 
|---|
| 1703 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h2 " | 
|---|
| 1704 | <<h1->NElts()<<" "<<h2->NElts()<<endl; return;} | 
|---|
| 1705 | Vector* h3 = NULL; | 
|---|
| 1706 | if( mobjh3 == NULL ) {  // l'objet n'existe pas, on le cree | 
|---|
| 1707 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1708 | h3 = new Vector(*h1); | 
|---|
| 1709 | #else | 
|---|
| 1710 | h3 = new Vector(*h1,false); | 
|---|
| 1711 | #endif | 
|---|
| 1712 | *h3 = 0.; omg.AddObj(h3,h3name); mobjh3 = omg.GetObj(h3name); | 
|---|
| 1713 | } | 
|---|
| 1714 | h3 = dynamic_cast<Vector*>(mobjh3); | 
|---|
| 1715 | if(h3 == NULL)  // ce n'est pas un Vector | 
|---|
| 1716 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3\n" | 
|---|
| 1717 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl; return;} | 
|---|
| 1718 | if(h1->NElts() != h3->NElts()) | 
|---|
| 1719 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 " | 
|---|
| 1720 | <<h1->NElts()<<" "<<h3->NElts()<<endl; return;} | 
|---|
| 1721 | if( oper[0]=='+')      *h3 = *h1 + *h2; | 
|---|
| 1722 | else if( oper[0]=='-') *h3 = *h1 - *h2; | 
|---|
| 1723 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1724 | else if(oper[0]=='*' || oper[0]=='/') | 
|---|
| 1725 | cout<<"PAWExecutor::h_oper Error: operation "<<oper[0] | 
|---|
| 1726 | <<" not implemented for Vector in Peida"<<endl; | 
|---|
| 1727 | #else | 
|---|
| 1728 | else if( oper[0]=='*') {h3->Clone(*h1); h3->MulElt(*h2,*h3);} | 
|---|
| 1729 | else if( oper[0]=='/') {h3->Clone(*h1); h3->DivElt(*h2,*h3,false,true);} | 
|---|
| 1730 | #endif | 
|---|
| 1731 |  | 
|---|
| 1732 | // Operations on Matrix | 
|---|
| 1733 | } else if( dynamic_cast<Matrix*>(mobjh1) != NULL ) { | 
|---|
| 1734 | if( dynamic_cast<Matrix*>(mobjh2) == NULL ) | 
|---|
| 1735 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h2\n" | 
|---|
| 1736 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh2).name()<<endl; | 
|---|
| 1737 | return;} | 
|---|
| 1738 | Matrix* h1 =(Matrix*) mobjh1; | 
|---|
| 1739 | Matrix* h2 =(Matrix*) mobjh2; | 
|---|
| 1740 | if( h1->NRows() != h2->NRows() || h1->NCol() != h2->NCol() ) | 
|---|
| 1741 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h2 " | 
|---|
| 1742 | <<h1->NRows()<<","<<h1->NCol()<<"   " | 
|---|
| 1743 | <<h2->NRows()<<","<<h2->NCol()<<endl; return;} | 
|---|
| 1744 | Matrix* h3 = NULL; | 
|---|
| 1745 | if( mobjh3 == NULL ) {  // l'objet n'existe pas, on le cree | 
|---|
| 1746 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1747 | h3 = new Matrix(*h1); | 
|---|
| 1748 | #else | 
|---|
| 1749 | h3 = new Matrix(*h1,false); | 
|---|
| 1750 | #endif | 
|---|
| 1751 | *h3 = 0.; omg.AddObj(h3,h3name); mobjh3 = omg.GetObj(h3name); | 
|---|
| 1752 | } | 
|---|
| 1753 | h3 = dynamic_cast<Matrix*>(mobjh3); | 
|---|
| 1754 | if(h3 == NULL)  // ce n'est pas un Matrix | 
|---|
| 1755 | {cout<<"PAWExecutor::h_oper Error: type mismatch between h1 and h3\n" | 
|---|
| 1756 | <<typeid(*mobjh1).name()<<" , "<<typeid(*mobjh3).name()<<endl; return;} | 
|---|
| 1757 | if( h1->NRows() != h3->NRows() || h1->NCol() != h3->NCol() ) | 
|---|
| 1758 | {cout<<"PAWExecutor::h_oper Error: size mismatch between h1, h3 " | 
|---|
| 1759 | <<h1->NRows()<<","<<h1->NCol()<<"   " | 
|---|
| 1760 | <<h3->NRows()<<","<<h3->NCol()<<endl; return;} | 
|---|
| 1761 | if( oper[0]=='+')      *h3 = *h1 + *h2; | 
|---|
| 1762 | else if( oper[0]=='-') *h3 = *h1 - *h2; | 
|---|
| 1763 | #ifdef SANS_EVOLPLANCK | 
|---|
| 1764 | else if(oper[0]=='*' || oper[0]=='/') | 
|---|
| 1765 | cout<<"PAWExecutor::h_oper Error: operation "<<oper[0] | 
|---|
| 1766 | <<" not implemented for Vector in Peida"<<endl; | 
|---|
| 1767 | #else | 
|---|
| 1768 | else if( oper[0]=='*') {h3->Clone(*h1); h3->MulElt(*h2,*h3);} | 
|---|
| 1769 | else if( oper[0]=='/') {h3->Clone(*h1); h3->DivElt(*h2,*h3,false,true);} | 
|---|
| 1770 | #endif | 
|---|
| 1771 |  | 
|---|
| 1772 | // Doesn't work for other objects | 
|---|
| 1773 | } else { | 
|---|
| 1774 | cout<<"PAWExecutor::h_oper Error: not implemented for " | 
|---|
| 1775 | <<typeid(*mobjh1).name()<<endl; | 
|---|
| 1776 | return; | 
|---|
| 1777 | } | 
|---|
| 1778 |  | 
|---|
| 1779 | return; | 
|---|
| 1780 | } | 
|---|
| 1781 |  | 
|---|
| 1782 | /* methode */ | 
|---|
| 1783 | void PAWExecutor::h_plot_2d(vector<string>& tokens) | 
|---|
| 1784 | // plot for 2D histogramme: plot histo, bandx/y, slicex/y or projx/y | 
|---|
| 1785 | { | 
|---|
| 1786 | if(tokens.size()<1) | 
|---|
| 1787 | {cout<<"Usage: h/plot/2d nameh2d to_plot [n/s] [dopt]"<<endl; return;} | 
|---|
| 1788 | string proj = "h"; if(tokens.size()>1) proj = tokens[1]; | 
|---|
| 1789 | NamedObjMgr omg; | 
|---|
| 1790 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 1791 | if(mobj==NULL) | 
|---|
| 1792 | {cout<<"PAWExecutor::h_plot_2d Error: unknow object"<<tokens[0]<<endl; | 
|---|
| 1793 | return;} | 
|---|
| 1794 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); | 
|---|
| 1795 | if(!h2) | 
|---|
| 1796 | {cout<<"PAWExecutor::h_plot_2d Error: "<<tokens[0]<<" not an Histo2D"<<endl; | 
|---|
| 1797 | return;} | 
|---|
| 1798 |  | 
|---|
| 1799 | Histo* h1p = NULL; string nametoplot = "/autoc/h_plot_2d_h1"; | 
|---|
| 1800 |  | 
|---|
| 1801 | string dopt = ""; if(tokens.size()>=3) dopt = tokens[2]; | 
|---|
| 1802 | if(proj == "show") { | 
|---|
| 1803 | h2->ShowProj(); | 
|---|
| 1804 | h2->ShowBand(2); | 
|---|
| 1805 | h2->ShowSli(2); | 
|---|
| 1806 | return; | 
|---|
| 1807 | } else if(proj == "h") { | 
|---|
| 1808 | nametoplot = tokens[0]; | 
|---|
| 1809 | } else if(proj == "px") { | 
|---|
| 1810 | if((h1p=h2->HProjX())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
| 1811 | else {h2->ShowProj(); return;} | 
|---|
| 1812 | } else if(proj == "py") { | 
|---|
| 1813 | if((h1p=h2->HProjY())) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
| 1814 | else {h2->ShowProj(); return;} | 
|---|
| 1815 | } else { | 
|---|
| 1816 | if(tokens.size()<3) | 
|---|
| 1817 | {cout<<"Usage: h/plot/2d nameh2d bx/by/sx/sy n [dopt]"<<endl; return;} | 
|---|
| 1818 | int_4 n = atoi(tokens[2].c_str()); | 
|---|
| 1819 | dopt = ""; if(tokens.size()>=4) dopt = tokens[3]; | 
|---|
| 1820 | if(proj == "bx") { | 
|---|
| 1821 | if((h1p=h2->HBandX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
| 1822 | else {h2->ShowBand(); return;} | 
|---|
| 1823 | } else if(proj == "by") { | 
|---|
| 1824 | if((h1p=h2->HBandY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
| 1825 | else {h2->ShowBand(); return;} | 
|---|
| 1826 | } else if(proj == "sx") { | 
|---|
| 1827 | if((h1p=h2->HSliX(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
| 1828 | else {h2->ShowSli(); return;} | 
|---|
| 1829 | } else if(proj == "sy") { | 
|---|
| 1830 | if((h1p=h2->HSliY(n))) {Histo* h1=new Histo(*h1p); omg.AddObj(h1,nametoplot);} | 
|---|
| 1831 | else {h2->ShowSli(); return;} | 
|---|
| 1832 | } | 
|---|
| 1833 | } | 
|---|
| 1834 |  | 
|---|
| 1835 | omg.DisplayObj(nametoplot,dopt); | 
|---|
| 1836 | } | 
|---|
| 1837 |  | 
|---|
| 1838 | /* methode */ | 
|---|
| 1839 | int_4 PAWExecutor::decodepawstring(string tokens,string& nameobj | 
|---|
| 1840 | ,string& xexp,string& yexp,string& zexp) | 
|---|
| 1841 | // Decodage general de "nameobj.xexp" | 
|---|
| 1842 | //                     "nameobj.yexp%xexp" | 
|---|
| 1843 | //                     "nameobj.zexp%yexp%xexp" | 
|---|
| 1844 | // Return: nombre de variables trouvees, -1 si probleme | 
|---|
| 1845 | { | 
|---|
| 1846 | nameobj = ""; xexp= ""; yexp= ""; zexp= ""; | 
|---|
| 1847 |  | 
|---|
| 1848 | int_4 lt = (int) tokens.length(); | 
|---|
| 1849 | if(lt<=0) return -1; | 
|---|
| 1850 |  | 
|---|
| 1851 | // decodage de la chaine de type PAW. | 
|---|
| 1852 | char *str = new char[lt+2]; | 
|---|
| 1853 | strcpy(str,tokens.c_str()); strip(str,'B',' '); lt = strlen(str); | 
|---|
| 1854 | //cout<<"chaine1["<<lt<<"] :"<<str<<":"<<endl; | 
|---|
| 1855 | char *c[3] = {NULL,NULL,NULL}; | 
|---|
| 1856 | int_4 i, np=0; bool namefound = false; | 
|---|
| 1857 | for(i=0;i<lt;i++) { | 
|---|
| 1858 | if(!namefound && str[i]=='.') { | 
|---|
| 1859 | str[i]='\0'; | 
|---|
| 1860 | namefound=true; | 
|---|
| 1861 | c[np] = str+i+1; np++; | 
|---|
| 1862 | } | 
|---|
| 1863 | if( namefound && str[i]=='%') { | 
|---|
| 1864 | str[i]='\0'; | 
|---|
| 1865 | if(np<3) {c[np] = str+i+1; np++;} | 
|---|
| 1866 | } | 
|---|
| 1867 | } | 
|---|
| 1868 | //cout<<"chaine2 :"; for(i=0;i<lt;i++) cout<<str[i]; cout<<":"<<endl; | 
|---|
| 1869 |  | 
|---|
| 1870 | // Remplissage du nom et des variables | 
|---|
| 1871 | nameobj = str; | 
|---|
| 1872 | if(np==1)  xexp=c[0]; | 
|---|
| 1873 | if(np==2) {yexp=c[0]; xexp=c[1];} | 
|---|
| 1874 | if(np==3) {zexp=c[0]; yexp=c[1]; xexp=c[2];} | 
|---|
| 1875 | //cout<<"pawstring str,c[0-2] "<<str<<" "<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl; | 
|---|
| 1876 | delete [] str; | 
|---|
| 1877 |  | 
|---|
| 1878 | // Comptage des variables | 
|---|
| 1879 | np = -1; | 
|---|
| 1880 | if(nameobj.length()>0) | 
|---|
| 1881 | {np = 0; if(xexp.length()>0) | 
|---|
| 1882 | {np++; if(yexp.length()>0) | 
|---|
| 1883 | {np++; if(zexp.length()>0) np++;}}} | 
|---|
| 1884 | //cout<<"pawstring["<<np<<"] name="<<nameobj | 
|---|
| 1885 | //    <<" xexp="<<xexp<<" yexp="<<yexp<<" zexp="<<zexp<<endl; | 
|---|
| 1886 | return np; | 
|---|
| 1887 | } | 
|---|
| 1888 |  | 
|---|
| 1889 | /* methode */ | 
|---|
| 1890 | void PAWExecutor::h_put_vec(vector<string>& tokens) | 
|---|
| 1891 | // Pour remplir un histo avec le contenu d'un vecteur ou d'une matrice | 
|---|
| 1892 | // L'histogramme doit deja exister. Le nombre de bins remplit | 
|---|
| 1893 | // depend des tailles respectives des 2 objets. | 
|---|
| 1894 | // tokens[2] = "cont" : on remplit les valeurs de l'histogramme (ou "!") | 
|---|
| 1895 | //           = "err2" : on remplit les erreurs de l'histogramme | 
|---|
| 1896 | { | 
|---|
| 1897 | if(tokens.size()<2) | 
|---|
| 1898 | {cout<<"Usage: h/put_vec  namehisto namevector"<<endl; | 
|---|
| 1899 | return;} | 
|---|
| 1900 | string toput = "cont"; if(tokens.size()>2) toput = tokens[2]; | 
|---|
| 1901 | if(toput=="!") toput = "cont"; | 
|---|
| 1902 | if(toput!="cont" && toput!="err2") | 
|---|
| 1903 | {cout<<"PAWExecutor::h_put_vec Error: unknow filling "<<toput<<endl; | 
|---|
| 1904 | return;} | 
|---|
| 1905 | string hname = tokens[0]; | 
|---|
| 1906 | string vname = tokens[1]; | 
|---|
| 1907 |  | 
|---|
| 1908 | // Get objects | 
|---|
| 1909 | NamedObjMgr omg; | 
|---|
| 1910 | AnyDataObj* mobjh = omg.GetObj(hname); | 
|---|
| 1911 | AnyDataObj* mobjv = omg.GetObj(vname); | 
|---|
| 1912 | if( mobjh==NULL || mobjv==NULL ) | 
|---|
| 1913 | {cout<<"PAWExecutor::h_put_vec Error: unknow object(s) "<<hname<<" or "<<vname<<endl; | 
|---|
| 1914 | return;} | 
|---|
| 1915 |  | 
|---|
| 1916 | // Fill Histo from Vector | 
|---|
| 1917 | if(typeid(*mobjh) == typeid(Histo) && typeid(*mobjv) == typeid(Vector)) { | 
|---|
| 1918 | Histo*  h = dynamic_cast<Histo*>(mobjh); | 
|---|
| 1919 | Vector* v = dynamic_cast<Vector*>(mobjv); | 
|---|
| 1920 | if(toput=="cont")      h->PutValue(*v); | 
|---|
| 1921 | else if(toput=="err2") h->PutError2(*v); | 
|---|
| 1922 |  | 
|---|
| 1923 | // Fill Histo2D from Matrix | 
|---|
| 1924 | } else if(typeid(*mobjh) == typeid(Histo2D) && typeid(*mobjv) == typeid(Matrix)) { | 
|---|
| 1925 | Histo2D* h = dynamic_cast<Histo2D*>(mobjh); | 
|---|
| 1926 | Matrix*  v = dynamic_cast<Matrix*>(mobjv); | 
|---|
| 1927 | if(toput=="cont")      h->PutValue(*v); | 
|---|
| 1928 | else if(toput=="err2") h->PutError2(*v); | 
|---|
| 1929 |  | 
|---|
| 1930 | } else { | 
|---|
| 1931 | cout<<"PAWExecutor::h_put_vec Error: type mismatch between histogram and vector/matrix\n" | 
|---|
| 1932 | <<typeid(*mobjh).name()<<" , "<<typeid(*mobjv).name()<<endl; | 
|---|
| 1933 | return; | 
|---|
| 1934 | } | 
|---|
| 1935 |  | 
|---|
| 1936 | } | 
|---|
| 1937 |  | 
|---|
| 1938 | /* methode */ | 
|---|
| 1939 | void PAWExecutor::h_get_vec(vector<string>& tokens) | 
|---|
| 1940 | // Pour copier un histo dans un vecteur ou une matrice | 
|---|
| 1941 | // Si le vecteur (matrice) n'existe pas, il est cree. | 
|---|
| 1942 | // Le vecteur ou la matrice est re-dimensionne correctement. | 
|---|
| 1943 | // tokens[2] = "cont" : on copie les valeurs de l'histogramme (ou "!") | 
|---|
| 1944 | //           = "err2" : on copie les erreurs de l'histogramme | 
|---|
| 1945 | //           = "absc" : on copie les erreurs de l'histogramme (1D only) | 
|---|
| 1946 | // tokens[3[,4]] = show : show available projections for Histo2D | 
|---|
| 1947 | //                 px   : get X projection | 
|---|
| 1948 | //                 py   : get Y projection | 
|---|
| 1949 | //                 bx n : get X band number n | 
|---|
| 1950 | //                 by n : get Y band number n | 
|---|
| 1951 | //                 sx n : get X slice number n | 
|---|
| 1952 | //                 sy n : get Y slice number n | 
|---|
| 1953 | { | 
|---|
| 1954 | if(tokens.size()<2) | 
|---|
| 1955 | {cout<<"Usage: h/get_vec namehisto namevector"<<endl; | 
|---|
| 1956 | return;} | 
|---|
| 1957 | string toget = "cont"; if(tokens.size()>2) toget = tokens[2]; | 
|---|
| 1958 | if(toget=="!") toget = "cont"; | 
|---|
| 1959 | if(toget!="cont" && toget!="err2" && toget!="absc") | 
|---|
| 1960 | {cout<<"PAWExecutor::h_get_vec Error: unknow filling "<<toget<<endl; | 
|---|
| 1961 | return;} | 
|---|
| 1962 | string proj = "h";  if(tokens.size()>3) proj = tokens[3]; | 
|---|
| 1963 | int_4 nproj = -1;   if(tokens.size()>4) nproj = atoi(tokens[4].c_str()); | 
|---|
| 1964 | string hname = tokens[0]; | 
|---|
| 1965 | string vname = tokens[1]; | 
|---|
| 1966 |  | 
|---|
| 1967 | // Get objects | 
|---|
| 1968 | NamedObjMgr omg; | 
|---|
| 1969 | AnyDataObj* mobjh = omg.GetObj(hname); | 
|---|
| 1970 | AnyDataObj* mobjv = omg.GetObj(vname); | 
|---|
| 1971 | if( mobjh==NULL) | 
|---|
| 1972 | {cout<<"PAWExecutor::h_put_vec Error: unknow object(s) "<<hname<<endl; | 
|---|
| 1973 | return;} | 
|---|
| 1974 |  | 
|---|
| 1975 | // Copy Histo/Histo2D/Projection to Vector/Matrix | 
|---|
| 1976 | Histo*   h  = dynamic_cast<Histo*>(mobjh); | 
|---|
| 1977 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobjh); | 
|---|
| 1978 | if( h != NULL ) {  // Histo ou HProf | 
|---|
| 1979 | h->UpdateHisto();  // pour le cas ou c'est un HProf | 
|---|
| 1980 | Vector* v = NULL; | 
|---|
| 1981 | if(mobjv==NULL)   // le vecteur n'existe pas | 
|---|
| 1982 | {v = new Vector(1); omg.AddObj(v,vname); mobjv = omg.GetObj(vname);} | 
|---|
| 1983 | if(typeid(*mobjv) != typeid(Vector)) | 
|---|
| 1984 | {cout<<"PAWExecutor::h_get_vec Error: type mismatch between Histo/HProf and vector\n" | 
|---|
| 1985 | <<typeid(*mobjv).name()<<endl; return;} | 
|---|
| 1986 | v = dynamic_cast<Vector*>(mobjv); | 
|---|
| 1987 | if(toget=="cont")      h->GetValue(*v); | 
|---|
| 1988 | else if(toget=="err2") h->GetError2(*v); | 
|---|
| 1989 | else if(toget=="absc") h->GetAbsc(*v); | 
|---|
| 1990 |  | 
|---|
| 1991 | } else if( h2 != NULL) {  // Histo2D | 
|---|
| 1992 |  | 
|---|
| 1993 | if(proj == "h") {   // On veut les valeurs de l'histogramme 2D | 
|---|
| 1994 | Matrix*  v = NULL; | 
|---|
| 1995 | if(mobjv==NULL)   // la matrice n'existe pas | 
|---|
| 1996 | {v = new Matrix(1,1); omg.AddObj(v,vname); mobjv = omg.GetObj(vname);} | 
|---|
| 1997 | if(typeid(*mobjv) != typeid(Matrix)) | 
|---|
| 1998 | {cout<<"PAWExecutor::h_get_vec Error: type mismatch between Histo2D and matrix\n" | 
|---|
| 1999 | <<typeid(*mobjv).name()<<endl; return;} | 
|---|
| 2000 | v = dynamic_cast<Matrix*>(mobjv); | 
|---|
| 2001 | if(toget=="cont")      h2->GetValue(*v); | 
|---|
| 2002 | else if(toget=="err2") h2->GetError2(*v); | 
|---|
| 2003 | else | 
|---|
| 2004 | {cout<<"PAWExecutor::h_get_vec Error: option "<<toget<<" not valid for Histo2D"<<endl; | 
|---|
| 2005 | return;} | 
|---|
| 2006 |  | 
|---|
| 2007 | } else {   // On veut les valeurs d'une projection de l'histo 2D | 
|---|
| 2008 | h = NULL; | 
|---|
| 2009 | if(proj == "show") {h2->ShowProj(); h2->ShowBand(2); h2->ShowSli(2);} | 
|---|
| 2010 | else if(proj == "px") h = h2->HProjX(); | 
|---|
| 2011 | else if(proj == "py") h = h2->HProjY(); | 
|---|
| 2012 | else if(proj == "bx") h = h2->HBandX(nproj); | 
|---|
| 2013 | else if(proj == "by") h = h2->HBandY(nproj); | 
|---|
| 2014 | else if(proj == "sx") h = h2->HSliX(nproj); | 
|---|
| 2015 | else if(proj == "sy") h = h2->HSliY(nproj); | 
|---|
| 2016 | if(h==NULL) | 
|---|
| 2017 | {cout<<"PAWExecutor::h_get_vec Error: unknown projection "<<proj | 
|---|
| 2018 | <<" number "<<nproj<<endl; return;} | 
|---|
| 2019 | Vector* v = NULL; | 
|---|
| 2020 | if(mobjv==NULL)   // le vecteur n'existe pas | 
|---|
| 2021 | {v = new Vector(1); omg.AddObj(v,vname); mobjv = omg.GetObj(vname);} | 
|---|
| 2022 | if(typeid(*mobjv) != typeid(Vector)) | 
|---|
| 2023 | {cout<<"PAWExecutor::h_get_vec Error: type mismatch between Histo2D "<<proj | 
|---|
| 2024 | <<" and vector\n"<<typeid(*mobjv).name()<<endl; return;} | 
|---|
| 2025 | v = dynamic_cast<Vector*>(mobjv); | 
|---|
| 2026 | if(toget=="cont")      h->GetValue(*v); | 
|---|
| 2027 | else if(toget=="err2") h->GetError2(*v); | 
|---|
| 2028 | else if(toget=="absc") h->GetAbsc(*v); | 
|---|
| 2029 | } | 
|---|
| 2030 |  | 
|---|
| 2031 | } else { | 
|---|
| 2032 | cout<<"PAWExecutor::h_get_vec Error: type mismatch for histogram\n" | 
|---|
| 2033 | <<typeid(*mobjh).name()<<endl; | 
|---|
| 2034 | return; | 
|---|
| 2035 | } | 
|---|
| 2036 |  | 
|---|
| 2037 | } | 
|---|
| 2038 |  | 
|---|
| 2039 | /* methode */ | 
|---|
| 2040 | void PAWExecutor::h_copy(vector<string>& tokens) | 
|---|
| 2041 | // Pour copier un object dans un object | 
|---|
| 2042 | // objects are Vector,Matrix,Histo,Histo2D | 
|---|
| 2043 | //   h/copy namefrom nametocopy [i1[:i2]] [j1[:j2]] [ic1[:jc1]] | 
|---|
| 2044 | //   copy obj1Dfrom(i1->i2) into obj1Dto(ic1->) | 
|---|
| 2045 | //   copy obj2Dfrom(i1,j1->i2,j2) into obj2Dto(ic1,jc1->) | 
|---|
| 2046 | // Attention: elements depuis i1 jusqu'a i2 COMPRIS | 
|---|
| 2047 | // Si obj1Dto n'existe pas, il est cree avec une taille i2-i1+1 | 
|---|
| 2048 | //    ou obj2Dto avec une taille i2-i1+1,j2-j1+1 | 
|---|
| 2049 | // Le contenu de obj?Dfrom adresse est surecrit | 
|---|
| 2050 | // Le contenu de obj?Dfrom non adresse reste le meme | 
|---|
| 2051 | { | 
|---|
| 2052 | int_4 tks = tokens.size(); | 
|---|
| 2053 | if(tks<2) | 
|---|
| 2054 | {cout<<"Usage: h_copy namefrom nametocopy [i1[:i2]] [j1[:j2]] [ic1[:jc1]]"<<endl; | 
|---|
| 2055 | return;} | 
|---|
| 2056 |  | 
|---|
| 2057 | NamedObjMgr omg; | 
|---|
| 2058 | AnyDataObj* mobjv1 = omg.GetObj(tokens[0]); | 
|---|
| 2059 | if( mobjv1==NULL) | 
|---|
| 2060 | {cout<<"PAWExecutor::h_copy Error: unknow object "<<tokens[0]<<endl; | 
|---|
| 2061 | return;} | 
|---|
| 2062 | AnyDataObj* mobjv2 = omg.GetObj(tokens[1]); | 
|---|
| 2063 |  | 
|---|
| 2064 | int_4 i1=0,i2=0, j1=0,j2=0, ic1=0,jc1=0, i,ii, j,jj, nx1,ny1, nx2,ny2; | 
|---|
| 2065 |  | 
|---|
| 2066 | // Cas d'un Vector | 
|---|
| 2067 | if(typeid(*mobjv1) == typeid(Vector)) { | 
|---|
| 2068 | Vector* v1 = dynamic_cast<Vector*>(mobjv1); nx1 = (int_4)v1->NElts(); | 
|---|
| 2069 | i2=nx1-1; | 
|---|
| 2070 | if(tks>2) if(tokens[2]!="!") sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2); | 
|---|
| 2071 | if(i1<0) i1=0; if(i2>=nx1) i2=nx1-1; | 
|---|
| 2072 | if(i2<i1) | 
|---|
| 2073 | {cout<<"PAWExecutor::h_copy Error: wrong range ["<<i1<<":"<<i2<<"] for NElts=" | 
|---|
| 2074 | <<nx1<<endl; return;} | 
|---|
| 2075 | Vector* v2 = NULL; | 
|---|
| 2076 | if(mobjv2==NULL) | 
|---|
| 2077 | {v2 = new Vector(i2-i1+1); omg.AddObj(v2,tokens[1]); mobjv2 = omg.GetObj(tokens[1]);} | 
|---|
| 2078 | if(typeid(*mobjv2) != typeid(Vector)) | 
|---|
| 2079 | {cout<<"PAWExecutor::h_copy Error: type mismatch for Vector " | 
|---|
| 2080 | <<typeid(*mobjv2).name()<<endl; return;} | 
|---|
| 2081 | v2 = dynamic_cast<Vector*>(mobjv2); nx2 = (int_4)v2->NElts(); | 
|---|
| 2082 | if(tks>4) if(tokens[4]!="!") sscanf(tokens[4].c_str(),"%d",&ic1); | 
|---|
| 2083 | if(ic1<0) ic1=0; | 
|---|
| 2084 | if(ic1>=nx2) | 
|---|
| 2085 | {cout<<"PAWExecutor::h_copy Error: wrong pointer to copy ["<<ic1<<"] for NElts=" | 
|---|
| 2086 | <<nx2<<endl; return;} | 
|---|
| 2087 | cout<<"copy "<<tokens[0]<<"("<<i1<<":"<<i2<<") to "<<tokens[1]<<"("<<ic1<<"->...)"<<endl; | 
|---|
| 2088 | for(i=i1,ii=ic1; i<=i2 && i<nx1 && ii<nx2; i++,ii++) (*v2)(ii) = (*v1)(i); | 
|---|
| 2089 | return; | 
|---|
| 2090 | } | 
|---|
| 2091 |  | 
|---|
| 2092 | // Cas d'un Histo | 
|---|
| 2093 | if(typeid(*mobjv1) == typeid(Histo)) { | 
|---|
| 2094 | Histo* v1 = dynamic_cast<Histo*>(mobjv1); nx1 = (int_4)v1->NBins(); | 
|---|
| 2095 | i2=nx1-1; | 
|---|
| 2096 | if(tks>2) if(tokens[2]!="!") sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2); | 
|---|
| 2097 | if(i1<0) i1=0; if(i2>=nx1) i2=nx1-1; | 
|---|
| 2098 | if(i2<i1) | 
|---|
| 2099 | {cout<<"PAWExecutor::h_copy Error: wrong range ["<<i1<<":"<<i2<<"] for NBins=" | 
|---|
| 2100 | <<nx1<<endl; return;} | 
|---|
| 2101 | Histo* v2 = NULL; | 
|---|
| 2102 | if(mobjv2==NULL) | 
|---|
| 2103 | {v2 = new Histo(0.,(r_8)(i2-i1+1),i2-i1+1); | 
|---|
| 2104 | omg.AddObj(v2,tokens[1]); mobjv2 = omg.GetObj(tokens[1]);} | 
|---|
| 2105 | if(typeid(*mobjv2) != typeid(Histo)) | 
|---|
| 2106 | {cout<<"PAWExecutor::h_copy Error: type mismatch for Histo " | 
|---|
| 2107 | <<typeid(*mobjv2).name()<<endl; return;} | 
|---|
| 2108 | v2 = dynamic_cast<Histo*>(mobjv2); nx2 = (int_4)v2->NBins(); | 
|---|
| 2109 | if(v1->HasErrors() && !(v2->HasErrors())) v2->Errors(); | 
|---|
| 2110 | if(tks>4) if(tokens[4]!="!") sscanf(tokens[4].c_str(),"%d",&ic1); | 
|---|
| 2111 | if(ic1<0) ic1=0; | 
|---|
| 2112 | if(ic1>=nx2) | 
|---|
| 2113 | {cout<<"PAWExecutor::h_copy Error: wrong pointer to copy ["<<ic1<<"] for NBins=" | 
|---|
| 2114 | <<nx2<<endl; return;} | 
|---|
| 2115 | cout<<"copy "<<tokens[0]<<"("<<i1<<":"<<i2<<") to "<<tokens[1]<<"("<<ic1<<"->...)"<<endl; | 
|---|
| 2116 | for(i=i1,ii=ic1; i<=i2 && i<nx1 && ii<nx2; i++,ii++) | 
|---|
| 2117 | {(*v2)(ii) = (*v1)(i); if(v1->HasErrors()) v2->Error2(ii) = v1->Error2(i);} | 
|---|
| 2118 | return; | 
|---|
| 2119 | } | 
|---|
| 2120 |  | 
|---|
| 2121 | // Cas d'une Matrix | 
|---|
| 2122 | if(typeid(*mobjv1) == typeid(Matrix)) { | 
|---|
| 2123 | Matrix* v1 = dynamic_cast<Matrix*>(mobjv1); nx1=v1->NRows(); ny1=v1->NCol(); | 
|---|
| 2124 | i2=nx1-1; j2=ny1-1; | 
|---|
| 2125 | if(tks>2) if(tokens[2]!="!") sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2); | 
|---|
| 2126 | if(tks>3) if(tokens[3]!="!") sscanf(tokens[3].c_str(),"%d:%d",&j1,&j2); | 
|---|
| 2127 | if(i1<0) i1=0; if(i2>=nx1) i2=nx1-1; if(j1<0) j1=0; if(j2>=ny1) j2=ny1-1; | 
|---|
| 2128 | if(i2<i1 || j2<j1) | 
|---|
| 2129 | {cout<<"PAWExecutor::h_copy Error: wrong range ["<<i1<<":"<<i2 | 
|---|
| 2130 | <<"] , ["<<j1<<":"<<j2<<"] for NRows,NCol=" | 
|---|
| 2131 | <<nx1<<" , "<<ny1<<endl; return;} | 
|---|
| 2132 | Matrix* v2 = NULL; | 
|---|
| 2133 | if(mobjv2==NULL) | 
|---|
| 2134 | {v2 = new Matrix(i2-i1+1,j2-j1+1); | 
|---|
| 2135 | omg.AddObj(v2,tokens[1]); mobjv2 = omg.GetObj(tokens[1]);} | 
|---|
| 2136 | if(typeid(*mobjv2) != typeid(Matrix)) | 
|---|
| 2137 | {cout<<"PAWExecutor::h_copy Error: type mismatch for Matrix " | 
|---|
| 2138 | <<typeid(*mobjv2).name()<<endl; return;} | 
|---|
| 2139 | v2 = dynamic_cast<Matrix*>(mobjv2); nx2=v2->NRows(); ny2=v2->NCol(); | 
|---|
| 2140 | if(tks>4) if(tokens[4]!="!") sscanf(tokens[4].c_str(),"%d:%d",&ic1,&jc1); | 
|---|
| 2141 | if(ic1<0) ic1=0; if(jc1<0) jc1=0; | 
|---|
| 2142 | if(ic1>=nx2 || jc1>=ny2) | 
|---|
| 2143 | {cout<<"PAWExecutor::h_copy Error: wrong pointer to copy ["<<ic1<<","<<jc1 | 
|---|
| 2144 | <<"] for NRows,NCol="<<nx2<<","<<ny2<<endl; return;} | 
|---|
| 2145 | cout<<"copy "<<tokens[0]<<"("<<i1<<":"<<i2<<","<<j1<<":"<<j2 | 
|---|
| 2146 | <<") to "<<tokens[1]<<"("<<ic1<<","<<jc1<<"->...)"<<endl; | 
|---|
| 2147 | for(i=i1,ii=ic1; i<=i2 && i<nx1 && ii<nx2; i++,ii++) | 
|---|
| 2148 | for(j=j1,jj=jc1; j<=j2 && j<ny1 && jj<ny2; j++,jj++) (*v2)(ii,jj) = (*v1)(i,j); | 
|---|
| 2149 | return; | 
|---|
| 2150 | } | 
|---|
| 2151 |  | 
|---|
| 2152 | // Cas d'un Histo2D | 
|---|
| 2153 | if(typeid(*mobjv1) == typeid(Histo2D)) { | 
|---|
| 2154 | Histo2D* v1 = dynamic_cast<Histo2D*>(mobjv1); nx1=v1->NBinX(); ny1=v1->NBinY(); | 
|---|
| 2155 | i2=nx1-1; j2=ny1-1; | 
|---|
| 2156 | if(tks>2) if(tokens[2]!="!") sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2); | 
|---|
| 2157 | if(tks>3) if(tokens[3]!="!") sscanf(tokens[3].c_str(),"%d:%d",&j1,&j2); | 
|---|
| 2158 | if(i1<0) i1=0; if(i2>=nx1) i2=nx1-1; if(j1<0) j1=0; if(j2>=ny1) j2=ny1-1; | 
|---|
| 2159 | if(i2<i1 || j2<j1) | 
|---|
| 2160 | {cout<<"PAWExecutor::h_copy Error: wrong range ["<<i1<<":"<<i2 | 
|---|
| 2161 | <<"] , ["<<j1<<":"<<j2<<"] for NBinX,NBinY=" | 
|---|
| 2162 | <<nx1<<" , "<<ny1<<endl; return;} | 
|---|
| 2163 | Histo2D* v2 = NULL; | 
|---|
| 2164 | if(mobjv2==NULL) | 
|---|
| 2165 | {v2 = new Histo2D(0.,(r_8)(i2-i1+1),i2-i1+1,0.,(r_8)(j2-j1+1),j2-j1+1); | 
|---|
| 2166 | omg.AddObj(v2,tokens[1]); mobjv2 = omg.GetObj(tokens[1]);} | 
|---|
| 2167 | if(typeid(*mobjv2) != typeid(Histo2D)) | 
|---|
| 2168 | {cout<<"PAWExecutor::h_copy Error: type mismatch for Histo2D" | 
|---|
| 2169 | <<typeid(*mobjv2).name()<<endl; return;} | 
|---|
| 2170 | v2 = dynamic_cast<Histo2D*>(mobjv2); nx2=v2->NBinX(); ny2=v2->NBinY(); | 
|---|
| 2171 | if(v1->HasErrors() && !(v2->HasErrors())) v2->Errors(); | 
|---|
| 2172 | if(tks>4) sscanf(tokens[4].c_str(),"%d:%d",&ic1,&jc1); | 
|---|
| 2173 | if(ic1<0) ic1=0; if(jc1<0) jc1=0; | 
|---|
| 2174 | if(ic1>=nx2 || jc1>=ny2) | 
|---|
| 2175 | {cout<<"PAWExecutor::h_copy Error: wrong pointer to copy ["<<ic1<<","<<jc1 | 
|---|
| 2176 | <<"] for NBinX,NBinY="<<nx2<<","<<ny2<<endl; return;} | 
|---|
| 2177 | cout<<"copy "<<tokens[0]<<"("<<i1<<":"<<i2<<","<<j1<<":"<<j2 | 
|---|
| 2178 | <<") to "<<tokens[1]<<"("<<ic1<<","<<jc1<<"->...)"<<endl; | 
|---|
| 2179 | for(i=i1,ii=ic1; i<=i2 && i<nx1 && ii<nx2; i++,ii++) | 
|---|
| 2180 | for(j=j1,jj=jc1; j<=j2 && j<ny1 && jj<ny2; j++,jj++) | 
|---|
| 2181 | {(*v2)(ii,jj) = (*v1)(i,j); if(v1->HasErrors()) v2->Error2(ii,jj) = v1->Error2(i,j);} | 
|---|
| 2182 | return; | 
|---|
| 2183 | } | 
|---|
| 2184 |  | 
|---|
| 2185 | // Cas non prevu | 
|---|
| 2186 | cout<<"PAWExecutor::h_copy Error: type mismatch for Vector/Matrix/Histo/Histo2D\n" | 
|---|
| 2187 | <<typeid(*mobjv1).name()<<endl; | 
|---|
| 2188 | return; | 
|---|
| 2189 | } | 
|---|
| 2190 |  | 
|---|
| 2191 | /* methode */ | 
|---|
| 2192 | void PAWExecutor::h_set(string dum,vector<string>& tokens) | 
|---|
| 2193 | // Mise de valeurs/erreurs d'un histo 1D ou 2D a une valeur donnee | 
|---|
| 2194 | // dum = err  : on change les valeurs des erreurs | 
|---|
| 2195 | //       cont : on change les valeurs du contenu des bins | 
|---|
| 2196 | // tokens[0] : nom de l'histogramme | 
|---|
| 2197 | // tokens[1] : valeur de remplacement | 
|---|
| 2198 | // tokens[2-3] : i1:i2 j1:j2  intervalle des bins qui doivent etre remplace | 
|---|
| 2199 | //             : v v1:v2  remplacement des bins ayant une valeur dans cet intervalle | 
|---|
| 2200 | //             : e e1:e2  remplacement des bins ayant une erreur dans cet intervalle | 
|---|
| 2201 | { | 
|---|
| 2202 | int_4 tks = tokens.size(); | 
|---|
| 2203 | if(tks<3) | 
|---|
| 2204 | {cout<<"Usage: h/set/[err,cont] namehisto setvalue i1[:i2]  [j1[:j2]]\n" | 
|---|
| 2205 | <<"                                           v v1:v2\n" | 
|---|
| 2206 | <<"                                           e e1:e2" | 
|---|
| 2207 | <<endl; return;} | 
|---|
| 2208 |  | 
|---|
| 2209 | // Decodage arguments | 
|---|
| 2210 | bool replerr = false; if(dum=="err") replerr = true; | 
|---|
| 2211 | r_8 setval = atof(tokens[1].c_str()); | 
|---|
| 2212 | int_4 testcont=0; if(tokens[2]=="v") testcont=1; if(tokens[2]=="e") testcont=2; | 
|---|
| 2213 | int_4 i1=-1, i2=-1, j1=-1, j2=-1; | 
|---|
| 2214 | r_8 v1=0., v2=0.; | 
|---|
| 2215 | if(testcont==0) { | 
|---|
| 2216 | sscanf(tokens[2].c_str(),"%d:%d",&i1,&i2); | 
|---|
| 2217 | if(tks>3) sscanf(tokens[3].c_str(),"%d:%d",&j1,&j2); | 
|---|
| 2218 | } else { | 
|---|
| 2219 | if(tks<=3) | 
|---|
| 2220 | {cout<<"PAWExecutor::h_set Error: h/set/... v v1:v2, please give v1:v2"<<endl; | 
|---|
| 2221 | return;} | 
|---|
| 2222 | sscanf(tokens[3].c_str(),"%lf:%lf",&v1,&v2); | 
|---|
| 2223 | } | 
|---|
| 2224 |  | 
|---|
| 2225 | if(replerr) {if(setval<0.) setval = 0.; else setval *= setval;} | 
|---|
| 2226 | if(testcont!=0 && v2<v1) | 
|---|
| 2227 | {cout<<"PAWExecutor::h_set Error: bad value range="<<v1<<","<<v2<<endl; return;} | 
|---|
| 2228 |  | 
|---|
| 2229 | // identification objet | 
|---|
| 2230 | NamedObjMgr omg; | 
|---|
| 2231 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 2232 | if( mobj==NULL) | 
|---|
| 2233 | {cout<<"PAWExecutor::h_set Error: unknow object "<<tokens[0]<<endl; | 
|---|
| 2234 | return;} | 
|---|
| 2235 |  | 
|---|
| 2236 | // Traitement | 
|---|
| 2237 | if(typeid(*mobj) == typeid(Histo)) {  // Histo 1D | 
|---|
| 2238 | Histo* h  = dynamic_cast<Histo*>(mobj); | 
|---|
| 2239 | if( (replerr || testcont==2) && !(h->HasErrors()) ) | 
|---|
| 2240 | {cout<<"PAWExecutor::h_set Error: histogram has no errors"<<endl; return;} | 
|---|
| 2241 | if(testcont!=0) {i1=0; i2=h->NBins()-1;} | 
|---|
| 2242 | if(i1<0 || i1>=h->NBins()) | 
|---|
| 2243 | {cout<<"PAWExecutor::h_set Error: bad bin range i1="<<i1<<endl; return;} | 
|---|
| 2244 | if(i2<i1) i2=i1; if(i2>=h->NBins()) i2=h->NBins()-1; | 
|---|
| 2245 | for(int_4 i=i1;i<=i2;i++) { | 
|---|
| 2246 | bool change = true; | 
|---|
| 2247 | if(testcont==1) {if((*h)(i)<v1 || (*h)(i)>v2) change = false;} | 
|---|
| 2248 | else if(testcont==2) {if(h->Error(i)<v1 || h->Error(i)>v2) change = false;} | 
|---|
| 2249 | if(!change) continue; | 
|---|
| 2250 | if(replerr) h->Error2(i) = setval; else (*h)(i) = setval; | 
|---|
| 2251 | } | 
|---|
| 2252 |  | 
|---|
| 2253 | } else if(typeid(*mobj) == typeid(Histo2D)) {  // Histo 2D | 
|---|
| 2254 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); | 
|---|
| 2255 | if( (replerr || testcont==2) && !(h2->HasErrors()) ) | 
|---|
| 2256 | {cout<<"PAWExecutor::h_set Error: histogram has no errors"<<endl; return;} | 
|---|
| 2257 | if(testcont!=0) {i1=0; i2=h2->NBinX()-1;j1=0; j2=h2->NBinY()-1;} | 
|---|
| 2258 | if(i1<0 || i1>=h2->NBinX() || j1<0 || j1>=h2->NBinY()) | 
|---|
| 2259 | {cout<<"PAWExecutor::h_set Error: bad bin range i1,j1="<<i1<<","<<j1<<endl; return;} | 
|---|
| 2260 | if(i2<i1) i2=i1; if(i2>=h2->NBinX()) i2=h2->NBinX()-1; | 
|---|
| 2261 | if(j2<j1) j2=j1; if(j2>=h2->NBinY()) j2=h2->NBinY()-1; | 
|---|
| 2262 | for(int_4 i=i1;i<=i2;i++) for(int_4 j=j1;j<=j2;j++) { | 
|---|
| 2263 | bool change = true; | 
|---|
| 2264 | if(testcont==1) {if((*h2)(i,j)<v1 || (*h2)(i,j)>v2) change = false;} | 
|---|
| 2265 | else if(testcont==2) {if(h2->Error(i,j)<v1 || h2->Error(i,j)>v2) change = false;} | 
|---|
| 2266 | if(!change) continue; | 
|---|
| 2267 | if(replerr) h2->Error2(i,j) = setval; else (*h2)(i,j) = setval; | 
|---|
| 2268 | } | 
|---|
| 2269 |  | 
|---|
| 2270 | } else { | 
|---|
| 2271 | cout<<"PAWExecutor::h_set Error: type mismatch for Histo/Histo2D\n" | 
|---|
| 2272 | <<typeid(*mobj).name()<<endl; | 
|---|
| 2273 | return; | 
|---|
| 2274 | } | 
|---|
| 2275 |  | 
|---|
| 2276 | } | 
|---|
| 2277 |  | 
|---|
| 2278 | /* methode */ | 
|---|
| 2279 | void PAWExecutor::h_err(vector<string>& tokens) | 
|---|
| 2280 | // Mise des erreurs d'un histo 1D ou 2D a une valeur | 
|---|
| 2281 | // donnee par une fonction de la valeur du bin | 
|---|
| 2282 | // tokens[0] : nom de l'histogramme | 
|---|
| 2283 | // tokens[1] : expression de la fonction | 
|---|
| 2284 | { | 
|---|
| 2285 | if(tokens.size()<2) | 
|---|
| 2286 | {cout<<"Usage: h/err namehisto expr_func"<<endl; return;} | 
|---|
| 2287 |  | 
|---|
| 2288 | // identification objet | 
|---|
| 2289 | NamedObjMgr omg; | 
|---|
| 2290 | AnyDataObj* mobj = omg.GetObj(tokens[0]); | 
|---|
| 2291 | if( mobj==NULL) | 
|---|
| 2292 | {cout<<"PAWExecutor::h_err Error: unknow object "<<tokens[0]<<endl; | 
|---|
| 2293 | return;} | 
|---|
| 2294 |  | 
|---|
| 2295 | // Fonction | 
|---|
| 2296 | FILE *fip = NULL; | 
|---|
| 2297 | string expfunc = ""; {for(int_4 i=1;i<(int)tokens.size();i++) expfunc += tokens[i];} | 
|---|
| 2298 | string fname = "func1or2_pia_dl.c"; | 
|---|
| 2299 | string func = "func1or2_pia_dl_func"; | 
|---|
| 2300 | if((fip = fopen(fname.c_str(), "w")) == NULL) | 
|---|
| 2301 | {cout<<"PAWExecutor::h_err Error: open function file "<<fname<<endl; | 
|---|
| 2302 | return;} | 
|---|
| 2303 | fprintf(fip,"#include <math.h>\n"); | 
|---|
| 2304 | fprintf(fip,"double %s(double x) \n{\n",func.c_str()); | 
|---|
| 2305 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str()); | 
|---|
| 2306 | fclose(fip); | 
|---|
| 2307 | DlFunctionOfX f = (DlFunctionOfX) omg.GetServiceObj()->LinkFunctionFromFile(fname,func); | 
|---|
| 2308 | if(!f) | 
|---|
| 2309 | {cout<<"PAWExecutor::h_err Error: bad function "<<func<<","<<fname<<endl; | 
|---|
| 2310 | return;} | 
|---|
| 2311 |  | 
|---|
| 2312 | // Traitement | 
|---|
| 2313 | if(typeid(*mobj) == typeid(Histo)) {  // Histo 1D | 
|---|
| 2314 | Histo* h  = dynamic_cast<Histo*>(mobj); | 
|---|
| 2315 | if(!(h->HasErrors())) h->Errors(); | 
|---|
| 2316 | for(int_4 i=0;i<h->NBins();i++) { | 
|---|
| 2317 | r_8 x = (*h)(i); | 
|---|
| 2318 | r_8 e = f(x); | 
|---|
| 2319 | h->SetErr2(i,e*e); | 
|---|
| 2320 | } | 
|---|
| 2321 |  | 
|---|
| 2322 | } else if(typeid(*mobj) == typeid(Histo2D)) {  // Histo 2D | 
|---|
| 2323 | Histo2D* h2 = dynamic_cast<Histo2D*>(mobj); | 
|---|
| 2324 | if(!(h2->HasErrors())) h2->Errors(); | 
|---|
| 2325 | for(int_4 i=0;i<h2->NBinX();i++) for(int_4 j=0;j<h2->NBinY();j++) { | 
|---|
| 2326 | r_8 x = (*h2)(i,j); | 
|---|
| 2327 | r_8 e = f(x); | 
|---|
| 2328 | h2->Error2(i,j) = e*e; | 
|---|
| 2329 | } | 
|---|
| 2330 |  | 
|---|
| 2331 | } else { | 
|---|
| 2332 | cout<<"PAWExecutor::h_err Error: type mismatch for Histo/Histo2D\n" | 
|---|
| 2333 | <<typeid(*mobj).name()<<endl; | 
|---|
| 2334 | return; | 
|---|
| 2335 | } | 
|---|
| 2336 |  | 
|---|
| 2337 | } | 
|---|