Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/externals/g4tools/include/tools/xml/aidas

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/xml/aidas (Version 11.3.0) and /externals/g4tools/include/tools/xml/aidas (Version 11.1.2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_xml_aidas                             4 #ifndef tools_xml_aidas
  5 #define tools_xml_aidas                             5 #define tools_xml_aidas
  6                                                     6 
  7 #include "../raxml_out"                             7 #include "../raxml_out"
  8                                                     8 
  9 #include "../sprintf"                               9 #include "../sprintf"
 10 #include "../histo/h1d"                            10 #include "../histo/h1d"
 11 #include "../histo/h2d"                            11 #include "../histo/h2d"
 12 #include "../histo/h3d"                            12 #include "../histo/h3d"
 13 #include "../histo/p1d"                            13 #include "../histo/p1d"
 14 #include "../histo/p2d"                            14 #include "../histo/p2d"
 15 #include "../histo/c1d"                            15 #include "../histo/c1d"
 16 #include "../histo/c2d"                            16 #include "../histo/c2d"
 17 #include "../histo/c3d"                            17 #include "../histo/c3d"
 18 #include "../histo/dps"                            18 #include "../histo/dps"
 19 #include "../aida_ntuple"                          19 #include "../aida_ntuple"
 20 #include "../S_STRING"                             20 #include "../S_STRING"
 21 #include "../forit"                                21 #include "../forit"
 22                                                    22 
 23 #include "tree"                                    23 #include "tree"
 24                                                    24 
 25 #include <vector>                                  25 #include <vector>
 26 #include <map>                                     26 #include <map>
 27 #include <utility>                             << 
 28                                                    27 
 29 namespace tools {                                  28 namespace tools {
 30 namespace xml {                                    29 namespace xml {
 31                                                    30 
 32 class aidas {                                      31 class aidas {
 33 public:                                            32 public:
 34   //tree,out,verbose,path.                         33   //tree,out,verbose,path.
 35   typedef raxml_out (*reader)(tree&,std::ostre     34   typedef raxml_out (*reader)(tree&,std::ostream&,bool,void*);
 36   typedef std::map<std::string,reader> readers     35   typedef std::map<std::string,reader> readers;
 37 public:                                            36 public:
 38   aidas()                                          37   aidas()
 39   {                                                38   {
 40     add_default_readers();                         39     add_default_readers();
 41   }                                                40   }
 42   virtual ~aidas(){                                41   virtual ~aidas(){
 43     m_objects.clear(); //it may delete histos,     42     m_objects.clear(); //it may delete histos, etc...
 44   }                                                43   }
 45 protected:                                         44 protected:
 46   aidas(const aidas&){}                            45   aidas(const aidas&){}
 47   aidas& operator=(const aidas&){return *this;     46   aidas& operator=(const aidas&){return *this;}
 48 public:                                            47 public:
 49   std::vector<raxml_out>& objects() {return m_     48   std::vector<raxml_out>& objects() {return m_objects;}
 50 protected:                                         49 protected:
 51   void clear_readers() {m_readers.clear();}        50   void clear_readers() {m_readers.clear();}
 52   void add_reader(const std::string& a_class,      51   void add_reader(const std::string& a_class,
 53                          reader a_reader,          52                          reader a_reader,
 54                          bool a_check = false)     53                          bool a_check = false){
 55     if(a_check) {if(find_reader(a_class)) retu     54     if(a_check) {if(find_reader(a_class)) return;}
 56     m_readers[a_class] = a_reader;                 55     m_readers[a_class] = a_reader;
 57   }                                                56   }
 58                                                    57 
 59   reader find_reader(const std::string& a_clas     58   reader find_reader(const std::string& a_class) const {
 60     std::map<std::string,reader>::const_iterat     59     std::map<std::string,reader>::const_iterator it = m_readers.find(a_class);
 61     if(it!=m_readers.end()) return (*it).secon     60     if(it!=m_readers.end()) return (*it).second;
 62     return 0;                                      61     return 0;
 63   }                                                62   }
 64                                                    63 
 65 protected:                                         64 protected:
 66   TOOLS_CLASS_STRING(aida)                         65   TOOLS_CLASS_STRING(aida)
 67                                                    66 
 68   TOOLS_CLASS_STRING(annotation)                   67   TOOLS_CLASS_STRING(annotation)
 69   TOOLS_CLASS_STRING(histogram1d)                  68   TOOLS_CLASS_STRING(histogram1d)
 70   TOOLS_CLASS_STRING(histogram2d)                  69   TOOLS_CLASS_STRING(histogram2d)
 71   TOOLS_CLASS_STRING(histogram3d)                  70   TOOLS_CLASS_STRING(histogram3d)
 72   TOOLS_CLASS_STRING(profile1d)                    71   TOOLS_CLASS_STRING(profile1d)
 73   TOOLS_CLASS_STRING(profile2d)                    72   TOOLS_CLASS_STRING(profile2d)
 74   TOOLS_CLASS_STRING(axis)                         73   TOOLS_CLASS_STRING(axis)
 75   TOOLS_CLASS_STRING(statistics)                   74   TOOLS_CLASS_STRING(statistics)
 76   TOOLS_CLASS_STRING(statistic)                    75   TOOLS_CLASS_STRING(statistic)
 77   TOOLS_CLASS_STRING(data1d)                       76   TOOLS_CLASS_STRING(data1d)
 78   TOOLS_CLASS_STRING(data2d)                       77   TOOLS_CLASS_STRING(data2d)
 79   TOOLS_CLASS_STRING(data3d)                       78   TOOLS_CLASS_STRING(data3d)
 80   TOOLS_CLASS_STRING(tuple)                        79   TOOLS_CLASS_STRING(tuple)
 81   TOOLS_CLASS_STRING(columns)                      80   TOOLS_CLASS_STRING(columns)
 82   TOOLS_CLASS_STRING(rows)                         81   TOOLS_CLASS_STRING(rows)
 83   TOOLS_CLASS_STRING(row)                          82   TOOLS_CLASS_STRING(row)
 84   TOOLS_CLASS_STRING(entryITuple)                  83   TOOLS_CLASS_STRING(entryITuple)
 85   TOOLS_CLASS_STRING(entryTuple)                   84   TOOLS_CLASS_STRING(entryTuple)
 86   TOOLS_CLASS_STRING(cloud1d)                      85   TOOLS_CLASS_STRING(cloud1d)
 87   TOOLS_CLASS_STRING(cloud2d)                      86   TOOLS_CLASS_STRING(cloud2d)
 88   TOOLS_CLASS_STRING(cloud3d)                      87   TOOLS_CLASS_STRING(cloud3d)
 89   TOOLS_CLASS_STRING(entries1d)                    88   TOOLS_CLASS_STRING(entries1d)
 90   TOOLS_CLASS_STRING(entries2d)                    89   TOOLS_CLASS_STRING(entries2d)
 91   TOOLS_CLASS_STRING(entries3d)                    90   TOOLS_CLASS_STRING(entries3d)
 92   TOOLS_CLASS_STRING(dataPointSet)                 91   TOOLS_CLASS_STRING(dataPointSet)
 93   TOOLS_CLASS_STRING(dataPoint)                    92   TOOLS_CLASS_STRING(dataPoint)
 94   //TOOLS_CLASS_STRING(function)                   93   //TOOLS_CLASS_STRING(function)
 95   //TOOLS_CLASS_STRING(arguments)                  94   //TOOLS_CLASS_STRING(arguments)
 96   //TOOLS_CLASS_STRING(argument)                   95   //TOOLS_CLASS_STRING(argument)
 97   //TOOLS_CLASS_STRING(parameters)                 96   //TOOLS_CLASS_STRING(parameters)
 98                                                    97 
 99   TOOLS_CLASS_STRING(type)                         98   TOOLS_CLASS_STRING(type)
100   TOOLS_CLASS_STRING(name)                         99   TOOLS_CLASS_STRING(name)
101   TOOLS_CLASS_STRING(path)                        100   TOOLS_CLASS_STRING(path)
102   TOOLS_CLASS_STRING(title)                       101   TOOLS_CLASS_STRING(title)
103   TOOLS_CLASS_STRING(numberOfBins)                102   TOOLS_CLASS_STRING(numberOfBins)
104   TOOLS_CLASS_STRING(min)                         103   TOOLS_CLASS_STRING(min)
105   TOOLS_CLASS_STRING(max)                         104   TOOLS_CLASS_STRING(max)
106   TOOLS_CLASS_STRING(direction)                   105   TOOLS_CLASS_STRING(direction)
107   TOOLS_CLASS_STRING(value)                       106   TOOLS_CLASS_STRING(value)
108   TOOLS_CLASS_STRING(entries)                     107   TOOLS_CLASS_STRING(entries)
109   TOOLS_CLASS_STRING(mean)                        108   TOOLS_CLASS_STRING(mean)
110   TOOLS_CLASS_STRING(rms)                         109   TOOLS_CLASS_STRING(rms)
111   TOOLS_CLASS_STRING(height)                      110   TOOLS_CLASS_STRING(height)
112   TOOLS_CLASS_STRING(error)                       111   TOOLS_CLASS_STRING(error)
113   TOOLS_CLASS_STRING(weightedMean)                112   TOOLS_CLASS_STRING(weightedMean)
114   TOOLS_CLASS_STRING(weightedRms)                 113   TOOLS_CLASS_STRING(weightedRms)
115   TOOLS_CLASS_STRING(weightedMeanX)               114   TOOLS_CLASS_STRING(weightedMeanX)
116   TOOLS_CLASS_STRING(weightedMeanY)               115   TOOLS_CLASS_STRING(weightedMeanY)
117   TOOLS_CLASS_STRING(weightedMeanZ)               116   TOOLS_CLASS_STRING(weightedMeanZ)
118   TOOLS_CLASS_STRING(weightedRmsX)                117   TOOLS_CLASS_STRING(weightedRmsX)
119   TOOLS_CLASS_STRING(weightedRmsY)                118   TOOLS_CLASS_STRING(weightedRmsY)
120   TOOLS_CLASS_STRING(weightedRmsZ)                119   TOOLS_CLASS_STRING(weightedRmsZ)
121   TOOLS_CLASS_STRING(booking)                     120   TOOLS_CLASS_STRING(booking)
122   TOOLS_CLASS_STRING(default)                     121   TOOLS_CLASS_STRING(default)
123   TOOLS_CLASS_STRING(entry)                       122   TOOLS_CLASS_STRING(entry)
124   TOOLS_CLASS_STRING(binBorder)                   123   TOOLS_CLASS_STRING(binBorder)
125   TOOLS_CLASS_STRING(maxEntries)                  124   TOOLS_CLASS_STRING(maxEntries)
126   TOOLS_CLASS_STRING(valueX)                      125   TOOLS_CLASS_STRING(valueX)
127   TOOLS_CLASS_STRING(valueY)                      126   TOOLS_CLASS_STRING(valueY)
128   TOOLS_CLASS_STRING(valueZ)                      127   TOOLS_CLASS_STRING(valueZ)
129   TOOLS_CLASS_STRING(weight)                      128   TOOLS_CLASS_STRING(weight)
130   TOOLS_CLASS_STRING(entry1d)                     129   TOOLS_CLASS_STRING(entry1d)
131   TOOLS_CLASS_STRING(entry2d)                     130   TOOLS_CLASS_STRING(entry2d)
132   TOOLS_CLASS_STRING(entry3d)                     131   TOOLS_CLASS_STRING(entry3d)
133   TOOLS_CLASS_STRING(dimension)                   132   TOOLS_CLASS_STRING(dimension)
134   TOOLS_CLASS_STRING(errorPlus)                   133   TOOLS_CLASS_STRING(errorPlus)
135   TOOLS_CLASS_STRING(errorMinus)                  134   TOOLS_CLASS_STRING(errorMinus)
136   TOOLS_CLASS_STRING(measurement)                 135   TOOLS_CLASS_STRING(measurement)
137                                                   136 
138   void set_default_tags(std::vector<std::strin    137   void set_default_tags(std::vector<std::string>& a_tags) {
139     a_tags.clear();                               138     a_tags.clear();
140     a_tags.push_back(s_aida());                   139     a_tags.push_back(s_aida());
141     a_tags.push_back(s_annotation());             140     a_tags.push_back(s_annotation());
142     a_tags.push_back(s_histogram1d());            141     a_tags.push_back(s_histogram1d());
143     a_tags.push_back(s_histogram2d());            142     a_tags.push_back(s_histogram2d());
144     a_tags.push_back(s_histogram3d());            143     a_tags.push_back(s_histogram3d());
145     a_tags.push_back(s_profile1d());              144     a_tags.push_back(s_profile1d());
146     a_tags.push_back(s_profile2d());              145     a_tags.push_back(s_profile2d());
147     a_tags.push_back(s_axis());                   146     a_tags.push_back(s_axis());
148     a_tags.push_back(s_statistics());             147     a_tags.push_back(s_statistics());
149     a_tags.push_back(s_data1d());                 148     a_tags.push_back(s_data1d());
150     a_tags.push_back(s_data2d());                 149     a_tags.push_back(s_data2d());
151     a_tags.push_back(s_data3d());                 150     a_tags.push_back(s_data3d());
152                                                   151 
153     a_tags.push_back(s_tuple());                  152     a_tags.push_back(s_tuple());
154     a_tags.push_back(s_columns());                153     a_tags.push_back(s_columns());
155     a_tags.push_back(s_rows());                   154     a_tags.push_back(s_rows());
156     a_tags.push_back(s_row());                    155     a_tags.push_back(s_row());
157     a_tags.push_back(s_entryITuple()); //aida.    156     a_tags.push_back(s_entryITuple()); //aida.dtd spec.
158     a_tags.push_back(s_entryTuple());  //not i    157     a_tags.push_back(s_entryTuple());  //not in aida.dtd ! Back comp.
159                                                   158 
160     a_tags.push_back(s_cloud1d());                159     a_tags.push_back(s_cloud1d());
161     a_tags.push_back(s_cloud2d());                160     a_tags.push_back(s_cloud2d());
162     a_tags.push_back(s_cloud3d());                161     a_tags.push_back(s_cloud3d());
163     a_tags.push_back(s_entries1d());              162     a_tags.push_back(s_entries1d());
164     a_tags.push_back(s_entries2d());              163     a_tags.push_back(s_entries2d());
165     a_tags.push_back(s_entries3d());              164     a_tags.push_back(s_entries3d());
166     a_tags.push_back(s_dataPointSet());           165     a_tags.push_back(s_dataPointSet());
167     a_tags.push_back(s_dataPoint());              166     a_tags.push_back(s_dataPoint());
168   //a_tags.push_back(s_function());               167   //a_tags.push_back(s_function());
169   //a_tags.push_back(s_arguments());              168   //a_tags.push_back(s_arguments());
170   //a_tags.push_back(s_argument());               169   //a_tags.push_back(s_argument());
171   //a_tags.push_back(s_parameters());             170   //a_tags.push_back(s_parameters());
172   }                                               171   }
173                                                   172 
174   void add_default_readers(){                     173   void add_default_readers(){
175     add_reader(s_histogram1d(),read_h1d);         174     add_reader(s_histogram1d(),read_h1d);
176     add_reader(s_histogram2d(),read_h2d);         175     add_reader(s_histogram2d(),read_h2d);
177     add_reader(s_histogram3d(),read_h3d);         176     add_reader(s_histogram3d(),read_h3d);
178     add_reader(s_profile1d(),read_p1d);           177     add_reader(s_profile1d(),read_p1d);
179     add_reader(s_profile2d(),read_p2d);           178     add_reader(s_profile2d(),read_p2d);
180     add_reader(s_cloud1d(),read_cloud1d);         179     add_reader(s_cloud1d(),read_cloud1d);
181     add_reader(s_cloud2d(),read_cloud2d);         180     add_reader(s_cloud2d(),read_cloud2d);
182     add_reader(s_cloud3d(),read_cloud3d);         181     add_reader(s_cloud3d(),read_cloud3d);
183     add_reader(s_tuple(),read_ntu);               182     add_reader(s_tuple(),read_ntu);
184     add_reader(s_dataPointSet(),read_dps);        183     add_reader(s_dataPointSet(),read_dps);
185   //add_reader(s_function(),read_Function);       184   //add_reader(s_function(),read_Function);
186   }                                               185   }
187   static raxml_out read_h1d(tree& a_tree,std::    186   static raxml_out read_h1d(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
188     return read_histo(a_tree,a_out,a_verbose,1    187     return read_histo(a_tree,a_out,a_verbose,1,false);
189   }                                               188   }
190   static raxml_out read_h2d(tree& a_tree,std::    189   static raxml_out read_h2d(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
191     return read_histo(a_tree,a_out,a_verbose,2    190     return read_histo(a_tree,a_out,a_verbose,2,false);
192   }                                               191   }
193   static raxml_out read_h3d(tree& a_tree,std::    192   static raxml_out read_h3d(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
194     return read_histo(a_tree,a_out,a_verbose,3    193     return read_histo(a_tree,a_out,a_verbose,3,false);
195   }                                               194   }
196   static raxml_out read_p1d(tree& a_tree,std::    195   static raxml_out read_p1d(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
197     return read_histo(a_tree,a_out,a_verbose,1    196     return read_histo(a_tree,a_out,a_verbose,1,true);
198   }                                               197   }
199   static raxml_out read_p2d(tree& a_tree,std::    198   static raxml_out read_p2d(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
200     return read_histo(a_tree,a_out,a_verbose,2    199     return read_histo(a_tree,a_out,a_verbose,2,true);
201   }                                               200   }
202                                                   201 
203   static raxml_out read_cloud1d(tree& a_tree,s    202   static raxml_out read_cloud1d(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
204     return read_cloud(a_tree,a_out,a_verbose,1    203     return read_cloud(a_tree,a_out,a_verbose,1);
205   }                                               204   }
206   static raxml_out read_cloud2d(tree& a_tree,s    205   static raxml_out read_cloud2d(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
207     return read_cloud(a_tree,a_out,a_verbose,2    206     return read_cloud(a_tree,a_out,a_verbose,2);
208   }                                               207   }
209   static raxml_out read_cloud3d(tree& a_tree,s    208   static raxml_out read_cloud3d(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
210     return read_cloud(a_tree,a_out,a_verbose,3    209     return read_cloud(a_tree,a_out,a_verbose,3);
211   }                                               210   }
212                                                   211 
213   static raxml_out read_dps(tree& a_tree,std::    212   static raxml_out read_dps(tree& a_tree,std::ostream& a_out,bool a_verbose,void*) {
214     std::string sname;                            213     std::string sname;
215     a_tree.attribute_value(s_name(),sname);       214     a_tree.attribute_value(s_name(),sname);
216                                                   215 
217     if(a_verbose) {                               216     if(a_verbose) {
218       a_out << "tools::xml::aidas::read_dps :"    217       a_out << "tools::xml::aidas::read_dps :"
219             << " with name " << sout(sname)       218             << " with name " << sout(sname)
220             << "..." << std::endl;                219             << "..." << std::endl;
221     }                                             220     }
222                                                   221 
223     std::string spath;                            222     std::string spath;
224     a_tree.attribute_value(s_path(),spath);       223     a_tree.attribute_value(s_path(),spath);
225                                                   224 
226     std::string stitle;                           225     std::string stitle;
227     a_tree.attribute_value(s_title(),stitle);     226     a_tree.attribute_value(s_title(),stitle);
228                                                   227 
229     // Booking parameters :                       228     // Booking parameters :
230     unsigned int dim = 0;                         229     unsigned int dim = 0;
231     if(!a_tree.attribute_value(s_dimension(),d    230     if(!a_tree.attribute_value(s_dimension(),dim)) return raxml_out();
232                                                   231 
233     // Create a BatchLab::DataPointSet :          232     // Create a BatchLab::DataPointSet :
234     histo::dps* dps = new histo::dps(stitle,di    233     histo::dps* dps = new histo::dps(stitle,dim);
235                                                   234 
236     // Data sub items :                           235     // Data sub items :
237    {looper _for(a_tree);                          236    {looper _for(a_tree);
238     while(tree* _tree = _for.next_tree()) {       237     while(tree* _tree = _for.next_tree()) {
239       if(!read_dps_data(*_tree,*dps)) {           238       if(!read_dps_data(*_tree,*dps)) {
240         delete dps;                               239         delete dps;
241         return raxml_out();                       240         return raxml_out();
242       }                                           241       }
243     }}                                            242     }}
244                                                   243 
245     base_handle* hdl = new handle<histo::dps>(    244     base_handle* hdl = new handle<histo::dps>(dps);
246     std::string sclass = histo::dps::s_class()    245     std::string sclass = histo::dps::s_class();
247                                                   246 
248     if(a_verbose) {                               247     if(a_verbose) {
249       a_out << "tools::xml::aidas::read_dps :"    248       a_out << "tools::xml::aidas::read_dps :"
250             << " with name " << sout(sname)       249             << " with name " << sout(sname)
251             << " and title " << sout(stitle)      250             << " and title " << sout(stitle)
252             << " done." << std::endl;             251             << " done." << std::endl;
253     }                                             252     }
254                                                   253 
255     return raxml_out(hdl,sclass,spath,sname);     254     return raxml_out(hdl,sclass,spath,sname);
256   }                                               255   }
257                                                   256 
258 protected:                                        257 protected:
259   typedef histo::axis<double,unsigned int>::bn    258   typedef histo::axis<double,unsigned int>::bn_t bn_t;
260 public: //used in BatchLab::XML_DataReader.       259 public: //used in BatchLab::XML_DataReader.
261   static raxml_out read_histo(tree& a_tree,       260   static raxml_out read_histo(tree& a_tree,
262                                std::ostream& a    261                                std::ostream& a_out,bool a_verbose,
263                                unsigned int a_    262                                unsigned int a_dim,bool a_is_prof){
264                                                   263 
265     std::string sname;                            264     std::string sname;
266     a_tree.attribute_value(s_name(),sname);       265     a_tree.attribute_value(s_name(),sname);
267                                                   266 
268     if(a_verbose) {                               267     if(a_verbose) {
269       a_out << "tools::xml::aidas::read_histo     268       a_out << "tools::xml::aidas::read_histo :"
270             << " with name " << sout(sname)       269             << " with name " << sout(sname)
271             << "..." << std::endl;                270             << "..." << std::endl;
272     }                                             271     }
273                                                   272 
274     std::string spath;                            273     std::string spath;
275     a_tree.attribute_value(s_path(),spath);       274     a_tree.attribute_value(s_path(),spath);
276                                                   275 
277     std::string stitle;                           276     std::string stitle;
278     a_tree.attribute_value(s_title(),stitle);     277     a_tree.attribute_value(s_title(),stitle);
279                                                   278 
280     // Booking parameters :                       279     // Booking parameters :
281     std::vector<bn_t> bins(a_dim);                280     std::vector<bn_t> bins(a_dim);
282     std::vector<double> mns(a_dim);               281     std::vector<double> mns(a_dim);
283     std::vector<double> mxs(a_dim);               282     std::vector<double> mxs(a_dim);
284     std::vector< std::vector<double> > edges(a    283     std::vector< std::vector<double> > edges(a_dim);
285                                                   284 
286     // Jump in subitems to find axes items :      285     // Jump in subitems to find axes items :
287     int not_found = -1;                           286     int not_found = -1;
288     unsigned int found = 0;                       287     unsigned int found = 0;
289     bool isVariableBins = false;                  288     bool isVariableBins = false;
290                                                   289 
291    {looper _for(a_tree);                          290    {looper _for(a_tree);
292     while(tree* _tree = _for.next_tree()) {       291     while(tree* _tree = _for.next_tree()) {
293                                                   292 
294       int iaxis;                                  293       int iaxis;
295       bn_t num;                                   294       bn_t num;
296       double mn,mx;                               295       double mn,mx;
297       std::vector<double> borders;                296       std::vector<double> borders;
298       bool variableBins;                          297       bool variableBins;
299       if(!read_axis(*_tree,a_dim,iaxis,num,mn,    298       if(!read_axis(*_tree,a_dim,iaxis,num,mn,mx,borders,variableBins,a_out)) return raxml_out();
300       if(iaxis!=not_found) {                      299       if(iaxis!=not_found) {
301         if((iaxis<0)||(iaxis>=(int)a_dim)) ret    300         if((iaxis<0)||(iaxis>=(int)a_dim)) return raxml_out();
302         bins[iaxis] = num;                        301         bins[iaxis] = num;
303         mns[iaxis] = mn;                          302         mns[iaxis] = mn;
304         mxs[iaxis] = mx;                          303         mxs[iaxis] = mx;
305         edges[iaxis] = std::move(borders);     << 304         edges[iaxis] = borders;
306         if(variableBins) isVariableBins = true    305         if(variableBins) isVariableBins = true;
307         found++;                                  306         found++;
308       }                                           307       }
309     }}                                            308     }}
310                                                   309 
311     if(found!=a_dim) return raxml_out();          310     if(found!=a_dim) return raxml_out();
312     if(isVariableBins) {                          311     if(isVariableBins) {
313       // Axes consistency :                       312       // Axes consistency :
314       for(unsigned int iaxis=0;iaxis<a_dim;iax    313       for(unsigned int iaxis=0;iaxis<a_dim;iaxis++) {
315         if(edges[iaxis].size()<=2) return raxm    314         if(edges[iaxis].size()<=2) return raxml_out();
316       }                                           315       }
317     }                                             316     }
318                                                   317 
319     // Create a native histogram :                318     // Create a native histogram :
320                                                   319 
321     base_handle* hdl = 0;                         320     base_handle* hdl = 0;
322     std::string sclass;                           321     std::string sclass;
323     if(a_is_prof) {                               322     if(a_is_prof) {
324       if(a_dim==1) {                              323       if(a_dim==1) {
325         histo::p1d* histo = 0;                    324         histo::p1d* histo = 0;
326         if(isVariableBins) {                      325         if(isVariableBins) {
327           histo = new histo::p1d(stitle,edges[    326           histo = new histo::p1d(stitle,edges[0]);
328         } else {                                  327         } else {
329           histo = new histo::p1d(stitle,bins[0    328           histo = new histo::p1d(stitle,bins[0],mns[0],mxs[0]);
330         }                                         329         }
331                                                   330 
332         // Sub items :                            331         // Sub items :
333         pd_data hd = histo->get_histo_data();     332         pd_data hd = histo->get_histo_data();
334         if(hd.m_bin_number<=0) {delete histo;r    333         if(hd.m_bin_number<=0) {delete histo;return raxml_out();}
335                                                   334 
336        {looper _for(a_tree);                      335        {looper _for(a_tree);
337         while(tree* _tree = _for.next_tree())     336         while(tree* _tree = _for.next_tree()) {
338                                                   337 
339           if(!read_bins(*_tree,hd,a_out,a_is_p    338           if(!read_bins(*_tree,hd,a_out,a_is_prof)) {
340             delete histo;                         339             delete histo;
341             return raxml_out();                   340             return raxml_out();
342           }                                       341           }
343                                                   342 
344         }}                                        343         }}
345                                                   344 
346         //give histo ownership to the handle.     345         //give histo ownership to the handle.
347         hdl = new handle<histo::p1d>(histo);      346         hdl = new handle<histo::p1d>(histo);
348         sclass = histo::p1d::s_class();           347         sclass = histo::p1d::s_class();
349                                                   348 
350         hd.update_fast_getters();                 349         hd.update_fast_getters();
351         histo->copy_from_data(hd);                350         histo->copy_from_data(hd);
352                                                   351 
353       } else if(a_dim==2) {                       352       } else if(a_dim==2) {
354         histo::p2d* histo = 0;                    353         histo::p2d* histo = 0;
355         if(isVariableBins) {                      354         if(isVariableBins) {
356           histo = new histo::p2d(stitle,edges[    355           histo = new histo::p2d(stitle,edges[0],edges[1]);
357         } else {                                  356         } else {
358           histo = new histo::p2d(stitle,bins[0    357           histo = new histo::p2d(stitle,bins[0],mns[0],mxs[0],bins[1],mns[1],mxs[1]);
359         }                                         358         }
360                                                   359 
361         pd_data hd = histo->get_histo_data();     360         pd_data hd = histo->get_histo_data();
362         if(hd.m_bin_number<=0) {delete histo;r    361         if(hd.m_bin_number<=0) {delete histo;return raxml_out();}
363                                                   362 
364        {looper _for(a_tree);                      363        {looper _for(a_tree);
365         while(tree* _tree = _for.next_tree())     364         while(tree* _tree = _for.next_tree()) {
366                                                   365 
367           if(!read_bins(*_tree,hd,a_out,a_is_p    366           if(!read_bins(*_tree,hd,a_out,a_is_prof)) {
368             delete histo;                         367             delete histo;
369             return raxml_out();                   368             return raxml_out();
370           }                                       369           }
371                                                   370 
372         }}                                        371         }}
373                                                   372 
374         hdl = new handle<histo::p2d>(histo);      373         hdl = new handle<histo::p2d>(histo);
375         sclass = histo::p2d::s_class();           374         sclass = histo::p2d::s_class();
376                                                   375 
377         hd.update_fast_getters();                 376         hd.update_fast_getters();
378         histo->copy_from_data(hd);                377         histo->copy_from_data(hd);
379       }                                           378       }
380     } else {                                      379     } else {
381       if(a_dim==1) {                              380       if(a_dim==1) {
382         histo::h1d* histo = 0;                    381         histo::h1d* histo = 0;
383         if(isVariableBins) {                      382         if(isVariableBins) {
384           histo = new histo::h1d(stitle,edges[    383           histo = new histo::h1d(stitle,edges[0]);
385         } else {                                  384         } else {
386           histo = new histo::h1d(stitle,bins[0    385           histo = new histo::h1d(stitle,bins[0],mns[0],mxs[0]);
387         }                                         386         }
388                                                   387 
389         pd_data hd(histo->dac());                 388         pd_data hd(histo->dac());
390         if(hd.m_bin_number<=0) {delete histo;r    389         if(hd.m_bin_number<=0) {delete histo;return raxml_out();}
391                                                   390 
392        {looper _for(a_tree);                      391        {looper _for(a_tree);
393         while(tree* _tree = _for.next_tree())     392         while(tree* _tree = _for.next_tree()) {
394                                                   393 
395           if(!read_bins(*_tree,hd,a_out,a_is_p    394           if(!read_bins(*_tree,hd,a_out,a_is_prof)) {
396             delete histo;                         395             delete histo;
397             return raxml_out();                   396             return raxml_out();
398           }                                       397           }
399                                                   398 
400         }}                                        399         }}
401                                                   400 
402         hdl = new handle<histo::h1d>(histo);      401         hdl = new handle<histo::h1d>(histo);
403         sclass = histo::h1d::s_class();           402         sclass = histo::h1d::s_class();
404                                                   403 
405         hd.update_fast_getters();                 404         hd.update_fast_getters();
406         histo->copy_from_data(hd);                405         histo->copy_from_data(hd);
407                                                   406 
408       } else if(a_dim==2) {                       407       } else if(a_dim==2) {
409         histo::h2d* histo = 0;                    408         histo::h2d* histo = 0;
410         if(isVariableBins) {                      409         if(isVariableBins) {
411           histo = new histo::h2d(stitle,edges[    410           histo = new histo::h2d(stitle,edges[0],edges[1]);
412         } else {                                  411         } else {
413           histo = new histo::h2d(stitle,bins[0    412           histo = new histo::h2d(stitle,bins[0],mns[0],mxs[0],bins[1],mns[1],mxs[1]);
414         }                                         413         }
415                                                   414 
416         pd_data hd(histo->dac());                 415         pd_data hd(histo->dac());
417         if(hd.m_bin_number<=0) {delete histo;r    416         if(hd.m_bin_number<=0) {delete histo;return raxml_out();}
418                                                   417 
419        {looper _for(a_tree);                      418        {looper _for(a_tree);
420         while(tree* _tree = _for.next_tree())     419         while(tree* _tree = _for.next_tree()) {
421                                                   420 
422           if(!read_bins(*_tree,hd,a_out,a_is_p    421           if(!read_bins(*_tree,hd,a_out,a_is_prof)) {
423             delete histo;                         422             delete histo;
424             return raxml_out();                   423             return raxml_out();
425           }                                       424           }
426                                                   425 
427         }}                                        426         }}
428                                                   427 
429         hdl = new handle<histo::h2d>(histo);      428         hdl = new handle<histo::h2d>(histo);
430         sclass = histo::h2d::s_class();           429         sclass = histo::h2d::s_class();
431                                                   430 
432         hd.update_fast_getters();                 431         hd.update_fast_getters();
433         histo->copy_from_data(hd);                432         histo->copy_from_data(hd);
434                                                   433 
435       } else if(a_dim==3) {                       434       } else if(a_dim==3) {
436         histo::h3d* histo = 0;                    435         histo::h3d* histo = 0;
437         if(isVariableBins) {                      436         if(isVariableBins) {
438           histo = new histo::h3d(stitle,edges[    437           histo = new histo::h3d(stitle,edges[0],edges[1],edges[2]);
439         } else {                                  438         } else {
440           histo = new histo::h3d(stitle,bins[0    439           histo = new histo::h3d(stitle,bins[0],mns[0],mxs[0],
441                                                   440                                                bins[1],mns[1],mxs[1],
442                                                   441                                                bins[2],mns[2],mxs[2]);
443         }                                         442         }
444                                                   443 
445         pd_data hd(histo->dac());                 444         pd_data hd(histo->dac());
446         if(hd.m_bin_number<=0) {delete histo;r    445         if(hd.m_bin_number<=0) {delete histo;return raxml_out();}
447                                                   446 
448        {looper _for(a_tree);                      447        {looper _for(a_tree);
449         while(tree* _tree = _for.next_tree())     448         while(tree* _tree = _for.next_tree()) {
450                                                   449 
451           if(!read_bins(*_tree,hd,a_out,a_is_p    450           if(!read_bins(*_tree,hd,a_out,a_is_prof)) {
452             delete histo;                         451             delete histo;
453             return raxml_out();                   452             return raxml_out();
454           }                                       453           }
455                                                   454 
456         }}                                        455         }}
457                                                   456 
458         hdl = new handle<histo::h3d>(histo);      457         hdl = new handle<histo::h3d>(histo);
459         sclass = histo::h3d::s_class();           458         sclass = histo::h3d::s_class();
460                                                   459 
461         hd.update_fast_getters();                 460         hd.update_fast_getters();
462         histo->copy_from_data(hd);                461         histo->copy_from_data(hd);
463                                                   462 
464       }                                           463       }
465     }                                             464     }
466                                                   465 
467     if(!hdl) return raxml_out();                  466     if(!hdl) return raxml_out();
468                                                   467 
469     if(a_verbose) {                               468     if(a_verbose) {
470       a_out << "tools::xml::aidas::read_histo     469       a_out << "tools::xml::aidas::read_histo :"
471             << " with name " << sout(sname)       470             << " with name " << sout(sname)
472             << " and title " << sout(stitle)      471             << " and title " << sout(stitle)
473             << " done." << std::endl;             472             << " done." << std::endl;
474     }                                             473     }
475                                                   474 
476     return raxml_out(hdl,sclass,spath,sname);     475     return raxml_out(hdl,sclass,spath,sname);
477   }                                               476   }
478                                                   477 
479   static raxml_out read_cloud(tree& a_tree,std    478   static raxml_out read_cloud(tree& a_tree,std::ostream& a_out,bool a_verbose,int a_dim){
480                                                   479 
481     std::string sname;                            480     std::string sname;
482     a_tree.attribute_value(s_name(),sname);       481     a_tree.attribute_value(s_name(),sname);
483                                                   482 
484     if(a_verbose) {                               483     if(a_verbose) {
485       a_out << "tools::xml::aidas::read_cloud     484       a_out << "tools::xml::aidas::read_cloud :"
486             << " name " << sout(sname)            485             << " name " << sout(sname)
487             << "..." << std::endl;                486             << "..." << std::endl;
488     }                                             487     }
489                                                   488 
490     std::string spath;                            489     std::string spath;
491     a_tree.attribute_value(s_path(),spath);       490     a_tree.attribute_value(s_path(),spath);
492                                                   491 
493     std::string stitle;                           492     std::string stitle;
494     a_tree.attribute_value(s_title(),stitle);     493     a_tree.attribute_value(s_title(),stitle);
495                                                   494 
496     std::string svalue;                           495     std::string svalue;
497                                                   496 
498     // Booking parameters :                       497     // Booking parameters :
499     int max_entries = -1; //UNLIMITED             498     int max_entries = -1; //UNLIMITED
500     if(a_tree.attribute_value(s_maxEntries(),s    499     if(a_tree.attribute_value(s_maxEntries(),svalue)) {
501       int ival;                                   500       int ival;
502       if(!to<int>(svalue,ival)) return raxml_o    501       if(!to<int>(svalue,ival)) return raxml_out();
503       max_entries = ival;                         502       max_entries = ival;
504     }                                             503     }
505                                                   504 
506     base_handle* hdl = 0;                         505     base_handle* hdl = 0;
507     std::string sclass;                           506     std::string sclass;
508                                                   507 
509     if(a_dim==1) {                                508     if(a_dim==1) {
510                                                   509 
511       histo::c1d* cloud = new histo::c1d(stitl    510       histo::c1d* cloud = new histo::c1d(stitle,max_entries);
512                                                   511 
513       // Data sub items :                         512       // Data sub items :
514      {looper _for(a_tree);                        513      {looper _for(a_tree);
515       while(tree* _tree = _for.next_tree()) {     514       while(tree* _tree = _for.next_tree()) {
516         if(!read_cloud_data(*_tree,*cloud,a_ve    515         if(!read_cloud_data(*_tree,*cloud,a_verbose,a_out)) {
517           delete cloud;                           516           delete cloud;
518           return raxml_out();                     517           return raxml_out();
519         }                                         518         }
520       }}                                          519       }}
521                                                   520 
522       hdl = new handle<histo::c1d>(cloud);        521       hdl = new handle<histo::c1d>(cloud);
523       sclass = histo::c1d::s_class();             522       sclass = histo::c1d::s_class();
524                                                   523 
525     } else if(a_dim==2) {                         524     } else if(a_dim==2) {
526                                                   525 
527       histo::c2d* cloud = new histo::c2d(stitl    526       histo::c2d* cloud = new histo::c2d(stitle,max_entries);
528                                                   527 
529       // Data sub items :                         528       // Data sub items :
530      {looper _for(a_tree);                        529      {looper _for(a_tree);
531       while(tree* _tree = _for.next_tree()) {     530       while(tree* _tree = _for.next_tree()) {
532         if(!read_cloud_data(*_tree,*cloud,a_ve    531         if(!read_cloud_data(*_tree,*cloud,a_verbose,a_out)) {
533           delete cloud;                           532           delete cloud;
534           return raxml_out();                     533           return raxml_out();
535         }                                         534         }
536       }}                                          535       }}
537                                                   536 
538       hdl = new handle<histo::c2d>(cloud);        537       hdl = new handle<histo::c2d>(cloud);
539       sclass = histo::c2d::s_class();             538       sclass = histo::c2d::s_class();
540                                                   539 
541     } else if(a_dim==3) {                         540     } else if(a_dim==3) {
542                                                   541 
543       histo::c3d* cloud = new histo::c3d(stitl    542       histo::c3d* cloud = new histo::c3d(stitle,max_entries);
544                                                   543 
545       // Data sub items :                         544       // Data sub items :
546      {looper _for(a_tree);                        545      {looper _for(a_tree);
547       while(tree* _tree = _for.next_tree()) {     546       while(tree* _tree = _for.next_tree()) {
548         if(!read_cloud_data(*_tree,*cloud,a_ve    547         if(!read_cloud_data(*_tree,*cloud,a_verbose,a_out)) {
549           delete cloud;                           548           delete cloud;
550           return raxml_out();                     549           return raxml_out();
551         }                                         550         }
552       }}                                          551       }}
553                                                   552 
554       hdl = new handle<histo::c3d>(cloud);        553       hdl = new handle<histo::c3d>(cloud);
555       sclass = histo::c3d::s_class();             554       sclass = histo::c3d::s_class();
556     }                                             555     }
557                                                   556 
558     if(!hdl) return raxml_out();                  557     if(!hdl) return raxml_out();
559                                                   558 
560     if(a_verbose) {                               559     if(a_verbose) {
561       a_out << "tools::xml::aidas::read_cloud     560       a_out << "tools::xml::aidas::read_cloud :"
562             << " with name " << sout(sname)       561             << " with name " << sout(sname)
563             << " and title " << sout(stitle)      562             << " and title " << sout(stitle)
564             << " done." << std::endl;             563             << " done." << std::endl;
565     }                                             564     }
566                                                   565 
567     return raxml_out(hdl,sclass,spath,sname);     566     return raxml_out(hdl,sclass,spath,sname);
568   }                                               567   }
569                                                   568 
570 protected:                                        569 protected:
571   typedef histo::profile_data<double,unsigned     570   typedef histo::profile_data<double,unsigned int,unsigned int,double,double> pd_data;
572   ////////////////////////////////////////////    571   ///////////////////////////////////////////////////////////////
573   /// read histo /////////////////////////////    572   /// read histo ////////////////////////////////////////////////
574   ////////////////////////////////////////////    573   ///////////////////////////////////////////////////////////////
575   static bool read_axis(                          574   static bool read_axis(
576    tree& a_tree                                   575    tree& a_tree
577   ,unsigned int a_dim                             576   ,unsigned int a_dim
578   ,int& aAxis                                     577   ,int& aAxis
579   ,bn_t& aNumberOfBins                            578   ,bn_t& aNumberOfBins
580   ,double& aMin                                   579   ,double& aMin
581   ,double& aMax                                   580   ,double& aMax
582   ,std::vector<double>& aEdges                    581   ,std::vector<double>& aEdges
583   ,bool& aVariableBins                            582   ,bool& aVariableBins
584   ,std::ostream& //a_out                          583   ,std::ostream& //a_out
585   ){                                              584   ){
586     int not_found = -1;                           585     int not_found = -1;
587     aAxis = not_found;                            586     aAxis = not_found;
588     aNumberOfBins = 0;                            587     aNumberOfBins = 0;
589     aMin = 0;                                     588     aMin = 0;
590     aMax = 0;                                     589     aMax = 0;
591     aEdges.clear();                               590     aEdges.clear();
592     aVariableBins = false;                        591     aVariableBins = false;
593                                                   592 
594     const std::string& tagName = a_tree.tag_na    593     const std::string& tagName = a_tree.tag_name();
595                                                   594 
596     std::string svalue;                           595     std::string svalue;
597                                                   596 
598     if(tagName==s_axis()) {                       597     if(tagName==s_axis()) {
599                                                   598 
600      {bn_t ival;                                  599      {bn_t ival;
601       if(!a_tree.attribute_value(s_numberOfBin    600       if(!a_tree.attribute_value(s_numberOfBins(),svalue)) return false;
602       if(!to<bn_t>(svalue,ival)) return false;    601       if(!to<bn_t>(svalue,ival)) return false;
603       aNumberOfBins = ival;}                      602       aNumberOfBins = ival;}
604                                                   603 
605       if(!a_tree.attribute_value(s_min(),svalu    604       if(!a_tree.attribute_value(s_min(),svalue)) return false;
606       if(!to<double>(svalue,aMin)) return fals    605       if(!to<double>(svalue,aMin)) return false;
607                                                   606 
608       if(!a_tree.attribute_value(s_max(),svalu    607       if(!a_tree.attribute_value(s_max(),svalue)) return false;
609       if(!to<double>(svalue,aMax)) return fals    608       if(!to<double>(svalue,aMax)) return false;
610                                                   609 
611       if(!a_tree.attribute_value(s_direction()    610       if(!a_tree.attribute_value(s_direction(),svalue)) return false;
612       if(!axis_index(a_dim,svalue,aAxis)) retu    611       if(!axis_index(a_dim,svalue,aAxis)) return false;
613                                                   612 
614       aEdges.push_back(aMin);                     613       aEdges.push_back(aMin);
615                                                   614 
616      {looper _for(a_tree);                        615      {looper _for(a_tree);
617       while(element* _elem = _for.next_element    616       while(element* _elem = _for.next_element()) {
618         if(_elem->name()==s_binBorder()) {        617         if(_elem->name()==s_binBorder()) {
619           if(!_elem->attribute_value(s_value()    618           if(!_elem->attribute_value(s_value(),svalue)) return false;
620           double value;                           619           double value;
621           if(!to<double>(svalue,value)) return    620           if(!to<double>(svalue,value)) return false;
622           aEdges.push_back(value);                621           aEdges.push_back(value);
623           aVariableBins = true;                   622           aVariableBins = true;
624         }                                         623         }
625       }}                                          624       }}
626                                                   625 
627       aEdges.push_back(aMax);                     626       aEdges.push_back(aMax);
628       if(aVariableBins) { // Variable bins his    627       if(aVariableBins) { // Variable bins histo.
629         if(aEdges.size()!=aNumberOfBins+1) ret    628         if(aEdges.size()!=aNumberOfBins+1) return false;
630       }                                           629       }
631                                                   630 
632     }                                             631     }
633                                                   632 
634     return true;                                  633     return true;
635   }                                               634   }
636   static bool to_double(const std::string& a_s    635   static bool to_double(const std::string& a_s,double& a_v,std::ostream& a_out,const std::string& a_what) {
637     if(!to<double>(a_s,a_v)) {                    636     if(!to<double>(a_s,a_v)) {
638       a_out << "tools::xml::aidas::read_bins :    637       a_out << "tools::xml::aidas::read_bins :"
639             << " problem converting a " << a_w    638             << " problem converting a " << a_what
640             << " attribute to a double."          639             << " attribute to a double."
641             << " Value was " << sout(a_s) << "    640             << " Value was " << sout(a_s) << "."
642             << std::endl;                         641             << std::endl;
643       return false;                               642       return false;
644     }                                             643     }
645     return true;                                  644     return true;
646   }                                               645   }
647                                                   646 
648   static bool read_bins(tree& a_tree,pd_data&     647   static bool read_bins(tree& a_tree,pd_data& aData,std::ostream& a_out,bool a_is_prof){
649     const std::string& tagName = a_tree.tag_na    648     const std::string& tagName = a_tree.tag_name();
650                                                   649 
651     std::string svalue;                           650     std::string svalue;
652                                                   651 
653     if(tagName==s_annotation()) { //FIXME         652     if(tagName==s_annotation()) { //FIXME
654                                                   653 
655       return true;                                654       return true;
656                                                   655 
657     } else if(tagName=="statistics") {            656     } else if(tagName=="statistics") {
658                                                   657 
659       if(!a_tree.attribute_value(s_entries(),s    658       if(!a_tree.attribute_value(s_entries(),svalue)) return false;
660       //unsigned int ival;                        659       //unsigned int ival;
661       //if(!to<unsigned int>(svalue,ival)) ret    660       //if(!to<unsigned int>(svalue,ival)) return false;
662       // aData.fEntries = ival;                   661       // aData.fEntries = ival;
663                                                   662 
664       unsigned int found = 0;                     663       unsigned int found = 0;
665                                                   664 
666      {looper _for(a_tree);                        665      {looper _for(a_tree);
667       while(element* _elem = _for.next_element    666       while(element* _elem = _for.next_element()) {
668                                                   667 
669         if(_elem->name()==s_statistic()) {        668         if(_elem->name()==s_statistic()) {
670           double mean,rms;                        669           double mean,rms;
671           if(!_elem->attribute_value(s_mean(),    670           if(!_elem->attribute_value(s_mean(),svalue)) return false;
672           if(!to<double>(svalue,mean)) return     671           if(!to<double>(svalue,mean)) return false;
673                                                   672 
674           if(!_elem->attribute_value(s_rms(),s    673           if(!_elem->attribute_value(s_rms(),svalue)) return false;
675           if(!to<double>(svalue,rms)) return f    674           if(!to<double>(svalue,rms)) return false;
676                                                   675 
677           if(!_elem->attribute_value(s_directi    676           if(!_elem->attribute_value(s_direction(),svalue)) return false;
678           int iaxis;                              677           int iaxis;
679           if(!axis_index(aData.m_dimension,sva    678           if(!axis_index(aData.m_dimension,svalue,iaxis)) return false;
680                                                   679 
681           //aData.m_axes[iaxis].fSxw = mean; /    680           //aData.m_axes[iaxis].fSxw = mean; //Temporarily put mean on fSxw.
682           //aData.m_axes[iaxis].fSx2w = rms; /    681           //aData.m_axes[iaxis].fSx2w = rms; //Temporarily put mean on fSx2w.
683                                                   682 
684           found++;                                683           found++;
685         }                                         684         }
686       }}                                          685       }}
687                                                   686 
688       if(found!=aData.m_dimension) return fals    687       if(found!=aData.m_dimension) return false;
689                                                   688 
690       return true;                                689       return true;
691                                                   690 
692     } else if(tagName==s_axis()) {                691     } else if(tagName==s_axis()) {
693                                                   692 
694       return true;                                693       return true;
695                                                   694 
696     }                                             695     }
697                                                   696 
698     unsigned int dimension = 0;                   697     unsigned int dimension = 0;
699     if(tagName==s_data1d()) {                     698     if(tagName==s_data1d()) {
700       dimension = 1;                              699       dimension = 1;
701     } else if(tagName==s_data2d()) {              700     } else if(tagName==s_data2d()) {
702       dimension = 2;                              701       dimension = 2;
703     } else if(tagName==s_data3d()) {              702     } else if(tagName==s_data3d()) {
704       dimension = 3;                              703       dimension = 3;
705     }                                             704     }
706                                                   705 
707     if(dimension) {                               706     if(dimension) {
708                                                   707 
709       if(dimension!=aData.m_dimension) return     708       if(dimension!=aData.m_dimension) return false;
710                                                   709 
711       std::string sbin;                           710       std::string sbin;
712       sprintf(sbin,32,"bin%dd",dimension);        711       sprintf(sbin,32,"bin%dd",dimension);
713                                                   712 
714      {looper _for(a_tree);                        713      {looper _for(a_tree);
715       while(element* _elem = _for.next_element    714       while(element* _elem = _for.next_element()) {
716                                                   715 
717         if(_elem->name()==sbin) {                 716         if(_elem->name()==sbin) {
718                                                   717 
719           std::vector<int> is(dimension);         718           std::vector<int> is(dimension);
720                                                   719 
721           unsigned int entries = 0;               720           unsigned int entries = 0;
722           double height = 0;                      721           double height = 0;
723           double error = 0;                       722           double error = 0;
724           double weightedMean = 0;                723           double weightedMean = 0;
725           double weightedMeanX = 0;               724           double weightedMeanX = 0;
726           double weightedMeanY = 0;               725           double weightedMeanY = 0;
727           double weightedMeanZ = 0;               726           double weightedMeanZ = 0;
728           double weightedRms = 0;                 727           double weightedRms = 0;
729           double weightedRmsX = 0;                728           double weightedRmsX = 0;
730           double weightedRmsY = 0;                729           double weightedRmsY = 0;
731           double weightedRmsZ = 0;                730           double weightedRmsZ = 0;
732           double rms = 0;                         731           double rms = 0;
733                                                   732 
734           // Required :                           733           // Required :
735           if(!_elem->attribute_value(s_entries    734           if(!_elem->attribute_value(s_entries(),svalue)) {
736             a_out << "tools::xml::aidas::read_    735             a_out << "tools::xml::aidas::read_bins :"
737                   << " a <bin1d> has no " << "    736                   << " a <bin1d> has no " << "entries"
738                   << " attribute."                737                   << " attribute."
739                   << std::endl;                   738                   << std::endl;
740             return false;                         739             return false;
741           }                                       740           }
742           if(!to<unsigned int>(svalue,entries)    741           if(!to<unsigned int>(svalue,entries)) {
743             a_out << "tools::xml::aidas::read_    742             a_out << "tools::xml::aidas::read_bins :"
744               << " problem converting a entrie    743               << " problem converting a entries attribute to an unsigned int."
745                 << " Value was " << sout(svalu    744                 << " Value was " << sout(svalue) << "."
746                 << std::endl;                     745                 << std::endl;
747             return false;                         746             return false;
748           }                                       747           }
749                                                   748 
750           // Optional :                           749           // Optional :
751           bool height_given;                      750           bool height_given;
752           if(_elem->attribute_value(s_height()    751           if(_elem->attribute_value(s_height(),svalue)) { //FIXME : optional ?
753             if(!to_double(svalue,height,a_out,    752             if(!to_double(svalue,height,a_out,s_height())) return false;
754             height_given = true;                  753             height_given = true;
755           } else { // no "height".                754           } else { // no "height".
756             // It is assumed that at fill time    755             // It is assumed that at fill time the weight
757             // argument "w" had always been 1.    756             // argument "w" had always been 1.
758             //   w = 1                            757             //   w = 1
759             //   sw = entries*1 = entries         758             //   sw = entries*1 = entries
760             height = double(entries);             759             height = double(entries);
761             height_given = false;                 760             height_given = false;
762           }                                       761           }
763                                                   762 
764           if(_elem->attribute_value(s_error(),    763           if(_elem->attribute_value(s_error(),svalue)) { //FIXME : optional ?
765             if(!to_double(svalue,error,a_out,s    764             if(!to_double(svalue,error,a_out,s_error())) return false;
766           } else { // no "error"                  765           } else { // no "error"
767             if(height_given) {                    766             if(height_given) {
768               // then we are going to have :      767               // then we are going to have :
769               //   sw = height                    768               //   sw = height
770               //   error = ?                      769               //   error = ?
771               // We can assume that at fill ti    770               // We can assume that at fill time the same weight "w"
772               // had been given to all entries    771               // had been given to all entries. Then :
773               //   sw = entries*w = height        772               //   sw = entries*w = height
774               //   w = height/entries;            773               //   w = height/entries;
775               //   sw2 = entries*(w*w) = (heig    774               //   sw2 = entries*(w*w) = (height**2)/entries
776               //   error = sqrt(sw2) = sqrt((h    775               //   error = sqrt(sw2) = sqrt((height**2)/entries)
777               if(entries) {                       776               if(entries) {
778                 error = ::sqrt(::fabs( ((heigh    777                 error = ::sqrt(::fabs( ((height*height)/entries) ));
779               }                                   778               }
780             } else {                              779             } else {
781               // It is assumed that at fill ti    780               // It is assumed that at fill time the weight
782               // argument "w" had always been     781               // argument "w" had always been 1.
783               //   w = 1                          782               //   w = 1
784               //   sw2 = entries*(w*w) = entri    783               //   sw2 = entries*(w*w) = entries;
785               //   error = sqrt(sw2) = sqrt(en    784               //   error = sqrt(sw2) = sqrt(entries);
786               error = ::sqrt(::fabs(double(ent    785               error = ::sqrt(::fabs(double(entries)));
787             }                                     786             }
788           }                                       787           }
789                                                   788 
790           if(_elem->attribute_value(s_rms(),sv    789           if(_elem->attribute_value(s_rms(),svalue)) {
791             if(!to_double(svalue,rms,a_out,s_r    790             if(!to_double(svalue,rms,a_out,s_rms())) return false;
792           }                                       791           }
793                                                   792 
794           if(dimension==1) {                      793           if(dimension==1) {
795             if(_elem->attribute_value(s_weight    794             if(_elem->attribute_value(s_weightedMean(),svalue)) {
796               if(!to_double(svalue,weightedMea    795               if(!to_double(svalue,weightedMean,a_out,s_weightedMean())) return false;
797             }                                     796             }
798             if(_elem->attribute_value(s_weight    797             if(_elem->attribute_value(s_weightedRms(),svalue)) {
799               if(!to_double(svalue,weightedRms    798               if(!to_double(svalue,weightedRms,a_out,s_weightedRms())) return false;
800             }                                     799             }
801           } else if(dimension==2) {               800           } else if(dimension==2) {
802             if(_elem->attribute_value(s_weight    801             if(_elem->attribute_value(s_weightedMeanX(),svalue)) {
803               if(!to_double(svalue,weightedMea    802               if(!to_double(svalue,weightedMeanX,a_out,s_weightedMeanX())) return false;
804             }                                     803             }
805             if(_elem->attribute_value(s_weight    804             if(_elem->attribute_value(s_weightedMeanY(),svalue)) {
806               if(!to_double(svalue,weightedMea    805               if(!to_double(svalue,weightedMeanY,a_out,s_weightedMeanY())) return false;
807             }                                     806             }
808             if(_elem->attribute_value(s_weight    807             if(_elem->attribute_value(s_weightedRmsX(),svalue)) {
809               if(!to_double(svalue,weightedRms    808               if(!to_double(svalue,weightedRmsX,a_out,s_weightedRmsX())) return false;
810             }                                     809             }
811             if(_elem->attribute_value(s_weight    810             if(_elem->attribute_value(s_weightedRmsY(),svalue)) {
812               if(!to_double(svalue,weightedRms    811               if(!to_double(svalue,weightedRmsY,a_out,s_weightedRmsY())) return false;
813             }                                     812             }
814           } else if(dimension==3) {               813           } else if(dimension==3) {
815             if(_elem->attribute_value(s_weight    814             if(_elem->attribute_value(s_weightedMeanX(),svalue)) {
816               if(!to_double(svalue,weightedMea    815               if(!to_double(svalue,weightedMeanX,a_out,s_weightedMeanX())) return false;
817             }                                     816             }
818             if(_elem->attribute_value(s_weight    817             if(_elem->attribute_value(s_weightedMeanY(),svalue)) {
819               if(!to_double(svalue,weightedMea    818               if(!to_double(svalue,weightedMeanY,a_out,s_weightedMeanY())) return false;
820             }                                     819             }
821             if(_elem->attribute_value(s_weight    820             if(_elem->attribute_value(s_weightedMeanZ(),svalue)) {
822               if(!to_double(svalue,weightedMea    821               if(!to_double(svalue,weightedMeanZ,a_out,s_weightedMeanZ())) return false;
823             }                                     822             }
824             if(_elem->attribute_value(s_weight    823             if(_elem->attribute_value(s_weightedRmsX(),svalue)) {
825               if(!to_double(svalue,weightedRms    824               if(!to_double(svalue,weightedRmsX,a_out,s_weightedRmsX())) return false;
826             }                                     825             }
827             if(_elem->attribute_value(s_weight    826             if(_elem->attribute_value(s_weightedRmsY(),svalue)) {
828               if(!to_double(svalue,weightedRms    827               if(!to_double(svalue,weightedRmsY,a_out,s_weightedRmsY())) return false;
829             }                                     828             }
830             if(_elem->attribute_value(s_weight    829             if(_elem->attribute_value(s_weightedRmsZ(),svalue)) {
831               if(!to_double(svalue,weightedRms    830               if(!to_double(svalue,weightedRmsZ,a_out,s_weightedRmsZ())) return false;
832             }                                     831             }
833           }                                       832           }
834                                                   833 
835          {for(unsigned int index=0;index<dimen    834          {for(unsigned int index=0;index<dimension;index++) {
836             std::string _s = "binNum";            835             std::string _s = "binNum";
837             if(dimension!=1) {                    836             if(dimension!=1) {
838               if(index==0) _s += "X";             837               if(index==0) _s += "X";
839               else if(index==1) _s += "Y";        838               else if(index==1) _s += "Y";
840               else if(index==2) _s += "Z";        839               else if(index==2) _s += "Z";
841             }                                     840             }
842             if(!_elem->attribute_value(_s,sval    841             if(!_elem->attribute_value(_s,svalue)) {
843               a_out << "tools::xml::aidas::rea    842               a_out << "tools::xml::aidas::read_bins :"
844                   << " a <bin1d> has no " << _    843                   << " a <bin1d> has no " << _s << std::endl;
845               return false;                       844               return false;
846             }                                     845             }
847             if(svalue=="UNDERFLOW") {             846             if(svalue=="UNDERFLOW") {
848               is[index] = histo::axis_UNDERFLO    847               is[index] = histo::axis_UNDERFLOW_BIN;
849             } else if(svalue=="OVERFLOW") {       848             } else if(svalue=="OVERFLOW") {
850               is[index] = histo::axis_OVERFLOW    849               is[index] = histo::axis_OVERFLOW_BIN;
851             } else {                              850             } else {
852               int ival = 0;                       851               int ival = 0;
853               if(!to<int>(svalue,ival)) {         852               if(!to<int>(svalue,ival)) {
854                 a_out << "tools::xml::aidas::r    853                 a_out << "tools::xml::aidas::read_bins :"
855                     << " problem converting bi    854                     << " problem converting binNum to an int."
856                     << " Value was " << sout(s    855                     << " Value was " << sout(svalue) << "."
857                     << std::endl;                 856                     << std::endl;
858                 return false;                     857                 return false;
859               }                                   858               }
860               int ibin = ival;                    859               int ibin = ival;
861               if( (ibin<0) || (ibin>=(int)aDat    860               if( (ibin<0) || (ibin>=(int)aData.m_axes[index].bins()) ) {
862                 a_out << "tools::xml::aidas::r    861                 a_out << "tools::xml::aidas::read_bins :"
863                     << " a binNum is out of ra    862                     << " a binNum is out of range."
864                     << std::endl;                 863                     << std::endl;
865                 return false;                     864                 return false;
866               }                                   865               }
867               is[index] = ibin;                   866               is[index] = ibin;
868             }                                     867             }
869           }}                                      868           }}
870                                                   869 
871           // If we are here, then we have a va    870           // If we are here, then we have a valid bin :
872           bn_t offset;                            871           bn_t offset;
873           histo::get_offset(aData.m_axes,is,of    872           histo::get_offset(aData.m_axes,is,offset);
874           aData.m_bin_entries[offset] = entrie    873           aData.m_bin_entries[offset] = entries;
875                                                   874 
876           if(!a_is_prof) {                        875           if(!a_is_prof) {
877                                                   876 
878             // From histo::base_histo, we have    877             // From histo::base_histo, we have :
879             //  height = sw                       878             //  height = sw
880             //  error = sqrt(sw)                  879             //  error = sqrt(sw)
881             //  weightedMean = sxw/sw             880             //  weightedMean = sxw/sw
882             //  weightedRms = sqrt(fabs(sx2w/s    881             //  weightedRms = sqrt(fabs(sx2w/sw - (sxw/sw)**2))
883                                                   882 
884             double sw = height;                   883             double sw = height;
885             aData.m_bin_Sw[offset] = sw;          884             aData.m_bin_Sw[offset] = sw;
886             aData.m_bin_Sw2[offset] = error *     885             aData.m_bin_Sw2[offset] = error * error;
887             if(dimension==1) {                    886             if(dimension==1) {
888               aData.m_bin_Sxw[offset][0] = wei    887               aData.m_bin_Sxw[offset][0] = weightedMean * sw;
889               aData.m_bin_Sx2w[offset][0] =       888               aData.m_bin_Sx2w[offset][0] =
890                 (weightedRms * weightedRms + w    889                 (weightedRms * weightedRms + weightedMean * weightedMean) * sw;
891             } else if(dimension==2){              890             } else if(dimension==2){
892               // X                                891               // X
893               aData.m_bin_Sxw[offset][0] = wei    892               aData.m_bin_Sxw[offset][0] = weightedMeanX * sw;
894               aData.m_bin_Sx2w[offset][0] =       893               aData.m_bin_Sx2w[offset][0] =
895                 (weightedRmsX*weightedRmsX + w    894                 (weightedRmsX*weightedRmsX + weightedMeanX*weightedMeanX) * sw;
896               // Y :                              895               // Y :
897               aData.m_bin_Sxw[offset][1] = wei    896               aData.m_bin_Sxw[offset][1] = weightedMeanY * sw;
898               aData.m_bin_Sx2w[offset][1] =       897               aData.m_bin_Sx2w[offset][1] =
899                 (weightedRmsY*weightedRmsY + w    898                 (weightedRmsY*weightedRmsY + weightedMeanY*weightedMeanY) * sw;
900             } else if(dimension==3){              899             } else if(dimension==3){
901               // X                                900               // X
902               aData.m_bin_Sxw[offset][0] = wei    901               aData.m_bin_Sxw[offset][0] = weightedMeanX * sw;
903               aData.m_bin_Sx2w[offset][0] =       902               aData.m_bin_Sx2w[offset][0] =
904                 (weightedRmsX*weightedRmsX + w    903                 (weightedRmsX*weightedRmsX + weightedMeanX*weightedMeanX) * sw;
905               // Y :                              904               // Y :
906               aData.m_bin_Sxw[offset][1] = wei    905               aData.m_bin_Sxw[offset][1] = weightedMeanY * sw;
907               aData.m_bin_Sx2w[offset][1] =       906               aData.m_bin_Sx2w[offset][1] =
908                 (weightedRmsY*weightedRmsY + w    907                 (weightedRmsY*weightedRmsY + weightedMeanY*weightedMeanY) * sw;
909               // Z :                              908               // Z :
910               aData.m_bin_Sxw[offset][2] = wei    909               aData.m_bin_Sxw[offset][2] = weightedMeanZ * sw;
911               aData.m_bin_Sx2w[offset][2] =       910               aData.m_bin_Sx2w[offset][2] =
912                 (weightedRmsZ*weightedRmsZ + w    911                 (weightedRmsZ*weightedRmsZ + weightedMeanZ*weightedMeanZ) * sw;
913             }                                     912             }
914                                                   913 
915           } else { // Profile :                   914           } else { // Profile :
916                                                   915 
917             // bin writing is :                   916             // bin writing is :
918             // " height=" << sout(aObj.bin_hei    917             // " height=" << sout(aObj.bin_height(aIndex))
919             // " error=" << sout(aObj.bin_erro    918             // " error=" << sout(aObj.bin_error(aIndex))
920             // " weightedMean=" << sout(aObj.b    919             // " weightedMean=" << sout(aObj.bin_mean(aIndex))
921             // " rms=" << sout(aObj.bin_rms_va    920             // " rms=" << sout(aObj.bin_rms_value(aIndex))
922             // " weightedRms=" << sout(bin_rms    921             // " weightedRms=" << sout(bin_rms(aIndex));
923                                                   922 
924             // From inlib profile, we have :      923             // From inlib profile, we have :
925             //  height = svw / sw                 924             //  height = svw / sw
926             //  error = sqrt(fabs(sv2w/sw - (s    925             //  error = sqrt(fabs(sv2w/sw - (svw/sw)**2))/sqrt(sw)
927             //  rms = sqrt(fabs(sv2w/sw - (svw    926             //  rms = sqrt(fabs(sv2w/sw - (svw/sw)**2))
928             //  weightedMean = sxw/sw             927             //  weightedMean = sxw/sw
929             //  weightedRms = sqrt(fabs(sx2w/s    928             //  weightedRms = sqrt(fabs(sx2w/sw - (sxw/sw)**2))
930                                                   929 
931             // Then :                             930             // Then :
932             //  sw = (rms/error)**2               931             //  sw = (rms/error)**2
933             //  svw = sw * height                 932             //  svw = sw * height
934             //  sv2w = sw * (rms**2 + height**    933             //  sv2w = sw * (rms**2 + height**2)
935             //  sxw = weightedMean * sw           934             //  sxw = weightedMean * sw
936             //  sx2w = (weightedRms*weightedRm    935             //  sx2w = (weightedRms*weightedRms+weightedMean*weightedMean) * sw;
937                                                   936 
938             double sw = 0;                        937             double sw = 0;
939             if(error==0) {                        938             if(error==0) {
940               // sv2w/sw = (svw/sw)**2            939               // sv2w/sw = (svw/sw)**2
941               // h = svw/sw                       940               // h = svw/sw
942               //FIXME : we lack an info to get    941               //FIXME : we lack an info to get sw.
943               // We assume that at fill time w    942               // We assume that at fill time weight==1 then :
944               //   sw == n                        943               //   sw == n
945               sw = (double)entries;               944               sw = (double)entries;
946             } else {                              945             } else {
947               double r_e = rms/error;             946               double r_e = rms/error;
948               sw = r_e * r_e;                     947               sw = r_e * r_e;
949             }                                     948             }
950             aData.m_bin_Sw[offset] = sw;          949             aData.m_bin_Sw[offset] = sw;
951             aData.m_bin_Sw2[offset] = 0; //FIX    950             aData.m_bin_Sw2[offset] = 0; //FIXME
952             if(dimension==1) {                    951             if(dimension==1) {
953               aData.m_bin_Sxw[offset][0] = wei    952               aData.m_bin_Sxw[offset][0] = weightedMean * sw;
954               aData.m_bin_Sx2w[offset][0] =       953               aData.m_bin_Sx2w[offset][0] =
955                 (weightedRms * weightedRms + w    954                 (weightedRms * weightedRms + weightedMean * weightedMean) * sw;
956             } else if(dimension==2){              955             } else if(dimension==2){
957               aData.m_bin_Sxw[offset][0] = wei    956               aData.m_bin_Sxw[offset][0] = weightedMeanX * sw;
958               aData.m_bin_Sxw[offset][1] = wei    957               aData.m_bin_Sxw[offset][1] = weightedMeanY * sw;
959               aData.m_bin_Sx2w[offset][0] =       958               aData.m_bin_Sx2w[offset][0] =
960                 (weightedRmsX*weightedRmsX + w    959                 (weightedRmsX*weightedRmsX + weightedMeanX*weightedMeanX) * sw;
961               aData.m_bin_Sx2w[offset][1] =       960               aData.m_bin_Sx2w[offset][1] =
962                 (weightedRmsY*weightedRmsY + w    961                 (weightedRmsY*weightedRmsY + weightedMeanY*weightedMeanY) * sw;
963             }                                     962             }
964             aData.m_bin_Svw[offset] = sw * hei    963             aData.m_bin_Svw[offset] = sw * height;
965             aData.m_bin_Sv2w[offset] = sw * (r    964             aData.m_bin_Sv2w[offset] = sw * (rms * rms + height * height);
966                                                   965 
967           }                                       966           }
968         }                                         967         }
969       }}                                          968       }}
970                                                   969 
971       return true;                                970       return true;
972     }                                             971     }
973                                                   972 
974     return false;                                 973     return false;
975   }                                               974   }
976                                                   975 
977   static bool axis_index(unsigned int a_dim,co    976   static bool axis_index(unsigned int a_dim,const std::string& a_axis,int& a_index) {
978     if(a_dim==1) {                                977     if(a_dim==1) {
979       if(a_axis=="x") {a_index = 0;return true    978       if(a_axis=="x") {a_index = 0;return true;}
980     } else if(a_dim==2) {                         979     } else if(a_dim==2) {
981       if(a_axis=="x") {a_index = 0;return true    980       if(a_axis=="x") {a_index = 0;return true;}
982       else if(a_axis=="y") {a_index = 1;return    981       else if(a_axis=="y") {a_index = 1;return true;}
983     } else if(a_dim==3) {                         982     } else if(a_dim==3) {
984       if(a_axis=="x") {a_index = 0;return true    983       if(a_axis=="x") {a_index = 0;return true;}
985       else if(a_axis=="y") {a_index = 1;return    984       else if(a_axis=="y") {a_index = 1;return true;}
986       else if(a_axis=="z") {a_index = 2;return    985       else if(a_axis=="z") {a_index = 2;return true;}
987     }                                             986     }
988     return false;                                 987     return false;
989   }                                               988   }
990                                                   989 
991   ////////////////////////////////////////////    990   ///////////////////////////////////////////////////////////////
992   /// read ntuple ////////////////////////////    991   /// read ntuple ///////////////////////////////////////////////
993   ////////////////////////////////////////////    992   ///////////////////////////////////////////////////////////////
994   class colbook {                                 993   class colbook {
995   public:                                         994   public:
996     colbook(const std::string& a_type,            995     colbook(const std::string& a_type,
997             const std::string& a_name,            996             const std::string& a_name,
998             const std::string& a_s,               997             const std::string& a_s,
999             bool a_ntu)                           998             bool a_ntu)
1000     :m_type(a_type),m_name(a_name),m_def_or_b    999     :m_type(a_type),m_name(a_name),m_def_or_bkg(a_s),m_ntu(a_ntu){}
1001   public:                                        1000   public:
1002     colbook(const colbook& a_from)               1001     colbook(const colbook& a_from)
1003     :m_type(a_from.m_type)                       1002     :m_type(a_from.m_type)
1004     ,m_name(a_from.m_name)                       1003     ,m_name(a_from.m_name)
1005     ,m_def_or_bkg(a_from.m_def_or_bkg)           1004     ,m_def_or_bkg(a_from.m_def_or_bkg)
1006     ,m_ntu(a_from.m_ntu)                         1005     ,m_ntu(a_from.m_ntu)
1007     {}                                           1006     {}
1008                                                  1007 
1009     colbook& operator=(const colbook& a_from)    1008     colbook& operator=(const colbook& a_from){
1010       if(&a_from==this) return *this;            1009       if(&a_from==this) return *this;
1011       m_type = a_from.m_type;                    1010       m_type = a_from.m_type;
1012       m_name = a_from.m_name;                    1011       m_name = a_from.m_name;
1013       m_def_or_bkg = a_from.m_def_or_bkg;        1012       m_def_or_bkg = a_from.m_def_or_bkg;
1014       m_ntu = a_from.m_ntu;                      1013       m_ntu = a_from.m_ntu;
1015       return *this;                              1014       return *this;
1016     }                                            1015     }
1017   public:                                        1016   public:
1018     const std::string& type() const {return m    1017     const std::string& type() const {return m_type;}
1019     const std::string& name() const {return m    1018     const std::string& name() const {return m_name;}
1020     const std::string& def_or_bkg() const {re    1019     const std::string& def_or_bkg() const {return m_def_or_bkg;}
1021     bool is_ntu() const {return m_ntu;}          1020     bool is_ntu() const {return m_ntu;}
1022   protected:                                     1021   protected:
1023     std::string m_type;                          1022     std::string m_type;
1024     std::string m_name;                          1023     std::string m_name;
1025     std::string m_def_or_bkg;                    1024     std::string m_def_or_bkg;
1026     bool m_ntu;                                  1025     bool m_ntu;
1027   };                                             1026   };
1028                                                  1027 
1029   static bool read_ntu_columns(tree& a_tree,     1028   static bool read_ntu_columns(tree& a_tree,
1030                                  bool& a_foun    1029                                  bool& a_found,
1031                                  std::vector<    1030                                  std::vector<colbook>& a_booking,
1032                                  std::ostream    1031                                  std::ostream& a_out){
1033     a_found = false;                             1032     a_found = false;
1034     a_booking.clear();                           1033     a_booking.clear();
1035                                                  1034 
1036     const std::string& tag_name = a_tree.tag_    1035     const std::string& tag_name = a_tree.tag_name();
1037                                                  1036 
1038     if(tag_name=="columns") {                    1037     if(tag_name=="columns") {
1039                                                  1038 
1040      {looper _for(a_tree);                       1039      {looper _for(a_tree);
1041       while(element* _elem = _for.next_elemen    1040       while(element* _elem = _for.next_element()) {
1042                                                  1041 
1043         if(_elem->name()=="column") {            1042         if(_elem->name()=="column") {
1044           std::string stype;                     1043           std::string stype;
1045           if(!_elem->attribute_value(s_type()    1044           if(!_elem->attribute_value(s_type(),stype)) {
1046             a_out << "tools::xml::aidas::read    1045             a_out << "tools::xml::aidas::read_ntu_columns :"
1047                   << " atb type missing on <c    1046                   << " atb type missing on <column>"
1048                   << std::endl;                  1047                   << std::endl;
1049             return false;                        1048             return false;
1050           }                                      1049           }
1051           std::string sname;                     1050           std::string sname;
1052           if(!_elem->attribute_value(s_name()    1051           if(!_elem->attribute_value(s_name(),sname)) {
1053             a_out << "tools::xml::aidas::read    1052             a_out << "tools::xml::aidas::read_ntu_columns :"
1054                   << " atb name missing on <c    1053                   << " atb name missing on <column>"
1055                   << std::endl;                  1054                   << std::endl;
1056             return false;                        1055             return false;
1057           }                                      1056           }
1058                                                  1057 
1059           std::string _s;                        1058           std::string _s;
1060           if(_elem->attribute_value(s_booking    1059           if(_elem->attribute_value(s_booking(),_s)) {
1061             a_booking.push_back(colbook(stype    1060             a_booking.push_back(colbook(stype,sname,_s,true));
1062           } else if(_elem->attribute_value(s_    1061           } else if(_elem->attribute_value(s_default(),_s)) {
1063             a_booking.push_back(colbook(stype    1062             a_booking.push_back(colbook(stype,sname,_s,false));
1064           } else {                               1063           } else {
1065             a_booking.push_back(colbook(stype    1064             a_booking.push_back(colbook(stype,sname,"",false));
1066           }                                      1065           }
1067         }                                        1066         }
1068                                                  1067 
1069       }}                                         1068       }}
1070                                                  1069 
1071       a_found = true;                            1070       a_found = true;
1072     }                                            1071     }
1073     return true;                                 1072     return true;
1074   }                                              1073   }
1075                                                  1074 
1076   static bool read_ntu_rows(tree& a_tree,        1075   static bool read_ntu_rows(tree& a_tree,
1077                                    aida::base    1076                                    aida::base_ntu& a_ntu,
1078                                    bool& a_fo    1077                                    bool& a_found,
1079                                    std::ostre    1078                                    std::ostream& a_out){
1080     a_found = false;                             1079     a_found = false;
1081                                                  1080 
1082     const std::string& tag_name = a_tree.tag_    1081     const std::string& tag_name = a_tree.tag_name();
1083                                                  1082 
1084     if(tag_name==s_annotation()) { //FIXME       1083     if(tag_name==s_annotation()) { //FIXME
1085                                                  1084 
1086       return true;                               1085       return true;
1087                                                  1086 
1088     } else if(tag_name==s_columns()) {           1087     } else if(tag_name==s_columns()) {
1089                                                  1088 
1090       return true;                               1089       return true;
1091                                                  1090 
1092     } else if(tag_name==s_rows()) {              1091     } else if(tag_name==s_rows()) {
1093                                                  1092 
1094       // Sub items :                             1093       // Sub items :
1095      {looper _for(a_tree);                       1094      {looper _for(a_tree);
1096       while(tree* _tree = _for.next_tree()) {    1095       while(tree* _tree = _for.next_tree()) {
1097                                                  1096 
1098         if(!read_ntu_rows(*_tree,a_ntu,a_foun    1097         if(!read_ntu_rows(*_tree,a_ntu,a_found,a_out)) {
1099           a_out << "tools::xml::aidas::read_n    1098           a_out << "tools::xml::aidas::read_ntu_rows :"
1100                 << " sub read_ntu_rows failed    1099                 << " sub read_ntu_rows failed."
1101                 << std::endl;                    1100                 << std::endl;
1102           return false;                          1101           return false;
1103         }                                        1102         }
1104                                                  1103 
1105       }}                                         1104       }}
1106                                                  1105 
1107       a_found = true;                            1106       a_found = true;
1108                                                  1107 
1109       return true;                               1108       return true;
1110                                                  1109 
1111     } else if(tag_name==s_row()) {               1110     } else if(tag_name==s_row()) {
1112                                                  1111 
1113       const std::vector<aida::base_col*>& col    1112       const std::vector<aida::base_col*>& cols = a_ntu.columns();
1114                                                  1113 
1115       std::vector<unsigned int> intus;           1114       std::vector<unsigned int> intus;
1116       std::vector<unsigned int> inot_ntus;       1115       std::vector<unsigned int> inot_ntus;
1117      {unsigned int index = 0;                    1116      {unsigned int index = 0;
1118       tools_vforcit(aida::base_col*,cols,it)     1117       tools_vforcit(aida::base_col*,cols,it) {
1119         if(safe_cast<aida::base_col,aida::aid    1118         if(safe_cast<aida::base_col,aida::aida_col_ntu>(*(*it))) {
1120           intus.push_back(index);                1119           intus.push_back(index);
1121         } else {                                 1120         } else {
1122           inot_ntus.push_back(index);            1121           inot_ntus.push_back(index);
1123         }                                        1122         }
1124         index++;                                 1123         index++;
1125       }}                                         1124       }}
1126                                                  1125 
1127       std::string svalue;                        1126       std::string svalue;
1128                                                  1127 
1129      {unsigned int icol = 0;                     1128      {unsigned int icol = 0;
1130                                                  1129 
1131      {looper _for(a_tree);                       1130      {looper _for(a_tree);
1132       while(element* _elem = _for.next_elemen    1131       while(element* _elem = _for.next_element()) {
1133                                                  1132 
1134         if(_elem->name()==s_entry()) {           1133         if(_elem->name()==s_entry()) {
1135           if(!_elem->attribute_value(s_value(    1134           if(!_elem->attribute_value(s_value(),svalue)) {
1136             a_out << "tools::xml::aidas::read    1135             a_out << "tools::xml::aidas::read_ntu_rows :"
1137                   << " can't get \"value\" at    1136                   << " can't get \"value\" attribute." << std::endl;
1138             return false;                        1137             return false;
1139           }                                      1138           }
1140           if(icol>=inot_ntus.size()) {           1139           if(icol>=inot_ntus.size()) {
1141             a_out << "tools::xml::aidas::read    1140             a_out << "tools::xml::aidas::read_ntu_rows :"
1142                   << " too much <entry>." <<     1141                   << " too much <entry>." << std::endl;
1143             return false;                        1142             return false;
1144           }                                      1143           }
1145           if(inot_ntus[icol]>=cols.size()) {     1144           if(inot_ntus[icol]>=cols.size()) {
1146             a_out << "tools::xml::aidas::read    1145             a_out << "tools::xml::aidas::read_ntu_rows :"
1147                   << " too much <entry>." <<     1146                   << " too much <entry>." << std::endl;
1148             return false;                        1147             return false;
1149           }                                      1148           }
1150                                                  1149 
1151           aida::base_col* bcol = cols[inot_nt    1150           aida::base_col* bcol = cols[inot_ntus[icol]];
1152                                                  1151 
1153           aida::aida_base_col* abcol =           1152           aida::aida_base_col* abcol =
1154           safe_cast<aida::base_col,aida::aida    1153           safe_cast<aida::base_col,aida::aida_base_col>(*bcol);
1155                                                  1154 
1156           if(!abcol->s_fill(svalue)) {           1155           if(!abcol->s_fill(svalue)) {
1157             a_out << "tools::xml::aidas::read    1156             a_out << "tools::xml::aidas::read_ntu_rows :"
1158                   << " can't get \"value\" at    1157                   << " can't get \"value\" attribute." << std::endl;
1159             return false;                        1158             return false;
1160           }                                      1159           }
1161           icol++;                                1160           icol++;
1162         }                                        1161         }
1163                                                  1162 
1164       }}}                                        1163       }}}
1165                                                  1164 
1166       // Sub items (entryITuple) :               1165       // Sub items (entryITuple) :
1167      {unsigned int icol = 0;                     1166      {unsigned int icol = 0;
1168                                                  1167 
1169      {looper _for(a_tree);                       1168      {looper _for(a_tree);
1170       while(tree* _tree = _for.next_tree()) {    1169       while(tree* _tree = _for.next_tree()) {
1171                                                  1170 
1172         const std::string& _tag_name = _tree-    1171         const std::string& _tag_name = _tree->tag_name();
1173         if(  (_tag_name==s_entryITuple())  ||    1172         if(  (_tag_name==s_entryITuple())  || //aida.dtd spec.
1174              (_tag_name==s_entryTuple())   ){    1173              (_tag_name==s_entryTuple())   ){ //backward comp.
1175           if(icol>=intus.size()) {               1174           if(icol>=intus.size()) {
1176             a_out << "tools::xml::aidas::read    1175             a_out << "tools::xml::aidas::read_ntu_rows :"
1177                   << " too much <entry>." <<     1176                   << " too much <entry>." << std::endl;
1178             return false;                        1177             return false;
1179           }                                      1178           }
1180           if(intus[icol]>=cols.size()) {         1179           if(intus[icol]>=cols.size()) {
1181             a_out << "tools::xml::aidas::read    1180             a_out << "tools::xml::aidas::read_ntu_rows :"
1182                   << " too much <entry>." <<     1181                   << " too much <entry>." << std::endl;
1183             return false;                        1182             return false;
1184           }                                      1183           }
1185                                                  1184 
1186           aida::base_col* bcol = cols[intus[i    1185           aida::base_col* bcol = cols[intus[icol]];
1187           aida::aida_col_ntu* col_ntu = safe_    1186           aida::aida_col_ntu* col_ntu = safe_cast<aida::base_col,aida::aida_col_ntu>(*bcol);
1188           if(!col_ntu) {                         1187           if(!col_ntu) {
1189             a_out << "tools::xml::aidas::read    1188             a_out << "tools::xml::aidas::read_ntu_rows :"
1190                   << " can't cast to bcol_ntu    1189                   << " can't cast to bcol_ntu."
1191                   << std::endl;                  1190                   << std::endl;
1192             return false;                        1191             return false;
1193           }                                      1192           }
1194           aida::base_ntu* ntu = col_ntu->get_    1193           aida::base_ntu* ntu = col_ntu->get_to_fill();
1195           if(!ntu) {                             1194           if(!ntu) {
1196             a_out << "tools::xml::aidas::read    1195             a_out << "tools::xml::aidas::read_ntu_rows :"
1197                   << " get_to_fill() returned    1196                   << " get_to_fill() returned null."
1198                   << std::endl;                  1197                   << std::endl;
1199             return false;                        1198             return false;
1200           }                                      1199           }
1201                                                  1200 
1202          {looper _for2(*_tree);                  1201          {looper _for2(*_tree);
1203           while(tree* _tree2 = _for2.next_tre    1202           while(tree* _tree2 = _for2.next_tree()) {
1204             bool found;                          1203             bool found;
1205             if(!read_ntu_rows(*_tree2,*ntu,fo    1204             if(!read_ntu_rows(*_tree2,*ntu,found,a_out)) return false;
1206           }}                                     1205           }}
1207                                                  1206 
1208           icol++;                                1207           icol++;
1209         }                                        1208         }
1210                                                  1209 
1211       }}}                                        1210       }}}
1212                                                  1211 
1213       if(!a_ntu.add_row()) {                     1212       if(!a_ntu.add_row()) {
1214         a_out << "tools::xml::aidas::read_ntu    1213         a_out << "tools::xml::aidas::read_ntu_rows :"
1215               << " can't add row to ntuple."     1214               << " can't add row to ntuple."
1216               << std::endl;                      1215               << std::endl;
1217         return false;                            1216         return false;
1218       }                                          1217       }
1219                                                  1218 
1220       return true;                               1219       return true;
1221                                                  1220 
1222     }                                            1221     }
1223                                                  1222 
1224     a_out << "tools::xml::aidas::read_ntu_row    1223     a_out << "tools::xml::aidas::read_ntu_rows :"
1225           << " unknown item class " << sout(t    1224           << " unknown item class " << sout(tag_name) << std::endl;
1226                                                  1225 
1227     return false;                                1226     return false;
1228   }                                              1227   }
1229                                                  1228 
1230   static raxml_out read_ntu(tree& a_tree,std:    1229   static raxml_out read_ntu(tree& a_tree,std::ostream& a_out,bool a_verbose,void*){
1231     std::string sname;                           1230     std::string sname;
1232     a_tree.attribute_value(s_name(),sname);      1231     a_tree.attribute_value(s_name(),sname);
1233                                                  1232 
1234     if(a_verbose) {                              1233     if(a_verbose) {
1235       a_out << "tools::xml::aidas::read_ntu :    1234       a_out << "tools::xml::aidas::read_ntu :"
1236             << " with name " << sout(sname)      1235             << " with name " << sout(sname)
1237             << "..." << std::endl;               1236             << "..." << std::endl;
1238     }                                            1237     }
1239                                                  1238 
1240     std::string spath;                           1239     std::string spath;
1241     a_tree.attribute_value(s_path(),spath);      1240     a_tree.attribute_value(s_path(),spath);
1242                                                  1241 
1243     std::string stitle;                          1242     std::string stitle;
1244     a_tree.attribute_value(s_title(),stitle);    1243     a_tree.attribute_value(s_title(),stitle);
1245                                                  1244 
1246     //FIXME annotation                           1245     //FIXME annotation
1247                                                  1246 
1248     // Booking parameters :                      1247     // Booking parameters :
1249     std::vector<colbook> booking;                1248     std::vector<colbook> booking;
1250                                                  1249 
1251     // Jump in subitems to find columns items    1250     // Jump in subitems to find columns items :
1252     bool found = false;                          1251     bool found = false;
1253                                                  1252 
1254    {looper _for(a_tree);                         1253    {looper _for(a_tree);
1255     while(tree* _tree = _for.next_tree()) {      1254     while(tree* _tree = _for.next_tree()) {
1256       if(!read_ntu_columns(*_tree,found,booki    1255       if(!read_ntu_columns(*_tree,found,booking,a_out)) return raxml_out();
1257       if(found) break;                           1256       if(found) break;
1258     }}                                           1257     }}
1259                                                  1258 
1260     if(!found) {                                 1259     if(!found) {
1261       a_out << "tools::xml::aidas::read_ntu :    1260       a_out << "tools::xml::aidas::read_ntu :"
1262             << " for ntuple name " << sout(sn    1261             << " for ntuple name " << sout(sname)
1263             << " unable to read columns..." <    1262             << " unable to read columns..." << std::endl;
1264       return raxml_out();                        1263       return raxml_out();
1265     }                                            1264     }
1266                                                  1265 
1267     // Create a aida::ntuple :                   1266     // Create a aida::ntuple :
1268     aida::ntuple* ntu = new aida::ntuple(a_ou    1267     aida::ntuple* ntu = new aida::ntuple(a_out,stitle);
1269    {tools_vforcit(colbook,booking,it) {          1268    {tools_vforcit(colbook,booking,it) {
1270       if(!aida::create_col(*ntu,                 1269       if(!aida::create_col(*ntu,
1271                                (*it).type(),     1270                                (*it).type(),
1272                                (*it).name(),     1271                                (*it).name(),
1273                                (*it).def_or_b    1272                                (*it).def_or_bkg(),
1274                                (*it).is_ntu()    1273                                (*it).is_ntu())){
1275         delete ntu;                              1274         delete ntu;
1276         return raxml_out();                      1275         return raxml_out();
1277       }                                          1276       }
1278     }}                                           1277     }}
1279                                                  1278 
1280     if(!ntu->columns().size()) { //??? we cou    1279     if(!ntu->columns().size()) { //??? we could have an empty ntu !
1281       a_out << "tools::xml::aidas::read_ntu :    1280       a_out << "tools::xml::aidas::read_ntu :"
1282             << " for ntuple name " << sout(sn    1281             << " for ntuple name " << sout(sname)
1283             << " unable to create a aida::ntu    1282             << " unable to create a aida::ntuple." << std::endl;
1284       delete ntu;                                1283       delete ntu;
1285       return raxml_out();                        1284       return raxml_out();
1286     }                                            1285     }
1287                                                  1286 
1288     // Get rows in sub items :                   1287     // Get rows in sub items :
1289     found = false;                               1288     found = false;
1290                                                  1289 
1291    {looper _for(a_tree);                         1290    {looper _for(a_tree);
1292     while(tree* _tree = _for.next_tree()) {      1291     while(tree* _tree = _for.next_tree()) {
1293                                                  1292 
1294       if(!read_ntu_rows(*_tree,*ntu,found,a_o    1293       if(!read_ntu_rows(*_tree,*ntu,found,a_out)) {
1295         a_out << "tools::xml::aidas::read_ntu    1294         a_out << "tools::xml::aidas::read_ntu :"
1296               << " for ntuple name " << sout(    1295               << " for ntuple name " << sout(sname)
1297               << " unable to read rows." << s    1296               << " unable to read rows." << std::endl;
1298         delete ntu;                              1297         delete ntu;
1299         return raxml_out();                      1298         return raxml_out();
1300       }                                          1299       }
1301       if(found) break;                           1300       if(found) break;
1302                                                  1301 
1303     }}                                           1302     }}
1304                                                  1303 
1305     if(a_verbose) {                              1304     if(a_verbose) {
1306       a_out << "tools::xml::aidas::read_ntu :    1305       a_out << "tools::xml::aidas::read_ntu :"
1307             << " name " << sout(sname)           1306             << " name " << sout(sname)
1308             << " done." << std::endl;            1307             << " done." << std::endl;
1309     }                                            1308     }
1310                                                  1309 
1311     std::string sclass = aida::ntuple::s_clas    1310     std::string sclass = aida::ntuple::s_class();
1312     return raxml_out(new handle<aida::ntuple>    1311     return raxml_out(new handle<aida::ntuple>(ntu),sclass,spath,sname);
1313   }                                              1312   }
1314                                                  1313 
1315   ///////////////////////////////////////////    1314   ///////////////////////////////////////////////////////////////
1316   /// read cloud ////////////////////////////    1315   /// read cloud ////////////////////////////////////////////////
1317   ///////////////////////////////////////////    1316   ///////////////////////////////////////////////////////////////
1318                                                  1317 
1319   static bool read_cloud_data(tree& a_tree,      1318   static bool read_cloud_data(tree& a_tree,
1320                               histo::c1d& aCl    1319                               histo::c1d& aCloud,bool a_verbose,
1321                               std::ostream& a    1320                               std::ostream& a_out){
1322     const std::string& tagName = a_tree.tag_n    1321     const std::string& tagName = a_tree.tag_name();
1323                                                  1322 
1324     std::string svalue;                          1323     std::string svalue;
1325                                                  1324 
1326     if(tagName==s_annotation()) { //FIXME        1325     if(tagName==s_annotation()) { //FIXME
1327                                                  1326 
1328       return true;                               1327       return true;
1329                                                  1328 
1330     } else if(tagName==s_entries1d()) {          1329     } else if(tagName==s_entries1d()) {
1331                                                  1330 
1332      {looper _for(a_tree);                       1331      {looper _for(a_tree);
1333       while(element* _elem = _for.next_elemen    1332       while(element* _elem = _for.next_element()) {
1334         if(_elem->name()==s_entry1d()) {         1333         if(_elem->name()==s_entry1d()) {
1335           double x;                              1334           double x;
1336           if(!_elem->attribute_value(s_valueX    1335           if(!_elem->attribute_value(s_valueX(),x)) return false;
1337           double w = 1;                          1336           double w = 1;
1338           if(_elem->attribute_value(s_weight(    1337           if(_elem->attribute_value(s_weight(),svalue)) {
1339             if(!to<double>(svalue,w)) return     1338             if(!to<double>(svalue,w)) return false;
1340           }                                      1339           }
1341           if(!aCloud.fill(x,w)) return false;    1340           if(!aCloud.fill(x,w)) return false;
1342         }                                        1341         }
1343       }}                                         1342       }}
1344       return true;                               1343       return true;
1345                                                  1344 
1346     } else if(tagName==s_histogram1d()) {        1345     } else if(tagName==s_histogram1d()) {
1347                                                  1346 
1348       raxml_out ro = read_h1d(a_tree,a_out,a_    1347       raxml_out ro = read_h1d(a_tree,a_out,a_verbose,0);
1349       if(ro.cls()==histo::h1d::s_class()) {      1348       if(ro.cls()==histo::h1d::s_class()) {
1350         histo::h1d* h = (histo::h1d*)ro.objec    1349         histo::h1d* h = (histo::h1d*)ro.object();
1351         if(h) {                                  1350         if(h) {
1352           aCloud.set_histogram(h);               1351           aCloud.set_histogram(h);
1353           ro.disown();                           1352           ro.disown();
1354         }                                        1353         }
1355       }                                          1354       }
1356       return true;                               1355       return true;
1357                                                  1356 
1358     }                                            1357     }
1359                                                  1358 
1360     return false;                                1359     return false;
1361   }                                              1360   }
1362                                                  1361 
1363   static bool read_cloud_data(tree& a_tree,      1362   static bool read_cloud_data(tree& a_tree,
1364                               histo::c2d& aCl    1363                               histo::c2d& aCloud,
1365                               bool a_verbose,    1364                               bool a_verbose,
1366                               std::ostream& a    1365                               std::ostream& a_out){
1367     const std::string& tagName = a_tree.tag_n    1366     const std::string& tagName = a_tree.tag_name();
1368                                                  1367 
1369     std::string svalue;                          1368     std::string svalue;
1370                                                  1369 
1371     if(tagName==s_annotation()) { //FIXME        1370     if(tagName==s_annotation()) { //FIXME
1372                                                  1371 
1373       return true;                               1372       return true;
1374                                                  1373 
1375     } else if(tagName==s_entries2d()) {          1374     } else if(tagName==s_entries2d()) {
1376                                                  1375 
1377      {looper _for(a_tree);                       1376      {looper _for(a_tree);
1378       while(element* _elem = _for.next_elemen    1377       while(element* _elem = _for.next_element()) {
1379         if(_elem->name()==s_entry2d()) {         1378         if(_elem->name()==s_entry2d()) {
1380           double x;                              1379           double x;
1381           if(!_elem->attribute_value(s_valueX    1380           if(!_elem->attribute_value(s_valueX(),x)) return false;
1382           double y;                              1381           double y;
1383           if(!_elem->attribute_value(s_valueY    1382           if(!_elem->attribute_value(s_valueY(),y)) return false;
1384           double w = 1;                          1383           double w = 1;
1385           if(_elem->attribute_value(s_weight(    1384           if(_elem->attribute_value(s_weight(),svalue)) {
1386             if(!to<double>(svalue,w)) return     1385             if(!to<double>(svalue,w)) return false;
1387           }                                      1386           }
1388           if(!aCloud.fill(x,y,w)) return fals    1387           if(!aCloud.fill(x,y,w)) return false;
1389         }                                        1388         }
1390       }}                                         1389       }}
1391       return true;                               1390       return true;
1392                                                  1391 
1393     } else if(tagName==s_histogram2d()) {        1392     } else if(tagName==s_histogram2d()) {
1394                                                  1393 
1395       raxml_out ro = read_h2d(a_tree,a_out,a_    1394       raxml_out ro = read_h2d(a_tree,a_out,a_verbose,0);
1396       if(ro.cls()==histo::h2d::s_class()) {      1395       if(ro.cls()==histo::h2d::s_class()) {
1397         histo::h2d* h = (histo::h2d*)ro.objec    1396         histo::h2d* h = (histo::h2d*)ro.object();
1398         if(h) {                                  1397         if(h) {
1399           aCloud.set_histogram(h);               1398           aCloud.set_histogram(h);
1400           ro.disown();                           1399           ro.disown();
1401         }                                        1400         }
1402       }                                          1401       }
1403       return true;                               1402       return true;
1404                                                  1403 
1405     }                                            1404     }
1406                                                  1405 
1407     return false;                                1406     return false;
1408   }                                              1407   }
1409                                                  1408 
1410   static bool read_cloud_data(tree& a_tree,      1409   static bool read_cloud_data(tree& a_tree,
1411                               histo::c3d& aCl    1410                               histo::c3d& aCloud,
1412                               bool a_verbose,    1411                               bool a_verbose,
1413                               std::ostream& a    1412                               std::ostream& a_out){
1414     const std::string& tagName = a_tree.tag_n    1413     const std::string& tagName = a_tree.tag_name();
1415                                                  1414 
1416     std::string svalue;                          1415     std::string svalue;
1417                                                  1416 
1418     if(tagName==s_annotation()) { //FIXME        1417     if(tagName==s_annotation()) { //FIXME
1419                                                  1418 
1420       return true;                               1419       return true;
1421                                                  1420 
1422     } else if(tagName==s_entries3d()) {          1421     } else if(tagName==s_entries3d()) {
1423                                                  1422 
1424      {looper _for(a_tree);                       1423      {looper _for(a_tree);
1425       while(element* _elem = _for.next_elemen    1424       while(element* _elem = _for.next_element()) {
1426         if(_elem->name()==s_entry3d()) {         1425         if(_elem->name()==s_entry3d()) {
1427           double x;                              1426           double x;
1428           if(!_elem->attribute_value(s_valueX    1427           if(!_elem->attribute_value(s_valueX(),x)) return false;
1429           double y;                              1428           double y;
1430           if(!_elem->attribute_value(s_valueY    1429           if(!_elem->attribute_value(s_valueY(),y)) return false;
1431           double z;                              1430           double z;
1432           if(!_elem->attribute_value(s_valueZ    1431           if(!_elem->attribute_value(s_valueZ(),z)) return false;
1433           double w = 1;                          1432           double w = 1;
1434           if(_elem->attribute_value(s_weight(    1433           if(_elem->attribute_value(s_weight(),svalue)) {
1435             if(!to<double>(svalue,w)) return     1434             if(!to<double>(svalue,w)) return false;
1436           }                                      1435           }
1437           if(!aCloud.fill(x,y,z,w)) return fa    1436           if(!aCloud.fill(x,y,z,w)) return false;
1438         }                                        1437         }
1439       }}                                         1438       }}
1440       return true;                               1439       return true;
1441                                                  1440 
1442     } else if(tagName==s_histogram3d()) {        1441     } else if(tagName==s_histogram3d()) {
1443                                                  1442 
1444       raxml_out ro = read_h3d(a_tree,a_out,a_    1443       raxml_out ro = read_h3d(a_tree,a_out,a_verbose,0);
1445       if(ro.cls()==histo::h3d::s_class()) {      1444       if(ro.cls()==histo::h3d::s_class()) {
1446         histo::h3d* h = (histo::h3d*)ro.objec    1445         histo::h3d* h = (histo::h3d*)ro.object();
1447         if(h) {                                  1446         if(h) {
1448           aCloud.set_histogram(h);               1447           aCloud.set_histogram(h);
1449           ro.disown();                           1448           ro.disown();
1450         }                                        1449         }
1451       }                                          1450       }
1452       return true;                               1451       return true;
1453                                                  1452 
1454     }                                            1453     }
1455                                                  1454 
1456     return false;                                1455     return false;
1457   }                                              1456   }
1458                                                  1457 
1459   static bool read_dps_data(tree& a_tree,hist    1458   static bool read_dps_data(tree& a_tree,histo::dps& a_dps){
1460     const std::string& tagName = a_tree.tag_n    1459     const std::string& tagName = a_tree.tag_name();
1461                                                  1460 
1462     std::string svalue;                          1461     std::string svalue;
1463                                                  1462 
1464     if(tagName==s_annotation()) { //FIXME        1463     if(tagName==s_annotation()) { //FIXME
1465                                                  1464 
1466       return true;                               1465       return true;
1467                                                  1466 
1468     } else if(tagName==s_dataPoint()) {          1467     } else if(tagName==s_dataPoint()) {
1469                                                  1468 
1470       histo::data_point& point = a_dps.add_po    1469       histo::data_point& point = a_dps.add_point();
1471                                                  1470 
1472       unsigned int coord = 0;                    1471       unsigned int coord = 0;
1473                                                  1472 
1474      {looper _for(a_tree);                       1473      {looper _for(a_tree);
1475       while(element* _elem = _for.next_elemen    1474       while(element* _elem = _for.next_element()) {
1476         if(_elem->name()==s_measurement()) {     1475         if(_elem->name()==s_measurement()) {
1477           if(coord>=a_dps.dimension()) return    1476           if(coord>=a_dps.dimension()) return false;
1478           double value;                          1477           double value;
1479           if(!_elem->attribute_value(s_value(    1478           if(!_elem->attribute_value(s_value(),value)) return false;
1480           double errorPlus = 0;                  1479           double errorPlus = 0;
1481           if(_elem->attribute_value(s_errorPl    1480           if(_elem->attribute_value(s_errorPlus(),svalue)) {
1482             if(!to<double>(svalue,errorPlus))    1481             if(!to<double>(svalue,errorPlus)) return false;
1483           }                                      1482           }
1484           double errorMinus = 0;                 1483           double errorMinus = 0;
1485           if(_elem->attribute_value(s_errorMi    1484           if(_elem->attribute_value(s_errorMinus(),svalue)) {
1486             if(!to<double>(svalue,errorMinus)    1485             if(!to<double>(svalue,errorMinus)) return false;
1487           }                                      1486           }
1488                                                  1487 
1489           histo::measurement& _m = point.coor    1488           histo::measurement& _m = point.coordinate(coord);
1490           _m.set_value(value);                   1489           _m.set_value(value);
1491           _m.set_error_plus(errorPlus);          1490           _m.set_error_plus(errorPlus);
1492           _m.set_error_minus(errorMinus);        1491           _m.set_error_minus(errorMinus);
1493                                                  1492 
1494           coord++;                               1493           coord++;
1495         }                                        1494         }
1496       }}                                         1495       }}
1497       return true;                               1496       return true;
1498                                                  1497 
1499     }                                            1498     }
1500                                                  1499 
1501     return false;                                1500     return false;
1502   }                                              1501   }
1503                                                  1502 
1504                                                  1503 
1505 protected:                                       1504 protected:
1506   readers m_readers;                             1505   readers m_readers;
1507   std::vector<raxml_out> m_objects;              1506   std::vector<raxml_out> m_objects;
1508 };                                               1507 };
1509                                                  1508 
1510 }}                                               1509 }}
1511                                                  1510 
1512 #endif                                           1511 #endif