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