CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SourceVariableSet.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_MVATrainer_SourceVariableSet_h
2 #define PhysicsTools_MVATrainer_SourceVariableSet_h
3 
4 #include <cstddef>
5 #include <vector>
6 #include <algorithm>
7 
9 
10 namespace PhysicsTools {
11 
12 class SourceVariable;
13 
15  public:
16  typedef std::size_t size_type;
17 
20 
21  enum Magic {
22  kRegular = 0,
25  };
26 
28  *find(Magic magic) const;
29 
30  bool append(SourceVariable *var, Magic magic = kRegular,
31  int offset = -1);
32  std::vector<SourceVariable*> get(bool withMagic = false) const;
33  size_type size(bool withMagic = false) const
34  {
35  if (withMagic)
36  return vars.size();
37  else
38  return std::count_if(vars.begin(), vars.end(),
39  std::mem_fun_ref(&PosVar::noMagic));
40  }
41 
42  private:
43  struct PosVar {
44  unsigned int pos;
47 
48  bool noMagic() const { return magic == kRegular; }
49 
50  static bool VarNameLess(const PosVar &var, AtomicId name)
51  { return var.var->getName() < name; }
52  };
53 
54  std::vector<PosVar> vars;
55 };
56 
57 } // namespace PhysicsTools
58 
59 #endif // PhysicsTools_MVATrainer_SourceVariable_h
static bool VarNameLess(const PosVar &var, AtomicId name)
Cheap generic unique keyword identifier class.
Definition: AtomicId.h:31
const AtomicId getName() const
Definition: Variable.h:143
size_type size(bool withMagic=false) const
bool append(SourceVariable *var, Magic magic=kRegular, int offset=-1)
SourceVariable * find(AtomicId name) const