source: Sophya/trunk/SophyaPI/PIext/servnobjm.cc@ 341

Last change on this file since 341 was 341, checked in by ercodmgr, 26 years ago

petites ameliorations+corr bugs dans fit cmv (30/7/99)

File size: 52.2 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <ctype.h>
4
5#include <typeinfo>
6#include <iostream.h>
7#include <string>
8#include <list>
9#include <map>
10#if defined(__KCC__)
11using std::string ;
12#include <list.h>
13#include <map.h>
14#endif
15
16#include "strutil.h"
17
18#include "nobjmgr.h"
19#include "servnobjm.h"
20#include "nomgadapter.h"
21#include "pistdimgapp.h"
22
23#include "fct1dfit.h"
24#include "fct2dfit.h"
25
26#include "matrix.h"
27#include "cvector.h"
28#include "ntuple.h"
29#include "cimage.h"
30
31#include "histos.h"
32#include "histos2.h"
33#include "ntuple.h"
34#include "hisprof.h"
35
36#include "piscdrawwdg.h"
37#include "pisurfdr.h"
38
39#include "pintuple.h"
40#include "pintup3d.h"
41
42#include "pipodrw.h"
43
44
45
46/* --Methode-- */
47Services2NObjMgr::Services2NObjMgr(NamedObjMgr* omg, string& tmpdir)
48{
49TmpDir = tmpdir;
50PDynLinkMgr::SetTmpDir(tmpdir);
51mImgapp = NULL;
52mOmg = omg;
53dynlink = NULL;
54InitGrAttNames();
55}
56
57/* --Methode-- */
58Services2NObjMgr::~Services2NObjMgr()
59{
60CloseDLL();
61}
62
63/* --Methode-- */
64void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
65{
66ObjAdaptList::iterator it;
67for(it = objadaplist.begin(); it != objadaplist.end(); it++)
68 if (typeid(*o) == typeid(*((*it).obj))) THROW(dupIdErr);
69
70dataobj_adapter oba;
71oba.obj = o;
72oba.obja = oa;
73objadaplist.push_back(oba);
74}
75
76/* --Methode-- */
77NObjMgrAdapter* Services2NObjMgr::GetAdapter(AnyDataObj* o)
78{
79ObjAdaptList::iterator it;
80for(it = objadaplist.begin(); it != objadaplist.end(); it++)
81 if (typeid(*o) == typeid(*((*it).obj))) return((*it).obja->Clone(o));
82return(new NObjMgrAdapter(o));
83}
84
85/* --Methode-- */
86void Services2NObjMgr::PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, int np, string dopt)
87{
88FILE *fip;
89string fname = TmpDir + "func1_pia_dl.c";
90string cmd;
91int rc;
92
93if (!mImgapp) return;
94
95cmd = "rm -f " + fname;
96rc = system(cmd.c_str());
97// printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
98
99if ((fip = fopen(fname.c_str(), "w")) == NULL) {
100 string sn = fname;
101 cout << "Services2NObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl;
102 return;
103 }
104
105// constitution du fichier a compiler
106fputs("#include <math.h> \n", fip);
107fputs("double func1_pia_dl_func(double x) \n{\n", fip);
108fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
109fclose(fip);
110
111string func = "func1_pia_dl_func";
112DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
113if (!f) return;
114PlotFunc(f, nom, xmin, xmax, np, dopt);
115CloseDLL();
116return;
117}
118
119/* --Methode-- */
120void Services2NObjMgr::PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax,
121 double ymin, double ymax, int npx, int npy, string dopt)
122{
123FILE *fip;
124string fname = TmpDir + "func2_pia_dl.c";
125string cmd;
126int rc;
127
128if (!mImgapp) return;
129
130cmd = "rm " + fname;
131rc = system(cmd.c_str());
132// printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
133
134if ((fip = fopen(fname.c_str(), "w")) == NULL) {
135 string sn = fname;
136 cout << "Services2NObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl;
137 return;
138 }
139
140// constitution du fichier a compiler
141fputs("#include <math.h> \n", fip);
142fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
143fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
144fclose(fip);
145
146string func = "func2_pia_dl_func";
147DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
148if (!f) return;
149PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
150CloseDLL();
151return;
152}
153
154/* --Methode-- */
155void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, string & nom,
156 double xmin, double xmax, int np, string dopt)
157{
158DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
159if (!f) return;
160PlotFunc(f, nom, xmin, xmax, np, dopt);
161CloseDLL();
162return;
163}
164
165/* --Methode-- */
166void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, string & nom,
167 double xmin, double xmax, double ymin, double ymax, int npx, int npy, string dopt)
168{
169DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
170if (!f) return;
171PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
172CloseDLL();
173return;
174}
175
176/* --Methode-- */
177void Services2NObjMgr::PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, int np, string dopt)
178{
179if (!mImgapp) return;
180
181int k;
182if (np < 1) np = 1;
183if (xmax <= xmin) xmax = xmin+1.;
184Vector* vpy = new Vector(np);
185
186double xx;
187double dx = (xmax-xmin)/np;
188TRY {
189 for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
190} CATCH(merr) {
191 fflush(stdout);
192 cout << endl;
193 cerr << endl;
194 string es = PeidaExc(merr);
195 cerr << "Services2NObjMgr::PlotFunc() Exception :" << merr << es;
196 delete vpy;
197 vpy = NULL;
198 } ENDTRY;
199
200
201if (vpy) {
202 string titre = (nom.length() < 1) ? "Function f(x)" : nom;
203 P1DArrayAdapter* vya = new POVectorAdapter(vpy, true);
204 vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
205 PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ;
206 bool fgsr = true;
207 dopt = "thinline," + dopt;
208 int opt = DecodeDispOption(dopt, fgsr);
209 int rsid = mImgapp->DispScDrawer(dr, titre, opt);
210 if (fgsr) mImgapp->RestoreGraphicAtt();
211 if (nom.length() > 0) {
212 mOmg->AddObj(vpy, nom);
213 mOmg->AddWRsId(nom, rsid);
214 }
215 }
216
217return;
218}
219
220/* --Methode-- */
221void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, double ymin, double ymax,
222 int npx, int npy, string dopt)
223{
224if (!mImgapp) return;
225
226if (npx < 3) npx = 3;
227if (npy < 3) npy = 3;
228if (npx > 250) npx = 250;
229if (npy > 250) npy = 250;
230if (xmax <= xmin) xmax = xmin+1.;
231if (ymax <= ymin) ymax = ymin+1.;
232
233Matrix* mtx = new Matrix(npy, npx);
234
235int i,j;
236double xx, yy;
237double dx = (xmax-xmin)/npx;
238double dy = (ymax-ymin)/npy;
239// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
240TRY {
241 for(j=0; j<npy; j++) {
242 yy = ymin+dy*j;
243 for(i=0; i<npx; i++) {
244 xx = xmin+dx*i;
245 (*mtx)(j, i) = f(xx, yy);
246 }
247 }
248} CATCH(merr) {
249 fflush(stdout);
250 cout << endl;
251 cerr << endl;
252 string es = PeidaExc(merr);
253 cerr << "Services2NObjMgr::PlotFunc2D() Exception :" << merr << es;
254 delete mtx; mtx = NULL;
255 } ENDTRY;
256
257if (mtx) {
258 string titre = (nom.length() < 1) ? "Function f(x,y)" : nom;
259 bool fgsr = true;
260 int opt = DecodeDispOption(dopt, fgsr);
261 P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true);
262 arr->DefineXYCoordinates(xmin, ymin, dx, dy);
263 PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
264 int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
265 if (fgsr) mImgapp->RestoreGraphicAtt();
266 if (nom.length() > 0) {
267 mOmg->AddObj(mtx, nom);
268 mOmg->AddWRsId(nom, rsid);
269 }
270 }
271
272return;
273}
274
275/* --Methode-- */
276void Services2NObjMgr::DisplayPoints2D(string& nom, string& expx, string& expy,
277 string& experrx, string& experry,
278 string& expcut, string dopt)
279{
280NObjMgrAdapter* obja=NULL;
281obja = mOmg->GetObjAdapter(nom);
282if (obja == NULL) {
283 cout << "Services2NObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl;
284 return;
285 }
286if (!mImgapp) return;
287
288// Creation NTuple
289char* ntn[4] = {"expx","expy","expex","expey",};
290NTuple* nt = NULL;
291bool haserr = false;
292
293if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) { haserr = true; nt = new NTuple(4, ntn); }
294else { haserr = false; experrx = experry = "0."; nt = new NTuple(2, ntn); }
295
296ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
297
298if (nt->NEntry() < 1) {
299 cout << "Services2NObjMgr::DisplayPoints2D() Warning Zero points satisfy cut !" << endl;
300 delete nt;
301 return;
302 }
303
304// nt->Show();
305// nt->Print(0,10);
306PINTuple* pin = new PINTuple(nt, true);
307pin->SelectXY(ntn[0], ntn[1]);
308if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
309
310bool fgsr = true;
311dopt = "defline," + dopt;
312int opt = DecodeDispOption(dopt, fgsr);
313string titre = nom + ":" + expy + "%" + expx;
314mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
315if (fgsr) mImgapp->RestoreGraphicAtt();
316return;
317}
318
319/* --Methode-- */
320void Services2NObjMgr::DisplayPoints3D(string& nom, string& expx, string& expy,
321 string& expz, string& expcut, string dopt)
322{
323NObjMgrAdapter* obja=NULL;
324obja = mOmg->GetObjAdapter(nom);
325if (obja == NULL) {
326 cout << "Services2NObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl;
327 return;
328 }
329if (!mImgapp) return;
330
331char* ntn[3] = {"expx","expy","expz"};
332NTuple* nt = new NTuple(3,ntn); // Creation NTuple
333
334string expwt = "1.";
335ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
336
337if (nt->NEntry() < 1) {
338 cout << "Services2NObjMgr::DisplayPoints3D() Warning Zero points satisfy cut !" << endl;
339 delete nt;
340 return;
341 }
342nt->Show();
343nt->Print(0,10);
344PINTuple3D* pin = new PINTuple3D(nt, true);
345pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
346bool fgsr = true;
347dopt = "defline," + dopt;
348int opt = DecodeDispOption(dopt, fgsr);
349
350// Pour plot a partir de DispScDrawer
351// string nomdisp = "_NT3D_";
352// mImgapp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
353// Pour plot a partir de Disp3DDrawer
354string titre = nom + ":" + expy + "%" + expx;
355mImgapp->Disp3DDrawer(pin, titre, opt);
356
357if (fgsr) mImgapp->RestoreGraphicAtt();
358return;
359}
360
361/* --Methode-- */
362void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy,
363 string& expwt, string& expcut, string dopt)
364{
365NObjMgrAdapter* obja=NULL;
366obja = mOmg->GetObjAdapter(nom);
367if (obja == NULL) {
368 cout << "Services2NObjMgr::DisplayPoints2DW() Error , Pas d'objet de nom " << nom << endl;
369 return;
370 }
371if (!mImgapp) return;
372
373char* ntn[3] = {"expx","expy","expw"};
374NTuple* nt = new NTuple(3,ntn); // Creation NTuple
375
376string exp = "1.";
377ComputeExpressions(obja, expx, expy, expwt, exp, expcut, nt, NULL, NULL);
378
379if (nt->NEntry() < 1) {
380 cout << "Services2NObjMgr::DisplayPoints2DW() Warning Zero points satisfy cut !" << endl;
381 delete nt;
382 return;
383 }
384
385PINTuple* pin = new PINTuple(nt, true);
386pin->SelectXY(ntn[0], ntn[1]);
387pin->SelectWt(ntn[2]);
388
389bool fgsr = true;
390int opt = DecodeDispOption(dopt, fgsr);
391string titre = nom + ":" + expwt + "_" + expy + "%" + expx ;
392mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
393if (fgsr) mImgapp->RestoreGraphicAtt();
394return;
395}
396
397/* --Methode-- */
398void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt,
399 string& expcut, string& nomh1, string dopt)
400{
401NObjMgrAdapter* obja=NULL;
402obja = mOmg->GetObjAdapter(nom);
403if (obja == NULL) {
404 cout << "Services2NObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl;
405 return;
406 }
407if (!mImgapp) return;
408
409Histo* h1 = NULL;
410NTuple* nt = NULL;
411AnyDataObj* oh = NULL;
412if (nomh1.length() > 0) oh=mOmg->GetObj(nomh1);
413else nomh1 = "/tmp/projh1d";
414if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) ) h1 = (Histo*)oh; // Pas de remise a zero ! h1->Zero();
415else {
416 char* ntn[2]= {"hxval", "hwt"};
417 nt = new NTuple(2,ntn); // Creation NTuple
418 }
419string expz = "0.";
420ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
421
422if ((!h1) && (!nt)) return;
423if (!h1) {
424 if (nt->NEntry() < 1) {
425 cout << "Services2NObjMgr::ProjectH1() Warning Zero points satisfy cut !" << endl;
426 delete nt;
427 return;
428 }
429 double xmin, xmax;
430 nt->GetMinMax(0, xmin, xmax);
431 h1 = new Histo(xmin, xmax, 100);
432 int k;
433 float* xn;
434 for(k=0; k<nt->NEntry(); k++) {
435 xn = nt->GetVec(k);
436 h1->Add(xn[0], xn[1]);
437 }
438 delete nt;
439 mOmg->AddObj(h1, nomh1);
440 }
441
442mOmg->DisplayObj(nomh1, dopt);
443return;
444}
445
446/* --Methode-- */
447void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt,
448 string& expcut, string& nomh2, string dopt)
449{
450NObjMgrAdapter* obja=NULL;
451obja = mOmg->GetObjAdapter(nom);
452if (obja == NULL) {
453 cout << "Services2NObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl;
454 return;
455 }
456if (!mImgapp) return;
457
458Histo2D* h2 = NULL;
459NTuple* nt = NULL;
460AnyDataObj* oh = NULL;
461if (nomh2.length() > 0) oh=mOmg->GetObj(nomh2);
462else nomh2 = "/tmp/projh2d";
463if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) ) h2 = (Histo2D*)oh; // Pas de remise a zero ! h2->Zero();
464else {
465 char* ntn[3]= {"hxval", "hyval", "hwt"};
466 nt = new NTuple(3,ntn); // Creation NTuple
467 }
468string expz = "0.";
469ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
470
471if ((!h2) && (!nt)) return;
472if (!h2) {
473 if (nt->NEntry() < 1) {
474 cout << "Services2NObjMgr::ProjectH2() Warning Zero points satisfy cut !" << endl;
475 delete nt;
476 return;
477 }
478 double xmin, xmax, ymin, ymax;
479 nt->GetMinMax(0, xmin, xmax);
480 nt->GetMinMax(0, ymin, ymax);
481 h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
482 int k;
483 float* xn;
484 for(k=0; k<nt->NEntry(); k++) {
485 xn = nt->GetVec(k);
486 h2->Add(xn[0], xn[1], xn[2]);
487 }
488 delete nt;
489 mOmg->AddObj(h2, nomh2);
490 }
491
492mOmg->DisplayObj(nomh2, dopt);
493return;
494
495}
496
497/* --Methode-- cmv 13/10/98 */
498void Services2NObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt,
499 string& expcut, string& nomprof, string dopt)
500// Pour remplir un ``GeneralFitData'' a partir de divers objets:
501//| nom = nom de l'objet a projeter dans un HProf.
502//| expx = expression X de definition du bin.
503//| expy = expression Y a additionner dans le bin.
504//| expwt = expression W du poids a additionner.
505//| expcut = expression du test de selection.
506//| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
507//| les limites Xmin,Xmax sont calculees automatiquement.
508//| sinon ce sont celles de l'objet preexistant.
509//| opt = options generales pour le display.
510{
511NObjMgrAdapter* obja=NULL;
512obja = mOmg->GetObjAdapter(nom);
513if (obja == NULL) {
514 cout << "Services2NObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl;
515 return;
516 }
517if (!mImgapp) return;
518
519HProf* hprof = NULL;
520NTuple* nt = NULL;
521AnyDataObj* oh = NULL;
522if (nomprof.length() > 0) oh=mOmg->GetObj(nomprof);
523else nomprof = "/tmp/projprof";
524if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) ) hprof = (HProf*)oh;
525else {
526 char* ntn[3]= {"hxval", "hyval", "hwt"};
527 nt = new NTuple(3,ntn); // Creation NTuple
528}
529string expz = "0.";
530ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
531
532if((!hprof) && (!nt)) return;
533if(!hprof) {
534 if (nt->NEntry() < 1) {
535 cout << "Services2NObjMgr::ProjectHProf() Warning Zero points satisfy cut !" << endl;
536 delete nt;
537 return;
538 }
539 double xmin, xmax;
540 nt->GetMinMax(0, xmin, xmax);
541 hprof = new HProf(xmin, xmax, 100);
542 int k;
543 float* xn;
544 for(k=0; k<nt->NEntry(); k++) {
545 xn = nt->GetVec(k);
546 hprof->Add(xn[0], xn[1], xn[2]);
547 }
548 delete nt;
549 mOmg->AddObj(hprof, nomprof);
550 }
551hprof->UpdateHisto();
552
553mOmg->DisplayObj(nomprof, dopt);
554return;
555}
556
557/* --Methode-- */
558void Services2NObjMgr::FillVect(string& nom, string& expx, string& expcut,
559 string& nomvec, string dopt)
560{
561NObjMgrAdapter* obja=NULL;
562obja = mOmg->GetObjAdapter(nom);
563if (obja == NULL) {
564 cout << "Services2NObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl;
565 return;
566 }
567if (!mImgapp) return;
568
569NTuple* nt = NULL;
570if (nomvec.length() < 1) nomvec = "/tmp/fillvec";
571
572char* ntn[2]= {"vecval", "vecwt"};
573nt = new NTuple(1,ntn); // Creation NTuple
574
575string expwt = "1.";
576string expz = "0.";
577ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
578
579if (!nt) return;
580if (nt->NEntry() < 1) {
581 cout << "Services2NObjMgr::FillVect() Warning Zero points satisfy cut !" << endl;
582 delete nt;
583 return;
584 }
585
586Vector* vec = new Vector(nt->NEntry());
587int k;
588float* xn;
589for(k=0; k<nt->NEntry(); k++) {
590 xn = nt->GetVec(k);
591 (*vec)(k) = xn[0];
592 }
593delete nt;
594mOmg->AddObj(vec, nomvec);
595mOmg->DisplayObj(nomvec, dopt);
596return;
597}
598
599/* --Methode-- */
600void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz,
601 string& expt, string& expcut, string& nomnt)
602{
603NObjMgrAdapter* obja=NULL;
604obja = mOmg->GetObjAdapter(nom);
605if (obja == NULL) {
606 cout << "Services2NObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl;
607 return;
608 }
609if (!mImgapp) return;
610
611bool fgnnt = false;
612NTuple* nt = NULL;
613AnyDataObj* oh = NULL;
614if (nomnt.length() > 0) oh=mOmg->GetObj(nomnt);
615else nomnt = "/tmp/fillnt";
616if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
617 nt = (NTuple*)oh;
618 if (nt->NVar() > 10) {
619 cout << "Services2NObjMgr::FillNT() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
620 nt = NULL;
621 }
622 }
623if (nt == NULL) {
624 char* ntn[4]= {"x", "y","z","t"};
625 nt = new NTuple(4,ntn); // Creation NTuple
626 fgnnt = true;
627 }
628
629ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
630
631if (fgnnt) mOmg->AddObj(nt, nomnt);
632return;
633
634}
635
636/* --Methode-- */
637void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname,
638 string const & funcname, string & nomnt)
639{
640if (!mImgapp) return;
641
642NObjMgrAdapter* obja=NULL;
643obja = mOmg->GetObjAdapter(nom);
644if (obja == NULL) {
645 cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No such object" <<endl;
646 return;
647 }
648NTupleInterface* objnt = obja->GetNTupleInterface();
649if (objnt == NULL) {
650 cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No NTupleInterface !" <<endl;
651 return;
652 }
653
654NTLoopExprFunc f = (NTLoopExprFunc)LinkFunctionFromFile(fname, funcname);
655if (!f) {
656 cerr << "Services2NObjMgr::FillNTFrCFile Error Creation NTLoopExprFunc" << endl;
657 return;
658 }
659
660bool fgnnt = false;
661NTuple* nt = NULL;
662if (nomnt.length() > 0) {
663 AnyDataObj* oh = NULL;
664 oh=mOmg->GetObj(nomnt);
665 if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
666 nt = (NTuple*)oh;
667 if (nt->NVar() > 10) {
668 cout << "Services2NObjMgr::FillNTFrCFile() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
669 nt = NULL;
670 }
671 }
672 if (nt == NULL) {
673 char* ntn[4]= {"x", "y","z","t"};
674 nt = new NTuple(4,ntn); // Creation NTuple
675 fgnnt = true;
676 }
677 }
678
679double xnt[10];
680float fxnt[10];
681
682int i,k;
683for(i=0; i<10; i++) fxnt[i] = xnt[i] = 0.;
684
685
686// $CHECK$ A virer des que possible - Pb blocage application quand trop d'impression
687// redirige - On redirige la sortie sur le terminal
688bool red = mImgapp->HasRedirectedStdOutErr();
689mImgapp->RedirectStdOutErr(false);
690
691TRY {
692 double* xn;
693 int kmax = objnt->NbLines();
694 for(k=0; k<kmax; k++) {
695 xn = objnt->GetLineD(k);
696 if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
697 if (nt) {
698 for(i=0; i<4; i++) fxnt[i] = xnt[i];
699 nt->Fill(fxnt);
700 }
701 }
702 }
703 }
704CATCH(merr) {
705 fflush(stdout);
706 cout << endl;
707 cerr << endl;
708 string es = PeidaExc(merr);
709 cerr << "Services2NObjMgr::FillNTFrCFile() Exception :" << merr << es;
710 } ENDTRY;
711
712CloseDLL();
713
714// $CHECK$ A virer des que possible On redirige la sortie sur la fenetre PIConsole
715mImgapp->RedirectStdOutErr(red);
716
717if (fgnnt) mOmg->AddObj(nt, nomnt);
718return;
719}
720
721/* --Methode-- */
722void Services2NObjMgr::PrepareNTExpressionCFile(string & nom, string const & fname,
723 string const & funcname)
724{
725NObjMgrAdapter* obja=NULL;
726obja = mOmg->GetObjAdapter(nom);
727if (obja == NULL) {
728 cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom << "...) No such object" <<endl;
729 return;
730 }
731NTupleInterface* objnt = obja->GetNTupleInterface();
732if (objnt == NULL) {
733 cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom
734 << "...) No NTupleInterface !" <<endl;
735 return;
736 }
737string vardec = objnt->VarList_C("_xnti_");
738
739FILE *fip;
740if ((fip = fopen(fname.c_str(), "w")) == NULL) {
741 cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl;
742 return;
743 }
744// constitution du fichier des decalarations des variables de l'interface NTuple
745fputs("#include <stdlib.h> \n", fip);
746fputs("#include <stdio.h> \n", fip);
747fputs("#include <math.h> \n\n", fip);
748fputs("/* NTupleInterface Variable declaration - Generated by piapp \n", fip);
749fputs(" -- Services2NObjMgr::PrepareNTExpressionCFile() -- */ \n\n", fip);
750fprintf(fip,"int %s(double* _xnti_, double* _rx_, double* _ry_, double* _rz_, \n",
751 funcname.c_str());
752fprintf(fip," double* _rt_, int _n_, int _nmax_) \n");
753fprintf(fip, "{ \n %s \n", vardec.c_str());
754fputs(" if (!1) { /* Cut Expression failed */ \n", fip);
755fputs(" *_rx_ = *_ry_ = *_rz_ = *_rt_ = 0.; return(0);", fip);
756fputs(" } \n /* Cut expression satisfied */ \n", fip);
757fputs(" *_rx_ = 1.; \n *_ry_ = 1.; \n *_rz_ = 1.; \n *_rt_ = 1.; \n", fip);
758fputs(" return(1); \n} \n", fip);
759
760fclose(fip);
761return;
762}
763
764
765/* --Methode-- cmv 13/10/98 */
766void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
767 string& experr, string& expcut, string& nomgfd)
768// Pour remplir un ``GeneralFitData'' a partir de divers objets:
769//| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
770//| Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
771//| expx = expression X du GeneralFitData (1er abscisse)
772//| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
773//| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
774//| experr = expression de l'erreur sur l'ordonnee Z
775//| expcut = expression du test de selection
776//| nomgfd = nom du GeneralFitData engendre (optionnel)
777{
778NObjMgrAdapter* obja=NULL;
779obja = mOmg->GetObjAdapter(nom);
780if (obja == NULL) {
781 cout << "Services2NObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
782 return;
783 }
784if(!mImgapp) return;
785
786// 2D ou 3D?
787int nvar = 2;
788if(expy.length()<=0) {nvar = 1; expy = "0.";}
789
790// Creation NTuple Buffer
791char* ntn[4]= {"x","y","f","e"};
792NTuple*nt = new NTuple(4,ntn);
793
794// Remplissage NTuple buffer
795ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
796if(nt->NEntry() < 1)
797 {cout<<"Services2NObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl;
798 delete nt; return;}
799
800//Remplissage de la structure GeneraFitData
801if (nt->NEntry() <= 0) {
802 cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
803 delete nt;
804 return;
805 }
806
807GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
808int k;
809float* xn;
810for(k=0; k<nt->NEntry(); k++) {
811 xn = nt->GetVec(k);
812 gfd->AddData(xn,xn[2],xn[3]);
813}
814
815// Menage et table d'objets
816delete nt;
817mOmg->AddObj(gfd, nomgfd);
818return;
819}
820
821
822///////////////////// Fit 1D et 2D //////////////////////////
823/* --Function static propre aux routines de fit 1D et 2D-- cmv 13/10/98 */
824struct DFOptions {
825 int okres, okfun;
826 int polcx,polcy; double xc,yc;
827 double err_e, err_E;
828 double stc2;
829 int nstep;
830 int lp,lpg;
831 int i1,i2,j1,j2;
832};
833typedef struct DFOptions DFOPTIONS;
834static void DecodeFitsOptions(string par,string step,string min,string max,string opt
835 ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O);
836void DecodeFitsOptions(string par,string step,string min,string max,string opt
837 ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O)
838//| Pour decoder les "string" et remplir les vecteurs du fit (cf commentaires dans Fit1D)
839{
840// set des vecteurs et decodage des string correspondantes
841int NParMax = 100;
842Par.Realloc(NParMax); Step.Realloc(NParMax);
843Min.Realloc(NParMax); Max.Realloc(NParMax);
844{
845 Vector* v=NULL; string* s=NULL;
846 {for(int i=0;i<NParMax;i++) {Par(i)=0.; Step(i)=1.; Min(i)=1.; Max(i)=-1.;}}
847 for(int j=0;j<4;j++) {
848 if(j==0) {v=&Par; s=&par;}
849 else if(j==1) {v=&Step; s=&step;}
850 else if(j==2) {v=&Min; s=&min;}
851 else if(j==3) {v=&Max; s=&max;}
852 if(s->length()>0) *s += ",";
853 for(int i=0;i<NParMax;i++) {
854 if(s->length()<=0) break;
855 sscanf(s->c_str(),"%lf",&(*v)(i));
856 size_t p = s->find_first_of(',') + 1;
857 if(p>=s->length()) *s = ""; else *s = s->substr(p);
858 }
859 }
860}
861
862// Decodage de options de opt
863O.okres = O.okfun = 0;
864O.polcx = O.polcy = 0;
865O.xc = O.yc = 0.;
866O.stc2 = 1.e-3;
867O.nstep = 100;
868O.err_e = O.err_E = -1.;
869O.lp = 1; O.lpg = 0;
870O.i1 = O.j1 = O.i2 = O.j2 = -1;
871
872if(opt.length()<=0) return;
873opt = "," + opt + ",";
874
875if(strstr(opt.c_str(),",r,")) O.okres = 1; // residus
876if(strstr(opt.c_str(),",f,")) O.okfun = 1; // fonction fittee
877if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
878 O.polcx = 2; // Le centrage est calcule automatiquement
879 size_t p = opt.find(",x");
880 size_t q = opt.find_first_of(',',p+1);
881 string dum = opt.substr(p,q-p);
882 if(dum.length()>2) {
883 sscanf(dum.c_str(),",x%lf",&O.xc);
884 O.polcx = 1; // Le centrage est fixe par la valeur lue
885 }
886}
887if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
888 O.polcy = 2; // Le centrage est calcule automatiquement
889 size_t p = opt.find(",y");
890 size_t q = opt.find_first_of(',',p+1);
891 string dum = opt.substr(p,q-p);
892 if(dum.length()>2) {
893 sscanf(dum.c_str(),",y%lf",&O.yc);
894 O.polcy = 1; // Le centrage est fixe par la valeur lue
895 }
896}
897if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)"
898 size_t p = opt.find(",E");
899 size_t q = opt.find_first_of(',',p+1);
900 string dum = opt.substr(p,q-p);
901 if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&O.err_E);
902 if(O.err_E<=0.) O.err_E = 1.;
903 O.err_e=-1.;
904}
905if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
906 size_t p = opt.find(",e");
907 size_t q = opt.find_first_of(',',p+1);
908 string dum = opt.substr(p,q-p);
909 if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&O.err_e);
910 if(O.err_e<=0.) O.err_e = 1.;
911 O.err_E=-1.;
912}
913if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
914 size_t p = opt.find(",X");
915 size_t q = opt.find_first_of(',',p+1);
916 string dum = opt.substr(p,q-p);
917 if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&O.stc2);
918 if(O.stc2<=0.) O.stc2 = 1.e-3;
919}
920if(strstr(opt.c_str(),",N")) { // Nombre maximum d'iterations
921 size_t p = opt.find(",N");
922 size_t q = opt.find_first_of(',',p+1);
923 string dum = opt.substr(p,q-p);
924 if(dum.length()>2) sscanf(dum.c_str(),",N%d",&O.nstep);
925 if(O.nstep<2) O.nstep = 100;
926}
927if(strstr(opt.c_str(),",l")) { // niveau de print
928 size_t p = opt.find(",l");
929 size_t q = opt.find_first_of(',',p+1);
930 string dum = opt.substr(p,q-p);
931 float ab;
932 if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
933 if(ab<0) ab = 0.;
934 O.lp = (int) ab; O.lpg = int(10.*(ab-(float)O.lp+0.01));
935}
936if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
937 size_t p = opt.find(",I");
938 size_t q = opt.find_first_of(',',p+1);
939 string dum = opt.substr(p,q-p);
940 if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&O.i1,&O.i2);
941}
942if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
943 size_t p = opt.find(",J");
944 size_t q = opt.find_first_of(',',p+1);
945 string dum = opt.substr(p,q-p);
946 if(dum.length()>2) sscanf(dum.c_str(),",J%d/%d",&O.j1,&O.j2);
947}
948return;
949}
950
951/* --Methode-- cmv 13/10/98 */
952void Services2NObjMgr::Fit12D(string& nom, string& func,
953 string par,string step,string min,string max,
954 string opt)
955//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
956//| nom : nom de l'objet qui peut etre:
957//| fit-1D: Vector,Histo1D,HProf ou GeneraFitData(1D)
958//| fit-2D: Matrix,Histo2D,Image<T> ou GeneraFitData(2D)
959//| func : pnn : fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
960//| : Pnn : fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D
961//| : gnn : fit gaussienne (hauteur) + polynome de degre nn 1D
962//| : g : fit gaussienne (hauteur) 1D
963//| : enn : fit exponentielle + polynome de degre nn 1D
964//| : e : fit exponentielle 1D
965//| : Gnn : fit gaussienne (volume) + polynome de degre nn 1D
966//| : G : fit gaussienne (volume) 1D
967//| : : fit gaussienne+fond (volume) 2D
968//| : Gi : fit gaussienne+fond integree (volume) 2D
969//| : d : fit DL de gaussienne+fond (volume) 2D
970//| : di : fit DL de gaussienne+fond integree (volume) 2D
971//| : D : fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D
972//| : Di : fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D
973//| : M : fit Moffat+fond (expos=p6) (volume) 2D
974//| : Mi : fit Moffat+fond integree (expos=p6) (volume) 2D
975//| par : p1,...,pn : valeur d'initialisation des parametres (def=0)
976//| step : s1,...,sn : valeur des steps de depart (def=1)
977//| min : m1,...,mn : valeur des minima (def=1)
978//| max : M1,...,Mn : valeur des maxima (def=-1) (max<=min : pas de limite)
979//| opt : options "Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
980//| f : generation d'un Objet identique contenant la fonction fittee
981//| r : generation d'un Objet identique contenant les residus
982//| Xaa.b : aa.b valeur du DXi2 d'arret (def=1.e-3)
983//| Naa : aa nombre maximum d'iterations (def=100)
984//| la.b : niveau "a.b" de print: a=niveau de print Fit1/2D
985//| b=niveau de debug GeneralFit
986//| Ii1/i2 numeros des bins X de l'histos utilises pour le fit [i1,i2]
987//|2D Jj1/j2 numeros des bins Y de l'histos utilises pour le fit [j1,j2]
988//| - L'erreur est celle associee a l'objet (si elle existe),
989//| elle est mise a 1 sinon, sauf si E... ou e... est precise:
990//| Eaa.b : si |val|>=1 erreur = aa.b*sqrt(|val|)
991//| si |val|<1 erreur = aa.b
992//| si aa.b <=0 alors aa.b=1.0
993//| E seul est equivalent a E1.0
994//| eaa.b : erreur = aa.b
995//| si aa.b <=0 alors aa.b=1.0
996//| e seul est equivalent a e1.0
997//| xaa.b : demande de centrage: on fit x-aa.b au lieu de x)
998//| x : demande de centrage: on fit x-xc au lieu de x
999//| avec xc=abscisse du milieu de l'histogramme
1000//| Actif pour exp+poly 1D, poly 1D
1001//| pour gauss+poly 1D, xc est le centre de la gaussienne.
1002//|2D yaa.b et y : idem "xaa.b et x" mais pour y
1003{
1004AnyDataObj* obj=mOmg->GetObj(nom);
1005if (obj == NULL) {
1006 cout<<"Services2NObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
1007 return;
1008}
1009if (!mImgapp) return;
1010if(func.length()<=0)
1011 {cout<<"Services2NObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
1012 return;}
1013string ctyp = typeid(*obj).name();
1014
1015int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
1016Vector* v = NULL; Histo* h = NULL;
1017Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
1018GeneralFitData* g = NULL;
1019
1020 // 1D
1021if (typeid(*obj) == typeid(Vector)) {
1022 ndim = 1;
1023 v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
1024 }
1025else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) {
1026 ndim = 1;
1027 h = (Histo*) obj; nbinx = h->NBins(); nbiny = 1;
1028 }
1029else if (typeid(*obj) == typeid(Matrix)) {
1030 ndim = 2;
1031 m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
1032 }
1033else if (typeid(*obj) == typeid(Histo2D)) {
1034 ndim = 2;
1035 h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
1036 }
1037else if (typeid(*obj) == typeid(GeneralFitData)) {
1038 g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
1039 if( g->NVar()==1) ndim = 1;
1040 else if(g->NVar()==2) ndim = 2;
1041 else {
1042 cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
1043 <<((GeneralFitData*) obj)->NVar()<<endl; return; }
1044 }
1045else if (dynamic_cast<RzImage*>(obj)) {
1046 ndim = 2;
1047 im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
1048 }
1049else {
1050 cout<<"Services2NObjMgr::Fit12D() Error , Objet n'est pas un "
1051 <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
1052 return;
1053 }
1054
1055ndata = nbinx*nbiny;
1056if(ndata<=0)
1057 {cout<<"L'objet a "<<nbinx<<","<<nbiny<<" bins ("<<ndata<<")"<<endl; return;}
1058
1059// Decodage des options et des parametres, mise en forme
1060Vector Par(1); Vector Step(1); Vector Min(1); Vector Max(1); DFOPTIONS O;
1061DecodeFitsOptions(par,step,min,max,opt,Par,Step,Min,Max,O);
1062O.i1 = (O.i1<0||O.i1>=nbinx)? 0: O.i1;
1063O.i2 = (O.i2<0||O.i2>=nbinx||O.i2<O.i1)? nbinx-1: O.i2;
1064if(ndim>=2) {
1065 O.j1 = (O.j1<0||O.j1>=nbiny)? 0: O.j1;
1066 O.j2 = (O.j2<0||O.j2>=nbiny||O.j2<O.j1)? nbiny-1: O.j2;
1067} else O.j2 = O.j1 = 0;
1068if(O.polcx==2) {
1069 if(v||m) O.xc = (O.i2-O.i1+1)/2.;
1070 else if(h) O.xc = (h->XMin()+h->XMax())/2.;
1071 else if(h2) O.xc = (h2->XMin()+h2->XMax())/2.;
1072 else if(g) {double mini,maxi; g->GetMinMax(2,mini,maxi); O.xc=(mini+maxi)/2.;}
1073 else if(im) {O.xc = im->XOrg() * im->XPxSize()*(O.i2-O.i1+1)/2.;}
1074}
1075if(O.polcy==2 && ndim>=2) {
1076 if(m) O.yc = (O.j2-O.j1+1)/2.;
1077 if(h2) O.yc = (h2->YMin()+h2->YMax())/2.;
1078 if(g) {double mini,maxi; g->GetMinMax(12,mini,maxi); O.yc=(mini+maxi)/2.;}
1079 if(im) {O.yc = im->YOrg() * im->YPxSize()*(O.j2-O.j1+1)/2.;}
1080}
1081if(O.lp>0)
1082 cout<<"Fit["<<nbinx<<","<<nbiny<<"] ("<<ndata<<") dim="<<ndim<<":"
1083 <<" Int=["<<O.i1<<","<<O.i2<<"],["<<O.j1<<","<<O.j2<<"]"<<endl
1084 <<" Cent="<<O.polcx<<","<<O.polcy<<","<<O.xc<<"+x"<<","<<O.yc<<"+y"
1085 <<" TypE="<<O.err_e<<","<<O.err_E
1086 <<" StpX2="<<O.stc2<<" Nstep="<<O.nstep
1087 <<" lp,lpg="<<O.lp<<","<<O.lpg<<endl;
1088
1089///////////////////////////////////
1090// Remplissage de GeneralFitData //
1091///////////////////////////////////
1092GeneralFitData mydata(ndim,ndata,0);
1093{for(int i=O.i1;i<=O.i2;i++) for(int j=O.j1;j<=O.j2;j++) {
1094 double x,y,f,e;
1095
1096 if(v)
1097 {x= (double) i; f=(*v)(i); e=1.;}
1098 else if(h)
1099 {x=h->BinCenter(i); f=(*h)(i); e=(h->HasErrors())?h->Error(i):1.;}
1100 else if(m)
1101 {x=(double) i; y=(double) j; f=(*m)(j,i); e=1.;}
1102 else if(h2)
1103 {float xf,yf; h2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
1104 f=(*h2)(i,j); e=(h2->HasErrors())?h2->Error(i,j):1.;}
1105 else if(im)
1106 {x=im->XOrg()+(i+0.5)*im->XPxSize(); y=im->YOrg()+(j+0.5)*im->YPxSize();
1107 f=im->DValue(i,j); e=1.;}
1108 else if(g&&ndim==1) {x= g->X(i); f=g->Val(i); e=g->EVal(i);}
1109 else if(g&&ndim==2) {x= g->X(i); y= g->Y(i); f=g->Val(i); e=g->EVal(i);}
1110 else x=y=f=e=0.;
1111
1112 // Gestion des erreurs a utiliser
1113 if(O.err_e>0.) e=O.err_e;
1114 else if(O.err_E>0.) {e=(f<-1.||f>1.)?O.err_E*sqrt(fabs(f)):O.err_E;}
1115
1116 // Remplissage de generalfit
1117 if(func[0]=='p') {x -= O.xc; if(ndim>=2) y -= O.yc;}
1118 if(ndim==1) mydata.AddData1(x,f,e);
1119 else if(ndim==2) mydata.AddData2(x,y,f,e);
1120}}
1121if(mydata.NData()<=0)
1122 {cout<<"Pas de donnees dans GeneralFitData: "<<mydata.NData()<<endl;
1123 return;}
1124if(O.lpg>1) {
1125 mydata.PrintStatus();
1126 mydata.PrintData(0);
1127 mydata.PrintData(mydata.NData()-1);
1128}
1129
1130////////////////////////////////////////////
1131// Identification de la fonction a fitter //
1132////////////////////////////////////////////
1133GeneralFunction* myfunc = NULL;
1134if(func[0]=='p' && ndim==1) {
1135 // Fit de polynome sans passer par les GeneralFit
1136 int degre = 0;
1137 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1138 cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
1139 Poly p1(0);
1140 double c2rl = mydata.PolFit(0,p1,degre);
1141 cout<<"C2r_lineaire = "<<c2rl<<endl;
1142 if(O.lp>0) cout<<p1<<endl;
1143 return;
1144
1145} else if(func[0]=='P' && ndim==1) {
1146 // Fit de polynome
1147 int degre = 0;
1148 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1149 cout<<"Fit polynome 1D de degre "<<degre<<endl;
1150 Polyn1D* myf = new Polyn1D(degre,O.xc);
1151 myfunc = myf;
1152
1153} else if(func[0]=='e' && ndim==1) {
1154 // Fit d'exponentielle
1155 int degre =-1;
1156 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1157 cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl;
1158 Exp1DPol* myf;
1159 if(degre>=0) myf = new Exp1DPol((unsigned int)degre,O.xc);
1160 else myf = new Exp1DPol(O.xc);
1161 myfunc = myf;
1162
1163} else if(func[0]=='g' && ndim==1) {
1164 // Fit de gaussienne en hauteur
1165 int degre =-1;
1166 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1167 cout<<"Fit de Gaussienne_en_hauteur+polynome 1D de degre "<<degre<<endl;
1168 Gauss1DPol* myf;
1169 if(degre>=0) myf = new Gauss1DPol((unsigned int)degre,((O.polcx)?true:false));
1170 else { bool bfg = (O.polcx)?true:false; myf = new Gauss1DPol(bfg); }
1171 myfunc = myf;
1172
1173} else if(func[0]=='G' && ndim==1) {
1174 // Fit de gaussienne en volume
1175 int degre =-1;
1176 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1177 cout<<"Fit de Gaussienne_en_volume+polynome 1D de degre "<<degre<<endl;
1178 GaussN1DPol* myf;
1179 if(degre>=0) myf = new GaussN1DPol((unsigned int)degre,((O.polcx)?true:false));
1180 else { bool bfg = (O.polcx)?true:false; myf = new GaussN1DPol(bfg); }
1181 myfunc = myf;
1182
1183} else if(func[0]=='p' && ndim==2) {
1184 // Fit de polynome 2D sans passer par les GeneralFit
1185 int degre = 0;
1186 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1187 cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
1188 Poly2 p2(0);
1189 double c2rl = mydata.PolFit(0,1,p2,degre);
1190 cout<<"C2r_lineaire = "<<c2rl<<endl;
1191 if(O.lp>0) cout<<p2<<endl;
1192 return;
1193
1194} else if(func[0]=='P' && ndim==2) {
1195 // Fit de polynome 2D
1196 int degre = 0;
1197 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1198 cout<<"Fit polynome 2D de degre "<<degre<<endl;
1199 Polyn2D* myf = new Polyn2D(degre,O.xc,O.yc);
1200 myfunc = myf;
1201
1202} else if(func[0]=='G' && ndim==2) {
1203 // Fit de gaussienne+fond en volume
1204 int integ = 0;
1205 if(func.length()>1) if(func[1]=='i') integ=1;
1206 cout<<"Fit de Gaussienne+Fond 2D integ="<<integ<<endl;
1207 if(integ) {GauRhInt2D* myf = new GauRhInt2D; myfunc = myf;}
1208 else {GauRho2D* myf = new GauRho2D; myfunc = myf;}
1209
1210} else if(func[0]=='d' && ndim==2) {
1211 // Fit de DL gaussienne+fond en volume
1212 int integ = 0;
1213 if(func.length()>1) if(func[1]=='i') integ=1;
1214 cout<<"Fit de DL de Gaussienne+Fond 2D integ="<<integ<<endl;
1215 if(integ) {GdlRhInt2D* myf = new GdlRhInt2D; myfunc = myf;}
1216 else {GdlRho2D* myf = new GdlRho2D; myfunc = myf;}
1217
1218} else if(func[0]=='D' && ndim==2) {
1219 // Fit de DL gaussienne+fond avec coeff variable p6 en volume
1220 int integ = 0;
1221 if(func.length()>1) if(func[1]=='i') integ=1;
1222 cout<<"Fit de DL de Gaussienne+Fond avec coeff variable (p6) 2D integ="<<integ<<endl;
1223 if(integ) {Gdl1RhInt2D* myf = new Gdl1RhInt2D; myfunc = myf;}
1224 else {Gdl1Rho2D* myf = new Gdl1Rho2D; myfunc = myf;}
1225
1226} else if(func[0]=='M' && ndim==2) {
1227 // Fit de Moffat+fond (volume)
1228 int integ = 0;
1229 if(func.length()>1) if(func[1]=='i') integ=1;
1230 cout<<"Fit de Moffat+Fond (expos=p6) 2D integ="<<integ<<endl;
1231 if(integ) {MofRhInt2D* myf = new MofRhInt2D; myfunc = myf;}
1232 else {MofRho2D* myf = new MofRho2D; myfunc = myf;}
1233
1234} else {
1235 cout<<"Fonction "<<func<<" inconnue pour la dim "<<ndim<<endl;
1236 return;
1237}
1238
1239/////////////////////////
1240// Fit avec generalfit //
1241/////////////////////////
1242if(myfunc->NPar()>Par.NElts())
1243 {cout<<"Trop de parametres: "<<myfunc->NPar()<<">"<<Par.NElts()<<endl;
1244 if(myfunc) delete myfunc; return;}
1245GeneralFit myfit(myfunc);
1246myfit.SetDebug(O.lpg);
1247myfit.SetData(&mydata);
1248myfit.SetStopChi2(O.stc2);
1249myfit.SetMaxStep(O.nstep);
1250{for(int i=0;i<myfunc->NPar();i++) {
1251 char str[10];
1252 sprintf(str,"P%d",i);
1253 myfit.SetParam(i,str,Par(i),Step(i),Min(i),Max(i));
1254}}
1255if(O.lp>1) myfit.PrintFit();
1256double c2r = -1.;
1257int rcfit = (double) myfit.Fit();
1258if(O.lp>0) myfit.PrintFit();
1259if(rcfit>0) {
1260 c2r = myfit.GetChi2Red();
1261 cout<<"C2r_Reduit = "<<c2r<<" nstep="<<myfit.GetNStep()<<" rc="<<rcfit<<endl;
1262 Vector ParFit(myfunc->NPar());
1263 for(int i=0;i<myfunc->NPar();i++) ParFit(i)=myfit.GetParm(i);
1264} else {
1265 cout<<"echec Fit, rc = "<<rcfit<<" nstep="<<myfit.GetNStep()<<endl;
1266 myfit.PrintFitErr(rcfit);
1267}
1268
1269// Mise a disposition des resultats
1270if(rcfit>=0 && myfunc && (O.okres>0||O.okfun>0)) {
1271 string nomres = nom + "res";
1272 string nomfun = nom + "fun";
1273 if(v) {
1274 if(O.okres) {Vector* ob = v->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1275 if(O.okfun) {Vector* ob = v->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1276 } else if(h) {
1277 if(O.okres) {Histo* ob = h->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1278 if(O.okfun) {Histo* ob = h->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1279 } else if(m) {
1280 if(O.okres) {Matrix* ob = m->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1281 if(O.okfun) {Matrix* ob = m->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1282 } else if(h2) {
1283 if(O.okres) {Histo2D* ob = h2->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1284 if(O.okfun) {Histo2D* ob = h2->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1285 } else if(im) {
1286 if(O.okres) {RzImage* ob = im->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1287 if(O.okfun) {RzImage* ob = im->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1288 } else if(g) {
1289 if(O.okres) {GeneralFitData* ob = g->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1290 if(O.okfun) {GeneralFitData* ob = g->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1291 }
1292}
1293
1294// Nettoyage
1295if(myfunc) delete myfunc;
1296return;
1297}
1298
1299
1300/* --Methode-- */
1301void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx,
1302 string& expy, string& expz, string& expt, string& expcut,
1303 NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
1304{
1305if (obja == NULL) return;
1306NTupleInterface* objnt = obja->GetNTupleInterface();
1307if (objnt == NULL) return;
1308string vardec = objnt->VarList_C("_zz6qi_");
1309
1310PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
1311if (!f) {
1312 cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " << endl;
1313 return;
1314 }
1315
1316double xnt[10];
1317float fxnt[10];
1318
1319int i,k;
1320for(i=0; i<10; i++) xnt[i] = 0.;
1321
1322TRY {
1323 double* xn;
1324 for(k=0; k<objnt->NbLines(); k++) {
1325 xn = objnt->GetLineD(k);
1326 if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
1327 if (nt) {
1328 for(i=0; i<4; i++) fxnt[i] = xnt[i];
1329 nt->Fill(fxnt);
1330 }
1331 if (h1) h1->Add(xnt[0], xnt[3]);
1332 if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
1333 if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
1334 }
1335 }
1336 }
1337CATCH(merr) {
1338 fflush(stdout);
1339 cout << endl;
1340 cerr << endl;
1341 string es = PeidaExc(merr);
1342 cerr << "Services2NObjMgr::ComputeExpressions() Exception :" << merr << es;
1343 } ENDTRY;
1344
1345
1346// Fermeture du fichier .so
1347CloseDLL();
1348return;
1349}
1350
1351
1352/* --Methode-- */
1353PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy,
1354 string& expz, string& expt, string& cut)
1355{
1356FILE *fip;
1357string fname = TmpDir + "expf_pia_dl.c";
1358string cmd;
1359int rc;
1360
1361cmd = "rm -f " + fname;
1362rc = system(cmd.c_str());
1363//DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
1364
1365if ((fip = fopen(fname.c_str(), "w")) == NULL) {
1366 string sn = fname;
1367 cout << "Services2NObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl;
1368 return(NULL);
1369 }
1370
1371// constitution du fichier a compiler
1372fputs("#include <stdlib.h> \n", fip);
1373fputs("#include <math.h> \n", fip);
1374fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
1375fprintf(fip,"%s \n", vardec.c_str());
1376fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.; return(0); } \n", cut.c_str());
1377fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
1378fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
1379fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
1380fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
1381fputs("return(1); \n} \n", fip);
1382fclose(fip);
1383string func = "expf_pia_dl_func";
1384return((PlotExprFunc)LinkFunctionFromFile(fname, func));
1385}
1386
1387
1388/* --Methode-- */
1389DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
1390{
1391// Le link dynamique
1392CloseDLL();
1393dynlink = PDynLinkMgr::BuildFromCFile(fname);
1394if (dynlink == NULL) {
1395 cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
1396 return(NULL);
1397 }
1398
1399DlFunction retfunc = dynlink->GetFunction(funcname);
1400if (retfunc == NULL) {
1401 string sn = funcname;
1402 cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
1403 CloseDLL();
1404 return(NULL);
1405 }
1406else return(retfunc);
1407}
1408
1409/* --Methode-- */
1410void Services2NObjMgr::CloseDLL()
1411{
1412if (dynlink) delete dynlink; dynlink = NULL;
1413}
1414
1415
1416/* --Methode-- */
1417string Services2NObjMgr::FileName2Name(string const & fn)
1418{
1419
1420char fsep[2] = {FILESEP, '\0'};
1421char tsep[2] = {'.', '\0'};
1422size_t p = fn.find_last_of(fsep);
1423size_t l = fn.length();
1424if (p >= l) p = 0;
1425else p++;
1426size_t q = fn.find_first_of(tsep,p);
1427if (q < p) q = l;
1428return(fn.substr(p,q-p));
1429}
1430
1431
1432typedef vector<string> GraTok;
1433
1434/* --Methode-- */
1435int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
1436{
1437int ropt = Disp_Next;
1438if (!mImgapp) return(ropt);
1439
1440for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
1441
1442if (fgsrgr) mImgapp->SaveGraphicAtt();
1443
1444if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini
1445 mImgapp->SetColAtt();
1446 mImgapp->SetLineAtt();
1447 mImgapp->SetFontAtt();
1448 mImgapp->SetMarkerAtt();
1449 mImgapp->SetColMapId();
1450 mImgapp->SetZoomAtt();
1451 mImgapp->SetAxesAtt();
1452 mImgapp->SetXYLimits();
1453 mImgapp->UseXYLimits();
1454 return(ropt);
1455 }
1456
1457// On separe en mots separes par des virgules
1458gratt = ","+gratt;
1459size_t p = 0;
1460size_t q = 0;
1461size_t l = gratt.length();
1462string token;
1463
1464GraTok grt;
1465
1466while (q < l) {
1467 p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
1468 if (p>=l) break;
1469 q = gratt.find_first_of(" ,",p); // la fin du token;
1470 token = gratt.substr(p,q-p);
1471 grt.push_back(token);
1472 }
1473
1474
1475static GrAttNames::iterator it;
1476
1477int k;
1478bool fgcont = true;
1479fgsrgr = false;
1480
1481for(k=0; k<grt.size(); k++) {
1482// cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
1483
1484 // Decodage option affichage (win, next, etc
1485 fgcont = true;
1486 if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
1487 else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
1488 else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
1489 else fgcont = false;
1490 if (fgcont) continue;
1491
1492 // Utilisation limites X-Y
1493 if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true); fgsrgr = true; continue; }
1494 // Si c'est une couleur
1495 it = GrAcolors.find(grt[k]);
1496 if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
1497 // Si c'est un attribut de lignes
1498 it = GrAlines.find(grt[k]);
1499 if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
1500 // Si c'est un attribut de fontes
1501 it = GrAfonts.find(grt[k]);
1502 if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
1503 fgsrgr = true; continue; }
1504 // Si c'est un attribut de markers
1505 it = GrAmarkers.find(grt[k]);
1506 if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
1507 fgsrgr = true; continue; }
1508 // Si c'est un colormap
1509 it = GrAcmap.find(grt[k]);
1510 if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
1511 // Si c'est un facteur de zoom
1512 it = GrAzoom.find(grt[k]);
1513 if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
1514 // Si c'est un attribut d'axe
1515 it = GrAaxes.find(grt[k]);
1516 if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
1517
1518 }
1519
1520return(ropt);
1521}
1522
1523
1524
1525// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1526// Initialisation des chaines de caracteres designant les attributs graphiques
1527
1528/* --Methode-- */
1529void Services2NObjMgr::InitGrAttNames()
1530{
1531gratt_item gi;
1532// Les couleurs
1533gi.a2 = 0;
1534gi.a1 = PI_NotDefColor;
1535GrAcolors["defcol"] = gi;
1536gi.a1 = PI_Black;
1537GrAcolors["black"] = gi;
1538gi.a1 = PI_White;
1539GrAcolors["white"] = gi;
1540gi.a1 = PI_Grey;
1541GrAcolors["grey"] = gi;
1542gi.a1 = PI_Red;
1543GrAcolors["red"] = gi;
1544gi.a1 = PI_Blue;
1545GrAcolors["blue"] = gi;
1546gi.a1 = PI_Green;
1547GrAcolors["green"] = gi;
1548gi.a1 = PI_Yellow;
1549GrAcolors["yellow"] = gi;
1550gi.a1 = PI_Magenta;
1551GrAcolors["magenta"] = gi;
1552
1553gi.a1 = PI_Cyan;
1554GrAcolors["cyan"] = gi;
1555gi.a1 = PI_Turquoise;
1556GrAcolors["turquoise"] = gi;
1557gi.a1 = PI_NavyBlue;
1558GrAcolors["navyblue"] = gi;
1559gi.a1 = PI_Orange;
1560GrAcolors["orange"] = gi;
1561gi.a1 = PI_SiennaRed;
1562GrAcolors["siennared"] = gi;
1563gi.a1 = PI_Purple;
1564GrAcolors["purple"] = gi;
1565gi.a1 = PI_LimeGreen;
1566GrAcolors["limegreen"] = gi;
1567gi.a1 = PI_Gold;
1568GrAcolors["gold"] = gi;
1569
1570// Les attributs de lignes
1571gi.a2 = 0;
1572gi.a1 = PI_NotDefLineAtt;
1573GrAlines["defline"] = gi;
1574gi.a1 = PI_NormalLine;
1575GrAlines["normalline"] = gi;
1576gi.a1 = PI_ThinLine;
1577GrAlines["thinline"] = gi;
1578gi.a1 = PI_ThickLine;
1579GrAlines["thickline"] = gi;
1580gi.a1 = PI_DashedLine;
1581GrAlines["dashedline"] = gi;
1582gi.a1 = PI_ThinDashedLine;
1583GrAlines["thindashedline"] = gi;
1584gi.a1 = PI_ThickDashedLine;
1585GrAlines["thickdashedline"] = gi;
1586gi.a1 = PI_DottedLine;
1587GrAlines["dottedline"] = gi;
1588gi.a1 = PI_ThinDottedLine;
1589GrAlines["thindottedline"] = gi;
1590gi.a1 = PI_ThickDottedLine;
1591GrAlines["thickdottedline"] = gi;
1592
1593// Les fontes
1594gi.a2 = PI_NotDefFontSize;
1595gi.a1 = PI_NotDefFontAtt;
1596GrAlines["deffont"] = gi;
1597
1598gi.a2 = PI_NormalSizeFont;
1599gi.a1 = PI_RomanFont;
1600GrAlines["normalfont"] = gi;
1601gi.a1 = PI_BoldFont;
1602GrAlines["boldfont"] = gi;
1603gi.a1 = PI_ItalicFont;
1604GrAlines["italicfont"] = gi;
1605gi.a2 = PI_SmallSizeFont;
1606gi.a1 = PI_RomanFont;
1607GrAlines["smallfont"] = gi;
1608gi.a1 = PI_BoldFont;
1609GrAlines["smallboldfont"] = gi;
1610gi.a1 = PI_ItalicFont;
1611GrAlines["smallitalicfont"] = gi;
1612gi.a2 = PI_BigSizeFont;
1613gi.a1 = PI_RomanFont;
1614GrAlines["bigfont"] = gi;
1615gi.a1 = PI_BoldFont;
1616GrAlines["bigboldfont"] = gi;
1617gi.a1 = PI_ItalicFont;
1618GrAlines["bigitalicfont"] = gi;
1619gi.a2 = PI_HugeSizeFont;
1620gi.a1 = PI_RomanFont;
1621GrAlines["hugefont"] = gi;
1622gi.a1 = PI_BoldFont;
1623GrAlines["hugeboldfont"] = gi;
1624gi.a1 = PI_ItalicFont;
1625GrAlines["hugeitalicfont"] = gi;
1626
1627
1628// Les markers
1629const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
1630 "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
1631 "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
1632PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
1633 PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
1634 PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
1635
1636gi.a2 = 0;
1637gi.a1 = PI_NotDefMarker;
1638GrAmarkers["defmarker"] = gi;
1639
1640for(int j=0; j<11; j++) {
1641 string smrk;
1642 char buff[16];
1643 for(int m=1; m<10; m+=2) {
1644 sprintf(buff,"%d",m);
1645 smrk = (string)mrkn[j] + (string)buff;
1646 gi.a1 = mrk[j]; gi.a2 = m;
1647 GrAmarkers[smrk] = gi;
1648 }
1649 }
1650
1651// Les tables de couleurs
1652gi.a2 = 0;
1653gi.a1 = CMAP_OTHER;
1654GrAcmap["defcmap"] = gi;
1655gi.a1 = CMAP_GREY32;
1656GrAcmap["grey32"] = gi;
1657gi.a1 = CMAP_GREYINV32;
1658GrAcmap["greyinv32"] = gi;
1659gi.a1 = CMAP_COLRJ32;
1660GrAcmap["colrj32"] = gi;
1661gi.a1 = CMAP_COLBR32;
1662GrAcmap["colbr32"] = gi;
1663gi.a1 = CMAP_GREY128;
1664GrAcmap["grey128"] = gi;
1665gi.a1 = CMAP_GREYINV128;
1666GrAcmap["greyinv128"] = gi;
1667gi.a1 = CMAP_COLRJ128;
1668GrAcmap["colrj128"] = gi;
1669gi.a1 = CMAP_COLBR128;
1670GrAcmap["colbr128"] = gi;
1671
1672// La valeur de zoom
1673gi.a2 = 0;
1674gi.a1 = 0;
1675GrAzoom["defzoom"] = gi;
1676gi.a1 = 1;
1677GrAzoom["zoomx1"] = gi;
1678gi.a1 = 2;
1679GrAzoom["zoomx2"] = gi;
1680gi.a1 = 3;
1681GrAzoom["zoomx3"] = gi;
1682gi.a1 = 4;
1683GrAzoom["zoomx4"] = gi;
1684gi.a1 = 5;
1685GrAzoom["zoomx5"] = gi;
1686gi.a1 = -2;
1687GrAzoom["zoom/2"] = gi;
1688gi.a1 = -3;
1689GrAzoom["zoom/3"] = gi;
1690gi.a1 = -4;
1691GrAzoom["zoom/4"] = gi;
1692gi.a1 = -5;
1693GrAzoom["zoom/5"] = gi;
1694
1695// Attributs d'axes
1696gi.a2 = 0;
1697gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
1698GrAaxes["stdaxes"] = gi;
1699GrAaxes["defaxes"] = gi;
1700GrAaxes["boxaxes"] = gi;
1701gi.a1 = (int)kAxesDflt;
1702GrAaxes["simpleaxes"] = gi;
1703gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
1704GrAaxes["boxaxesgrid"] = gi;
1705
1706gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
1707GrAaxes["fineaxes"] = gi;
1708 gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
1709GrAaxes["grid"] = gi;
1710GrAaxes["fineaxesgrid"] = gi;
1711
1712}
1713
1714
1715// SANS_EVOLPLANCK Attention !
1716#include "pclassids.h"
1717
1718/* --Methode-- */
1719char* Services2NObjMgr::PClassIdToClassName(int cid)
1720{
1721switch (cid) {
1722 case ClassId_Poly1 :
1723 return("Poly1");
1724 case ClassId_Poly2 :
1725 return("Poly2");
1726 case ClassId_Matrix :
1727 return("Matrix");
1728 case ClassId_Vector :
1729 return("Vector");
1730
1731 case ClassId_DVList :
1732 return("DVList");
1733
1734 case ClassId_Histo1D :
1735 return("Histo1D");
1736 case ClassId_Histo2D :
1737 return("Histo2D");
1738 case ClassId_HProf :
1739 return("HProf");
1740 case ClassId_NTuple :
1741 return("NTuple");
1742 case ClassId_GeneralFitData :
1743 return("GeneralFitData");
1744
1745 case ClassId_Image :
1746 return("RzImage");
1747 case ClassId_Image + kuint_1 :
1748 return("ImageU1");
1749 case ClassId_Image + kint_1 :
1750 return("ImageI1");
1751 case ClassId_Image + kuint_2 :
1752 return("ImageU2");
1753 case ClassId_Image + kint_2 :
1754 return("ImageI2");
1755 case ClassId_Image + kuint_4 :
1756 return("ImageU4");
1757 case ClassId_Image + kint_4 :
1758 return("ImageI4");
1759 case ClassId_Image + kr_4 :
1760 return("ImageR4");
1761 case ClassId_Image + kr_8 :
1762 return("ImageR8");
1763
1764 case ClassId_ZFidu :
1765 return("ZFidu");
1766
1767 case ClassId_StarList :
1768 return("StarList");
1769 case ClassId_Transfo :
1770 return("Transfo");
1771 case ClassId_PSF :
1772 return("PSF");
1773
1774
1775// - Ajout objet PPF
1776 default:
1777 return("AnyDataObj");
1778 }
1779}
1780
Note: See TracBrowser for help on using the repository browser.