24 using namespace PhysicsTools;
33 ProcNormalize(
const char *
name,
36 virtual ~ProcNormalize() {}
38 virtual void configure(ConfIterator iter,
unsigned int n)
override;
39 virtual void eval(ValueIterator iter,
unsigned int n)
const override;
40 virtual std::vector<double> deriv(
41 ValueIterator iter,
unsigned int n)
const override;
48 std::vector<double>
values(
58 void findMap(ValueIterator iter,
unsigned int n,
59 std::vector<Map>::const_iterator &
begin,
60 std::vector<Map>::const_iterator &
end)
const;
62 std::vector<Map> maps;
64 unsigned int nCategories;
69 ProcNormalize::ProcNormalize(
const char *
name,
73 maps(calib->distr.
begin(), calib->distr.
end()),
74 categoryIdx(calib->categoryIdx),
79 void ProcNormalize::configure(ConfIterator iter,
unsigned int n)
81 if (categoryIdx >= 0) {
82 if ((
int)n < categoryIdx + 1)
84 nCategories = maps.size() / (n - 1);
85 if (nCategories * (n - 1) != maps.size())
87 }
else if (n != maps.size())
92 if (categoryIdx == i++)
93 iter++(Variable::FLAG_NONE);
95 iter << iter++(Variable::FLAG_ALL);
99 void ProcNormalize::findMap(ValueIterator iter,
unsigned int n,
100 std::vector<Map>::const_iterator &
begin,
101 std::vector<Map>::const_iterator &
end)
const
103 if (categoryIdx >= 0) {
104 ValueIterator iter2 = iter;
105 for(
int i = 0; i < categoryIdx; i++)
108 int cat = (int)*iter2;
109 if (cat < 0 || (
unsigned int)cat >= nCategories) {
115 begin = maps.begin() + cat * (n - 1);
116 end = begin + (n - 1);
118 begin = maps.begin();
124 void ProcNormalize::eval(ValueIterator iter,
unsigned int n)
const
126 std::vector<Map>::const_iterator
map,
last;
127 findMap(iter, n, map, last);
129 for(
int i = 0; map !=
last; ++iter, i++) {
130 if (i == categoryIdx)
132 for(
double *
value = iter.begin();
135 val = (val - map->min) / map->width;
136 val = map->spline.integral(val);
144 std::vector<double> ProcNormalize::deriv(ValueIterator iter,
145 unsigned int n)
const
147 std::vector<Map>::const_iterator
map,
last;
148 findMap(iter, n, map, last);
150 unsigned int size = 0;
151 for(ValueIterator iter2 = iter; iter2; ++iter2)
152 size += iter2.size();
154 std::vector<double>
result(size * size);
157 for(
int i = 0; map !=
last; ++iter, i++) {
158 if (i == categoryIdx) {
163 for(
double *
value = iter.begin();
166 val = (val - map->min) / map->width;
167 val = map->spline.eval(val) *
168 (map->spline.numberOfEntries() - 1) /
169 (map->width * map->spline.getArea());
MVATrainerComputer * calib
tuple size
Write out results.