Geant4 Cross Reference |
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_sg_h2plot_cp 4 #ifndef tools_sg_h2plot_cp 5 #define tools_sg_h2plot_cp 5 #define tools_sg_h2plot_cp 6 6 7 // Inheritance : 7 // Inheritance : 8 #include "h2plot" 8 #include "h2plot" 9 9 10 namespace tools { 10 namespace tools { 11 namespace sg { 11 namespace sg { 12 12 13 class h1d2plot_cp : public h1d2plot { 13 class h1d2plot_cp : public h1d2plot { 14 public: 14 public: 15 TOOLS_SCLASS(tools::sg::h1d2plot_cp) 15 TOOLS_SCLASS(tools::sg::h1d2plot_cp) 16 public: 16 public: 17 virtual void* cast(const std::string& a_clas 17 virtual void* cast(const std::string& a_class) const { 18 if(void* p = cmp_cast<h1d2plot_cp>(this,a_ 18 if(void* p = cmp_cast<h1d2plot_cp>(this,a_class)) {return p;} 19 return h1d2plot::cast(a_class); 19 return h1d2plot::cast(a_class); 20 } 20 } 21 public: 21 public: 22 virtual plottable* copy() const {return new 22 virtual plottable* copy() const {return new h1d2plot_cp(*this);} 23 public: 23 public: 24 h1d2plot_cp(const histo::h1d& a_data) 24 h1d2plot_cp(const histo::h1d& a_data) 25 :h1d2plot(m_cp) //give ref of m_cp to h1d2pl 25 :h1d2plot(m_cp) //give ref of m_cp to h1d2plot. 26 ,m_cp(a_data) //do a local copy. 26 ,m_cp(a_data) //do a local copy. 27 //WARNING : the upper is ok as long as h1d2p 27 //WARNING : the upper is ok as long as h1d2plot constructor does nothing 28 // else than keeping the ref to m_c 28 // else than keeping the ref to m_cp. Else it would do 29 // something on an empty histo (and 29 // something on an empty histo (and not on a copy of the 30 // passed a_data). 30 // passed a_data). 31 { 31 { 32 #ifdef TOOLS_MEM 32 #ifdef TOOLS_MEM 33 mem::increment(s_class().c_str()); 33 mem::increment(s_class().c_str()); 34 #endif 34 #endif 35 } 35 } 36 virtual ~h1d2plot_cp(){ 36 virtual ~h1d2plot_cp(){ 37 #ifdef TOOLS_MEM 37 #ifdef TOOLS_MEM 38 mem::decrement(s_class().c_str()); 38 mem::decrement(s_class().c_str()); 39 #endif 39 #endif 40 } 40 } 41 public: 41 public: 42 h1d2plot_cp(const h1d2plot_cp& a_from) 42 h1d2plot_cp(const h1d2plot_cp& a_from) 43 :plottable(a_from) 43 :plottable(a_from) 44 ,bins1D(a_from) 44 ,bins1D(a_from) 45 ,h1d2plot(m_cp) 45 ,h1d2plot(m_cp) 46 ,m_cp(a_from.m_cp) 46 ,m_cp(a_from.m_cp) 47 { 47 { 48 #ifdef TOOLS_MEM 48 #ifdef TOOLS_MEM 49 mem::increment(s_class().c_str()); 49 mem::increment(s_class().c_str()); 50 #endif 50 #endif 51 } 51 } 52 h1d2plot_cp& operator=(const h1d2plot_cp& a_ 52 h1d2plot_cp& operator=(const h1d2plot_cp& a_from){ 53 h1d2plot::operator=(a_from); 53 h1d2plot::operator=(a_from); 54 m_cp = a_from.m_cp; 54 m_cp = a_from.m_cp; 55 return *this; 55 return *this; 56 } 56 } 57 public: 57 public: 58 const histo::h1d& data() const {return m_cp; 58 const histo::h1d& data() const {return m_cp;} 59 histo::h1d& data() {return m_cp;} 59 histo::h1d& data() {return m_cp;} 60 protected: 60 protected: 61 histo::h1d m_cp; 61 histo::h1d m_cp; 62 }; 62 }; 63 63 64 class h2d2plot_cp : public h2d2plot { 64 class h2d2plot_cp : public h2d2plot { 65 public: 65 public: 66 TOOLS_SCLASS(tools::sg::h2d2plot_cp) 66 TOOLS_SCLASS(tools::sg::h2d2plot_cp) 67 public: 67 public: 68 virtual void* cast(const std::string& a_clas 68 virtual void* cast(const std::string& a_class) const { 69 if(void* p = cmp_cast<h2d2plot_cp>(this,a_ 69 if(void* p = cmp_cast<h2d2plot_cp>(this,a_class)) {return p;} 70 return h2d2plot::cast(a_class); 70 return h2d2plot::cast(a_class); 71 } 71 } 72 public: 72 public: 73 virtual plottable* copy() const {return new 73 virtual plottable* copy() const {return new h2d2plot_cp(*this);} 74 public: 74 public: 75 h2d2plot_cp(const histo::h2d& a_data) 75 h2d2plot_cp(const histo::h2d& a_data) 76 :h2d2plot(m_cp) 76 :h2d2plot(m_cp) 77 ,m_cp(a_data) 77 ,m_cp(a_data) 78 { 78 { 79 #ifdef TOOLS_MEM 79 #ifdef TOOLS_MEM 80 mem::increment(s_class().c_str()); 80 mem::increment(s_class().c_str()); 81 #endif 81 #endif 82 } 82 } 83 virtual ~h2d2plot_cp(){ 83 virtual ~h2d2plot_cp(){ 84 #ifdef TOOLS_MEM 84 #ifdef TOOLS_MEM 85 mem::decrement(s_class().c_str()); 85 mem::decrement(s_class().c_str()); 86 #endif 86 #endif 87 } 87 } 88 public: 88 public: 89 h2d2plot_cp(const h2d2plot_cp& a_from) 89 h2d2plot_cp(const h2d2plot_cp& a_from) 90 :plottable(a_from),bins2D(a_from),h2d2plot(m 90 :plottable(a_from),bins2D(a_from),h2d2plot(m_cp) 91 ,m_cp(a_from.m_cp) 91 ,m_cp(a_from.m_cp) 92 { 92 { 93 #ifdef TOOLS_MEM 93 #ifdef TOOLS_MEM 94 mem::increment(s_class().c_str()); 94 mem::increment(s_class().c_str()); 95 #endif 95 #endif 96 } 96 } 97 h2d2plot_cp& operator=(const h2d2plot_cp& a_ 97 h2d2plot_cp& operator=(const h2d2plot_cp& a_from){ 98 h2d2plot::operator=(a_from); 98 h2d2plot::operator=(a_from); 99 m_cp = a_from.m_cp; 99 m_cp = a_from.m_cp; 100 return *this; 100 return *this; 101 } 101 } 102 protected: 102 protected: 103 histo::h2d m_cp; 103 histo::h2d m_cp; 104 }; 104 }; 105 105 106 class p1d2plot_cp : public p1d2plot { 106 class p1d2plot_cp : public p1d2plot { 107 public: 107 public: 108 TOOLS_SCLASS(tools::sg::p1d2plot_cp) 108 TOOLS_SCLASS(tools::sg::p1d2plot_cp) 109 public: 109 public: 110 virtual void* cast(const std::string& a_clas 110 virtual void* cast(const std::string& a_class) const { 111 if(void* p = cmp_cast<p1d2plot_cp>(this,a_ 111 if(void* p = cmp_cast<p1d2plot_cp>(this,a_class)) {return p;} 112 return p1d2plot::cast(a_class); 112 return p1d2plot::cast(a_class); 113 } 113 } 114 public: 114 public: 115 virtual plottable* copy() const {return new 115 virtual plottable* copy() const {return new p1d2plot_cp(*this);} 116 public: 116 public: 117 p1d2plot_cp(const histo::p1d& a_data) 117 p1d2plot_cp(const histo::p1d& a_data) 118 :p1d2plot(m_cp) 118 :p1d2plot(m_cp) 119 ,m_cp(a_data) 119 ,m_cp(a_data) 120 { 120 { 121 #ifdef TOOLS_MEM 121 #ifdef TOOLS_MEM 122 mem::increment(s_class().c_str()); 122 mem::increment(s_class().c_str()); 123 #endif 123 #endif 124 } 124 } 125 virtual ~p1d2plot_cp(){ 125 virtual ~p1d2plot_cp(){ 126 #ifdef TOOLS_MEM 126 #ifdef TOOLS_MEM 127 mem::decrement(s_class().c_str()); 127 mem::decrement(s_class().c_str()); 128 #endif 128 #endif 129 } 129 } 130 public: 130 public: 131 p1d2plot_cp(const p1d2plot_cp& a_from) 131 p1d2plot_cp(const p1d2plot_cp& a_from) 132 :plottable(a_from),bins1D(a_from),p1d2plot(m 132 :plottable(a_from),bins1D(a_from),p1d2plot(m_cp) 133 ,m_cp(a_from.m_cp) 133 ,m_cp(a_from.m_cp) 134 { 134 { 135 #ifdef TOOLS_MEM 135 #ifdef TOOLS_MEM 136 mem::increment(s_class().c_str()); 136 mem::increment(s_class().c_str()); 137 #endif 137 #endif 138 } 138 } 139 p1d2plot_cp& operator=(const p1d2plot_cp& a_ 139 p1d2plot_cp& operator=(const p1d2plot_cp& a_from){ 140 p1d2plot::operator=(a_from); 140 p1d2plot::operator=(a_from); 141 m_cp = a_from.m_cp; 141 m_cp = a_from.m_cp; 142 return *this; 142 return *this; 143 } 143 } 144 protected: 144 protected: 145 histo::p1d m_cp; 145 histo::p1d m_cp; 146 }; 146 }; 147 147 148 }} 148 }} 149 149 150 #endif 150 #endif