CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProcClassed.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MVAComputer
4 // Class : ProcClassed
5 //
6 
7 // Implementation:
8 // Variable processor that splits an input variable into n output
9 // variables depending on the integer value of the input variable.
10 // If the input variable has the value n, the nth output variable
11 // is set to 1, all others to 0.
12 //
13 // Author: Christophe Saout
14 // Created: Sat Apr 24 15:18 CEST 2007
15 //
16 
19 
20 using namespace PhysicsTools;
21 
22 namespace { // anonymous
23 
24  class ProcClassed : public VarProcessor {
25  public:
27 
28  ProcClassed(const char *name, const Calibration::ProcClassed *calib, const MVAComputer *computer);
29  ~ProcClassed() override {}
30 
31  void configure(ConfIterator iter, unsigned int n) override;
32  void eval(ValueIterator iter, unsigned int n) const override;
33 
34  private:
35  unsigned int nClasses;
36  };
37 
38  ProcClassed::Registry registry("ProcClassed");
39 
40  ProcClassed::ProcClassed(const char *name, const Calibration::ProcClassed *calib, const MVAComputer *computer)
41  : VarProcessor(name, calib, computer), nClasses(calib->nClasses) {}
42 
43  void ProcClassed::configure(ConfIterator iter, unsigned int n) {
44  if (n != 1)
45  return;
46 
47  iter(Variable::FLAG_NONE);
48  for (unsigned int i = 0; i < nClasses; i++)
49  iter << Variable::FLAG_NONE;
50  }
51 
52  void ProcClassed::eval(ValueIterator iter, unsigned int n) const {
53  unsigned int value = (unsigned int)(*iter + 0.5);
54 
55  for (unsigned int i = 0; i < nClasses; i++)
56  iter(i == value ? 1.0 : 0.0);
57  }
58 
59 } // anonymous namespace
template to generate a registry singleton for a type.
Main interface class to the generic discriminator computer framework.
Definition: MVAComputer.h:39
Common base class for variable processors.
Definition: VarProcessor.h:36