CombineHarvester
Parameter.cc
Go to the documentation of this file.
2 #include <iostream>
3 #include <string>
4 #include <limits>
5 #include "boost/format.hpp"
6 
7 namespace ch {
8 
10  : name_(""),
11  val_(0.0),
12  err_u_(1.0),
13  err_d_(-1.0),
14  range_u_(std::numeric_limits<double>::max()),
15  range_d_(std::numeric_limits<double>::lowest()),
16  frozen_(false) {
17  }
18 
20 
21 void swap(Parameter& first, Parameter& second) {
22  using std::swap;
23  swap(first.name_, second.name_);
24  swap(first.val_, second.val_);
25  swap(first.err_u_, second.err_u_);
26  swap(first.err_d_, second.err_d_);
27  swap(first.range_u_, second.range_u_);
28  swap(first.range_d_, second.range_d_);
29  swap(first.frozen_, second.frozen_);
30  swap(first.vars_, second.vars_);
31  swap(first.groups_, second.groups_);
32 }
33 
35  : name_(other.name_),
36  val_(other.val_),
37  err_u_(other.err_u_),
38  err_d_(other.err_d_),
39  range_u_(other.range_u_),
40  range_d_(other.range_d_),
41  frozen_(other.frozen_),
42  vars_(other.vars_),
43  groups_(other.groups_) {
44 }
45 
47  : name_(""),
48  val_(0.0),
49  err_u_(1.0),
50  err_d_(-1.0),
51  range_u_(std::numeric_limits<double>::max()),
52  range_d_(std::numeric_limits<double>::lowest()),
53  frozen_(false) {
54  swap(*this, other);
55 }
56 
58  swap(*this, other);
59  return (*this);
60 }
61 
62 std::ostream& Parameter::PrintHeader(std::ostream &out) {
63  std::string line =
64  (boost::format("%-70s %-10.4f %-9.4f %-7.4f %-6s %s")
65  % "name" % "value" % "error_d" % "error_u" % "frozen" % "groups").str();
66  std::string div(line.length(), '-');
67  out << div << std::endl;
68  out << line << std::endl;
69  out << div << std::endl;
70  return out;
71 }
72 
73 std::ostream& operator<< (std::ostream &out, Parameter &val) {
74  std::string grps = "";
75  unsigned i = 0;
76  unsigned n = val.groups().size();
77  for (auto it = val.groups().begin(); i < n; ++it, ++i) {
78  if (i < (n-1)) {
79  grps += (*it + ",");
80  } else {
81  grps += (*it);
82  }
83  }
84  out << boost::format("%-70s %-10.4f %-9.4f %-7.4f %-6i %s")
85  % val.name()
86  % val.val()
87  % val.err_d()
88  % val.err_u()
89  % val.frozen()
90  % grps;
91  return out;
92 }
93 }
double err_u() const
Definition: Parameter.h:34
bool frozen() const
Definition: Parameter.h:51
std::set< std::string > & groups()
Definition: Parameter.h:54
double err_d() const
Definition: Parameter.h:37
static std::ostream & PrintHeader(std::ostream &out)
Definition: Parameter.cc:62
friend void swap(Parameter &first, Parameter &second)
Definition: Parameter.cc:21
std::string const & name() const
Definition: Parameter.h:21
double val() const
Definition: Parameter.h:31
Parameter & operator=(Parameter other)
Definition: Parameter.cc:57
Definition: Algorithm.h:10
std::ostream & operator<<(std::ostream &out, HistMapping const &val)
Definition: HistMapping.cc:70
void swap(Parameter &first, Parameter &second)
Definition: Parameter.cc:21
void swap(CombineHarvester &first, CombineHarvester &second)