CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VParameterSetEntry.cc
Go to the documentation of this file.
5 
6 #include <cassert>
7 #include <ostream>
8 #include <sstream>
9 
10 namespace edm {
11 
13  tracked(false),
14  theVPSet(),
15  theIDs() {
16  }
17 
18  VParameterSetEntry::VParameterSetEntry(std::vector<ParameterSet> const& vpset, bool isTracked) :
19  tracked(isTracked),
20  theVPSet(new std::vector<ParameterSet>),
21  theIDs() {
22  for (std::vector<ParameterSet>::const_iterator i = vpset.begin(), e = vpset.end(); i != e; ++i) {
23  theVPSet->push_back(*i);
24  }
25  }
26 
28  tracked(rep[0] == '+'),
29  theVPSet(),
30  theIDs(new std::vector<ParameterSetID>) {
31  assert(rep[0] == '+' || rep[0] == '-');
32  std::vector<std::string> temp;
33  // need a substring that starts at the '{'
34  std::string bracketedRepr(rep.begin()+2, rep.end());
35  split(std::back_inserter(temp), bracketedRepr, '{', ',', '}');
36  theIDs->reserve(temp.size());
37  for (std::vector<std::string>::const_iterator i = temp.begin(), e = temp.end(); i != e; ++i) {
38  theIDs->push_back(ParameterSetID(*i));
39  }
40  }
41 
43 
44  void
46  assert(theIDs);
47  result += tracked ? "+q" : "-q";
48  result += '{';
50  std::string const between(",");
51  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
52  result += start;
53  i->toString(result);
54  start = between;
55  }
56  result += '}';
57  }
58 
59  void
61  assert(theIDs);
62  digest.append(tracked ? "+q{" : "-q{", 3);
63  bool started = false;
64  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
65  if (started)
66  digest.append(",", 1);
67  i->toDigest(digest);
68  started = true;
69  }
70  digest.append("}",1);
71  }
72 
75  toString(result);
76  return result;
77  }
78 
79  std::vector<ParameterSet> const& VParameterSetEntry::vpset() const {
80  if (!theVPSet) {
81  assert(theIDs);
82  theVPSet = value_ptr<std::vector<ParameterSet> >(new std::vector<ParameterSet>);
83  theVPSet->reserve(theIDs->size());
84  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
85  theVPSet->push_back(getParameterSet(*i));
86  }
87  }
88  return *theVPSet;
89  }
90 
91  std::vector<ParameterSet>& VParameterSetEntry::vpset() {
92  if (!theVPSet) {
93  assert(theIDs);
94  theVPSet = value_ptr<std::vector<ParameterSet> >(new std::vector<ParameterSet>);
95  theVPSet->reserve(theIDs->size());
96  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
97  theVPSet->push_back(getParameterSet(*i));
98  }
99  }
100  return *theVPSet;
101  }
102 
104  assert(theVPSet);
105  return theVPSet->at(i);
106  }
107 
109  vpset();
110  theIDs = value_ptr<std::vector<ParameterSetID> >(new std::vector<ParameterSetID>);
111  theIDs->resize(theVPSet->size());
112  for (std::vector<ParameterSet>::iterator i = theVPSet->begin(), e = theVPSet->end(); i != e; ++i) {
113  if (!i->isRegistered()) {
114  i->registerIt();
115  }
116  theIDs->at(i - theVPSet->begin()) = i->id();
117  }
118  }
119 
121  std::string indentation(indent, ' ');
122  std::ostringstream os;
123  std::vector<ParameterSet> const& vps = vpset();
124  os << "VPSet "<<(isTracked()?"tracked":"untracked")<<" = ({" << std::endl;
126  std::string const between(",\n");
127  for(std::vector<ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
128  os << start << indentation << i->dump(indent);
129  start = between;
130  }
131  if (!vps.empty()) {
132  os << std::endl;
133  }
134  os << indentation << "})";
135  return os.str();
136  }
137 
138  std::ostream& operator<<(std::ostream& os, VParameterSetEntry const& vpsetEntry) {
139  os << vpsetEntry.dump();
140  return os;
141  }
142 }
int i
Definition: DBlmapReader.cc:9
string rep
Definition: cuy.py:1188
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
std::string dump(unsigned int indent=0) const
Definition: Hash.h:41
ParameterSet const & getParameterSet(ParameterSetID const &id)
void toDigest(cms::Digest &digest) const
tuple result
Definition: query.py:137
std::vector< ParameterSet > const & vpset() const
bool split(OutIter result, std::string const &string_to_split, char first, char sep, char last)
Definition: split.h:88
Hash< ParameterSetType > ParameterSetID
value_ptr< std::vector< ParameterSetID > > theIDs
value_ptr< std::vector< ParameterSet > > theVPSet
std::string toString() const
ParameterSet & psetInVector(int i)
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
void append(std::string const &s)
Definition: Digest.cc:182