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 
9 namespace edm {
10 
12  tracked(false),
13  theVPSet(),
14  theIDs() {
15  }
16 
17  VParameterSetEntry::VParameterSetEntry(std::vector<ParameterSet> const& vpset, bool isTracked) :
18  tracked(isTracked),
19  theVPSet(new std::vector<ParameterSet>),
20  theIDs() {
21  for (std::vector<ParameterSet>::const_iterator i = vpset.begin(), e = vpset.end(); i != e; ++i) {
22  theVPSet->push_back(*i);
23  }
24  }
25 
26  VParameterSetEntry::VParameterSetEntry(std::string const& rep) :
27  tracked(rep[0] == '+'),
28  theVPSet(),
29  theIDs(new std::vector<ParameterSetID>) {
30  assert(rep[0] == '+' || rep[0] == '-');
31  std::vector<std::string> temp;
32  // need a substring that starts at the '{'
33  std::string bracketedRepr(rep.begin()+2, rep.end());
34  split(std::back_inserter(temp), bracketedRepr, '{', ',', '}');
35  theIDs->reserve(temp.size());
36  for (std::vector<std::string>::const_iterator i = temp.begin(), e = temp.end(); i != e; ++i) {
37  theIDs->push_back(ParameterSetID(*i));
38  }
39  }
40 
42 
43  void
44  VParameterSetEntry::toString(std::string& result) const {
45  assert(theIDs);
46  result += tracked ? "+q" : "-q";
47  result += '{';
48  std::string start;
49  std::string const between(",");
50  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
51  result += start;
52  i->toString(result);
53  start = between;
54  }
55  result += '}';
56  }
57 
58  void
60  assert(theIDs);
61  digest.append(tracked ? "+q{" : "-q{", 3);
62  bool started = false;
63  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
64  if (started)
65  digest.append(",", 1);
66  i->toDigest(digest);
67  started = true;
68  }
69  digest.append("}",1);
70  }
71 
72  std::string VParameterSetEntry::toString() const {
73  std::string result;
74  toString(result);
75  return result;
76  }
77 
78  std::vector<ParameterSet> const& VParameterSetEntry::vpset() const {
79  if (!theVPSet) {
80  assert(theIDs);
81  theVPSet = value_ptr<std::vector<ParameterSet> >(new std::vector<ParameterSet>);
82  theVPSet->reserve(theIDs->size());
83  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
84  theVPSet->push_back(getParameterSet(*i));
85  }
86  }
87  return *theVPSet;
88  }
89 
90  std::vector<ParameterSet>& VParameterSetEntry::vpset() {
91  if (!theVPSet) {
92  assert(theIDs);
93  theVPSet = value_ptr<std::vector<ParameterSet> >(new std::vector<ParameterSet>);
94  theVPSet->reserve(theIDs->size());
95  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
96  theVPSet->push_back(getParameterSet(*i));
97  }
98  }
99  return *theVPSet;
100  }
101 
103  assert(theVPSet);
104  return theVPSet->at(i);
105  }
106 
108  vpset();
109  theIDs = value_ptr<std::vector<ParameterSetID> >(new std::vector<ParameterSetID>);
110  theIDs->resize(theVPSet->size());
111  for (std::vector<ParameterSet>::iterator i = theVPSet->begin(), e = theVPSet->end(); i != e; ++i) {
112  if (!i->isRegistered()) {
113  i->registerIt();
114  }
115  theIDs->at(i - theVPSet->begin()) = i->id();
116  }
117  }
118 
119  std::ostream& operator<<(std::ostream& os, VParameterSetEntry const& vpsetEntry) {
120  std::vector<ParameterSet> const& vps = vpsetEntry.vpset();
121  os << "VPSet "<<(vpsetEntry.isTracked()?"tracked":"untracked")<<" = ({" << std::endl;
122  std::string start;
123  std::string const between(",\n");
124  for(std::vector<ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
125  os << start << *i;
126  start = between;
127  }
128  if (!vps.empty()) {
129  os << std::endl;
130  }
131  os << "})";
132  return os;
133  }
134 }
int i
Definition: DBlmapReader.cc:9
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