00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef HxIndxHisto_H
00018 #define HxIndxHisto_H
00019
00020 #include "HxIndxArray.h"
00021 #include "HxHistoList.h"
00022
00023 template<class ArrayT> ArrayT* getData(HxHistoList);
00024 template long* getData(HxHistoList);
00025 template float* getData(HxHistoList);
00026
00027 template<class HeaderT>
00028 class IndxHistHeaderT {
00029 public:
00030 friend STD_OSTREAM& operator<<(STD_OSTREAM& os,
00031 const IndxHistHeaderT& l)
00032 {return os << l.bins << " bins, " << l.chans <<
00033 ((l.chans == 1) ? HxString(" channel") :
00034 HxString(" channels"));}
00035
00037 int dimensionality() const
00038 { if (dimensionSize(3)>1)
00039 return 3;
00040 else
00041 if (dimensionSize(2)>1)
00042 return 2;
00043 return 1;
00044 }
00045
00049 int dimensionSize(int d) const
00050 { return dim[d-1]; }
00051
00053 double lowBin(int d) const
00054 { return low[d-1]; }
00055
00057 double highBin(int d) const
00058 { return high[d-1]; }
00059
00063 HxValueType dataType() const
00064 { return _dataType;}
00065
00066 int bins;
00067 int chans;
00068 HeaderT header;
00069
00070 int dim[3];
00071 double low[3];
00072 double high[3];
00073 HxValueType _dataType;
00074 };
00075
00076
00077 template<class ArrayT, class HeaderT>
00078 class indexedHisto : public indexedArray<ArrayT, IndxHistHeaderT<HeaderT> > {
00079 public:
00080 void create(HxString indexFile, HeaderT header);
00081 void add(HxString& key, HxHistoList& l);
00082 void search(HxHistoList& target, int n = 10, int refine = 0);
00083
00084
00085 int bins() const;
00086 int chans() const;
00087 HeaderT header() const;
00088 int dimensionSize(int d) const;
00089 int dimensionality() const;
00090 HxValueType dataType() const;
00091 double lowBin(int d) const;
00092 double highBin(int d) const;
00093
00094 friend STD_OSTREAM& operator<<(STD_OSTREAM& os,
00095 const indexedHisto& l)
00096 {return l.put(os);}
00097
00098 int arraySize(const IndxHistHeaderT<HeaderT>& header) const
00099 {return header.bins*header.chans;}
00100
00101 virtual double compare(ArrayT *e1, ArrayT *e2,
00102 const IndxHistHeaderT<HeaderT>& header) const;
00103
00104
00105 HxHistogram at(int ndx, int c=0) const;
00106
00107
00108 HxHistoList listAt(int ndx) const;
00109
00110
00111 HxHistogram get(HxString key, int c=0) const;
00112
00113
00114 HxString getKey(int ndx) const
00115 {return indexedArray<ArrayT, IndxHistHeaderT<HeaderT> >
00116 ::getKey(ndx);}
00117
00118 private:
00119
00120 HxHistogram makeHistogram(ArrayT* arr, int c=0) const;
00121
00122 int _create;
00123 HeaderT _header;
00124 };
00125
00126
00127 #ifdef INC_TEMPLATE_SRC
00128 #include "HxIndxHisto.c"
00129 #endif
00130
00131 #endif