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:
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
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
PhysicsTools::MVAComputer
Main interface class to the generic discriminator computer framework.
Definition: MVAComputer.h:39
PhysicsTools::VarProcessor
Common base class for variable processors.
Definition: VarProcessor.h:36
PhysicsTools::Calibration::ProcClassed
Definition: MVAComputer.h:93
calib
Definition: CalibElectron.h:12
PhysicsTools
Definition: Histogram.h:13
createfilelist.int
int
Definition: createfilelist.py:10
VarProcessor.h
value
Definition: value.py:1
PhysicsTools::ProcessRegistryImpl
template to generate a registry singleton for a type.
Definition: ProcessRegistry.h:25
Calibration.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HLT_FULL_cff.computer
computer
Definition: HLT_FULL_cff.py:52053