root/applications/bdmtoolbox/mex/merger.cpp @ 393

Revision 393, 1.3 kB (checked in by smidl, 15 years ago)

merger_mx works!

Line 
1#include <stat/merger.h>
2
3using namespace bdm;
4
5int main()
6{
7  UI_File Cfg("merger_mx.cfg");
8       
9        // Sources
10        Array<mpdf*> Sources;
11        //abuse Mer to store sources
12        Setting& _Sources=Cfg.lookup("Sources");
13        int Slen=_Sources.getLength();
14        Sources.set_size(Slen);
15        for (int i=0; i<Slen; i++){
16                try{
17                        mpdf* mtmp = UI::build<mpdf>(_Sources,i);
18                        Sources(i)=mtmp;
19                }
20                catch (UIbuildException e){
21                        // it is not mpdf - see if it is epdf
22                        try {
23                                epdf* etmp = UI::build<epdf>(_Sources,i);
24                                if (etmp){
25                                        Sources(i) = new mepdf(etmp, true);
26                                }
27                               
28                        }
29                        catch (...) {it_error("no mpdfs or epdfs found!");}
30                }
31
32        }
33
34        merger_base* Merger=UI::build<merger_base>(Cfg,"Merger");
35
36        // Support
37        Setting & _Supp=Cfg.lookup("Support");
38       
39        if (_Supp.exists("grid") &&  _Supp.exists("nbins")) {
40        Array<vec> bounds (0);
41        UI::get (bounds, _Supp, "grid");
42        ivec nbins(0);
43        UI::get (nbins, _Supp, "nbins");
44        Merger->set_support (bounds,nbins);
45       
46        }else {
47                if (_Supp.exists("pdf") &&  _Supp.exists("nsamples")){
48                        epdf *g0=UI::build<epdf> (_Supp, "pdf");
49                        int npoints=100;
50                        _Supp.lookupValue("nsamples",npoints);
51                        Merger->set_support (*g0,npoints);
52                        delete g0;     
53                }
54                else it_error("Use either [grid,nbins] or [pdf,nsamples].");
55        }
56// COMPUTE RESULTS
57        Merger->set_sources(Sources,true); // takes care of deletion of sources
58        Merger->merge();
59       
60}
Note: See TracBrowser for help on using the browser.