25 using namespace PhysicsTools;
34 ProcNormalize(
const char *
name,
37 virtual ~ProcNormalize() {}
39 virtual void configure(ConfIterator iter,
unsigned int n);
40 virtual void eval(ValueIterator iter,
unsigned int n)
const;
41 virtual std::vector<double> deriv(
42 ValueIterator iter,
unsigned int n)
const;
49 std::vector<double>
values(
59 void findMap(ValueIterator iter,
unsigned int n,
60 std::vector<Map>::const_iterator &
begin,
61 std::vector<Map>::const_iterator &
end)
const;
63 std::vector<Map> maps;
65 unsigned int nCategories;
70 ProcNormalize::ProcNormalize(
const char *
name,
74 maps(calib->distr.
begin(), calib->distr.
end()),
75 categoryIdx(calib->categoryIdx),
80 void ProcNormalize::configure(ConfIterator iter,
unsigned int n)
82 if (categoryIdx >= 0) {
83 if ((
int)n < categoryIdx + 1)
85 nCategories = maps.size() / (n - 1);
86 if (nCategories * (n - 1) != maps.size())
88 }
else if (n != maps.size())
93 if (categoryIdx == i++)
94 iter++(Variable::FLAG_NONE);
96 iter << iter++(Variable::FLAG_ALL);
100 void ProcNormalize::findMap(ValueIterator iter,
unsigned int n,
101 std::vector<Map>::const_iterator &
begin,
102 std::vector<Map>::const_iterator &
end)
const
104 if (categoryIdx >= 0) {
105 ValueIterator iter2 = iter;
106 for(
int i = 0; i < categoryIdx; i++)
109 int cat = (int)*iter2;
110 if (cat < 0 || (
unsigned int)cat >= nCategories) {
116 begin = maps.begin() + cat * (n - 1);
117 end = begin + (n - 1);
119 begin = maps.begin();
125 void ProcNormalize::eval(ValueIterator iter,
unsigned int n)
const
127 std::vector<Map>::const_iterator
map,
last;
128 findMap(iter, n, map, last);
130 for(
int i = 0; map !=
last; ++iter, i++) {
131 if (i == categoryIdx)
133 for(
double *
value = iter.begin();
136 val = (val - map->min) / map->width;
137 val = map->spline.integral(val);
145 std::vector<double> ProcNormalize::deriv(ValueIterator iter,
146 unsigned int n)
const
148 std::vector<Map>::const_iterator
map,
last;
149 findMap(iter, n, map, last);
151 unsigned int size = 0;
152 for(ValueIterator iter2 = iter; iter2; ++iter2)
153 size += iter2.size();
155 std::vector<double>
result(size * size);
158 for(
int i = 0; map !=
last; ++iter, i++) {
159 if (i == categoryIdx) {
164 for(
double *
value = iter.begin();
167 val = (val - map->min) / map->width;
168 val = map->spline.eval(val) *
169 (map->spline.numberOfEntries() - 1) /
170 (map->width * map->spline.getArea());
detail::ThreadSafeRegistry< ParameterSetID, ParameterSet, ProcessParameterSetIDCache > Registry
MVATrainerComputer * calib
tuple size
Write out results.