CMS 3D CMS Logo

ProcClassed.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     MVAComputer
00004 // Class  :     ProcClassed
00005 // 
00006 
00007 // Implementation:
00008 //     Variable processor that splits an input variable into n output
00009 //     variables depending on the integer value of the input variable.
00010 //     If the input variable has the value n, the nth output variable
00011 //     is set to 1, all others to 0.
00012 //
00013 // Author:      Christophe Saout
00014 // Created:     Sat Apr 24 15:18 CEST 2007
00015 // $Id: ProcClassed.cc,v 1.3 2007/07/15 22:31:46 saout Exp $
00016 //
00017 
00018 #include "PhysicsTools/MVAComputer/interface/VarProcessor.h"
00019 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
00020 
00021 using namespace PhysicsTools;
00022 
00023 namespace { // anonymous
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 } // anonymous namespace

Generated on Tue Jun 9 17:41:27 2009 for CMSSW by  doxygen 1.5.4