CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProcSplitter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MVAComputer
4 // Class : ProcSplitter
5 //
6 
7 // Implementation:
8 // Splits the first n instances of the input variables into separate
9 // output variables.
10 //
11 // Author: Christophe Saout
12 // Created: Sat Apr 24 15:18 CEST 2007
13 //
14 
16 
19 
20 using namespace PhysicsTools;
21 
22 namespace { // anonymous
23 
24  class ProcSplitter : public VarProcessor {
25  public:
27 
28  ProcSplitter(const char *name, const Calibration::ProcSplitter *calib, const MVAComputer *computer);
29  ~ProcSplitter() override {}
30 
31  void configure(ConfIterator iter, unsigned int n) override;
32  void eval(ValueIterator iter, unsigned int n) const override;
33  std::vector<double> deriv(ValueIterator iter, unsigned int n) const override;
34 
35  private:
36  unsigned int count;
37  };
38 
39  ProcSplitter::Registry registry("ProcSplitter");
40 
41  ProcSplitter::ProcSplitter(const char *name, const Calibration::ProcSplitter *calib, const MVAComputer *computer)
42  : VarProcessor(name, calib, computer), count(calib->nFirst) {}
43 
44  void ProcSplitter::configure(ConfIterator iter, unsigned int n) {
45  while (iter) {
46  for (unsigned int i = 0; i < count; i++)
47  iter << Variable::FLAG_OPTIONAL;
48  iter << iter++(Variable::FLAG_ALL);
49  }
50  }
51 
52  void ProcSplitter::eval(ValueIterator iter, unsigned int n) const {
53  while (iter) {
54  unsigned int i = 0;
55  while (i < iter.size()) {
56  iter << iter[i];
57  if (i++ < count)
58  iter();
59  }
60  while (i++ < count)
61  iter();
62  iter();
63  iter++;
64  }
65  }
66 
67  std::vector<double> ProcSplitter::deriv(ValueIterator iter, unsigned int n) const {
68  unsigned int size = 0;
69  for (ValueIterator iter2 = iter; iter2; ++iter2)
70  size += iter2.size();
71 
72  std::vector<double> result(size * size);
73  for (unsigned int i = 0; i < size; i++)
74  result[i * size + i] = 1.0;
75 
76  return result;
77  }
78 
79 } // anonymous namespace
template to generate a registry singleton for a type.
tuple result
Definition: mps_fire.py:311
Main interface class to the generic discriminator computer framework.
Definition: MVAComputer.h:39
tuple size
Write out results.
Common base class for variable processors.
Definition: VarProcessor.h:36