14 #include <TBufferFile.h> 33 #define STANDALONE_HEADER "MVAComputer calibration\n" 47 this->owned.reset(calib);
76 std::vector<Calibration::VarProcessor*> processors =
79 for(std::vector<Calibration::VarProcessor*>::const_iterator iter =
81 iter != processors.end(); ++iter) {
87 << name <<
" could not be instantiated." 90 VarProcessor::ConfigCtx::iterator::difference_type
pos =
93 unsigned int nOutput = (config.
end() - config.
begin()) - pos;
96 << name <<
" rejected input variable " 97 "configuration" << std::endl;
103 iter != config.
end(); iter++) {
105 if (iter->origin >=
nVars)
106 iter->origin = origin->
origin;
111 config[iter->origin].origin++;
120 <<
"Output variable at index " <<
output 121 <<
" invalid." << std::endl;
125 for(std::vector<Calibration::Variable>::const_iterator iter = calib->
inputSet.begin(); iter != calib->
inputSet.end(); ++iter, i++) {
130 variables.insert(var);
137 for(
unsigned int j = 0; j <
i; j++)
161 double *
output = ctx.values() + ctx.n();
166 double *
v = ctx.values();
167 for(
int *
o = ctx.conf();
o < outConf;
o++) {
168 std::cout <<
"\tVar " << (
o - ctx.conf()) << std::endl;
169 for(
int i =
o[0];
i <
o[1];
i++)
170 std::cout <<
"\t\t" << *v++ << std::endl;
173 std::vector<Processor>::const_iterator iter =
varProcessors.begin();
175 std::vector<Processor>::const_iterator
loop = iter;
176 int *loopOutConf = outConf;
177 int *loopStart =
nullptr;
178 double *loopOutput =
output;
184 std::vector<Processor>::const_iterator
next = iter + 1;
194 ctx.eval(&*iter->processor, outConf, output,
195 loopStart ? loopStart : loopOutConf,
197 offset, iter->nOutput);
200 for(
unsigned int i = 0;
i < iter->nOutput;
202 std::cout <<
"\tVar " << (outConf - ctx.conf())
204 for(
int j = outConf[0]; j < outConf[1]; j++)
210 outConf += iter->nOutput;
211 output += *outConf - orig;
214 status = loop->processor->loop(output, outConf,
215 nextOutput, loopCtx, offset);
218 outConf = loopOutConf;
234 std::ifstream
file(filename);
242 <<
"Stream passed to MVAComputer::readCalibration " 243 "has an invalid state." << std::endl;
246 if (is.readsome(header,
sizeof header) !=
sizeof header ||
249 <<
"Stream passed to MVAComputer::readCalibration " 250 "is not a valid calibration file." << std::endl;
253 TClass::GetClass(
"PhysicsTools::Calibration::MVAComputer");
256 <<
"CondFormats dictionary for " 257 "PhysicsTools::Calibration::MVAComputer missing" 261 std::ostringstream ss;
265 TBufferFile
buffer(TBuffer::kRead, buf.size(),
const_cast<void*
>(
266 static_cast<const void*
>(buf.c_str())), kFALSE);
269 std::unique_ptr<Calibration::MVAComputer>
calib(
271 buffer.StreamObject(static_cast<void*>(calib.get()), rootClass);
273 return calib.release();
279 std::ofstream
file(filename);
288 <<
"Stream passed to MVAComputer::writeCalibration " 289 "has an invalid state." << std::endl;
294 TClass::GetClass(
"PhysicsTools::Calibration::MVAComputer");
297 <<
"CondFormats dictionary for " 298 "PhysicsTools::Calibration::MVAComputer missing" 301 TBufferFile
buffer(TBuffer::kWrite);
302 buffer.StreamObject(const_cast<void*>(static_cast<const void*>(calib)),
306 ozs.write(buffer.Buffer(), buffer.Length());
315 unsigned int offset,
unsigned int out)
const 318 loop, ctx, offset,
n(), out, deriv_);
322 std::vector<double> &derivs)
const 329 std::copy(&deriv_.front() + n_ * (pos - n_),
330 &deriv_.front() + n_ * (pos - n_ + 1),
331 std::back_inserter(derivs));
double output(unsigned int output, std::vector< double > &derivs) const
TrainProcessor *const proc
std::vector< Variable::Flags > flags
MVATrainerComputer * calib
void eval(const VarProcessor *proc, int *outConf, double *output, int *loop, VarProcessor::LoopCtx &ctx, unsigned int offset, unsigned int out) const
std::string typeDemangle(char const *mangledName)