CMS 3D CMS Logo

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:
26  typedef VarProcessor::Registry::Registry<ProcSplitter,
27  Calibration::ProcSplitter> Registry;
28 
29  ProcSplitter(const char *name,
31  const MVAComputer *computer);
32  ~ProcSplitter() override {}
33 
34  void configure(ConfIterator iter, unsigned int n) override;
35  void eval(ValueIterator iter, unsigned int n) const override;
36  std::vector<double> deriv(
37  ValueIterator iter, unsigned int n) const override;
38 
39  private:
40  unsigned int count;
41 };
42 
43 ProcSplitter::Registry registry("ProcSplitter");
44 
45 ProcSplitter::ProcSplitter(const char *name,
47  const MVAComputer *computer) :
48  VarProcessor(name, calib, computer),
49  count(calib->nFirst)
50 {
51 }
52 
53 void ProcSplitter::configure(ConfIterator iter, unsigned int n)
54 {
55  while(iter) {
56  for(unsigned int i = 0; i < count; i++)
57  iter << Variable::FLAG_OPTIONAL;
58  iter << iter++(Variable::FLAG_ALL);
59  }
60 }
61 
62 void ProcSplitter::eval(ValueIterator iter, unsigned int n) const
63 {
64  while(iter) {
65  unsigned int i = 0;
66  while(i < iter.size()) {
67  iter << iter[i];
68  if (i++ < count)
69  iter();
70  }
71  while(i++ < count)
72  iter();
73  iter();
74  iter++;
75  }
76 }
77 
78 std::vector<double> ProcSplitter::deriv(
79  ValueIterator iter, unsigned int n) const
80 {
81  unsigned int size = 0;
82  for(ValueIterator iter2 = iter; iter2; ++iter2)
83  size += iter2.size();
84 
85  std::vector<double> result(size * size);
86  for(unsigned int i = 0; i < size; i++)
87  result[i * size + i] = 1.0;
88 
89  return result;
90 }
91 
92 } // anonymous namespace
size
Write out results.
template to generate a registry singleton for a type.
Main interface class to the generic discriminator computer framework.
Definition: MVAComputer.h:39
static Interceptor::Registry registry("Interceptor")
Common base class for variable processors.
Definition: VarProcessor.h:36