File indexing completed on 2024-04-06 12:23:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "PhysicsTools/MVAComputer/interface/VarProcessor.h"
0018 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
0019
0020 using namespace PhysicsTools;
0021
0022 namespace {
0023
0024 class ProcClassed : public VarProcessor {
0025 public:
0026 typedef VarProcessor::Registry::Registry<ProcClassed, Calibration::ProcClassed> Registry;
0027
0028 ProcClassed(const char *name, const Calibration::ProcClassed *calib, const MVAComputer *computer);
0029 ~ProcClassed() override {}
0030
0031 void configure(ConfIterator iter, unsigned int n) override;
0032 void eval(ValueIterator iter, unsigned int n) const override;
0033
0034 private:
0035 unsigned int nClasses;
0036 };
0037
0038 ProcClassed::Registry registry("ProcClassed");
0039
0040 ProcClassed::ProcClassed(const char *name, const Calibration::ProcClassed *calib, const MVAComputer *computer)
0041 : VarProcessor(name, calib, computer), nClasses(calib->nClasses) {}
0042
0043 void ProcClassed::configure(ConfIterator iter, unsigned int n) {
0044 if (n != 1)
0045 return;
0046
0047 iter(Variable::FLAG_NONE);
0048 for (unsigned int i = 0; i < nClasses; i++)
0049 iter << Variable::FLAG_NONE;
0050 }
0051
0052 void ProcClassed::eval(ValueIterator iter, unsigned int n) const {
0053 unsigned int value = (unsigned int)(*iter + 0.5);
0054
0055 for (unsigned int i = 0; i < nClasses; i++)
0056 iter(i == value ? 1.0 : 0.0);
0057 }
0058
0059 }