00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "PhysicsTools/MVAComputer/interface/VarProcessor.h"
00019 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
00020
00021 using namespace PhysicsTools;
00022
00023 namespace {
00024
00025 class ProcClassed : public VarProcessor {
00026 public:
00027 typedef VarProcessor::Registry::Registry<ProcClassed,
00028 Calibration::ProcClassed> Registry;
00029
00030 ProcClassed(const char *name,
00031 const Calibration::ProcClassed *calib,
00032 const MVAComputer *computer);
00033 virtual ~ProcClassed() {}
00034
00035 virtual void configure(ConfIterator iter, unsigned int n);
00036 virtual void eval(ValueIterator iter, unsigned int n) const;
00037
00038 private:
00039 unsigned int nClasses;
00040 };
00041
00042 static ProcClassed::Registry registry("ProcClassed");
00043
00044 ProcClassed::ProcClassed(const char *name,
00045 const Calibration::ProcClassed *calib,
00046 const MVAComputer *computer) :
00047 VarProcessor(name, calib, computer),
00048 nClasses(calib->nClasses)
00049 {
00050 }
00051
00052 void ProcClassed::configure(ConfIterator iter, unsigned int n)
00053 {
00054 if (n != 1)
00055 return;
00056
00057 iter(Variable::FLAG_NONE);
00058 for(unsigned int i = 0; i < nClasses; i++)
00059 iter << Variable::FLAG_NONE;
00060 }
00061
00062 void ProcClassed::eval(ValueIterator iter, unsigned int n) const
00063 {
00064 unsigned int value = (unsigned int)(*iter + 0.5);
00065
00066 for(unsigned int i = 1; i < nClasses; i++)
00067 iter(i == value ? 1.0 : 0.0);
00068 }
00069
00070 }