CMS 3D CMS Logo

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 
10 
11 namespace PhysicsTools {
12 
14  public:
15  typedef std::size_t size_type;
16 
19 
20  enum Magic {
21  kRegular = 0,
24  };
25 
27  *find(Magic magic) const;
28 
29  bool append(SourceVariable *var, Magic magic = kRegular,
30  int offset = -1);
31  std::vector<SourceVariable*> get(bool withMagic = false) const;
32  size_type size(bool withMagic = false) const
33  {
34  if (withMagic)
35  return vars.size();
36  else
37  return std::count_if(vars.begin(), vars.end(),
38  std::mem_fun_ref(&PosVar::noMagic));
39  }
40 
41  private:
42  struct PosVar {
43  unsigned int pos;
46 
47  bool noMagic() const { return magic == kRegular; }
48 
49  static bool VarNameLess(const PosVar &var, AtomicId name)
50  { return var.var->getName() < name; }
51  };
52 
53  std::vector<PosVar> vars;
54 };
55 
56 } // namespace PhysicsTools
57 
58 #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
vars
Definition: DeepTauId.cc:77