test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SourceVariableSet.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 #include <vector>
4 
6 
9 
10 namespace PhysicsTools {
11 
13 {
14  std::vector<PosVar>::iterator pos =
15  std::lower_bound(vars.begin(), vars.end(),
17 
18  if (pos != vars.end() && (pos->var == var ||
19  (pos->var->getSource() == var->getSource() &&
20  pos->var->getName() == var->getName())))
21  return true;
22 
23  PosVar item;
24  item.pos = offset < 0 ? vars.size() : offset;
25  item.var = var;
26  item.magic = magic;
27 
28  vars.insert(pos, 1, item);
29 
30  return false;
31 }
32 
34 {
35  std::vector<PosVar>::const_iterator pos =
36  std::lower_bound(vars.begin(), vars.end(),
38 
39  if (pos == vars.end() || pos->var->getName() != name)
40  return 0;
41 
42  return pos->var;
43 }
44 
46 {
47  for(std::vector<PosVar>::const_iterator pos = vars.begin();
48  pos != vars.end(); ++pos)
49  if (pos->magic == magic)
50  return pos->var;
51 
52  return 0;
53 }
54 
55 std::vector<SourceVariable*> SourceVariableSet::get(bool withMagic) const
56 {
57  std::vector<SourceVariable*> result(vars.size());
58 
59  for(std::vector<PosVar>::const_iterator iter = vars.begin();
60  iter != vars.end(); iter++)
61  result[iter->pos] = iter->var;
62 
63  if (!withMagic) {
64  unsigned int pos = vars.size();
65  for(std::vector<PosVar>::const_iterator iter = vars.begin();
66  iter != vars.end(); iter++)
67  if (iter->magic != kRegular) {
68  result.erase(result.begin() +
69  (iter->pos - (iter->pos >= pos)));
70  pos = iter->pos;
71  }
72  }
73 
74  return result;
75 }
76 
77 } // namespace PhysicsTools
Source * getSource() const
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
tuple result
Definition: query.py:137
std::vector< SourceVariable * > get(bool withMagic=false) const
unsigned int offset(bool)
bool append(SourceVariable *var, Magic magic=kRegular, int offset=-1)
SourceVariable * find(AtomicId name) const
AtomicId getName() const
Definition: Source.h:19
if(conf.exists("allCellsPositionCalc"))