CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenericMVAComputerCache.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <memory>
4 
8 
9 using namespace PhysicsTools::Calibration;
10 
12 {
13 }
14 
16  const IndividualComputer &orig) :
17  label(orig.label)
18 {
19 }
20 
22 {
23 }
24 
26  const std::vector<std::string> &labels) :
27  computers(labels.size()),
28  cacheId(MVAComputerContainer::CacheId()),
30  empty(true)
31 {
32  std::vector<IndividualComputer>::iterator computer = computers.begin();
33  for(std::vector<std::string>::const_iterator iter = labels.begin();
34  iter != labels.end(); iter++) {
35  computer->label = *iter;
36  computer->cacheId = MVAComputer::CacheId();
37  computer++;
38  }
39 }
40 
42 {
43 }
44 
46 {
47  // check container for changes
48  if (initialized && !calib->changed(cacheId))
49  return false;
50 
51  empty = true;
52 
53  bool changed = false;
54  for(std::vector<IndividualComputer>::iterator iter = computers.begin();
55  iter != computers.end(); iter++) {
56  // empty labels means we don't want a computer
57  if (iter->label.empty())
58  continue;
59 
60  const MVAComputer *computerCalib = &calib->find(iter->label);
61  if (!computerCalib) {
62  iter->computer.reset();
63  continue;
64  }
65 
66  // check container content for changes
67  if (iter->computer.get() &&
68  !computerCalib->changed(iter->cacheId)) {
69  empty = false;
70  continue;
71  }
72 
73  // drop old computer
74  iter->computer.reset();
75 
76  if (!computerCalib)
77  continue;
78 
79  // instantiate new MVAComputer with uptodate calibration
80  iter->computer = std::auto_ptr<GenericMVAComputer>(
81  new GenericMVAComputer(computerCalib));
82 
83  iter->cacheId = computerCalib->getCacheId();
84 
85  changed = true;
86  empty = false;
87  }
88 
89  cacheId = calib->getCacheId();
90  initialized = true;
91 
92  return changed;
93 }
PhysicsTools::Calibration::MVAComputerContainer::CacheId cacheId
virtual const MVAComputer & find(const std::string &label) const
Definition: MVAComputer.cc:192
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
bool update(const PhysicsTools::Calibration::MVAComputerContainer *calib)
GenericMVAComputerCache(const std::vector< std::string > &labels)
bool changed(CacheId old) const
Definition: MVAComputer.h:175
std::vector< IndividualComputer > computers
tuple size
Write out results.