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

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

Trace de NTuple en 2D avec Marker de taille proportionnelle a Weight
Introduction des repertoires dans la gestion d'objets NameObjMgr
Reorganisation NamedObjMgr et Services2NObjMgr, ajout de commandes , ...
Reza 12/7/99

File size: 51.7 KB
RevLine 
[165]1#include <stdio.h>
2#include <stdlib.h>
3#include <ctype.h>
4
[295]5#include <typeinfo>
[165]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"
[330]20#include "nomgadapter.h"
[165]21#include "pistdimgapp.h"
22
[333]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
[165]31#include "histos.h"
32#include "histos2.h"
33#include "ntuple.h"
34#include "hisprof.h"
35
[326]36#include "piscdrawwdg.h"
37#include "pisurfdr.h"
[333]38
39#include "pintuple.h"
40#include "pintup3d.h"
41
[326]42#include "pipodrw.h"
[165]43
44
[326]45
[165]46/* --Methode-- */
[333]47Services2NObjMgr::Services2NObjMgr(NamedObjMgr* omg, string& tmpdir)
[165]48{
49TmpDir = tmpdir;
[171]50PDynLinkMgr::SetTmpDir(tmpdir);
[333]51mImgapp = NULL;
52mOmg = omg;
[171]53dynlink = NULL;
[165]54InitGrAttNames();
55}
56
57/* --Methode-- */
58Services2NObjMgr::~Services2NObjMgr()
59{
60CloseDLL();
61}
62
63/* --Methode-- */
[295]64void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
[165]65{
[295]66ObjAdaptList::iterator it;
67for(it = objadaplist.begin(); it != objadaplist.end(); it++)
68 if (typeid(*o) == typeid(*((*it).obj))) THROW(dupIdErr);
[165]69
[295]70dataobj_adapter oba;
71oba.obj = o;
72oba.obja = oa;
73objadaplist.push_back(oba);
74}
[165]75
[295]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}
[165]84
[295]85/* --Methode-- */
[333]86void Services2NObjMgr::PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, int np, string dopt)
[295]87{
[165]88FILE *fip;
[326]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;
[333]101 cout << "Services2NObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl;
[326]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;
[333]114PlotFunc(f, nom, xmin, xmax, np, dopt);
[326]115CloseDLL();
116return;
117}
118
119/* --Methode-- */
[333]120void Services2NObjMgr::PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax,
121 double ymin, double ymax, int npx, int npy, string dopt)
[326]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;
[333]136 cout << "Services2NObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl;
[326]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;
[333]149PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
[326]150CloseDLL();
151return;
152}
153
154/* --Methode-- */
[333]155void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, string & nom,
156 double xmin, double xmax, int np, string dopt)
[326]157{
158DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
159if (!f) return;
[333]160PlotFunc(f, nom, xmin, xmax, np, dopt);
[326]161CloseDLL();
162return;
163}
164
165/* --Methode-- */
[333]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)
[326]168{
169DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
170if (!f) return;
[333]171PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
[326]172CloseDLL();
173return;
174}
175
176/* --Methode-- */
[333]177void Services2NObjMgr::PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, int np, string dopt)
[326]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) {
[333]202 string titre = (nom.length() < 1) ? "Function f(x)" : nom;
[326]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);
[333]209 int rsid = mImgapp->DispScDrawer(dr, titre, opt);
[326]210 if (fgsr) mImgapp->RestoreGraphicAtt();
[333]211 if (nom.length() > 0) {
212 mOmg->AddObj(vpy, nom);
213 mOmg->AddWRsId(nom, rsid);
214 }
[326]215 }
216
217return;
218}
219
220/* --Methode-- */
[333]221void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, double ymin, double ymax,
[326]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) {
[333]258 string titre = (nom.length() < 1) ? "Function f(x,y)" : nom;
[326]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);
[333]264 int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
[326]265 if (fgsr) mImgapp->RestoreGraphicAtt();
[333]266 if (nom.length() > 0) {
267 mOmg->AddObj(mtx, nom);
268 mOmg->AddWRsId(nom, rsid);
269 }
[326]270 }
271
272return;
273}
274
275/* --Methode-- */
[333]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// $CHECK$ - cmv calculait le nombre d'entree ndata
791// en fonction de chaque objet - Je l'ai vire Reza 11/05/99
792
793// Creation NTuple Buffer
794char* ntn[4]= {"x","y","f","e"};
795NTuple*nt = new NTuple(4,ntn);
796
797// Remplissage NTuple buffer
798ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
799if(nt->NEntry() < 1)
800 {cout<<"Services2NObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl;
801 delete nt; return;}
802
803//Remplissage de la structure GeneraFitData
804if (nt->NEntry() <= 0) {
805 cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
806 delete nt;
807 return;
808 }
809
810GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
811int k;
812float* xn;
813for(k=0; k<nt->NEntry(); k++) {
814 xn = nt->GetVec(k);
815 gfd->AddData(xn,xn[2],xn[3]);
816}
817
818// Menage et table d'objets
819delete nt;
820mOmg->AddObj(gfd, nomgfd);
821return;
822}
823
824
825///////////////////// Fit 1D et 2D //////////////////////////
826/* --Function static propre aux routines de fit 1D et 2D-- cmv 13/10/98 */
827struct DFOptions {
828 int okres, okfun;
829 int polcx,polcy; double xc,yc;
830 double err_e, err_E;
831 double stc2;
832 int lp,lpg;
833 int i1,i2,j1,j2;
834};
835typedef struct DFOptions DFOPTIONS;
836static void DecodeFitsOptions(string par,string step,string min,string max,string opt
837 ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O);
838void DecodeFitsOptions(string par,string step,string min,string max,string opt
839 ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O)
840//| Pour decoder les "string" et remplir les vecteurs du fit (cf commentaires dans Fit1D)
841{
842// set des vecteurs et decodage des string correspondantes
843int NParMax = 100;
844Par.Realloc(NParMax); Step.Realloc(NParMax);
845Min.Realloc(NParMax); Max.Realloc(NParMax);
846{
847 Vector* v=NULL; string* s=NULL;
848 {for(int i=0;i<NParMax;i++) {Par(i)=0.; Step(i)=1.; Min(i)=1.; Max(i)=-1.;}}
849 for(int j=0;j<4;j++) {
850 if(j==0) {v=&Par; s=&par;}
851 else if(j==1) {v=&Step; s=&step;}
852 else if(j==2) {v=&Min; s=&min;}
853 else if(j==3) {v=&Max; s=&max;}
854 if(s->length()>0) *s += ",";
855 for(int i=0;i<NParMax;i++) {
856 if(s->length()<=0) break;
857 sscanf(s->c_str(),"%lf",&(*v)(i));
858 size_t p = s->find_first_of(',') + 1;
859 if(p>=s->length()) *s = ""; else *s = s->substr(p);
860 }
861 }
862}
863
864// Decodage de options de opt
865O.okres = O.okfun = 0;
866O.polcx = O.polcy = 0;
867O.xc = O.yc = 0.;
868O.stc2 = 1.e-3;
869O.err_e = O.err_E = -1.;
870O.lp = 1; O.lpg = 0;
871O.i1 = O.j1 = O.i2 = O.j2 = -1;
872
873if(opt.length()<=0) return;
874opt = "," + opt + ",";
875
876if(strstr(opt.c_str(),",r,")) O.okres = 1; // residus
877if(strstr(opt.c_str(),",f,")) O.okfun = 1; // fonction fittee
878if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
879 O.polcx = 2; // Le centrage est calcule automatiquement
880 size_t p = opt.find(",x");
881 size_t q = opt.find_first_of(',',p+1);
882 string dum = opt.substr(p,q-p);
883 if(dum.length()>2) {
884 sscanf(dum.c_str(),",x%lf",&O.xc);
885 O.polcx = 1; // Le centrage est fixe par la valeur lue
886 }
887}
888if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
889 O.polcy = 2; // Le centrage est calcule automatiquement
890 size_t p = opt.find(",y");
891 size_t q = opt.find_first_of(',',p+1);
892 string dum = opt.substr(p,q-p);
893 if(dum.length()>2) {
894 sscanf(dum.c_str(),",y%lf",&O.yc);
895 O.polcy = 1; // Le centrage est fixe par la valeur lue
896 }
897}
898if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)"
899 size_t p = opt.find(",E");
900 size_t q = opt.find_first_of(',',p+1);
901 string dum = opt.substr(p,q-p);
902 if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&O.err_E);
903 if(O.err_E<=0.) O.err_E = 1.;
904 O.err_e=-1.;
905}
906if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
907 size_t p = opt.find(",e");
908 size_t q = opt.find_first_of(',',p+1);
909 string dum = opt.substr(p,q-p);
910 if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&O.err_e);
911 if(O.err_e<=0.) O.err_e = 1.;
912 O.err_E=-1.;
913}
914if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
915 size_t p = opt.find(",X");
916 size_t q = opt.find_first_of(',',p+1);
917 string dum = opt.substr(p,q-p);
918 if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&O.stc2);
919 if(O.stc2<=0.) O.stc2 = 1.e-3;
920}
921if(strstr(opt.c_str(),",l")) { // niveau de print
922 size_t p = opt.find(",l");
923 size_t q = opt.find_first_of(',',p+1);
924 string dum = opt.substr(p,q-p);
925 float ab;
926 if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
927 if(ab<0) ab = 0.;
928 O.lp = (int) ab; O.lpg = (int) 10.*(ab-O.lp);
929}
930if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
931 size_t p = opt.find(",I");
932 size_t q = opt.find_first_of(',',p+1);
933 string dum = opt.substr(p,q-p);
934 if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&O.i1,&O.i2);
935}
936if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
937 size_t p = opt.find(",J");
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(),",J%d/%d",&O.j1,&O.j2);
941}
942return;
943}
944
945/* --Methode-- cmv 13/10/98 */
946void Services2NObjMgr::Fit12D(string& nom, string& func,
947 string par,string step,string min,string max,
948 string opt)
949//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
950//| nom : nom de l'objet qui peut etre:
951//| fit-1D: Vector,Histo1D,HProf ou GeneraFitData(1D)
952//| fit-2D: Matrix,Histo2D,Imagexx ou GeneraFitData(2D)
953//| func : pnn = fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
954//| : Pnn = fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D
955//| : gnn = fit gaussienne (hauteur) + polynome de degre nn 1D
956//| : g = fit gaussienne (hauteur) 1D
957//| : enn = fit exponentielle + polynome de degre nn 1D
958//| : e = fit exponentielle 1D
959//| : Gnn = fit gaussienne (volume) + polynome de degre nn 1D
960//| : G = fit gaussienne (volume) 1D
961//| : = fit gaussienne+fond (volume) 2D
962//| : Gi = fit gaussienne+fond integree (volume) 2D
963//| : d = fit DL de gaussienne+fond (volume) 2D
964//| : di = fit DL de gaussienne+fond integree (volume) 2D
965//| : D = fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D
966//| : Di = fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D
967//| : M = fit Moffat+fond (expos=p6) (volume) 2D
968//| : Mi = fit Moffat+fond integree (expos=p6) (volume) 2D
969//| par : p1,...,pn valeur d'initialisation des parametres (def=0)
970//| step : s1,...,sn valeur des steps de depart (def=1)
971//| min : m1,...,mn valeur des minima (def=1)
972//| max : M1,...,Mn valeur des maxima (def=-1) (max<=min : pas de limite)
973//| opt : options "Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
974//| f = generation d'un Objet identique contenant la fonction fittee
975//| r = generation d'un Objet identique contenant les residus
976//| Xaa.b = aa.b valeur du DXi2 d'arret (def=1.e-3)
977//| la.b = niveau "a.b" de print: a=niveau de print Fit1/2D
978//| b=niveau de debug GeneralFit
979//| Ii1/i2 numeros des bins X de l'histos utilises pour le fit [i1,i2]
980//|2D Jj1/j2 numeros des bins Y de l'histos utilises pour le fit [j1,j2]
981//| - L'erreur est celle associee a l'objet si existe, 1 sinon sauf si
982//| E = erreur prise comme la racine de la valeur a fitter
983//| Eaa.b = erreur prise aa.b*sqrt(val)
984//| e = erreur prise egale a 1 pour toutes les valeurs
985//| eaa.b = erreur prise egale a aa.b
986//| xaa.b = demande de centrage: on fit x-aa.b au lieu de x)
987//| x = demande de centrage: on fit x-xc au lieu de x
988//| avec xc=abscisse du milieu de l'histogramme
989//| Actif pour: exp+poly 1D, poly 1D
990//| gauss+poly 1D (mais xc est le centre de la gaussienne)
991//|2D yaa.b et y = idem "xaa.b et x" mais pour y
992{
993AnyDataObj* obj=mOmg->GetObj(nom);
994if (obj == NULL) {
995 cout<<"Services2NObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
996 return;
997}
998if (!mImgapp) return;
999if(func.length()<=0)
1000 {cout<<"Services2NObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
1001 return;}
1002string ctyp = typeid(*obj).name();
1003
1004int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
1005Vector* v = NULL; Histo* h = NULL;
1006Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
1007GeneralFitData* g = NULL;
1008
1009 // 1D
1010if (typeid(*obj) == typeid(Vector)) {
1011 ndim = 1;
1012 v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
1013 }
1014else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) {
1015 ndim = 1;
1016 h = (Histo*) obj; nbinx = h->NBins(); nbiny = 1;
1017 }
1018else if (typeid(*obj) == typeid(Matrix)) {
1019 ndim = 2;
1020 m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
1021 }
1022else if (typeid(*obj) == typeid(Histo2D)) {
1023 ndim = 2;
1024 h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
1025 }
1026else if (typeid(*obj) == typeid(GeneralFitData)) {
1027 g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
1028 if( g->NVar()==1) ndim = 1;
1029 else if(g->NVar()==2) ndim = 2;
1030 else {
1031 cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
1032 <<((GeneralFitData*) obj)->NVar()<<endl; return; }
1033 }
1034else if (dynamic_cast<RzImage*>(obj)) {
1035 ndim = 2;
1036 im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
1037 }
1038else {
1039 cout<<"Services2NObjMgr::Fit12D() Error , Objet n'est pas un "
1040 <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
1041 return;
1042 }
1043
1044ndata = nbinx*nbiny;
1045if(ndata<=0)
1046 {cout<<"L'objet a "<<nbinx<<","<<nbiny<<" bins ("<<ndata<<")"<<endl; return;}
1047
1048// Decodage des options et des parametres, mise en forme
1049Vector Par(1); Vector Step(1); Vector Min(1); Vector Max(1); DFOPTIONS O;
1050DecodeFitsOptions(par,step,min,max,opt,Par,Step,Min,Max,O);
1051O.i1 = (O.i1<0||O.i1>=nbinx)? 0: O.i1;
1052O.i2 = (O.i2<0||O.i2>=nbinx||O.i2<O.i1)? nbinx-1: O.i2;
1053if(ndim>=2) {
1054 O.j1 = (O.j1<0||O.j1>=nbiny)? 0: O.j1;
1055 O.j2 = (O.j2<0||O.j2>=nbiny||O.j2<O.j1)? nbiny-1: O.j2;
1056} else O.j2 = O.j1 = 0;
1057if(O.polcx==2) {
1058 if(v||m) O.xc = (O.i2-O.i1+1)/2.;
1059 else if(h) O.xc = (h->XMin()+h->XMax())/2.;
1060 else if(h2) O.xc = (h2->XMin()+h2->XMax())/2.;
1061 else if(g) {double mini,maxi; g->GetMinMax(2,mini,maxi); O.xc=(mini+maxi)/2.;}
1062 else if(im) {O.xc = im->XOrg() * im->XPxSize()*(O.i2-O.i1+1)/2.;}
1063}
1064if(O.polcy==2 && ndim>=2) {
1065 if(m) O.yc = (O.j2-O.j1+1)/2.;
1066 if(h2) O.yc = (h2->YMin()+h2->YMax())/2.;
1067 if(g) {double mini,maxi; g->GetMinMax(12,mini,maxi); O.yc=(mini+maxi)/2.;}
1068 if(im) {O.yc = im->YOrg() * im->YPxSize()*(O.j2-O.j1+1)/2.;}
1069}
1070if(O.lp>0)
1071 cout<<"Fit["<<nbinx<<","<<nbiny<<"] ("<<ndata<<") dim="<<ndim<<":"
1072 <<" Int=["<<O.i1<<","<<O.i2<<"],["<<O.j1<<","<<O.j2<<"]"<<endl
1073 <<" Cent="<<O.polcx<<","<<O.polcy<<","<<O.xc<<"+x"<<","<<O.yc<<"+y"
1074 <<" TypE="<<O.err_e<<","<<O.err_E
1075 <<" StpX2="<<O.stc2
1076 <<" lp,lpg="<<O.lp<<","<<O.lpg<<endl;
1077
1078///////////////////////////////////
1079// Remplissage de GeneralFitData //
1080///////////////////////////////////
1081GeneralFitData mydata(ndim,ndata,0);
1082{for(int i=O.i1;i<=O.i2;i++) for(int j=O.j1;j<=O.j2;j++) {
1083 double x,y,f,e;
1084
1085 if(v)
1086 {x= (double) i; f=(*v)(i); e=1.;}
1087 else if(h)
1088 {x=h->BinCenter(i); f=(*h)(i); e=(h->HasErrors())?h->Error(i):1.;}
1089 else if(m)
1090 {x=(double) i; y=(double) j; f=(*m)(j,i); e=1.;}
1091 else if(h2)
1092 {float xf,yf; h2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
1093 f=(*h2)(i,j); e=(h2->HasErrors())?h2->Error(i,j):1.;}
1094 else if(im)
1095 {x=im->XOrg()+(i+0.5)*im->XPxSize(); y=im->YOrg()+(j+0.5)*im->YPxSize();
1096 f=im->DValue(i,j); e=1.;}
1097 else if(g&&ndim==1) {x= g->X(i); f=g->Val(i); e=g->EVal(i);}
1098 else if(g&&ndim==2) {x= g->X(i); y= g->Y(i); f=g->Val(i); e=g->EVal(i);}
1099 else x=y=f=e=0.;
1100
1101 // Gestion des erreurs a utiliser
1102 if(O.err_e>0.) e=O.err_e;
1103 else if(O.err_E>0.) {e=(y<-1.||y>1.)?O.err_E*sqrt(fabs(y)):O.err_E;}
1104
1105 // Remplissage de generalfit
1106 if(func[0]=='p') {x -= O.xc; if(ndim>=2) y -= O.yc;}
1107 if(ndim==1) mydata.AddData1(x,f,e);
1108 else if(ndim==2) mydata.AddData2(x,y,f,e);
1109}}
1110if(mydata.NData()<=0)
1111 {cout<<"Pas de donnees dans GeneralFitData: "<<mydata.NData()<<endl;
1112 return;}
1113if(O.lpg>1) {
1114 mydata.PrintStatus();
1115 mydata.PrintData(0);
1116 mydata.PrintData(mydata.NData()-1);
1117}
1118
1119////////////////////////////////////////////
1120// Identification de la fonction a fitter //
1121////////////////////////////////////////////
1122GeneralFunction* myfunc = NULL;
1123if(func[0]=='p' && ndim==1) {
1124 // Fit de polynome sans passer par les GeneralFit
1125 int degre = 0;
1126 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1127 cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
1128 Poly p1(0);
1129 double c2rl = mydata.PolFit(0,p1,degre);
1130 cout<<"C2r_lineaire = "<<c2rl<<endl;
1131 if(O.lp>0) cout<<p1<<endl;
1132 return;
1133
1134} else if(func[0]=='P' && ndim==1) {
1135 // Fit de polynome
1136 int degre = 0;
1137 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1138 cout<<"Fit polynome 1D de degre "<<degre<<endl;
1139 Polyn1D* myf = new Polyn1D(degre,O.xc);
1140 myfunc = myf;
1141
1142} else if(func[0]=='e' && ndim==1) {
1143 // Fit d'exponentielle
1144 int degre =-1;
1145 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1146 cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl;
1147 Exp1DPol* myf;
1148 if(degre>=0) myf = new Exp1DPol((unsigned int)degre,O.xc);
1149 else myf = new Exp1DPol(O.xc);
1150 myfunc = myf;
1151
1152} else if(func[0]=='g' && ndim==1) {
1153 // Fit de gaussienne en hauteur
1154 int degre =-1;
1155 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1156 cout<<"Fit de Gaussienne_en_hauteur+polynome 1D de degre "<<degre<<endl;
1157 Gauss1DPol* myf;
1158 if(degre>=0) myf = new Gauss1DPol((unsigned int)degre,((O.polcx)?true:false));
1159 else { bool bfg = (O.polcx)?true:false; myf = new Gauss1DPol(bfg); }
1160 myfunc = myf;
1161
1162} else if(func[0]=='G' && ndim==1) {
1163 // Fit de gaussienne en volume
1164 int degre =-1;
1165 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1166 cout<<"Fit de Gaussienne_en_volume+polynome 1D de degre "<<degre<<endl;
1167 GaussN1DPol* myf;
1168 if(degre>=0) myf = new GaussN1DPol((unsigned int)degre,((O.polcx)?true:false));
1169 else { bool bfg = (O.polcx)?true:false; myf = new GaussN1DPol(bfg); }
1170 myfunc = myf;
1171
1172} else if(func[0]=='p' && ndim==2) {
1173 // Fit de polynome 2D sans passer par les GeneralFit
1174 int degre = 0;
1175 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1176 cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
1177 Poly2 p2(0);
1178 double c2rl = mydata.PolFit(0,1,p2,degre);
1179 cout<<"C2r_lineaire = "<<c2rl<<endl;
1180 if(O.lp>0) cout<<p2<<endl;
1181 return;
1182
1183} else if(func[0]=='P' && ndim==2) {
1184 // Fit de polynome 2D
1185 int degre = 0;
1186 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1187 cout<<"Fit polynome 2D de degre "<<degre<<endl;
1188 Polyn2D* myf = new Polyn2D(degre,O.xc,O.yc);
1189 myfunc = myf;
1190
1191} else if(func[0]=='G' && ndim==2) {
1192 // Fit de gaussienne+fond en volume
1193 int integ = 0;
1194 if(func.length()>1) if(func[1]=='i') integ=1;
1195 cout<<"Fit de Gaussienne+Fond 2D integ="<<integ<<endl;
1196 if(integ) {GauRhInt2D* myf = new GauRhInt2D; myfunc = myf;}
1197 else {GauRho2D* myf = new GauRho2D; myfunc = myf;}
1198
1199} else if(func[0]=='d' && ndim==2) {
1200 // Fit de DL gaussienne+fond en volume
1201 int integ = 0;
1202 if(func.length()>1) if(func[1]=='i') integ=1;
1203 cout<<"Fit de DL de Gaussienne+Fond 2D integ="<<integ<<endl;
1204 if(integ) {GdlRhInt2D* myf = new GdlRhInt2D; myfunc = myf;}
1205 else {GdlRho2D* myf = new GdlRho2D; myfunc = myf;}
1206
1207} else if(func[0]=='D' && ndim==2) {
1208 // Fit de DL gaussienne+fond avec coeff variable p6 en volume
1209 int integ = 0;
1210 if(func.length()>1) if(func[1]=='i') integ=1;
1211 cout<<"Fit de DL de Gaussienne+Fond avec coeff variable (p6) 2D integ="<<integ<<endl;
1212 if(integ) {Gdl1RhInt2D* myf = new Gdl1RhInt2D; myfunc = myf;}
1213 else {Gdl1Rho2D* myf = new Gdl1Rho2D; myfunc = myf;}
1214
1215} else if(func[0]=='M' && ndim==2) {
1216 // Fit de Moffat+fond (volume)
1217 int integ = 0;
1218 if(func.length()>1) if(func[1]=='i') integ=1;
1219 cout<<"Fit de Moffat+Fond (expos=p6) 2D integ="<<integ<<endl;
1220 if(integ) {MofRhInt2D* myf = new MofRhInt2D; myfunc = myf;}
1221 else {MofRho2D* myf = new MofRho2D; myfunc = myf;}
1222
1223} else {
1224 cout<<"Fonction "<<func<<" inconnue pour la dim "<<ndim<<endl;
1225 return;
1226}
1227
1228/////////////////////////
1229// Fit avec generalfit //
1230/////////////////////////
1231if(myfunc->NPar()>Par.NElts())
1232 {cout<<"Trop de parametres: "<<myfunc->NPar()<<">"<<Par.NElts()<<endl;
1233 if(myfunc) delete myfunc; return;}
1234GeneralFit myfit(myfunc);
1235myfit.SetDebug(O.lpg);
1236myfit.SetData(&mydata);
1237myfit.SetStopChi2(O.stc2);
1238{for(int i=0;i<myfunc->NPar();i++) {
1239 char str[10];
1240 sprintf(str,"P%d",i);
1241 myfit.SetParam(i,str,Par(i),Step(i),Min(i),Max(i));
1242}}
1243if(O.lp>1) myfit.PrintFit();
1244double c2r = (double) myfit.Fit();
1245if(O.lp>0) myfit.PrintFit();
1246if(c2r>0.) {
1247 c2r = myfit.GetChi2Red();
1248 cout<<"C2r_Reduit = "<<c2r<<" nstep="<<myfit.GetNStep()<<endl;
1249 Vector ParFit(myfunc->NPar());
1250 for(int i=0;i<myfunc->NPar();i++) ParFit(i)=myfit.GetParm(i);
1251} else {
1252 cout<<"echec Fit, rc = "<<c2r<<" nstep="<<myfit.GetNStep()<<endl;
1253}
1254
1255// Mise a disposition des resultats
1256if(c2r>=0. && myfunc && (O.okres>0||O.okfun>0)) {
1257 string nomres = nom + "res";
1258 string nomfun = nom + "fun";
1259 if(v) {
1260 if(O.okres) {Vector* ob = v->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1261 if(O.okfun) {Vector* ob = v->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1262 } else if(h) {
1263 if(O.okres) {Histo* ob = h->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1264 if(O.okfun) {Histo* ob = h->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1265 } else if(m) {
1266 if(O.okres) {Matrix* ob = m->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1267 if(O.okfun) {Matrix* ob = m->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1268 } else if(h2) {
1269 if(O.okres) {Histo2D* ob = h2->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1270 if(O.okfun) {Histo2D* ob = h2->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1271 } else if(im) {
1272 if(O.okres) {RzImage* ob = im->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1273 if(O.okfun) {RzImage* ob = im->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1274 } else if(g) {
1275 if(O.okres) {GeneralFitData* ob = g->FitResidus(myfit); if(ob) mOmg->AddObj(ob,nomres);}
1276 if(O.okfun) {GeneralFitData* ob = g->FitFunction(myfit); if(ob) mOmg->AddObj(ob,nomfun);}
1277 }
1278}
1279
1280// Nettoyage
1281if(myfunc) delete myfunc;
1282return;
1283}
1284
1285
1286/* --Methode-- */
1287void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx,
1288 string& expy, string& expz, string& expt, string& expcut,
1289 NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
1290{
1291if (obja == NULL) return;
1292NTupleInterface* objnt = obja->GetNTupleInterface();
1293if (objnt == NULL) return;
1294string vardec = objnt->VarList_C("_zz6qi_");
1295
1296PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
1297if (!f) {
1298 cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " << endl;
1299 return;
1300 }
1301
1302double xnt[10];
1303float fxnt[10];
1304
1305int i,k;
1306for(i=0; i<10; i++) xnt[i] = 0.;
1307
1308TRY {
1309 double* xn;
1310 for(k=0; k<objnt->NbLines(); k++) {
1311 xn = objnt->GetLineD(k);
1312 if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
1313 if (nt) {
1314 for(i=0; i<4; i++) fxnt[i] = xnt[i];
1315 nt->Fill(fxnt);
1316 }
1317 if (h1) h1->Add(xnt[0], xnt[3]);
1318 if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
1319 if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
1320 }
1321 }
1322 }
1323CATCH(merr) {
1324 fflush(stdout);
1325 cout << endl;
1326 cerr << endl;
1327 string es = PeidaExc(merr);
1328 cerr << "Services2NObjMgr::ComputeExpressions() Exception :" << merr << es;
1329 } ENDTRY;
1330
1331
1332// Fermeture du fichier .so
1333CloseDLL();
1334return;
1335}
1336
1337
1338/* --Methode-- */
1339PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy,
1340 string& expz, string& expt, string& cut)
1341{
1342FILE *fip;
1343string fname = TmpDir + "expf_pia_dl.c";
1344string cmd;
1345int rc;
1346
1347cmd = "rm -f " + fname;
1348rc = system(cmd.c_str());
1349//DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
1350
1351if ((fip = fopen(fname.c_str(), "w")) == NULL) {
1352 string sn = fname;
1353 cout << "Services2NObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl;
1354 return(NULL);
1355 }
1356
1357// constitution du fichier a compiler
1358fputs("#include <stdlib.h> \n", fip);
1359fputs("#include <math.h> \n", fip);
1360fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
1361fprintf(fip,"%s \n", vardec.c_str());
1362fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.; return(0); } \n", cut.c_str());
1363fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
1364fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
1365fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
1366fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
1367fputs("return(1); \n} \n", fip);
1368fclose(fip);
1369string func = "expf_pia_dl_func";
1370return((PlotExprFunc)LinkFunctionFromFile(fname, func));
1371}
1372
1373
1374/* --Methode-- */
1375DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
1376{
1377// Le link dynamique
1378CloseDLL();
1379dynlink = PDynLinkMgr::BuildFromCFile(fname);
1380if (dynlink == NULL) {
1381 cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
1382 return(NULL);
1383 }
1384
1385DlFunction retfunc = dynlink->GetFunction(funcname);
1386if (retfunc == NULL) {
1387 string sn = funcname;
1388 cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
1389 CloseDLL();
1390 return(NULL);
1391 }
1392else return(retfunc);
1393}
1394
1395/* --Methode-- */
1396void Services2NObjMgr::CloseDLL()
1397{
1398if (dynlink) delete dynlink; dynlink = NULL;
1399}
1400
1401
1402/* --Methode-- */
[165]1403string Services2NObjMgr::FileName2Name(string const & fn)
1404{
1405
1406char fsep[2] = {FILESEP, '\0'};
1407char tsep[2] = {'.', '\0'};
1408size_t p = fn.find_last_of(fsep);
[194]1409size_t l = fn.length();
1410if (p >= l) p = 0;
1411else p++;
1412size_t q = fn.find_first_of(tsep,p);
1413if (q < p) q = l;
[165]1414return(fn.substr(p,q-p));
1415}
1416
1417
1418typedef vector<string> GraTok;
1419
1420/* --Methode-- */
1421int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
1422{
1423int ropt = Disp_Next;
1424if (!mImgapp) return(ropt);
1425
1426for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
1427
1428if (fgsrgr) mImgapp->SaveGraphicAtt();
1429
[326]1430if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini
[165]1431 mImgapp->SetColAtt();
1432 mImgapp->SetLineAtt();
1433 mImgapp->SetFontAtt();
1434 mImgapp->SetMarkerAtt();
1435 mImgapp->SetColMapId();
1436 mImgapp->SetZoomAtt();
[331]1437 mImgapp->SetAxesAtt();
1438 mImgapp->SetXYLimits();
1439 mImgapp->UseXYLimits();
[165]1440 return(ropt);
1441 }
1442
1443// On separe en mots separes par des virgules
1444gratt = ","+gratt;
1445size_t p = 0;
1446size_t q = 0;
1447size_t l = gratt.length();
1448string token;
1449
1450GraTok grt;
1451
1452while (q < l) {
1453 p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
1454 if (p>=l) break;
1455 q = gratt.find_first_of(" ,",p); // la fin du token;
1456 token = gratt.substr(p,q-p);
1457 grt.push_back(token);
1458 }
1459
1460
1461static GrAttNames::iterator it;
1462
1463int k;
1464bool fgcont = true;
1465fgsrgr = false;
1466
1467for(k=0; k<grt.size(); k++) {
1468// cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
1469
1470 // Decodage option affichage (win, next, etc
1471 fgcont = true;
1472 if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
1473 else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
1474 else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
1475 else fgcont = false;
1476 if (fgcont) continue;
[331]1477
1478 // Utilisation limites X-Y
1479 if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true); fgsrgr = true; continue; }
[165]1480 // Si c'est une couleur
1481 it = GrAcolors.find(grt[k]);
1482 if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
1483 // Si c'est un attribut de lignes
1484 it = GrAlines.find(grt[k]);
1485 if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
1486 // Si c'est un attribut de fontes
1487 it = GrAfonts.find(grt[k]);
1488 if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
1489 fgsrgr = true; continue; }
1490 // Si c'est un attribut de markers
1491 it = GrAmarkers.find(grt[k]);
1492 if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
1493 fgsrgr = true; continue; }
1494 // Si c'est un colormap
1495 it = GrAcmap.find(grt[k]);
1496 if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
1497 // Si c'est un facteur de zoom
1498 it = GrAzoom.find(grt[k]);
1499 if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
[203]1500 // Si c'est un attribut d'axe
1501 it = GrAaxes.find(grt[k]);
1502 if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
[165]1503
1504 }
1505
1506return(ropt);
1507}
1508
1509
1510
1511// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1512// Initialisation des chaines de caracteres designant les attributs graphiques
1513
1514/* --Methode-- */
1515void Services2NObjMgr::InitGrAttNames()
1516{
1517gratt_item gi;
1518// Les couleurs
1519gi.a2 = 0;
1520gi.a1 = PI_NotDefColor;
1521GrAcolors["defcol"] = gi;
1522gi.a1 = PI_Black;
1523GrAcolors["black"] = gi;
1524gi.a1 = PI_White;
1525GrAcolors["white"] = gi;
1526gi.a1 = PI_Grey;
1527GrAcolors["grey"] = gi;
1528gi.a1 = PI_Red;
1529GrAcolors["red"] = gi;
1530gi.a1 = PI_Blue;
1531GrAcolors["blue"] = gi;
1532gi.a1 = PI_Green;
1533GrAcolors["green"] = gi;
1534gi.a1 = PI_Yellow;
1535GrAcolors["yellow"] = gi;
1536gi.a1 = PI_Magenta;
1537GrAcolors["magenta"] = gi;
1538
1539gi.a1 = PI_Cyan;
1540GrAcolors["cyan"] = gi;
1541gi.a1 = PI_Turquoise;
1542GrAcolors["turquoise"] = gi;
1543gi.a1 = PI_NavyBlue;
1544GrAcolors["navyblue"] = gi;
1545gi.a1 = PI_Orange;
1546GrAcolors["orange"] = gi;
1547gi.a1 = PI_SiennaRed;
1548GrAcolors["siennared"] = gi;
1549gi.a1 = PI_Purple;
1550GrAcolors["purple"] = gi;
1551gi.a1 = PI_LimeGreen;
1552GrAcolors["limegreen"] = gi;
1553gi.a1 = PI_Gold;
1554GrAcolors["gold"] = gi;
1555
1556// Les attributs de lignes
1557gi.a2 = 0;
1558gi.a1 = PI_NotDefLineAtt;
1559GrAlines["defline"] = gi;
1560gi.a1 = PI_NormalLine;
1561GrAlines["normalline"] = gi;
1562gi.a1 = PI_ThinLine;
1563GrAlines["thinline"] = gi;
1564gi.a1 = PI_ThickLine;
1565GrAlines["thickline"] = gi;
1566gi.a1 = PI_DashedLine;
1567GrAlines["dashedline"] = gi;
1568gi.a1 = PI_ThinDashedLine;
1569GrAlines["thindashedline"] = gi;
1570gi.a1 = PI_ThickDashedLine;
1571GrAlines["thickdashedline"] = gi;
[192]1572gi.a1 = PI_DottedLine;
1573GrAlines["dottedline"] = gi;
1574gi.a1 = PI_ThinDottedLine;
1575GrAlines["thindottedline"] = gi;
1576gi.a1 = PI_ThickDottedLine;
1577GrAlines["thickdottedline"] = gi;
[165]1578
[293]1579// Les fontes
[165]1580gi.a2 = PI_NotDefFontSize;
1581gi.a1 = PI_NotDefFontAtt;
1582GrAlines["deffont"] = gi;
1583
1584gi.a2 = PI_NormalSizeFont;
1585gi.a1 = PI_RomanFont;
1586GrAlines["normalfont"] = gi;
1587gi.a1 = PI_BoldFont;
1588GrAlines["boldfont"] = gi;
1589gi.a1 = PI_ItalicFont;
1590GrAlines["italicfont"] = gi;
1591gi.a2 = PI_SmallSizeFont;
1592gi.a1 = PI_RomanFont;
1593GrAlines["smallfont"] = gi;
1594gi.a1 = PI_BoldFont;
1595GrAlines["smallboldfont"] = gi;
1596gi.a1 = PI_ItalicFont;
1597GrAlines["smallitalicfont"] = gi;
1598gi.a2 = PI_BigSizeFont;
1599gi.a1 = PI_RomanFont;
1600GrAlines["bigfont"] = gi;
1601gi.a1 = PI_BoldFont;
1602GrAlines["bigboldfont"] = gi;
1603gi.a1 = PI_ItalicFont;
1604GrAlines["bigitalicfont"] = gi;
[192]1605gi.a2 = PI_HugeSizeFont;
1606gi.a1 = PI_RomanFont;
1607GrAlines["hugefont"] = gi;
1608gi.a1 = PI_BoldFont;
1609GrAlines["hugeboldfont"] = gi;
1610gi.a1 = PI_ItalicFont;
1611GrAlines["hugeitalicfont"] = gi;
[165]1612
1613
1614// Les markers
[176]1615const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
1616 "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
1617 "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
[165]1618PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
1619 PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
1620 PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
1621
1622gi.a2 = 0;
1623gi.a1 = PI_NotDefMarker;
1624GrAmarkers["defmarker"] = gi;
1625
1626for(int j=0; j<11; j++) {
1627 string smrk;
1628 char buff[16];
1629 for(int m=1; m<10; m+=2) {
1630 sprintf(buff,"%d",m);
1631 smrk = (string)mrkn[j] + (string)buff;
1632 gi.a1 = mrk[j]; gi.a2 = m;
1633 GrAmarkers[smrk] = gi;
1634 }
1635 }
1636
1637// Les tables de couleurs
1638gi.a2 = 0;
1639gi.a1 = CMAP_OTHER;
1640GrAcmap["defcmap"] = gi;
1641gi.a1 = CMAP_GREY32;
1642GrAcmap["grey32"] = gi;
1643gi.a1 = CMAP_GREYINV32;
1644GrAcmap["greyinv32"] = gi;
1645gi.a1 = CMAP_COLRJ32;
1646GrAcmap["colrj32"] = gi;
1647gi.a1 = CMAP_COLBR32;
1648GrAcmap["colbr32"] = gi;
1649gi.a1 = CMAP_GREY128;
1650GrAcmap["grey128"] = gi;
1651gi.a1 = CMAP_GREYINV128;
1652GrAcmap["greyinv128"] = gi;
1653gi.a1 = CMAP_COLRJ128;
1654GrAcmap["colrj128"] = gi;
1655gi.a1 = CMAP_COLBR128;
1656GrAcmap["colbr128"] = gi;
1657
[203]1658// La valeur de zoom
[165]1659gi.a2 = 0;
1660gi.a1 = 0;
1661GrAzoom["defzoom"] = gi;
1662gi.a1 = 1;
1663GrAzoom["zoomx1"] = gi;
1664gi.a1 = 2;
1665GrAzoom["zoomx2"] = gi;
1666gi.a1 = 3;
1667GrAzoom["zoomx3"] = gi;
1668gi.a1 = 4;
1669GrAzoom["zoomx4"] = gi;
1670gi.a1 = 5;
1671GrAzoom["zoomx5"] = gi;
1672gi.a1 = -2;
1673GrAzoom["zoom/2"] = gi;
1674gi.a1 = -3;
1675GrAzoom["zoom/3"] = gi;
1676gi.a1 = -4;
1677GrAzoom["zoom/4"] = gi;
1678gi.a1 = -5;
1679GrAzoom["zoom/5"] = gi;
[203]1680
1681// Attributs d'axes
1682gi.a2 = 0;
1683gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
1684GrAaxes["stdaxes"] = gi;
1685GrAaxes["defaxes"] = gi;
1686GrAaxes["boxaxes"] = gi;
1687gi.a1 = (int)kAxesDflt;
1688GrAaxes["simpleaxes"] = gi;
1689gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
1690GrAaxes["boxaxesgrid"] = gi;
1691
1692gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
1693GrAaxes["fineaxes"] = gi;
1694 gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
1695GrAaxes["grid"] = gi;
1696GrAaxes["fineaxesgrid"] = gi;
1697
[165]1698}
[333]1699
1700
1701// SANS_EVOLPLANCK Attention !
1702#include "pclassids.h"
1703
1704/* --Methode-- */
1705char* Services2NObjMgr::PClassIdToClassName(int cid)
1706{
1707switch (cid) {
1708 case ClassId_Poly1 :
1709 return("Poly1");
1710 case ClassId_Poly2 :
1711 return("Poly2");
1712 case ClassId_Matrix :
1713 return("Matrix");
1714 case ClassId_Vector :
1715 return("Vector");
1716
1717 case ClassId_DVList :
1718 return("DVList");
1719
1720 case ClassId_Histo1D :
1721 return("Histo1D");
1722 case ClassId_Histo2D :
1723 return("Histo2D");
1724 case ClassId_HProf :
1725 return("HProf");
1726 case ClassId_NTuple :
1727 return("NTuple");
1728 case ClassId_GeneralFitData :
1729 return("GeneralFitData");
1730
1731 case ClassId_Image :
1732 return("RzImage");
1733 case ClassId_Image + kuint_1 :
1734 return("ImageU1");
1735 case ClassId_Image + kint_1 :
1736 return("ImageI1");
1737 case ClassId_Image + kuint_2 :
1738 return("ImageU2");
1739 case ClassId_Image + kint_2 :
1740 return("ImageI2");
1741 case ClassId_Image + kuint_4 :
1742 return("ImageU4");
1743 case ClassId_Image + kint_4 :
1744 return("ImageI4");
1745 case ClassId_Image + kr_4 :
1746 return("ImageR4");
1747 case ClassId_Image + kr_8 :
1748 return("ImageR8");
1749
1750 case ClassId_ZFidu :
1751 return("ZFidu");
1752
1753 case ClassId_StarList :
1754 return("StarList");
1755 case ClassId_Transfo :
1756 return("Transfo");
1757 case ClassId_PSF :
1758 return("PSF");
1759
1760
1761// - Ajout objet PPF
1762 default:
1763 return("AnyDataObj");
1764 }
1765}
1766
Note: See TracBrowser for help on using the repository browser.