CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 // $Id: ProcClassed.cc,v 1.4 2010/02/20 12:16:20 saout Exp $
16 //
17 
20 
21 using namespace PhysicsTools;
22 
23 namespace { // anonymous
24 
25 class ProcClassed : public VarProcessor {
26  public:
27  typedef VarProcessor::Registry::Registry<ProcClassed,
29 
30  ProcClassed(const char *name,
32  const MVAComputer *computer);
33  virtual ~ProcClassed() {}
34 
35  virtual void configure(ConfIterator iter, unsigned int n);
36  virtual void eval(ValueIterator iter, unsigned int n) const;
37 
38  private:
39  unsigned int nClasses;
40 };
41 
42 static ProcClassed::Registry registry("ProcClassed");
43 
44 ProcClassed::ProcClassed(const char *name,
46  const MVAComputer *computer) :
47  VarProcessor(name, calib, computer),
48  nClasses(calib->nClasses)
49 {
50 }
51 
52 void ProcClassed::configure(ConfIterator iter, unsigned int n)
53 {
54  if (n != 1)
55  return;
56 
57  iter(Variable::FLAG_NONE);
58  for(unsigned int i = 0; i < nClasses; i++)
59  iter << Variable::FLAG_NONE;
60 }
61 
62 void ProcClassed::eval(ValueIterator iter, unsigned int n) const
63 {
64  unsigned int value = (unsigned int)(*iter + 0.5);
65 
66  for(unsigned int i = 0; i < nClasses; i++)
67  iter(i == value ? 1.0 : 0.0);
68 }
69 
70 } // anonymous namespace
int i
Definition: DBlmapReader.cc:9
detail::ThreadSafeRegistry< ParameterSetID, ParameterSet, ProcessParameterSetIDCache > Registry
Definition: Registry.h:37
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
Main interface class to the generic discriminator computer framework.
Definition: MVAComputer.h:40
template to generate a registry singleton for a type.
static Interceptor::Registry registry("Interceptor")
Common base class for variable processors.
Definition: VarProcessor.h:39