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:
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
PhysicsTools::Calibration::ProcSplitter
Definition: MVAComputer.h:101
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
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
calib
Definition: CalibElectron.h:12
PhysicsTools
Definition: Histogram.h:13
VarProcessor.h
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
Exception.h
mps_fire.result
result
Definition: mps_fire.py:311
HLT_FULL_cff.computer
computer
Definition: HLT_FULL_cff.py:52053
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443