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