g4tools  5.4.0
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
tools::sg::fit2plot Class Reference
Inheritance diagram for tools::sg::fit2plot:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::fit2plot:
Collaboration graph
[legend]

Public Member Functions

virtual void * cast (const std::string &a_class) const
 
virtual plottablecopy () const
 
virtual bool is_valid () const
 
virtual const std::string & name () const
 
virtual void set_name (const std::string &a_s)
 
virtual const std::string & title () const
 
virtual const std::string & legend () const
 
virtual void set_legend (const std::string &a_s)
 
virtual void infos (const std::string &a_opts, std::string &a_sinfos) const
 
 fit2plot (const std::vector< std::string > &a_names, const std::vector< double > &a_output)
 
virtual ~fit2plot ()
 
 fit2plot (const fit2plot &a_from)
 
fit2plotoperator= (const fit2plot &a_from)
 
- Public Member Functions inherited from tools::sg::plottable
virtual ~plottable ()
 

Static Public Member Functions

static const std::string & s_class ()
 

Protected Attributes

std::vector< std::string > m_names
 
std::vector< double > m_output
 
std::string m_name
 
std::string m_legend
 

Detailed Description

Definition at line 19 of file fit2plot.

Constructor & Destructor Documentation

◆ fit2plot() [1/2]

tools::sg::fit2plot::fit2plot ( const std::vector< std::string > &  a_names,
const std::vector< double > &  a_output 
)
inline

Definition at line 102 of file fit2plot.

104  :m_names(a_names)
105  ,m_output(a_output)
106  {
107 #ifdef TOOLS_MEM
108  mem::increment(s_class().c_str());
109 #endif
110  size_t nparam = (m_output.size()-2)/4;
111  if(m_names.size()!=nparam) {
112  //should issue a warning.
113  m_names.clear();
114  m_output.clear();
115  }
116  }

◆ ~fit2plot()

virtual tools::sg::fit2plot::~fit2plot ( )
inlinevirtual

Definition at line 117 of file fit2plot.

117  {
118 #ifdef TOOLS_MEM
119  mem::decrement(s_class().c_str());
120 #endif
121  }

◆ fit2plot() [2/2]

tools::sg::fit2plot::fit2plot ( const fit2plot a_from)
inline

Definition at line 123 of file fit2plot.

124  : plottable(a_from)
125  ,m_names(a_from.m_names)
126  ,m_output(a_from.m_output)
127  ,m_name(a_from.m_name)
128  ,m_legend(a_from.m_legend)
129  {
130 #ifdef TOOLS_MEM
131  mem::increment(s_class().c_str());
132 #endif
133  }

Member Function Documentation

◆ cast()

virtual void* tools::sg::fit2plot::cast ( const std::string &  a_class) const
inlinevirtual

Reimplemented from tools::sg::plottable.

Definition at line 30 of file fit2plot.

30  {
31  if(void* p = cmp_cast<fit2plot>(this,a_class)) {return p;}
32  return plottable::cast(a_class);
33  }

◆ copy()

virtual plottable* tools::sg::fit2plot::copy ( ) const
inlinevirtual

Implements tools::sg::plottable.

Definition at line 35 of file fit2plot.

35 {return new fit2plot(*this);}

◆ infos()

virtual void tools::sg::fit2plot::infos ( const std::string &  a_opts,
std::string &  a_sinfos 
) const
inlinevirtual

Implements tools::sg::plottable.

Definition at line 43 of file fit2plot.

43  {
44  a_sinfos.clear();
45  std::string f_lf("\n");
46  std::vector<std::string> ws;
47  words(a_opts," ",false,ws);
48  std::vector<std::string>::const_iterator it;
49 
50  bool show_fit_ndf = false;
51  {for(it=ws.begin();it!=ws.end();++it) {
52  if((*it)=="fit_ndf") {show_fit_ndf = true;break;}
53  }}
54  bool show_fit_errors = false;
55  {for(it=ws.begin();it!=ws.end();++it) {
56  if((*it)=="fit_errors") {show_fit_errors = true;break;}
57  }}
58 
59  for(it=ws.begin();it!=ws.end();++it) {
60  if(((*it)=="name") && m_name.size()) {
61  if(a_sinfos.size()) a_sinfos += f_lf;
62  a_sinfos += "Name";
63  a_sinfos += f_lf;
64  a_sinfos += m_name;
65 
66  } else if((*it)=="fit_quality") {
67  if(show_fit_ndf) {
68  if(a_sinfos.size()) a_sinfos += f_lf;
69  a_sinfos += "[h]^2! / ndf";
70  a_sinfos += f_lf;
71  if(!numas<double>(m_output[0],a_sinfos)){}
72  a_sinfos += " / ";
73  if(!numas<double>(m_output[1],a_sinfos)){}
74  } else { //show chi2 only.
75  if(a_sinfos.size()) a_sinfos += f_lf;
76  a_sinfos += "[h]^2!";
77  a_sinfos += f_lf;
78  if(!numas<double>(m_output[0],a_sinfos)){}
79  }
80 
81  } else if((*it)=="fit_parameters") {
82  size_t nparam = m_names.size();
83  for(size_t iparam=0;iparam<nparam;iparam++) {
84  if(show_fit_errors) {
85  if(a_sinfos.size()) a_sinfos += f_lf;
86  a_sinfos += m_names[iparam];
87  a_sinfos += f_lf;
88  if(!numas<double>(m_output[2+4*iparam+0],a_sinfos)){} //value
89  a_sinfos += " +&_ ";
90  if(!numas<double>(m_output[2+4*iparam+1],a_sinfos)){} //error
91  } else {
92  if(a_sinfos.size()) a_sinfos += f_lf;
93  a_sinfos += m_names[iparam];
94  a_sinfos += f_lf;
95  if(!numas<double>(m_output[2+4*iparam+0],a_sinfos)){}
96  }
97  }
98  }
99  }
100  }

◆ is_valid()

virtual bool tools::sg::fit2plot::is_valid ( ) const
inlinevirtual

Implements tools::sg::plottable.

Definition at line 36 of file fit2plot.

36 {return true;}

◆ legend()

virtual const std::string& tools::sg::fit2plot::legend ( ) const
inlinevirtual

Implements tools::sg::plottable.

Definition at line 40 of file fit2plot.

40 {return m_legend;}

◆ name()

virtual const std::string& tools::sg::fit2plot::name ( ) const
inlinevirtual

Implements tools::sg::plottable.

Definition at line 37 of file fit2plot.

37 {return m_name;}

◆ operator=()

fit2plot& tools::sg::fit2plot::operator= ( const fit2plot a_from)
inline

Definition at line 134 of file fit2plot.

134  {
135  m_names = a_from.m_names;
136  m_output = a_from.m_output;
137  m_name = a_from.m_name;
138  m_legend = a_from.m_legend;
139  return *this;
140  }

◆ s_class()

static const std::string& tools::sg::fit2plot::s_class ( )
inlinestatic

Definition at line 25 of file fit2plot.

25  {
26  static const std::string s_v(s_tools_sg_fit2plot());
27  return s_v;
28  }

◆ set_legend()

virtual void tools::sg::fit2plot::set_legend ( const std::string &  a_s)
inlinevirtual

Implements tools::sg::plottable.

Definition at line 41 of file fit2plot.

41 {m_legend = a_s;}

◆ set_name()

virtual void tools::sg::fit2plot::set_name ( const std::string &  a_s)
inlinevirtual

Implements tools::sg::plottable.

Definition at line 38 of file fit2plot.

38 {m_name = a_s;}

◆ title()

virtual const std::string& tools::sg::fit2plot::title ( ) const
inlinevirtual

Implements tools::sg::plottable.

Definition at line 39 of file fit2plot.

39 {return s_empty();}

Member Data Documentation

◆ m_legend

std::string tools::sg::fit2plot::m_legend
protected

Definition at line 145 of file fit2plot.

◆ m_name

std::string tools::sg::fit2plot::m_name
protected

Definition at line 144 of file fit2plot.

◆ m_names

std::vector<std::string> tools::sg::fit2plot::m_names
protected

Definition at line 142 of file fit2plot.

◆ m_output

std::vector<double> tools::sg::fit2plot::m_output
protected

Definition at line 143 of file fit2plot.


The documentation for this class was generated from the following file:
tools::sg::plottable::cast
virtual void * cast(const std::string &a_class) const
Definition: plottable:19
tools::sg::fit2plot::m_output
std::vector< double > m_output
Definition: fit2plot:143
tools::sg::fit2plot::fit2plot
fit2plot(const std::vector< std::string > &a_names, const std::vector< double > &a_output)
Definition: fit2plot:102
tools::sg::s_tools_sg_fit2plot
const std::string & s_tools_sg_fit2plot()
Definition: plottables:162
tools::sg::fit2plot::m_names
std::vector< std::string > m_names
Definition: fit2plot:142
tools::sg::fit2plot::s_class
static const std::string & s_class()
Definition: fit2plot:25
tools::words
void words(const std::string &a_string, const std::string &a_sep, bool a_take_empty, std::vector< std::string > &a_words, bool a_clear=true)
Definition: words:12
tools::sg::fit2plot::m_name
std::string m_name
Definition: fit2plot:144
tools::sg::fit2plot::m_legend
std::string m_legend
Definition: fit2plot:145