CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 // $Id: ProcSplitter.cc,v 1.4 2009/06/03 09:50:14 saout Exp $
14 //
15 
17 
20 
21 using namespace PhysicsTools;
22 
23 namespace { // anonymous
24 
25 class ProcSplitter : public VarProcessor {
26  public:
27  typedef VarProcessor::Registry::Registry<ProcSplitter,
29 
30  ProcSplitter(const char *name,
32  const MVAComputer *computer);
33  virtual ~ProcSplitter() {}
34 
35  virtual void configure(ConfIterator iter, unsigned int n);
36  virtual void eval(ValueIterator iter, unsigned int n) const;
37  virtual std::vector<double> deriv(
38  ValueIterator iter, unsigned int n) const;
39 
40  private:
41  unsigned int count;
42 };
43 
44 static ProcSplitter::Registry registry("ProcSplitter");
45 
46 ProcSplitter::ProcSplitter(const char *name,
48  const MVAComputer *computer) :
49  VarProcessor(name, calib, computer),
50  count(calib->nFirst)
51 {
52 }
53 
54 void ProcSplitter::configure(ConfIterator iter, unsigned int n)
55 {
56  while(iter) {
57  for(unsigned int i = 0; i < count; i++)
58  iter << Variable::FLAG_OPTIONAL;
59  iter << iter++(Variable::FLAG_ALL);
60  }
61 }
62 
63 void ProcSplitter::eval(ValueIterator iter, unsigned int n) const
64 {
65  while(iter) {
66  unsigned int i = 0;
67  while(i < iter.size()) {
68  iter << iter[i];
69  if (i++ < count)
70  iter();
71  }
72  while(i++ < count)
73  iter();
74  iter();
75  iter++;
76  }
77 }
78 
79 std::vector<double> ProcSplitter::deriv(
80  ValueIterator iter, unsigned int n) const
81 {
82  unsigned int size = 0;
83  for(ValueIterator iter2 = iter; iter2; ++iter2)
84  size += iter2.size();
85 
86  std::vector<double> result(size * size);
87  for(unsigned int i = 0; i < size; i++)
88  result[i * size + i] = 1.0;
89 
90  return result;
91 }
92 
93 } // 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
tuple result
Definition: query.py:137
template to generate a registry singleton for a type.
static Interceptor::Registry registry("Interceptor")
tuple size
Write out results.
Common base class for variable processors.
Definition: VarProcessor.h:39