Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/cloud2plot is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_sg_cloud2plot
0005 #define tools_sg_cloud2plot
0006 
0007 #include "plottables"
0008 
0009 #include "../words"
0010 #include "../num2s"
0011 
0012 #include "../histo/c2d"
0013 
0014 #ifdef TOOLS_MEM
0015 #include "../mem"
0016 #endif
0017 
0018 namespace tools {
0019 namespace sg {
0020 
0021 class c2d2plot : public virtual points2D {
0022   TOOLS_SCLASS(tools::sg::c2d2plot)
0023 public: //plottable
0024   virtual plottable* copy() const {return new c2d2plot(*this);}
0025   virtual bool is_valid() const {return true;}
0026   virtual const std::string& name() const {return m_name;}
0027   virtual void set_name(const std::string& a_s) {m_name = a_s;}
0028   virtual const std::string& title() const {return m_data.title();}
0029   virtual const std::string& legend() const {return m_legend;}
0030   virtual void set_legend(const std::string& a_s) {m_legend = a_s;}
0031 
0032   virtual void infos(const std::string& a_opts,std::string& a_sinfos) const {
0033     a_sinfos.clear();
0034     std::string f_lf("\n");
0035     std::vector<std::string> ws;
0036     words(a_opts," ",false,ws);
0037     std::vector<std::string>::const_iterator it;
0038 
0039     for(it=ws.begin();it!=ws.end();++it) {
0040       if(((*it)=="name") && m_name.size()) {
0041         if(a_sinfos.size()) a_sinfos += f_lf;
0042         a_sinfos += "Name\n";
0043         a_sinfos += m_name;
0044 
0045       } else if((*it)=="entries") {
0046         if(a_sinfos.size()) a_sinfos += f_lf;
0047         a_sinfos += "Entries\n";
0048         if(!numas<unsigned int>(m_data.entries(),a_sinfos)){}
0049 
0050       } else if((*it)=="mean") {
0051         if(a_sinfos.size()) a_sinfos += f_lf;
0052         a_sinfos += "MeanX\n";
0053         if(!numas<double>(m_data.mean_x(),a_sinfos)){}
0054         a_sinfos += f_lf;
0055         a_sinfos += "MeanY\n";
0056         if(!numas<double>(m_data.mean_y(),a_sinfos)){}
0057 
0058       } else if((*it)=="rms") {
0059         if(a_sinfos.size()) a_sinfos += f_lf;
0060         a_sinfos += "RMS X\n";
0061         if(!numas<double>(m_data.rms_x(),a_sinfos)){}
0062         a_sinfos += f_lf;
0063         a_sinfos += "RMS Y\n";
0064         if(!numas<double>(m_data.rms_y(),a_sinfos)){}
0065 
0066       }
0067     }
0068   }
0069 public: //points2D
0070   virtual float x_axis_min() const {return (float)m_data.lower_edge_x();}
0071   virtual float x_axis_max() const {return (float)m_data.upper_edge_x();}
0072   virtual float y_axis_min() const {return (float)m_data.lower_edge_y();}
0073   virtual float y_axis_max() const {return (float)m_data.upper_edge_y();}
0074 
0075   virtual unsigned int points() const {return m_data.entries();}
0076   virtual bool ith_point(unsigned int a_index,float& a_x,float& a_y) const {
0077     if(a_index>=m_data.entries()) {a_x = 0;a_y = 0;return false;}
0078     if(a_index>=m_data.entries()) {a_x = 0;a_y = 0;return false;}
0079     a_x = (float)m_data.value_x(a_index);
0080     a_y = (float)m_data.value_y(a_index);
0081     return true;
0082   }
0083 public:
0084   c2d2plot(const histo::c2d& a_data)
0085   :m_data(a_data)
0086   {
0087 #ifdef TOOLS_MEM
0088     mem::increment(s_class().c_str());
0089 #endif
0090   }
0091   virtual ~c2d2plot(){
0092 #ifdef TOOLS_MEM
0093     mem::decrement(s_class().c_str());
0094 #endif
0095   }
0096 public:
0097   c2d2plot(const c2d2plot& a_from)
0098   :plottable(a_from)
0099   ,points2D(a_from)
0100   ,m_data(a_from.m_data)
0101   ,m_name(a_from.m_name)
0102   ,m_legend(a_from.m_legend)
0103   {
0104 #ifdef TOOLS_MEM
0105     mem::increment(s_class().c_str());
0106 #endif
0107   }
0108   c2d2plot& operator=(const c2d2plot& a_from){
0109     m_name = a_from.m_name;
0110     m_legend = a_from.m_legend;
0111     return *this;
0112   }
0113 protected:
0114   const histo::c2d& m_data;
0115   std::string m_name;
0116   std::string m_legend;
0117 };
0118 
0119 }}
0120 
0121 #include "../histo/c3d"
0122 
0123 namespace tools {
0124 namespace sg {
0125 
0126 class c3d2plot : public virtual points3D {
0127   TOOLS_SCLASS(tools::sg::c3d2plot)
0128 public: //plottable
0129   virtual plottable* copy() const {return new c3d2plot(*this);}
0130   virtual bool is_valid() const {return true;}
0131   virtual const std::string& name() const {return m_name;}
0132   virtual void set_name(const std::string& a_s) {m_name = a_s;}
0133   virtual const std::string& title() const {return m_data.title();}
0134   virtual const std::string& legend() const {return m_legend;}
0135   virtual void set_legend(const std::string& a_s) {m_legend = a_s;}
0136 
0137   virtual void infos(const std::string& a_opts,std::string& a_sinfos) const {
0138     a_sinfos.clear();
0139     std::string f_lf("\n");
0140     std::vector<std::string> ws;
0141     words(a_opts," ",false,ws);
0142     std::vector<std::string>::const_iterator it;
0143 
0144     for(it=ws.begin();it!=ws.end();++it) {
0145       if(((*it)=="name") && m_name.size()) {
0146         if(a_sinfos.size()) a_sinfos += f_lf;
0147         a_sinfos += "Name\n";
0148         a_sinfos += m_name;
0149 
0150       } else if((*it)=="entries") {
0151         if(a_sinfos.size()) a_sinfos += f_lf;
0152         a_sinfos += "Entries\n";
0153         if(!numas<unsigned int>(m_data.entries(),a_sinfos)){}
0154 
0155       } else if((*it)=="mean") {
0156         if(a_sinfos.size()) a_sinfos += f_lf;
0157         a_sinfos += "MeanX\n";
0158         if(!numas<double>(m_data.mean_x(),a_sinfos)){}
0159         a_sinfos += f_lf;
0160         a_sinfos += "MeanY\n";
0161         if(!numas<double>(m_data.mean_y(),a_sinfos)){}
0162         a_sinfos += f_lf;
0163         a_sinfos += "MeanZ\n";
0164         if(!numas<double>(m_data.mean_z(),a_sinfos)){}
0165 
0166       } else if((*it)=="rms") {
0167         if(a_sinfos.size()) a_sinfos += f_lf;
0168         a_sinfos += "RMS X\n";
0169         if(!numas<double>(m_data.rms_x(),a_sinfos)){}
0170         a_sinfos += f_lf;
0171         a_sinfos += "RMS Y\n";
0172         if(!numas<double>(m_data.rms_y(),a_sinfos)){}
0173         a_sinfos += f_lf;
0174         a_sinfos += "RMS Z\n";
0175         if(!numas<double>(m_data.rms_z(),a_sinfos)){}
0176 
0177       }
0178     }
0179   }
0180 public: //points2D
0181   virtual float x_axis_min() const {return (float)m_data.lower_edge_x();}
0182   virtual float x_axis_max() const {return (float)m_data.upper_edge_x();}
0183   virtual float y_axis_min() const {return (float)m_data.lower_edge_y();}
0184   virtual float y_axis_max() const {return (float)m_data.upper_edge_y();}
0185   virtual float z_axis_min() const {return (float)m_data.lower_edge_z();}
0186   virtual float z_axis_max() const {return (float)m_data.upper_edge_z();}
0187 
0188   virtual unsigned int points() const {return m_data.entries();}
0189   virtual bool ith_point(unsigned int a_index,float& a_x,float& a_y,float& a_z) const {
0190     if(a_index>=m_data.entries()) {a_x = 0;a_y = 0;a_z = 0;return false;}
0191     if(a_index>=m_data.entries()) {a_x = 0;a_y = 0;a_z = 0;return false;}
0192     a_x = (float)m_data.value_x(a_index);
0193     a_y = (float)m_data.value_y(a_index);
0194     a_z = (float)m_data.value_z(a_index);
0195     return true;
0196   }
0197 public:
0198   c3d2plot(const histo::c3d& a_data)
0199   :m_data(a_data)
0200   {
0201 #ifdef TOOLS_MEM
0202     mem::increment(s_class().c_str());
0203 #endif
0204   }
0205   virtual ~c3d2plot(){
0206 #ifdef TOOLS_MEM
0207     mem::decrement(s_class().c_str());
0208 #endif
0209   }
0210 public:
0211   c3d2plot(const c3d2plot& a_from)
0212   :plottable(a_from)
0213   ,points3D(a_from)
0214   ,m_data(a_from.m_data)
0215   ,m_name(a_from.m_name)
0216   ,m_legend(a_from.m_legend)
0217   {
0218 #ifdef TOOLS_MEM
0219     mem::increment(s_class().c_str());
0220 #endif
0221   }
0222   c3d2plot& operator=(const c3d2plot& a_from){
0223     m_name = a_from.m_name;
0224     m_legend = a_from.m_legend;
0225     return *this;
0226   }
0227 protected:
0228   const histo::c3d& m_data;
0229   std::string m_name;
0230   std::string m_legend;
0231 };
0232 
0233 }}
0234 
0235 #endif