source: Sophya/trunk/SophyaPI/PIext/nobjmgr.cc@ 311

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

Mise aux "normes" version DPC/Planck - Gestion des objets a travers

un adaptateur/interface NTuple par NamedObjMgr.
Enregistrement d'objets et de l'adaptateur (I/O PPersist, display, ...)
par ServNobjMgr .... Reza 13/05/99

File size: 50.4 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#include "datatypes.h"
18
19#include "nobjmgr.h"
20#include "servnobjm.h"
21#include "pistdimgapp.h"
22
23#include "matrix.h"
24#include "cvector.h"
25
26// EVOL-PLANCK
27#ifdef SANS_EVOLPLANCK
28#include "fitsimage.h"
29#endif
30
31#include "fct1dfit.h"
32#include "fct2dfit.h"
33
34#include "pisurfdr.h"
35#include "pipodrw.h"
36#include "pihisto.h"
37#include "hisprof.h"
38#include "pihisto2d.h"
39#include "pintuple.h"
40#include "pintup3d.h"
41#include "pigfd1.h"
42#include "pigfd2.h"
43
44
45//++
46// Class NamedObjMgr
47// Lib PI
48// include nobjmgr.h
49//
50// Cette classe fournit les services nécéssaire àla gestion des objets
51// (l'ensemble des objets PPersist de PEIDA++) au sein du programme
52// d'analyse interactive *piapp* . Elle constitue en outre l'interface
53// entre les fonctions utilisateur et l'application graphique.
54//--
55//++
56// Links Voir aussi
57// PIStdImgApp
58// Services2NObjMgr
59// PIACmd
60//--
61
62
63// ..................................................................
64// ...... Gestion des objets nommes, variables globales ............
65struct nobj_item {
66 AnyDataObj* obj;
67 NObjMgrAdapter* obja;
68 int num;
69 list<int> wrsid;
70 bool operator==(nobj_item const& b) const
71 { return (this->obj == b.obj); }
72};
73
74typedef map<string, nobj_item, less<string> > NObjList;
75
76static NObjList* myObjs;
77static int fgOInit = 0;
78static int myNObj = 0;
79static string* lastobj = NULL;
80
81static PIStdImgApp* myImgApp=NULL;
82static Services2NObjMgr* servnobjm=NULL;
83
84static string* TmpDir; // Repertoire pour les compilations / link dynamique
85
86//++
87// Titre Constructeurs
88//--
89//++
90// NamedObjMgr()
91// Constructeur. Les différents instantiation de la classe "NamedObjMgr"
92// dans une même application créent des objets qui travaillent sur la même
93// liste d'objets. Les objets de cette classe ne possedent en effet pas
94// de variables membres.
95//--
96
97/* --Methode-- */
98NamedObjMgr::NamedObjMgr()
99{
100if (fgOInit == 0) {
101 myObjs = new NObjList;
102 lastobj = new string("");
103 char* varenv;
104 TmpDir = new string("");
105 if ( (varenv=getenv("PEIDA_TMP")) != NULL ) (*TmpDir) = varenv;
106 else if ( (varenv=getenv("TMPDIR")) != NULL ) (*TmpDir) = varenv;
107 int l = (*TmpDir).length();
108 if ( (l>0) && ((*TmpDir)[l-1] != '/') ) (*TmpDir) += '/';
109 servnobjm = new Services2NObjMgr(NULL, (*TmpDir));
110 }
111fgOInit++;
112}
113
114
115/* --Methode-- */
116NamedObjMgr::~NamedObjMgr()
117{
118fgOInit--;
119if (fgOInit == 0) delete myObjs;
120}
121
122//++
123// Titre Méthodes
124//--
125//++
126// void SetImgApp(PIStdImgApp* app)
127// Spécifie l'objet "PIStdImgApp" associé.
128// PIStdImgApp* GetImgApp()
129// Accès à l'objet "PIStdImgApp" associé.
130//--
131
132/* --Methode-- */
133void NamedObjMgr::SetImgApp(PIStdImgApp* app)
134{
135myImgApp = app;
136servnobjm->SetImgApp(app);
137}
138
139/* --Methode-- */
140PIStdImgApp* NamedObjMgr::GetImgApp()
141{
142return(myImgApp);
143}
144
145/* --Methode-- */
146Services2NObjMgr* NamedObjMgr::GetServiceObj()
147{
148return(servnobjm);
149}
150
151//++
152// Titre Gestion de la liste des objets
153//--
154//++
155// void AddObj(AnyDataObj* obj, string& nom)
156// Ajoute l'objet "obj" à la liste, identifié par "nom".
157// Si un objet de même nom existe, l'ancien objet est renommé en concaténant
158// un numéro à son nom.
159// void DelObj(string const& nom, bool fgd=true)
160// Supprime l'objet "nom" de la liste. L'objet est détruit si "fgd==true" ("delete obj")
161// void DelObjects(string const& patt, bool fgd=true)
162// Supprime l'ensemble des objets dont le nom correspond au patron "patt".
163// Le patron peut contenir les caractères "*" et "?" . Les objets sont détruits si "fgd==true"
164// AnyDataObj* GetObj(string const& nom)
165// Retourne l'objet identifié par "nom" dans la liste. Retourne "NULL" si "nom" n'est
166// pas dans la liste.
167// void RenameObj(string const& nom, string& nomnew)
168// Change le nom d'un objet dans la liste.
169// string LastObjName()
170// Renvoie le nom du dernier objet ajouté à la liste
171//--
172
173
174/* --Methode-- */
175void NamedObjMgr::AddObj(AnyDataObj* obj, string& nom, bool)
176{
177
178if (obj == NULL) return;
179// on supprime les blancs de debut et de fin
180size_t p = nom.find_first_not_of(" ");
181if(p>nom.length()) {
182 nom = "";
183} else {
184 nom = nom.substr(p);
185 p = nom.find_first_of(" ");
186 if(p>nom.length()) p=nom.length();
187 nom = nom.substr(0, p);
188}
189
190myNObj++;
191if (nom.length() < 1) nom = typeid(*obj).name();
192NObjList::iterator it = myObjs->find(nom);
193if (it != myObjs->end()) { // l'objet existe deja
194 char strg[16];
195 sprintf(strg, "%d", myNObj);
196 string nomnew = nom + strg;
197 RenameObj(nom, nomnew);
198 }
199
200(*lastobj) = nom;
201nobj_item no;
202no.obj = obj;
203no.obja = servnobjm->GetAdapter(obj); // L'adaptateur
204no.num = myNObj;
205(*myObjs)[(*lastobj)] = no;
206if (myImgApp) {
207 string str = (*lastobj) + " (T= " + typeid(*obj).name() + ")" ;
208 (myImgApp->ObjMgrW())->AddObj(str.c_str(), myNObj+1000);
209}
210
211cout << "NamedObjMgr::AddObj() Object " << (*lastobj) << " ( "
212 << typeid(*obj).name() << " ) added (Total= " << myObjs->size() << ")" << endl;
213return;
214}
215
216/* --Methode-- */
217void NamedObjMgr::DelObj(string const& nom, bool fgd)
218{
219NObjList::iterator it = myObjs->find(nom);
220if (it == myObjs->end()) return;
221list<int>::iterator ii;
222if (myImgApp) {
223//DBG cerr << " *DBG* NamedObjMgr::DelObj Sz= " << (*it).second.wrsid.size() << endl;
224 for(ii=(*it).second.wrsid.begin(); ii != (*it).second.wrsid.end(); ii++)
225 myImgApp->DelWRsId((*ii));
226 (myImgApp->ObjMgrW())->DelObj((*it).second.num+1000);
227}
228delete (*it).second.obj; // destruction de l'adaptateur
229if (fgd) delete (*it).second.obj;
230myObjs->erase(it);
231if (fgd) cout << "NamedObjMgr::DelObj() Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
232else cout << "NamedObjMgr::DelObj() Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
233return;
234}
235
236/* --Methode-- */
237void NamedObjMgr::DelObjects(string const& patt, bool fgd)
238{
239NObjList::iterator it;
240list<string> odel;
241string cn;
242for(it = myObjs->begin(); it != myObjs->end(); it++) {
243 cn = (*it).first;
244 if (csh_parse(cn.c_str(), patt.c_str()) != 0) odel.push_back(cn);
245 }
246list<string>::iterator ii;
247for(ii=odel.begin(); ii != odel.end(); ii++) DelObj(*ii, fgd);
248}
249
250/* --Methode-- */
251AnyDataObj* NamedObjMgr::GetObj(string const& nom)
252{
253NObjList::iterator it = myObjs->find(nom);
254if (it == myObjs->end()) return(NULL);
255return((*it).second.obj);
256}
257
258/* --Methode-- */
259NObjMgrAdapter* NamedObjMgr::GetObjAdapter(string const& nom)
260{
261NObjList::iterator it = myObjs->find(nom);
262if (it == myObjs->end()) return(NULL);
263return((*it).second.obja);
264}
265
266/* --Methode-- */
267void NamedObjMgr::RenameObj(string const& nom, string& nomnew)
268{
269AnyDataObj* obj = GetObj(nom);
270if (obj == NULL) return;
271DelObj(nom, false);
272AddObj(obj, nomnew);
273return;
274}
275
276/* --Methode-- */
277string NamedObjMgr::LastObjName()
278{
279return((*lastobj));
280}
281
282//++
283// Titre Entrées-Sorties (I/O) sur les objets
284//--
285//++
286// void ReadObj(PInPersist& s, int num=-1)
287// Lit l'objet à partir avec le tag numéro "num" dans le flot "PInPersist s"
288// et l'ajoute à la liste. Si "num" est négatif, tous les objets présents
289// sur le flot "s" sont créés et ajoutés à la liste.
290// void ReadObj(string const & nomppf, string nobj="")
291// Lit le premier objet à partir du fichier PPF "nomppf". L'objet est ajouté
292// à la liste avec le nom "nobj". Si "nobj" est une chaîne vide, un nom est
293// composé à partir du nom de fichier.
294//--
295
296/* --Methode-- */
297void NamedObjMgr::ReadObj(string const & flnm, string nobj)
298{
299PPersist* obj=NULL;
300bool ok = true;
301
302TRY{
303 PInPersist pis(flnm);
304 obj = PPersistMgr::ReadObject(pis);
305 if (obj == NULL) ok = false;
306} CATCH(merr)
307 { printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n",
308 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
309
310if (!ok) return;
311if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
312AddObj(obj->DataObj(), nobj);
313return;
314}
315
316/* --Methode-- */
317void NamedObjMgr::ReadObj(PInPersist& s, int num)
318{
319int i, cid, key, ln;
320int n0, n1;
321bool ok = true;
322PPersist* obj=NULL;
323string nom;
324
325if ( (s.NbTags() < 1) || (num >= s.NbTags()) ) {
326 if (num >= 0) {
327 printf("NamedObjMgr::ReadObj(PInPersist, %d) Error! NbTags = %d \n", num, s.NbTags());
328 return;
329 }
330 TRY {
331 obj = PPersistMgr::ReadObject(s);
332 if (obj == NULL) ok = false;
333 } CATCH(merr) {
334 printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
335 ok = false;
336 } ENDTRY;
337 if (!ok) return;
338 nom = "";
339 AddObj(obj->DataObj(), nom);
340}
341
342if (num < 0) { n0 = 0; n1 = s.NbTags(); }
343else { n0 = num; n1 = num+1; }
344for(i=n0; i<n1; i++) {
345 key = s.TagKey(i, cid, ln);
346 if (ln <= 0) nom = "";
347 else nom = s.TagName(i);
348 s.GotoTag(i);
349 TRY {
350 obj = PPersistMgr::ReadObject(s);
351 if (obj == NULL) ok = false;
352 } CATCH(merr) {
353 printf("NamedObjMgr::ReadObj()/Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
354 ok = false;
355 } ENDTRY;
356 if (ok) AddObj(obj->DataObj(), nom);
357}
358
359return;
360}
361/* --Methode-- */
362void NamedObjMgr::ReadAll(string const & flnm)
363{
364bool ok = true;
365PPersist* obj=NULL;
366
367PInPersist* ppin;
368TRY{
369 ppin = new PInPersist(flnm);
370 if (ppin->NbTags() < 1) obj = PPersistMgr::ReadObject((*ppin));
371 else obj = NULL;
372} CATCH(merr)
373 { printf("NamedObjMgr::ReadAll()/Error Exception= %ld (%s) \n",
374 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
375
376if (!ok) return;
377if (obj) {
378 string nom = servnobjm->FileName2Name(flnm);
379 AddObj(obj->DataObj(), nom);
380 }
381else ReadObj((*ppin), -1);
382delete ppin;
383return;
384}
385
386/* --Methode-- */
387void NamedObjMgr::ReadFits(string const & flnm, string nobj)
388{
389bool ok = true;
390RzImage* obj;
391
392TRY{
393// obj = RzReadFits((char*)flnm.c_str(), ImgOffX, ImgOffY, ImgSizX, ImgSizY, ImgBitSgn);
394#ifdef SANS_EVOLPLANCK
395 obj = RzReadFits((char*)flnm.c_str());
396#else
397 printf("NamedObjMgr::ReadFITS( NON-Disponible EVOL-PLANCK) \n");
398 obj = NULL;
399#endif
400 if (obj == NULL) ok = false;
401} CATCH(merr) {
402 printf("NamedObjMgr::ReadFITS(_Error Exception= %ld (%s) \n", (long)merr, PeidaExc(merr));
403 ok = false;
404} ENDTRY;
405if (ok) {
406 if (nobj.length()<1) nobj = servnobjm->FileName2Name(flnm);
407 AddObj((AnyDataObj*)obj, nobj);
408}
409return;
410}
411
412
413static int key_for_write = 5000;
414/* --Methode-- */
415void NamedObjMgr::SaveObj(string const& nom, POutPersist& s)
416{
417NObjMgrAdapter* obja=NULL;
418obja = GetObjAdapter(nom);
419if (obja == NULL) return;
420printf("NamedObjMgr::SaveObj(%s, ) (Type=%s) \n",
421 nom.c_str(), typeid(*(obja->GetDataObj())).name());
422obja->SavePPF(s, nom);
423return;
424}
425
426/* --Methode-- */
427void NamedObjMgr::SaveAll(string const& flnm)
428{
429bool ok = true;
430
431POutPersist* pout;
432TRY{
433 pout = new POutPersist(flnm);
434} CATCH(merr)
435 { printf("NamedObjMgr::SaveAll()/Error Exception= %ld (%s) \n",
436 (long)merr, PeidaExc(merr)); ok = false; } ENDTRY;
437if (!ok) return;
438NObjList::iterator it;
439for(it = myObjs->begin(); it != myObjs->end(); it++) SaveObj((*it).first, (*pout));
440delete pout;
441return;
442}
443
444/* --Methode-- */
445void NamedObjMgr::SaveFits(string const& nom, string const & flnm)
446{
447NObjMgrAdapter* obja=NULL;
448obja = GetObjAdapter(nom);
449if (obja == NULL) return;
450obja->SaveFits(flnm);
451return;
452}
453
454
455/* --Methode-- */
456void NamedObjMgr::ListObjs()
457{
458int k;
459AnyDataObj* obj=NULL;
460string ctyp;
461char strg[256];
462
463cout << "NamedObjMgr::ListObjs() NObjs= " << myObjs->size() << "\n" ;
464NObjList::iterator it; k = 0;
465for(it = myObjs->begin(); it != myObjs->end(); it++) {
466 obj = (*it).second.obj;
467
468 ctyp = typeid(*obj).name();
469 sprintf(strg, "%2d/ %16s : %s", k, typeid(*obj).name(), ((*it).first).c_str());
470 ctyp = strg;
471 cout << ctyp << "\n" ;
472 k++;
473}
474cout << endl;
475return;
476}
477
478/* --Methode-- */
479void NamedObjMgr::PrintObj(string const& nom)
480{
481NObjMgrAdapter* obja=NULL;
482obja = GetObjAdapter(nom);
483if (obja == NULL) return;
484
485string ctyp = typeid(*obja->GetDataObj()).name();
486cout << "NamedObjMgr::PrintObj(" << nom << ") Type: " << ctyp << endl;
487obja->Print(cout);
488
489return;
490}
491
492/* --Methode-- */
493void NamedObjMgr::DisplayObj(string const& nom, string dopt)
494{
495NObjMgrAdapter* obja=NULL;
496obja = GetObjAdapter(nom);
497if (obja == NULL) {
498 cout << "NamedObjMgr::DisplayObj() Error , Pas d'objet de nom " << nom << endl;
499 return;
500}
501if (!myImgApp) return;
502
503PIDrawer * dr = NULL;
504P2DArrayAdapter* arr = NULL;
505dr = obja->GetDrawer(dopt);
506if (!dr) arr = obja->Get2DArray(dopt);
507
508if (!dr && !arr) {
509 string ctyp = typeid(*(obja->GetDataObj())).name();
510 cout << "NamedObjMgr::DisplayObj() Error , Pas de display pour " << ctyp << endl;
511 return;
512 }
513
514int wrsid = 0;
515bool fgsr = true;
516int opt = servnobjm->DecodeDispOption(dopt, fgsr);
517
518if (dr) {
519 PIDrawer3D * dr3 = dynamic_cast<PIDrawer3D *>(dr);
520 if(dr3) wrsid = myImgApp->Disp3DDrawer(dr3, nom, opt);
521 else wrsid = myImgApp->DispScDrawer( dr, nom, opt);
522 }
523else if (arr) wrsid = myImgApp->DispImage(arr, nom, opt);
524
525if(wrsid != 0) {
526 NObjList::iterator it = myObjs->find(nom);
527 if (it == myObjs->end()) return;
528 (*it).second.wrsid.push_back(wrsid);
529 }
530if (fgsr) myImgApp->RestoreGraphicAtt();
531return;
532}
533
534/* --Methode-- */
535void NamedObjMgr::DisplayImage(string const& nom, string dopt)
536{
537NObjMgrAdapter* obja=NULL;
538obja = GetObjAdapter(nom);
539if (obja == NULL) {
540 cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl;
541 return;
542}
543if (!myImgApp) return;
544
545P2DArrayAdapter* arr = obja->Get2DArray(dopt);
546
547if (!arr) {
548 string ctyp = typeid(*(obja->GetDataObj())).name();
549 cout << "NamedObjMgr::DisplayImage() Error , Non supporte pour " << ctyp << endl;
550 return;
551 }
552
553int wrsid = 0;
554bool fgsr = true;
555int opt = servnobjm->DecodeDispOption(dopt, fgsr);
556wrsid = myImgApp->DispImage(arr, nom, opt);
557
558if(wrsid != 0) {
559 NObjList::iterator it = myObjs->find(nom);
560 if (it == myObjs->end()) return;
561 (*it).second.wrsid.push_back(wrsid);
562 }
563if (fgsr) myImgApp->RestoreGraphicAtt();
564return;
565}
566/* --Methode-- */
567void NamedObjMgr::DisplaySurf3D(string const& nom, string dopt)
568{
569NObjMgrAdapter* obja=NULL;
570obja = GetObjAdapter(nom);
571if (obja == NULL) {
572 cout << "NamedObjMgr::DisplayImage() Error , Pas d'objet de nom " << nom << endl;
573 return;
574}
575if (!myImgApp) return;
576
577P2DArrayAdapter* arr = obja->Get2DArray(dopt);
578
579if (!arr) {
580 string ctyp = typeid(*(obja->GetDataObj())).name();
581 cout << "NamedObjMgr::DisplaySurf3D() Error , Non supporte pour " << ctyp << endl;
582 return;
583 }
584
585if ((arr->XSize() > 250) || (arr->YSize() > 250)) {
586 cout << "NamedObjMgr::DisplaySurf3D() Error , 2D-Array(" << arr->XSize()
587 << "x" << arr->YSize() << ") trop grand (max=250x250)" << endl;
588 delete arr;
589 return;
590 }
591
592int wrsid = 0;
593bool fgsr = true;
594int opt = servnobjm->DecodeDispOption(dopt, fgsr);
595PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
596wrsid = myImgApp->Disp3DDrawer(sdr, nom, opt);
597if(wrsid >= 0) {
598 NObjList::iterator it = myObjs->find(nom);
599 if (it == myObjs->end()) return;
600 (*it).second.wrsid.push_back(wrsid);
601 }
602
603if (fgsr) myImgApp->RestoreGraphicAtt();
604return;
605}
606
607/* --Methode-- */
608void NamedObjMgr::DisplayNT(string const& nom, string& nmx, string& nmy, string& nmz,
609 string& erx, string& ery, string& erz, string dopt)
610{
611AnyDataObj* obj=GetObj(nom);
612if (obj == NULL) {
613 cout << "NamedObjMgr::DisplayNT() Error , Pas d'objet de nom " << nom << endl;
614 return;
615}
616if (!myImgApp) return;
617
618if (typeid(*obj) != typeid(NTuple)) {
619 string ctyp = typeid(*obj).name();
620 cout << "NamedObjMgr::DisplayNT() Error , Objet n'est pas un NTuple " << ctyp << endl;
621 return;
622 }
623
624int wrsid = 0;
625bool fgsr = true;
626int opt = servnobjm->DecodeDispOption(dopt, fgsr);
627
628if (nmz.length()>0) { // Display 3D
629 PINTuple3D* pin = new PINTuple3D(((NTuple*)obj), false);
630 pin->SelectXYZ(nmx.c_str(), nmy.c_str(), nmz.c_str());
631 pin->SelectErrBar(erx.c_str(), ery.c_str(), erz.c_str());
632 string titre = nmz + "%" + nmy + "%" + nmz;
633 wrsid = myImgApp->Disp3DDrawer(pin, nom, opt, titre);
634}
635else {
636 PINTuple* pin = new PINTuple(((NTuple*)obj), false);
637 pin->SelectXY(nmx.c_str(), nmy.c_str());
638 pin->SelectErrBar(erx.c_str(), ery.c_str());
639 string titre = nmy + "%" + nmz;
640 wrsid = myImgApp->DispScDrawer( (PIDrawer*)pin, nom, opt, titre);
641 }
642
643if(wrsid >= 0) {
644 NObjList::iterator it = myObjs->find(nom);
645 if (it == myObjs->end()) return;
646 (*it).second.wrsid.push_back(wrsid);
647 }
648
649if (fgsr) myImgApp->RestoreGraphicAtt();
650return;
651}
652
653/* --Methode-- cmv 13/10/98 */
654void NamedObjMgr::DisplayGFD(string const& nom, string& numvarx, string& numvary, string& err, string dopt)
655// Pour le display 2D ou 3D d'un ``GeneralFitData''.
656//| nom = nom de l'objet GeneralFitData a representer.
657//| numvarx = numero (nombre entier) de la 1ere variable d'abscisse.
658//| numvary = numero (nombre entier) de la 2sd variable d'abscisse (3D).
659//| Pour le display 2D, numvary="" string vide.
660//| err = qu'elles erreurs faut il representer ?
661//| - 2D : x y xy (display y=f(x))
662//| - 3D : x y z xy xz yz xzy (display z=f(x,y))
663//| Ceci n'est suivi que si on a PI_NotDefLineAtt, sinon toutes
664//| les barres d'erreurs sont representees.
665//| opt = options generales pour le display.
666{
667AnyDataObj* obj=GetObj(nom);
668if(obj == NULL)
669 {cout << "NamedObjMgr::DisplayGFD() Error , Pas d'objet de nom " << nom << endl;
670 return;}
671if(!myImgApp) return;
672if(typeid(*obj) != typeid(GeneralFitData))
673 {string ctyp = typeid(*obj).name();
674 cout<<"NamedObjMgr::DisplayGFD() Error , Objet n'est pas un GeneralFitData "<<ctyp<<endl;
675 return;}
676
677// Decodage des options classiques
678bool fgsr = true;
679int opt = servnobjm->DecodeDispOption(dopt, fgsr);
680// Decodage des erreurs a representer
681bool errx=false, erry=false, errz=false;
682if(err.length()>0) {
683 for(int i=0;i<err.length();i++)
684 if (err[i]=='x' || err[i]=='X') errx = true;
685 else if(err[i]=='y' || err[i]=='Y') erry = true;
686 else if(err[i]=='z' || err[i]=='Z') errz = true;
687}
688// Decodage des numeros de variables en abscisse
689int numvx=-1, numvy=-1;
690if(numvarx.length()>0) numvx = atoi(numvarx.c_str());
691if(numvary.length()>0) numvy = atoi(numvary.c_str());
692
693int wrsid = 0;
694if(numvy>=0) { // Display 3D
695 PIGenFitDat3D* pigfd = new PIGenFitDat3D(((GeneralFitData*)obj),false);
696 pigfd->SelectXY(numvx,numvy);
697 pigfd->SelectErrBar(errx,erry,errz);
698 wrsid = myImgApp->Disp3DDrawer(pigfd,nom,opt);
699} else { // Display 2D
700 PIGenFitDat* pigfd = new PIGenFitDat(((GeneralFitData*)obj),false);
701 pigfd->SelectX(numvx);
702 pigfd->SelectErrBar(errx,erry);
703 wrsid = myImgApp->DispScDrawer((PIDrawer*)pigfd,nom,opt);
704}
705
706if(wrsid >= 0) {
707 NObjList::iterator it = myObjs->find(nom);
708 if (it == myObjs->end()) return;
709 (*it).second.wrsid.push_back(wrsid);
710}
711if (fgsr) myImgApp->RestoreGraphicAtt();
712return;
713}
714
715/* --Methode--
716void NamedObjMgr::DisplayImage(string const& nom, string dopt)
717{
718 cout << "NamedObjMgr::DisplayImage() a faire ! " << endl;
719}
720*/
721
722
723
724
725/* --Methode-- */
726void NamedObjMgr::SetGraphicAttributes(string gratt)
727{
728bool fg = false;
729servnobjm->DecodeDispOption(gratt, fg);
730}
731/* --Methode-- */
732void NamedObjMgr::SetGraphicWinZone(int nzx, int nzy, bool fcr)
733{
734if (!myImgApp) return;
735if (fcr) myImgApp->CreateGraphWin(nzx, nzy);
736else myImgApp->SetZone(nzx, nzy);
737}
738
739/* --Methode-- */
740void NamedObjMgr::DisplayPoints2D(string const& nom, string& expx, string& expy,
741 string& experrx, string& experry,
742 string& expcut, string dopt)
743{
744NObjMgrAdapter* obja=NULL;
745obja = GetObjAdapter(nom);
746if (obja == NULL) {
747 cout << "NamedObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl;
748 return;
749 }
750if (!myImgApp) return;
751
752// Creation NTuple
753char* ntn[4] = {"expx","expy","expex","expey",};
754NTuple* nt = NULL;
755bool haserr = false;
756
757if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) { haserr = true; nt = new NTuple(2, ntn); }
758else { haserr = false; experrx = experry = "0."; nt = new NTuple(2, ntn); }
759
760servnobjm->Nobj_ComputeExpressions(obja, expx, expy, experrx, experry, expcut, nt, NULL, NULL);
761
762if (nt->NEntry() < 1) {
763 cout << "NamedObjMgr::DisplayPoints2D() Warning Zero points satisfy cut !" << endl;
764 delete nt;
765 return;
766 }
767
768// nt->Show();
769// nt->Print(0,10);
770PINTuple* pin = new PINTuple(nt, true);
771pin->SelectXY(ntn[0], ntn[1]);
772if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
773
774bool fgsr = true;
775int opt = servnobjm->DecodeDispOption(dopt, fgsr);
776string titre = nom + ":" + expy + "%" + expx;
777myImgApp->DispScDrawer( (PIDrawer*)pin, titre, opt);
778if (fgsr) myImgApp->RestoreGraphicAtt();
779return;
780}
781
782/* --Methode-- */
783void NamedObjMgr::DisplayPoints3D(string const& nom, string& expx, string& expy, string& expz,
784 string& expcut, string dopt)
785{
786NObjMgrAdapter* obja=NULL;
787obja = GetObjAdapter(nom);
788if (obja == NULL) {
789 cout << "NamedObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl;
790 return;
791 }
792if (!myImgApp) return;
793
794char* ntn[3] = {"expx","expy","expz"};
795NTuple* nt = new NTuple(3,ntn); // Creation NTuple
796
797string expwt = "1.";
798servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expwt, expcut, nt, NULL, NULL);
799
800if (nt->NEntry() < 1) {
801 cout << "NamedObjMgr::DisplayPoints3D() Warning Zero points satisfy cut !" << endl;
802 delete nt;
803 return;
804 }
805nt->Show();
806nt->Print(0,10);
807PINTuple3D* pin = new PINTuple3D(nt, true);
808pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
809bool fgsr = true;
810int opt = servnobjm->DecodeDispOption(dopt, fgsr);
811
812// Pour plot a partir de DispScDrawer
813// string nomdisp = "_NT3D_";
814// myImgApp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
815// Pour plot a partir de Disp3DDrawer
816string titre = nom + ":" + expy + "%" + expx;
817myImgApp->Disp3DDrawer(pin, titre, opt);
818
819if (fgsr) myImgApp->RestoreGraphicAtt();
820return;
821}
822
823/* --Methode-- */
824void NamedObjMgr::ProjectH1(string const& nom, string& expx, string& expwt, string& expcut, string& nomh1, string dopt)
825{
826NObjMgrAdapter* obja=NULL;
827obja = GetObjAdapter(nom);
828if (obja == NULL) {
829 cout << "NamedObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl;
830 return;
831 }
832if (!myImgApp) return;
833
834Histo* h1 = NULL;
835NTuple* nt = NULL;
836AnyDataObj* oh = NULL;
837if (nomh1.length() > 0) oh=GetObj(nomh1);
838else nomh1 = "H1Proj";
839if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) ) h1 = (Histo*)oh; // Pas de remise a zero ! h1->Zero();
840else {
841 char* ntn[2]= {"hxval", "hwt"};
842 nt = new NTuple(2,ntn); // Creation NTuple
843 }
844string expz = "0.";
845servnobjm->Nobj_ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, nt, h1, NULL);
846
847if ((!h1) && (!nt)) return;
848if (!h1) {
849 if (nt->NEntry() < 1) {
850 cout << "NamedObjMgr::ProjectH1() Warning Zero points satisfy cut !" << endl;
851 delete nt;
852 return;
853 }
854 float xmin, xmax;
855 nt->GetMinMax(0, xmin, xmax);
856 h1 = new Histo(xmin, xmax, 100);
857 int k;
858 float* xn;
859 for(k=0; k<nt->NEntry(); k++) {
860 xn = nt->GetVec(k);
861 h1->Add(xn[0], xn[1]);
862 }
863 delete nt;
864 AddObj(h1, nomh1);
865 }
866
867DisplayObj(nomh1, dopt);
868return;
869}
870
871/* --Methode-- */
872void NamedObjMgr::ProjectH2(string const& nom, string& expx, string& expy, string& expwt, string& expcut,
873 string& nomh2, string dopt)
874{
875NObjMgrAdapter* obja=NULL;
876obja = GetObjAdapter(nom);
877if (obja == NULL) {
878 cout << "NamedObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl;
879 return;
880 }
881if (!myImgApp) return;
882
883Histo2D* h2 = NULL;
884NTuple* nt = NULL;
885AnyDataObj* oh = NULL;
886if (nomh2.length() > 0) oh=GetObj(nomh2);
887else nomh2 = "H2Proj";
888if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) ) h2 = (Histo2D*)oh; // Pas de remise a zero ! h2->Zero();
889else {
890 char* ntn[3]= {"hxval", "hyval", "hwt"};
891 nt = new NTuple(3,ntn); // Creation NTuple
892 }
893string expz = "0.";
894servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, h2);
895
896if ((!h2) && (!nt)) return;
897if (!h2) {
898 if (nt->NEntry() < 1) {
899 cout << "NamedObjMgr::ProjectH2() Warning Zero points satisfy cut !" << endl;
900 delete nt;
901 return;
902 }
903 float xmin, xmax, ymin, ymax;
904 nt->GetMinMax(0, xmin, xmax);
905 nt->GetMinMax(0, ymin, ymax);
906 h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
907 int k;
908 float* xn;
909 for(k=0; k<nt->NEntry(); k++) {
910 xn = nt->GetVec(k);
911 h2->Add(xn[0], xn[1], xn[2]);
912 }
913 delete nt;
914 AddObj(h2, nomh2);
915 }
916
917DisplayObj(nomh2, dopt);
918return;
919
920}
921
922/* --Methode-- cmv 13/10/98 */
923void NamedObjMgr::ProjectHProf(string const& nom, string& expx, string& expy, string& expwt, string& expcut,
924 string& nomprof, string dopt)
925// Pour remplir un ``GeneralFitData'' a partir de divers objets:
926//| nom = nom de l'objet a projeter dans un HProf.
927//| expx = expression X de definition du bin.
928//| expy = expression Y a additionner dans le bin.
929//| expwt = expression W du poids a additionner.
930//| expcut = expression du test de selection.
931//| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
932//| les limites Xmin,Xmax sont calculees automatiquement.
933//| sinon ce sont celles de l'objet preexistant.
934//| opt = options generales pour le display.
935{
936NObjMgrAdapter* obja=NULL;
937obja = GetObjAdapter(nom);
938if (obja == NULL) {
939 cout << "NamedObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl;
940 return;
941 }
942if (!myImgApp) return;
943
944HProf* hprof = NULL;
945NTuple* nt = NULL;
946AnyDataObj* oh = NULL;
947if (nomprof.length() > 0) oh=GetObj(nomprof);
948else nomprof = "ProfProj";
949if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) ) hprof = (HProf*)oh;
950else {
951 char* ntn[3]= {"hxval", "hyval", "hwt"};
952 nt = new NTuple(3,ntn); // Creation NTuple
953}
954string expz = "0.";
955servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, nt, NULL, NULL, hprof);
956
957if((!hprof) && (!nt)) return;
958if(!hprof) {
959 if (nt->NEntry() < 1) {
960 cout << "NamedObjMgr::ProjectHProf() Warning Zero points satisfy cut !" << endl;
961 delete nt;
962 return;
963 }
964 float xmin, xmax;
965 nt->GetMinMax(0, xmin, xmax);
966 hprof = new HProf(xmin, xmax, 100);
967 int k;
968 float* xn;
969 for(k=0; k<nt->NEntry(); k++) {
970 xn = nt->GetVec(k);
971 hprof->Add(xn[0], xn[1], xn[2]);
972 }
973 delete nt;
974 AddObj(hprof, nomprof);
975 }
976hprof->UpdateHisto();
977
978DisplayObj(nomprof, dopt);
979return;
980}
981
982/* --Methode-- */
983void NamedObjMgr::FillVect(string const& nom, string& expx, string& expcut, string& nomvec, string dopt)
984{
985NObjMgrAdapter* obja=NULL;
986obja = GetObjAdapter(nom);
987if (obja == NULL) {
988 cout << "NamedObjMgr::FillVect() Error , Pas d'objet de nom " << nom << endl;
989 return;
990 }
991if (!myImgApp) return;
992
993NTuple* nt = NULL;
994if (nomvec.length() < 1) nomvec = "VecFill";
995
996char* ntn[2]= {"vecval", "vecwt"};
997nt = new NTuple(1,ntn); // Creation NTuple
998
999string expwt = "1.";
1000string expz = "0.";
1001servnobjm->Nobj_ComputeExpressions(obja, expx, expz, expz, expwt, expcut, nt, NULL, NULL);
1002
1003if (!nt) return;
1004if (nt->NEntry() < 1) {
1005 cout << "NamedObjMgr::FillVect() Warning Zero points satisfy cut !" << endl;
1006 delete nt;
1007 return;
1008 }
1009
1010Vector* vec = new Vector(nt->NEntry());
1011int k;
1012float* xn;
1013for(k=0; k<nt->NEntry(); k++) {
1014 xn = nt->GetVec(k);
1015 (*vec)(k) = xn[0];
1016 }
1017delete nt;
1018AddObj(vec, nomvec);
1019DisplayObj(nomvec, dopt);
1020return;
1021}
1022
1023/* --Methode-- */
1024void NamedObjMgr::FillNT(string const& nom, string& expx, string& expy, string& expz, string& expt,
1025 string& expcut, string& nomnt)
1026{
1027NObjMgrAdapter* obja=NULL;
1028obja = GetObjAdapter(nom);
1029if (obja == NULL) {
1030 cout << "NamedObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl;
1031 return;
1032 }
1033if (!myImgApp) return;
1034
1035bool fgnnt = false;
1036NTuple* nt = NULL;
1037AnyDataObj* oh = NULL;
1038if (nomnt.length() > 0) oh=GetObj(nomnt);
1039else nomnt = "NTFill";
1040if ( (oh != NULL) && (typeid(*oh) == typeid(HProf)) ) {
1041 nt = (NTuple*)oh;
1042 if (nt->NVar() > 10) {
1043 cout << "NamedObjMgr::FillNT() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
1044 nt = NULL;
1045 }
1046 }
1047if (nt == NULL) {
1048 char* ntn[4]= {"x", "y","z","t"};
1049 nt = new NTuple(4,ntn); // Creation NTuple
1050 fgnnt = true;
1051 }
1052
1053servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, expt, expcut, nt, NULL, NULL);
1054
1055if (fgnnt) AddObj(nt, nomnt);
1056return;
1057
1058}
1059
1060/* --Methode-- cmv 13/10/98 */
1061void NamedObjMgr::FillGFD(string const& nom, string& expx, string& expy, string& expz,
1062 string& experr, string& expcut, string& nomgfd)
1063// Pour remplir un ``GeneralFitData'' a partir de divers objets:
1064//| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
1065//| Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
1066//| expx = expression X du GeneralFitData (1er abscisse)
1067//| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
1068//| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
1069//| experr = expression de l'erreur sur l'ordonnee Z
1070//| expcut = expression du test de selection
1071//| nomgfd = nom du GeneralFitData engendre (optionnel)
1072{
1073NObjMgrAdapter* obja=NULL;
1074obja = GetObjAdapter(nom);
1075if (obja == NULL) {
1076 cout << "NamedObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
1077 return;
1078 }
1079if(!myImgApp) return;
1080
1081// 2D ou 3D?
1082int nvar = 2;
1083if(expy.length()<=0) {nvar = 1; expy = "0.";}
1084
1085// $CHECK$ - cmv calculait le nombre d'entree ndata
1086// en fonction de chaque objet - Je l'ai vire Reza 11/05/99
1087
1088// Creation NTuple Buffer
1089char* ntn[4]= {"x","y","f","e"};
1090NTuple*nt = new NTuple(4,ntn);
1091
1092// Remplissage NTuple buffer
1093servnobjm->Nobj_ComputeExpressions(obja, expx, expy, expz, experr, expcut, nt, NULL, NULL);
1094if(nt->NEntry() < 1)
1095 {cout<<"NamedObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl;
1096 delete nt; return;}
1097
1098//Remplissage de la structure GeneraFitData
1099if (nt->NEntry() <= 0) {
1100 cout<<"NamedObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
1101 delete nt;
1102 return;
1103 }
1104
1105GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
1106int k;
1107float* xn;
1108for(k=0; k<nt->NEntry(); k++) {
1109 xn = nt->GetVec(k);
1110 gfd->AddData(xn,xn[2],xn[3]);
1111}
1112
1113// Menage et table d'objets
1114delete nt;
1115AddObj(gfd, nomgfd);
1116return;
1117}
1118
1119/* --Methode-- */
1120void NamedObjMgr::PlotFunc(string& expfunc, float xmin, float xmax, int np, string dopt)
1121{
1122FILE *fip;
1123string fname = (*TmpDir) + "func1_pia_dl.c";
1124string fnamer = (*TmpDir) + "func1_pia_dl";
1125string cmd;
1126int rc;
1127
1128if (!myImgApp) return;
1129
1130cmd = "rm -f " + fname;
1131rc = system(cmd.c_str());
1132printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
1133
1134if ((fip = fopen(fname.c_str(), "w")) == NULL) {
1135 string sn = fname;
1136 cout << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl;
1137 return;
1138 }
1139
1140// constitution du fichier a compiler
1141fputs("#include <math.h> \n", fip);
1142fputs("double func1_pia_dl_func(double x) \n{\n", fip);
1143fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
1144fclose(fip);
1145
1146DlFunctionOfX f = (DlFunctionOfX) servnobjm->LinkFunctionFromFile(fnamer, "func1_pia_dl_func");
1147if (!f) return;
1148PlotFunc(f, xmin, xmax, np, dopt);
1149servnobjm->CloseDLL();
1150return;
1151}
1152
1153/* --Methode-- */
1154void NamedObjMgr::PlotFunc2D(string& expfunc, float xmin, float xmax, float ymin, float ymax,
1155 int npx, int npy, string dopt)
1156{
1157FILE *fip;
1158string fname = (*TmpDir) + "func2_pia_dl.c";
1159string fnamer = (*TmpDir) + "func2_pia_dl";
1160string cmd;
1161int rc;
1162
1163if (!myImgApp) return;
1164
1165cmd = "rm " + fname;
1166rc = system(cmd.c_str());
1167printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
1168
1169if ((fip = fopen(fname.c_str(), "w")) == NULL) {
1170 string sn = fname;
1171 cout << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl;
1172 return;
1173 }
1174
1175// constitution du fichier a compiler
1176fputs("#include <math.h> \n", fip);
1177fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
1178fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
1179fclose(fip);
1180
1181DlFunctionOfXY f = (DlFunctionOfXY) servnobjm->LinkFunctionFromFile(fnamer, "func2_pia_dl_func");
1182if (!f) return;
1183PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
1184servnobjm->CloseDLL();
1185return;
1186}
1187
1188/* --Methode-- */
1189void NamedObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)
1190{
1191if (!myImgApp) return;
1192
1193int k;
1194if (np < 1) np = 1;
1195if (xmax <= xmin) xmax = xmin+1.;
1196Vector* vpy = new Vector(np);
1197
1198double xx;
1199double dx = (xmax-xmin)/np;
1200TRY {
1201 for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
1202} CATCH(merr) {
1203 fflush(stdout);
1204 cout << endl;
1205 cerr << endl;
1206 string es = PeidaExc(merr);
1207 cerr << "NamedObjMgr::PlotFunc() Exception :" << merr << es;
1208 delete vpy;
1209 vpy = NULL;
1210 } ENDTRY;
1211
1212
1213if (vpy) {
1214 string nom = "Func";
1215 AddObj(vpy, nom);
1216 P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);
1217 vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
1218 PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ;
1219 bool fgsr = true;
1220 dopt = "thinline," + dopt;
1221 int opt = servnobjm->DecodeDispOption(dopt, fgsr);
1222 int wrsid = myImgApp->DispScDrawer(dr, nom, opt);
1223 if(wrsid >= 0) {
1224 NObjList::iterator it = myObjs->find(nom);
1225 if (it == myObjs->end()) return;
1226 (*it).second.wrsid.push_back(wrsid);
1227 }
1228 if (fgsr) myImgApp->RestoreGraphicAtt();
1229 }
1230
1231return;
1232}
1233
1234/* --Methode-- */
1235void NamedObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax,
1236 int npx, int npy, string dopt)
1237{
1238if (!myImgApp) return;
1239
1240if (npx < 1) npx = 1;
1241if (npy < 1) npy = 1;
1242if (xmax <= xmin) xmax = xmin+1.;
1243if (ymax <= ymin) ymax = ymin+1.;
1244
1245Matrix* mtx = new Matrix(npy, npx);
1246
1247int i,j;
1248double xx, yy;
1249double dx = (xmax-xmin)/npx;
1250double dy = (ymax-ymin)/npy;
1251// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
1252TRY {
1253 for(j=0; j<npy; j++) {
1254 yy = ymin+dy*j;
1255 for(i=0; i<npx; i++) {
1256 xx = xmin+dx*i;
1257 (*mtx)(j, i) = f(xx, yy);
1258 }
1259 }
1260} CATCH(merr) {
1261 fflush(stdout);
1262 cout << endl;
1263 cerr << endl;
1264 string es = PeidaExc(merr);
1265 cerr << "NamedObjMgr::PlotFunc2D() Exception :" << merr << es;
1266 delete mtx; mtx = NULL;
1267 } ENDTRY;
1268
1269if (mtx) {
1270 string nom = "Func2";
1271 AddObj(mtx, nom);
1272 DisplaySurf3D(nom, dopt);
1273 }
1274
1275return;
1276}
1277
1278///////////////////// Fit 1D et 2D //////////////////////////
1279/* --Function static propre aux routines de fit 1D et 2D-- cmv 13/10/98 */
1280struct DFOptions {
1281 int okres, okfun;
1282 int polcx,polcy; double xc,yc;
1283 double err_e, err_E;
1284 double stc2;
1285 int lp,lpg;
1286 int i1,i2,j1,j2;
1287};
1288typedef struct DFOptions DFOPTIONS;
1289static void DecodeFitsOptions(string par,string step,string min,string max,string opt
1290 ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O);
1291void DecodeFitsOptions(string par,string step,string min,string max,string opt
1292 ,Vector& Par,Vector& Step,Vector& Min,Vector& Max,DFOPTIONS& O)
1293//| Pour decoder les "string" et remplir les vecteurs du fit (cf commentaires dans Fit1D)
1294{
1295// set des vecteurs et decodage des string correspondantes
1296int NParMax = 100;
1297Par.Realloc(NParMax); Step.Realloc(NParMax);
1298Min.Realloc(NParMax); Max.Realloc(NParMax);
1299{
1300 Vector* v; string* s;
1301 {for(int i=0;i<NParMax;i++) {Par(i)=0.; Step(i)=1.; Min(i)=1.; Max(i)=-1.;}}
1302 for(int j=0;j<4;j++) {
1303 if(j==0) {v=&Par; s=&par;}
1304 else if(j==1) {v=&Step; s=&step;}
1305 else if(j==2) {v=&Min; s=&min;}
1306 else if(j==3) {v=&Max; s=&max;}
1307 if(s->length()>0) *s += ",";
1308 for(int i=0;i<NParMax;i++) {
1309 if(s->length()<=0) break;
1310 sscanf(s->c_str(),"%lf",&(*v)(i));
1311 size_t p = s->find_first_of(',') + 1;
1312 if(p>=s->length()) *s = ""; else *s = s->substr(p);
1313 }
1314 }
1315}
1316
1317// Decodage de options de opt
1318O.okres = O.okfun = 0;
1319O.polcx = O.polcy = 0;
1320O.xc = O.yc = 0.;
1321O.stc2 = 1.e-3;
1322O.err_e = O.err_E = -1.;
1323O.lp = 1; O.lpg = 0;
1324O.i1 = O.j1 = O.i2 = O.j2 = -1;
1325
1326if(opt.length()<=0) return;
1327opt = "," + opt + ",";
1328
1329if(strstr(opt.c_str(),",r,")) O.okres = 1; // residus
1330if(strstr(opt.c_str(),",f,")) O.okfun = 1; // fonction fittee
1331if(strstr(opt.c_str(),",x")) { // Demande de centrage (fit X=x-xc)
1332 O.polcx = 2; // Le centrage est calcule automatiquement
1333 size_t p = opt.find(",x");
1334 size_t q = opt.find_first_of(',',p+1);
1335 string dum = opt.substr(p,q-p);
1336 if(dum.length()>2) {
1337 sscanf(dum.c_str(),",x%lf",&O.xc);
1338 O.polcx = 1; // Le centrage est fixe par la valeur lue
1339 }
1340}
1341if(strstr(opt.c_str(),",y")) { // Demande de centrage (fit Y=y-yc)
1342 O.polcy = 2; // Le centrage est calcule automatiquement
1343 size_t p = opt.find(",y");
1344 size_t q = opt.find_first_of(',',p+1);
1345 string dum = opt.substr(p,q-p);
1346 if(dum.length()>2) {
1347 sscanf(dum.c_str(),",y%lf",&O.yc);
1348 O.polcy = 1; // Le centrage est fixe par la valeur lue
1349 }
1350}
1351if(strstr(opt.c_str(),",E")) { // Erreurs imposees a "sqrt(val)" ou "aa.b*sqrt(val)"
1352 size_t p = opt.find(",E");
1353 size_t q = opt.find_first_of(',',p+1);
1354 string dum = opt.substr(p,q-p);
1355 if(dum.length()>2) sscanf(dum.c_str(),",E%lf",&O.err_E);
1356 if(O.err_E<=0.) O.err_E = 1.;
1357 O.err_e=-1.;
1358}
1359if(strstr(opt.c_str(),",e")) { // Erreurs imposees a "1" ou "aa.b"
1360 size_t p = opt.find(",e");
1361 size_t q = opt.find_first_of(',',p+1);
1362 string dum = opt.substr(p,q-p);
1363 if(dum.length()>2) sscanf(dum.c_str(),",e%lf",&O.err_e);
1364 if(O.err_e<=0.) O.err_e = 1.;
1365 O.err_E=-1.;
1366}
1367if(strstr(opt.c_str(),",X")) { // Valeur du StopChi2
1368 size_t p = opt.find(",X");
1369 size_t q = opt.find_first_of(',',p+1);
1370 string dum = opt.substr(p,q-p);
1371 if(dum.length()>2) sscanf(dum.c_str(),",X%lf",&O.stc2);
1372 if(O.stc2<=0.) O.stc2 = 1.e-3;
1373}
1374if(strstr(opt.c_str(),",l")) { // niveau de print
1375 size_t p = opt.find(",l");
1376 size_t q = opt.find_first_of(',',p+1);
1377 string dum = opt.substr(p,q-p);
1378 float ab;
1379 if(dum.length()>2) sscanf(dum.c_str(),",l%f",&ab);
1380 if(ab<0) ab = 0.;
1381 O.lp = (int) ab; O.lpg = (int) 10.*(ab-O.lp);
1382}
1383if(strstr(opt.c_str(),",I")) { // intervalle de fit selon X
1384 size_t p = opt.find(",I");
1385 size_t q = opt.find_first_of(',',p+1);
1386 string dum = opt.substr(p,q-p);
1387 if(dum.length()>2) sscanf(dum.c_str(),",I%d/%d",&O.i1,&O.i2);
1388}
1389if(strstr(opt.c_str(),",J")) { // intervalle de fit selon Y
1390 size_t p = opt.find(",J");
1391 size_t q = opt.find_first_of(',',p+1);
1392 string dum = opt.substr(p,q-p);
1393 if(dum.length()>2) sscanf(dum.c_str(),",J%d/%d",&O.j1,&O.j2);
1394}
1395return;
1396}
1397
1398/* --Methode-- cmv 13/10/98 */
1399void NamedObjMgr:: Fit12D(string const& nom, string& func,
1400 string par,string step,string min,string max,
1401 string opt)
1402//| --------------- Fit d'objets a 1 et 2 dimensions ---------------
1403//| nom : nom de l'objet qui peut etre:
1404//| fit-1D: Vector,Histo1D,HProf ou GeneraFitData(1D)
1405//| fit-2D: Matrix,Histo2D,Imagexx ou GeneraFitData(2D)
1406//| func : pnn = fit polynome degre nn avec classe Poly (lineaire) 1D ou 2D
1407//| : Pnn = fit polynome degre nn avec GeneralFit (non-lineaire) 1D ou 2D
1408//| : gnn = fit gaussienne (hauteur) + polynome de degre nn 1D
1409//| : g = fit gaussienne (hauteur) 1D
1410//| : enn = fit exponentielle + polynome de degre nn 1D
1411//| : e = fit exponentielle 1D
1412//| : Gnn = fit gaussienne (volume) + polynome de degre nn 1D
1413//| : G = fit gaussienne (volume) 1D
1414//| : = fit gaussienne+fond (volume) 2D
1415//| : Gi = fit gaussienne+fond integree (volume) 2D
1416//| : d = fit DL de gaussienne+fond (volume) 2D
1417//| : di = fit DL de gaussienne+fond integree (volume) 2D
1418//| : D = fit DL de gaussienne+fond avec coeff variable p6 (volume) 2D
1419//| : Di = fit DL de gaussienne+fond integree avec coeff variable p6 (volume) 2D
1420//| : M = fit Moffat+fond (expos=p6) (volume) 2D
1421//| : Mi = fit Moffat+fond integree (expos=p6) (volume) 2D
1422//| par : p1,...,pn valeur d'initialisation des parametres (def=0)
1423//| step : s1,...,sn valeur des steps de depart (def=1)
1424//| min : m1,...,mn valeur des minima (def=1)
1425//| max : M1,...,Mn valeur des maxima (def=-1) (max<=min : pas de limite)
1426//| opt : options "Eaa.b,eaa.b,f,r,caa.b,Xaa.b"
1427//| f = generation d'un Objet identique contenant la fonction fittee
1428//| r = generation d'un Objet identique contenant les residus
1429//| Xaa.b = aa.b valeur du DXi2 d'arret (def=1.e-3)
1430//| la.b = niveau "a.b" de print: a=niveau de print Fit1/2D
1431//| b=niveau de debug GeneralFit
1432//| Ii1/i2 numeros des bins X de l'histos utilises pour le fit [i1,i2]
1433//|2D Jj1/j2 numeros des bins Y de l'histos utilises pour le fit [j1,j2]
1434//| - L'erreur est celle associee a l'objet si existe, 1 sinon sauf si
1435//| E = erreur prise comme la racine de la valeur a fitter
1436//| Eaa.b = erreur prise aa.b*sqrt(val)
1437//| e = erreur prise egale a 1 pour toutes les valeurs
1438//| eaa.b = erreur prise egale a aa.b
1439//| xaa.b = demande de centrage: on fit x-aa.b au lieu de x)
1440//| x = demande de centrage: on fit x-xc au lieu de x
1441//| avec xc=abscisse du milieu de l'histogramme
1442//| Actif pour: exp+poly 1D, poly 1D
1443//| gauss+poly 1D (mais xc est le centre de la gaussienne)
1444//|2D yaa.b et y = idem "xaa.b et x" mais pour y
1445{
1446AnyDataObj* obj=GetObj(nom);
1447if (obj == NULL) {
1448 cout<<"NamedObjMgr::Fit12D() Error , Pas d'objet de nom "<<nom<<endl;
1449 return;
1450}
1451if (!myImgApp) return;
1452if(func.length()<=0)
1453 {cout<<"NamedObjMgr::Fit12D() Donnez un nom de fonction a fitter."<<endl;
1454 return;}
1455string ctyp = typeid(*obj).name();
1456
1457int ndim = 0, nbinx=0, nbiny=0, ndata = 0;
1458Vector* v = NULL; Histo* h = NULL;
1459Matrix* m = NULL; Histo2D* h2 = NULL; RzImage* im = NULL;
1460GeneralFitData* g = NULL;
1461
1462 // 1D
1463if (typeid(*obj) == typeid(Vector)) {
1464 ndim = 1;
1465 v = (Vector*) obj; nbinx = v->NElts(); nbiny = 1;
1466 }
1467else if ( (typeid(*obj) == typeid(HProf)) || (typeid(*obj) == typeid(Histo)) ) {
1468 ndim = 1;
1469 h = (Histo*) obj; nbinx = h->NBins(); nbiny = 1;
1470 }
1471else if (typeid(*obj) == typeid(Matrix)) {
1472 ndim = 2;
1473 m = (Matrix*) obj; nbinx = m->NCol(); nbiny = m->NRows();
1474 }
1475else if (typeid(*obj) == typeid(Histo2D)) {
1476 ndim = 2;
1477 h2 = (Histo2D*) obj; nbinx = h2->NBinX(); nbiny = h2->NBinY();
1478 }
1479else if (typeid(*obj) == typeid(GeneralFitData)) {
1480 g = (GeneralFitData*) obj; nbinx = g->NData(); nbiny = 1;
1481 if( g->NVar()==1) ndim = 1;
1482 else if(g->NVar()==2) ndim = 2;
1483 else {
1484 cout<<"GeneralFitData ne peut avoir que 1 ou 2 variables d'abscisse: "
1485 <<((GeneralFitData*) obj)->NVar()<<endl; return; }
1486 }
1487else if (dynamic_cast<RzImage*>(obj)) {
1488 ndim = 2;
1489 im = (RzImage*) obj; nbinx = im->XSize(); nbiny = im->YSize();
1490 }
1491else {
1492 cout<<"NamedObjMgr::Fit12D() Error , Objet n'est pas un "
1493 <<"Histo1D/HProf/Vector/Histo2D/Image/Matrix/GeneralFitData "<<ctyp<<endl;
1494 return;
1495 }
1496
1497ndata = nbinx*nbiny;
1498if(ndata<=0)
1499 {cout<<"L'objet a "<<nbinx<<","<<nbiny<<" bins ("<<ndata<<")"<<endl; return;}
1500
1501// Decodage des options et des parametres, mise en forme
1502Vector Par(1); Vector Step(1); Vector Min(1); Vector Max(1); DFOPTIONS O;
1503DecodeFitsOptions(par,step,min,max,opt,Par,Step,Min,Max,O);
1504O.i1 = (O.i1<0||O.i1>=nbinx)? 0: O.i1;
1505O.i2 = (O.i2<0||O.i2>=nbinx||O.i2<O.i1)? nbinx-1: O.i2;
1506if(ndim>=2) {
1507 O.j1 = (O.j1<0||O.j1>=nbiny)? 0: O.j1;
1508 O.j2 = (O.j2<0||O.j2>=nbiny||O.j2<O.j1)? nbiny-1: O.j2;
1509} else O.j2 = O.j1 = 0;
1510if(O.polcx==2) {
1511 if(v||m) O.xc = (O.i2-O.i1+1)/2.;
1512 else if(h) O.xc = (h->XMin()+h->XMax())/2.;
1513 else if(h2) O.xc = (h2->XMin()+h2->XMax())/2.;
1514 else if(g) {double mini,maxi; g->GetMinMax(2,mini,maxi); O.xc=(mini+maxi)/2.;}
1515 else if(im) {O.xc = im->XOrg() * im->XPxSize()*(O.i2-O.i1+1)/2.;}
1516}
1517if(O.polcy==2 && ndim>=2) {
1518 if(m) O.yc = (O.j2-O.j1+1)/2.;
1519 if(h2) O.yc = (h2->YMin()+h2->YMax())/2.;
1520 if(g) {double mini,maxi; g->GetMinMax(12,mini,maxi); O.yc=(mini+maxi)/2.;}
1521 if(im) {O.yc = im->YOrg() * im->YPxSize()*(O.j2-O.j1+1)/2.;}
1522}
1523if(O.lp>0)
1524 cout<<"Fit["<<nbinx<<","<<nbiny<<"] ("<<ndata<<") dim="<<ndim<<":"
1525 <<" Int=["<<O.i1<<","<<O.i2<<"],["<<O.j1<<","<<O.j2<<"]"<<endl
1526 <<" Cent="<<O.polcx<<","<<O.polcy<<","<<O.xc<<"+x"<<","<<O.yc<<"+y"
1527 <<" TypE="<<O.err_e<<","<<O.err_E
1528 <<" StpX2="<<O.stc2
1529 <<" lp,lpg="<<O.lp<<","<<O.lpg<<endl;
1530
1531///////////////////////////////////
1532// Remplissage de GeneralFitData //
1533///////////////////////////////////
1534GeneralFitData mydata(ndim,ndata,0);
1535{for(int i=O.i1;i<=O.i2;i++) for(int j=O.j1;j<=O.j2;j++) {
1536 double x,y,f,e;
1537
1538 if(v)
1539 {x= (double) i; f=(*v)(i); e=1.;}
1540 else if(h)
1541 {x=h->BinCenter(i); f=(*h)(i); e=(h->HasErrors())?h->Error(i):1.;}
1542 else if(m)
1543 {x=(double) i; y=(double) j; f=(*m)(j,i); e=1.;}
1544 else if(h2)
1545 {float xf,yf; h2->BinCenter(i,j,xf,yf); x=(double)xf; y=(double)yf;
1546 f=(*h2)(i,j); e=(h2->HasErrors())?h2->Error(i,j):1.;}
1547 else if(im)
1548 {x=im->XOrg()+(i+0.5)*im->XPxSize(); y=im->YOrg()+(j+0.5)*im->YPxSize();
1549 f=im->DValue(i,j); e=1.;}
1550 else if(g&&ndim==1) {x= g->X(i); f=g->Val(i); e=g->EVal(i);}
1551 else if(g&&ndim==2) {x= g->X(i); y= g->Y(i); f=g->Val(i); e=g->EVal(i);}
1552 else x=y=f=e=0.;
1553
1554 // Gestion des erreurs a utiliser
1555 if(O.err_e>0.) e=O.err_e;
1556 else if(O.err_E>0.) {e=(y<-1.||y>1.)?O.err_E*sqrt(fabs(y)):O.err_E;}
1557
1558 // Remplissage de generalfit
1559 if(func[0]=='p') {x -= O.xc; if(ndim>=2) y -= O.yc;}
1560 if(ndim==1) mydata.AddData1(x,f,e);
1561 else if(ndim==2) mydata.AddData2(x,y,f,e);
1562}}
1563if(mydata.NData()<=0)
1564 {cout<<"Pas de donnees dans GeneralFitData: "<<mydata.NData()<<endl;
1565 return;}
1566if(O.lpg>1) {
1567 mydata.PrintStatus();
1568 mydata.PrintData(0);
1569 mydata.PrintData(mydata.NData()-1);
1570}
1571
1572////////////////////////////////////////////
1573// Identification de la fonction a fitter //
1574////////////////////////////////////////////
1575GeneralFunction* myfunc = NULL;
1576if(func[0]=='p' && ndim==1) {
1577 // Fit de polynome sans passer par les GeneralFit
1578 int degre = 0;
1579 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1580 cout<<"Fit (lineaire) 1D polynome de degre "<<degre<<endl;
1581 Poly p1(0);
1582 double c2rl = mydata.PolFit(0,p1,degre);
1583 cout<<"C2r_lineaire = "<<c2rl<<endl;
1584 if(O.lp>0) cout<<p1<<endl;
1585 return;
1586
1587} else if(func[0]=='P' && ndim==1) {
1588 // Fit de polynome
1589 int degre = 0;
1590 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1591 cout<<"Fit polynome 1D de degre "<<degre<<endl;
1592 Polyn1D* myf = new Polyn1D(degre,O.xc);
1593 myfunc = myf;
1594
1595} else if(func[0]=='e' && ndim==1) {
1596 // Fit d'exponentielle
1597 int degre =-1;
1598 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1599 cout<<"Fit d'exponentielle+polynome 1D de degre "<<degre<<endl;
1600 Exp1DPol* myf;
1601 if(degre>=0) myf = new Exp1DPol((unsigned int)degre,O.xc);
1602 else myf = new Exp1DPol(O.xc);
1603 myfunc = myf;
1604
1605} else if(func[0]=='g' && ndim==1) {
1606 // Fit de gaussienne en hauteur
1607 int degre =-1;
1608 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1609 cout<<"Fit de Gaussienne_en_hauteur+polynome 1D de degre "<<degre<<endl;
1610 Gauss1DPol* myf;
1611 if(degre>=0) myf = new Gauss1DPol((unsigned int)degre,((O.polcx)?true:false));
1612 else { bool bfg = (O.polcx)?true:false; myf = new Gauss1DPol(bfg); }
1613 myfunc = myf;
1614
1615} else if(func[0]=='G' && ndim==1) {
1616 // Fit de gaussienne en volume
1617 int degre =-1;
1618 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1619 cout<<"Fit de Gaussienne_en_volume+polynome 1D de degre "<<degre<<endl;
1620 GaussN1DPol* myf;
1621 if(degre>=0) myf = new GaussN1DPol((unsigned int)degre,((O.polcx)?true:false));
1622 else { bool bfg = (O.polcx)?true:false; myf = new GaussN1DPol(bfg); }
1623 myfunc = myf;
1624
1625} else if(func[0]=='p' && ndim==2) {
1626 // Fit de polynome 2D sans passer par les GeneralFit
1627 int degre = 0;
1628 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1629 cout<<"Fit (lineaire) polynome 2D de degre "<<degre<<endl;
1630 Poly2 p2(0);
1631 double c2rl = mydata.PolFit(0,1,p2,degre);
1632 cout<<"C2r_lineaire = "<<c2rl<<endl;
1633 if(O.lp>0) cout<<p2<<endl;
1634 return;
1635
1636} else if(func[0]=='P' && ndim==2) {
1637 // Fit de polynome 2D
1638 int degre = 0;
1639 if(func.length()>1) sscanf(func.c_str()+1,"%d",&degre);
1640 cout<<"Fit polynome 2D de degre "<<degre<<endl;
1641 Polyn2D* myf = new Polyn2D(degre,O.xc,O.yc);
1642 myfunc = myf;
1643
1644} else if(func[0]=='G' && ndim==2) {
1645 // Fit de gaussienne+fond en volume
1646 int integ = 0;
1647 if(func.length()>1) if(func[1]=='i') integ=1;
1648 cout<<"Fit de Gaussienne+Fond 2D integ="<<integ<<endl;
1649 if(integ) {GauRhInt2D* myf = new GauRhInt2D; myfunc = myf;}
1650 else {GauRho2D* myf = new GauRho2D; myfunc = myf;}
1651
1652} else if(func[0]=='d' && ndim==2) {
1653 // Fit de DL gaussienne+fond en volume
1654 int integ = 0;
1655 if(func.length()>1) if(func[1]=='i') integ=1;
1656 cout<<"Fit de DL de Gaussienne+Fond 2D integ="<<integ<<endl;
1657 if(integ) {GdlRhInt2D* myf = new GdlRhInt2D; myfunc = myf;}
1658 else {GdlRho2D* myf = new GdlRho2D; myfunc = myf;}
1659
1660} else if(func[0]=='D' && ndim==2) {
1661 // Fit de DL gaussienne+fond avec coeff variable p6 en volume
1662 int integ = 0;
1663 if(func.length()>1) if(func[1]=='i') integ=1;
1664 cout<<"Fit de DL de Gaussienne+Fond avec coeff variable (p6) 2D integ="<<integ<<endl;
1665 if(integ) {Gdl1RhInt2D* myf = new Gdl1RhInt2D; myfunc = myf;}
1666 else {Gdl1Rho2D* myf = new Gdl1Rho2D; myfunc = myf;}
1667
1668} else if(func[0]=='M' && ndim==2) {
1669 // Fit de Moffat+fond (volume)
1670 int integ = 0;
1671 if(func.length()>1) if(func[1]=='i') integ=1;
1672 cout<<"Fit de Moffat+Fond (expos=p6) 2D integ="<<integ<<endl;
1673 if(integ) {MofRhInt2D* myf = new MofRhInt2D; myfunc = myf;}
1674 else {MofRho2D* myf = new MofRho2D; myfunc = myf;}
1675
1676} else {
1677 cout<<"Fonction "<<func<<" inconnue pour la dim "<<ndim<<endl;
1678 return;
1679}
1680
1681/////////////////////////
1682// Fit avec generalfit //
1683/////////////////////////
1684if(myfunc->NPar()>Par.NElts())
1685 {cout<<"Trop de parametres: "<<myfunc->NPar()<<">"<<Par.NElts()<<endl;
1686 if(myfunc) delete myfunc; return;}
1687GeneralFit myfit(myfunc);
1688myfit.SetDebug(O.lpg);
1689myfit.SetData(&mydata);
1690myfit.SetStopChi2(O.stc2);
1691{for(int i=0;i<myfunc->NPar();i++) {
1692 char str[10];
1693 sprintf(str,"P%d",i);
1694 myfit.SetParam(i,str,Par(i),Step(i),Min(i),Max(i));
1695}}
1696if(O.lp>1) myfit.PrintFit();
1697double c2r = (double) myfit.Fit();
1698if(O.lp>0) myfit.PrintFit();
1699if(c2r>0.) {
1700 c2r = myfit.GetChi2Red();
1701 cout<<"C2r_Reduit = "<<c2r<<" nstep="<<myfit.GetNStep()<<endl;
1702 Vector ParFit(myfunc->NPar());
1703 for(int i=0;i<myfunc->NPar();i++) ParFit(i)=myfit.GetParm(i);
1704} else {
1705 cout<<"echec Fit, rc = "<<c2r<<" nstep="<<myfit.GetNStep()<<endl;
1706}
1707
1708// Mise a disposition des resultats
1709if(c2r>=0. && myfunc && (O.okres>0||O.okfun>0)) {
1710 string nomres = nom + "res";
1711 string nomfun = nom + "fun";
1712 if(v) {
1713 if(O.okres) {Vector* ob = v->FitResidus(myfit); if(ob) AddObj(ob,nomres);}
1714 if(O.okfun) {Vector* ob = v->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
1715 } else if(h) {
1716 if(O.okres) {Histo* ob = h->FitResidus(myfit); if(ob) AddObj(ob,nomres);}
1717 if(O.okfun) {Histo* ob = h->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
1718 } else if(m) {
1719 if(O.okres) {Matrix* ob = m->FitResidus(myfit); if(ob) AddObj(ob,nomres);}
1720 if(O.okfun) {Matrix* ob = m->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
1721 } else if(h2) {
1722 if(O.okres) {Histo2D* ob = h2->FitResidus(myfit); if(ob) AddObj(ob,nomres);}
1723 if(O.okfun) {Histo2D* ob = h2->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
1724 } else if(im) {
1725 if(O.okres) {RzImage* ob = im->FitResidus(myfit); if(ob) AddObj(ob,nomres);}
1726 if(O.okfun) {RzImage* ob = im->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
1727 } else if(g) {
1728 if(O.okres) {GeneralFitData* ob = g->FitResidus(myfit); if(ob) AddObj(ob,nomres);}
1729 if(O.okfun) {GeneralFitData* ob = g->FitFunction(myfit); if(ob) AddObj(ob,nomfun);}
1730 }
1731}
1732
1733// Nettoyage
1734if(myfunc) delete myfunc;
1735return;
1736}
1737
Note: See TracBrowser for help on using the repository browser.