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

Revision 400, 1.5 kB (checked in by smidl, 15 years ago)

details in mergers

Line 
1#include <stat/merger.h>
2
3using namespace bdm;
4
5int main()
6{
7  UIFile 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 (UIException){
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 (UIException e) 
30                        {
31                                it_error("No mpdfs or epdfs found! " + string(e.what()));
32                        }
33                        catch (std::exception e) {
34                                it_error("Error in UI at "+_Sources[i].getPath());
35                        }               
36                }
37                catch (std::exception e) {
38                        it_error("Error in UI at "+_Sources[i].getPath());
39                }               
40        }
41
42        merger_base* Merger=UI::build<merger_base>(Cfg,"Merger");
43
44        // Support
45        Setting & _Supp=Cfg.lookup("Support");
46       
47        if (_Supp.exists("grid") &&  _Supp.exists("nbins")) {
48        Array<vec> bounds (0);
49        UI::get (bounds, _Supp, "grid");
50        ivec nbins(0);
51        UI::get (nbins, _Supp, "nbins");
52        Merger->set_support (bounds,nbins);
53       
54        }else {
55                if (_Supp.exists("pdf") &&  _Supp.exists("nsamples")){
56                        epdf *g0=UI::build<epdf> (_Supp, "pdf");
57                        int npoints=100;
58                        _Supp.lookupValue("nsamples",npoints);
59                        Merger->set_support (*g0,npoints);
60                        delete g0;     
61                }
62                else it_error("Use either [grid,nbins] or [pdf,nsamples].");
63        }
64// COMPUTE RESULTS
65        Merger->set_sources(Sources,true); // takes care of deletion of sources
66        Merger->merge();
67       
68}
Note: See TracBrowser for help on using the browser.