CMS 3D CMS Logo

ProcClassed.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iterator>
3 #include <iostream>
4 #include <cstring>
5 #include <vector>
6 #include <string>
7 #include <set>
8 
9 #include <xercesc/dom/DOM.hpp>
10 
12 
14 
19 
21 
22 using namespace PhysicsTools;
23 
24 namespace { // anonymous
25 
26 class ProcClassed : public TrainProcessor {
27  public:
29 
30  ProcClassed(const char *name, const AtomicId *id, MVATrainer *trainer);
31  ~ProcClassed() override;
32 
33  void configure(DOMElement *elem) override;
34  Calibration::VarProcessor *getCalibration() const override;
35 
36  private:
37  unsigned int count;
38 };
39 
40 ProcClassed::Registry registry("ProcClassed");
41 
42 ProcClassed::ProcClassed(const char *name, const AtomicId *id,
43  MVATrainer *trainer) :
44  TrainProcessor(name, id, trainer)
45 {
46 }
47 
48 ProcClassed::~ProcClassed()
49 {
50 }
51 
52 void ProcClassed::configure(DOMElement *elem)
53 {
54  DOMNode *node = elem->getFirstChild();
55  while(node && node->getNodeType() != DOMNode::ELEMENT_NODE)
56  node = node->getNextSibling();
57 
58  if (!node ||
59  std::strcmp(XMLSimpleStr(node->getNodeName()), "classes") != 0)
60  throw cms::Exception("ProcClassed")
61  << "Expected classes tag in config section."
62  << std::endl;
63 
64  elem = static_cast<DOMElement*>(node);
65 
66  count = XMLDocument::readAttribute<unsigned int>(elem, "count");
67 
68  node = node->getNextSibling();
69  while(node && node->getNodeType() != DOMNode::ELEMENT_NODE)
70  node = node->getNextSibling();
71 
72  if (node)
73  throw cms::Exception("ProcClassed")
74  << "Superfluous tags in config section."
75  << std::endl;
76 
77  trained = true;
78 }
79 
80 Calibration::VarProcessor *ProcClassed::getCalibration() const
81 {
83  calib->nClasses = count;
84  return calib;
85 }
86 
87 } // anonymous namespace
template to generate a registry singleton for a type.
Cheap generic unique keyword identifier class.
Definition: AtomicId.h:31
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
static Interceptor::Registry registry("Interceptor")