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 
17  VParameterSetEntry::VParameterSetEntry(std::vector<ParameterSet> const& vpset, bool isTracked)
18  : tracked(isTracked),
19  theVPSet(new std::vector<ParameterSet>),
20  theIDs()
21  {
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  {
32  assert(rep[0] == '+' || rep[0] == '-');
33  std::vector<std::string> temp;
34  // need a substring that starts at the '{'
35  std::string bracketedRepr(rep.begin()+2, rep.end());
36  split(std::back_inserter(temp), bracketedRepr, '{', ',', '}');
37  theIDs->reserve(temp.size());
38  for (std::vector<std::string>::const_iterator i = temp.begin(), e = temp.end(); i != e; ++i) {
39  theIDs->push_back(ParameterSetID(*i));
40  }
41  }
42 
44 
45  void
46  VParameterSetEntry::toString(std::string& result) const {
47  assert(theIDs);
48  result += tracked ? "+q" : "-q";
49  result += '{';
50  std::string start;
51  std::string const between(",");
52  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
53  result += start;
54  i->toString(result);
55  start = between;
56  }
57  result += '}';
58  }
59 
60  std::string VParameterSetEntry::toString() const {
61  std::string result;
62  toString(result);
63  return result;
64  }
65 
66  std::vector<ParameterSet> const& VParameterSetEntry::vpset() const {
67  if (!theVPSet) {
68  assert(theIDs);
69  theVPSet = value_ptr<std::vector<ParameterSet> >(new std::vector<ParameterSet>);
70  theVPSet->reserve(theIDs->size());
71  for (std::vector<ParameterSetID>::const_iterator i = theIDs->begin(), e = theIDs->end(); i != e; ++i) {
72  theVPSet->push_back(getParameterSet(*i));
73  }
74  }
75  return *theVPSet;
76  }
77 
79  assert(theVPSet);
80  return theVPSet->at(i);
81  }
82 
84  vpset();
85  theIDs = value_ptr<std::vector<ParameterSetID> >(new std::vector<ParameterSetID>);
86  theIDs->resize(theVPSet->size());
87  for (std::vector<ParameterSet>::iterator i = theVPSet->begin(), e = theVPSet->end(); i != e; ++i) {
88  if (!i->isRegistered()) {
89  i->registerIt();
90  }
91  theIDs->at(i - theVPSet->begin()) = i->id();
92  }
93  }
94 
95  std::ostream & operator<<(std::ostream & os, VParameterSetEntry const& vpsetEntry) {
96  std::vector<ParameterSet> const& vps = vpsetEntry.vpset();
97  os << "VPSet "<<(vpsetEntry.isTracked()?"tracked":"untracked")<<" = ({" << std::endl;
98  std::string start;
99  std::string const between(",\n");
100  for(std::vector<ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
101  os << start << *i;
102  start = between;
103  }
104  if (!vps.empty()) {
105  os << std::endl;
106  }
107  os << "})";
108  return os;
109  }
110 }
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.