//------------------------------------------------------------------------------ // Main data class -- // (C) Piero Giubilato 2008-2010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "data_Layer.h" // [Author] "Piero Giubilato" // [Version] "1.1" // [Modified by] "Piero Giubilato" // [Last revision] "27 Jul 2009" // [Language] "C++" // [Compiler] "Visual C++ 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Main data class" // [Key documentation] // "Root user's guide" // "Visual C++ Reference Help" // {Trace} //______________________________________________________________________________ // Overloading check #ifndef data_Layer_H #define data_Layer_H // Keep ROOTCInt out of this! #ifndef __CINT__ // Standard componend #include // Root components #include #include // Application components #include "global.h" #include "data_Object.h" #include "data_Cluster.h" // Template definition //#define tT template #define tU template #define dL_T data_Layer #define dL_U data_Layer //______________________________________________________________________________ template class data_Layer: public data_Object { private: // Class identifiers static const UShort_t class_Ver = 1; // Class version // Data containers T* dp_Array; // Main data point (dp) array UInt_t dp_array_col_Count; // dp columns count UInt_t dp_array_row_Count; // dp rows count // Data functions void data_Resize(UInt_t col_Count, UInt_t row_Count); tU void data_Copy(const dL_U&); tU void data_Math(const U&, UInt_t Operation); tU void data_Math(const dL_U&, UInt_t Operation); // Konstants enum ka {km_Set, km_Add, km_Sub, km_Mul, km_Div, km_Sqr, km_Pow, km_Mir}; public: // Special member functions data_Layer(); // Default ctor data_Layer(UInt_t col_Count, UInt_t row_Count); // Dimension ctor data_Layer(const dL_T&); // Copy ctor to avoid compiler override tU data_Layer(const dL_U&); // Copy ctor ~data_Layer(); // Dtor // Operator = dL_T& operator=(const dL_T& ro) {data_Copy(ro); return *this;} tU dL_T& operator=(const dL_U& ro) {data_Copy(ro); return *this;} tU dL_T& operator=(const U& ro) {data_Math(ro, km_Set); return *this;} // Self assignement member unary operators (work on data_Layers and scalars) tU dL_T& operator+=(const U& ro) {data_Math(ro, km_Add); return *this;} tU dL_T& operator-=(const U& ro) {data_Math(ro, km_Sub); return *this;} tU dL_T& operator*=(const U& ro) {data_Math(ro, km_Mul); return *this;} tU dL_T& operator/=(const U& ro) {data_Math(ro, km_Div); return *this;} // New object member unary operators (work on data_Layers and scalars) tU dL_T operator+(const U& ro) {return dL_T(*this) += ro;} tU dL_T operator-(const U& ro) {return dL_T(*this) -= ro;} tU dL_T operator*(const U& ro) {return dL_T(*this) *= ro;} tU dL_T operator/(const U& ro) {return dL_T(*this) /= ro;} // New object binary friend operators (works only on data_Layers) tU dL_T friend operator+(const dL_T& lo, const dL_U& ro) {return dL_T(lo) += ro;} tU dL_T friend operator-(const dL_T& lo, const dL_U& ro) {return dL_T(lo) -= ro;} tU dL_T friend operator*(const dL_T& lo, const dL_U& ro) {return dL_T(ro) *= ro;} tU dL_T friend operator/(const dL_T& lo, const dL_U& ro) {return dL_T(lo) /= ro;} // Self assignement unary functions (scalar math) tU dL_T& dp_all_Set(U val) {data_Math(val, km_Set); return *this;} tU dL_T& dp_all_Add(U val) {data_Math(val, km_Add); return *this;} tU dL_T& dp_all_Sub(U val) {data_Math(val, km_Sub); return *this;} tU dL_T& dp_all_Mul(U val) {data_Math(val, km_Mul); return *this;} tU dL_T& dp_all_Div(U val) {data_Math(val, km_Div); return *this;} dL_T& dp_all_Mir(T val) {data_Math(val, km_Mir); return *this;} dL_T& dp_all_Sqr(void) {data_Math(0, km_Sqr); return *this;} dL_T& dp_all_Pow(Int_t exp = 2) {data_Math(exp, km_Pow); return *this;} dL_T& dp_all_Range(T start = 0, T step = 1); dL_T& dp_all_Lattice(Int_t radius = 3, Int_t space = 10); dL_T& dp_all_Wave(Double_t lenght = 1, Double_t tilt = 0); // Data clustering dL_T& dp_all_Populate(UInt_t cl_Count, UInt_t cl_Height, UInt_t cl_Size); data_Stack* dp_all_Clusterize(T min_Thr, T seed_Thr); // Data statistics void dp_all_Limits(T& min, T& max) const; void dp_all_Stat(Double_t& avg, Double_t& sgm) const; // Data access T operator() (UInt_t Col, UInt_t Row) {return dp_Value(Col, Row);} T dp_Value(UInt_t Idx) const; T& dp_Value(UInt_t Idx); T dp_Value(UInt_t Col, UInt_t Row) const; T& dp_Value(UInt_t Col, UInt_t Row); T* dp_Front() const; // Data dimensions (set/read) UInt_t dp_col_Count() const; UInt_t dp_col_Count(UInt_t col_Count); UInt_t dp_row_Count() const; UInt_t dp_row_Count(UInt_t row_Count); UInt_t dp_Count() const; UInt_t dp_Count(UInt_t dp_Count); UInt_t dp_Count(UInt_t col_Count, UInt_t row_Count); size_t dp_Size() const; // Data indexing conversions UInt_t dp_Idx(UInt_t Col, UInt_t Row) const; UInt_t dp_Col(UInt_t Idx) const; UInt_t dp_Row(UInt_t Idx) const; // Root overloaded void Streamer(TBuffer &b); void Dump() const {Dump(0);} void Dump(UInt_t level) const; // data_Object overloaded UInt_t obj_Type() const; UInt_t data_Type() const; }; // Reset definition //#undef tT #undef tU #undef dL_T #undef dL_U // Reference to the translation unit, allows to just include the .h file #include "data_Layer.cpp" // RootCint check #endif // Overloading check #endif