CMS 3D CMS Logo

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:
26  typedef VarProcessor::Registry::Registry<ProcClassed,
27  Calibration::ProcClassed> Registry;
28 
29  ProcClassed(const char *name,
31  const MVAComputer *computer);
32  ~ProcClassed() override {}
33 
34  void configure(ConfIterator iter, unsigned int n) override;
35  void eval(ValueIterator iter, unsigned int n) const override;
36 
37  private:
38  unsigned int nClasses;
39 };
40 
41 ProcClassed::Registry registry("ProcClassed");
42 
43 ProcClassed::ProcClassed(const char *name,
45  const MVAComputer *computer) :
46  VarProcessor(name, calib, computer),
47  nClasses(calib->nClasses)
48 {
49 }
50 
51 void ProcClassed::configure(ConfIterator iter, unsigned int n)
52 {
53  if (n != 1)
54  return;
55 
56  iter(Variable::FLAG_NONE);
57  for(unsigned int i = 0; i < nClasses; i++)
58  iter << Variable::FLAG_NONE;
59 }
60 
61 void ProcClassed::eval(ValueIterator iter, unsigned int n) const
62 {
63  unsigned int value = (unsigned int)(*iter + 0.5);
64 
65  for(unsigned int i = 0; i < nClasses; i++)
66  iter(i == value ? 1.0 : 0.0);
67 }
68 
69 } // anonymous namespace
template to generate a registry singleton for a type.
Main interface class to the generic discriminator computer framework.
Definition: MVAComputer.h:39
Definition: value.py:1
static Interceptor::Registry registry("Interceptor")
Common base class for variable processors.
Definition: VarProcessor.h:36