CMS 3D CMS Logo

VParameterSetEntry.cc
Go to the documentation of this file.
5 
6 #include <cassert>
7 #include <ostream>
8 #include <sstream>
9 
10 namespace edm {
11 
12  VParameterSetEntry::VParameterSetEntry() : tracked_(false), theVPSet_(), theIDs_() {}
13 
14  VParameterSetEntry::VParameterSetEntry(std::vector<ParameterSet> const& vpset, bool isTracked)
15  : tracked_(isTracked), theVPSet_(new std::vector<ParameterSet>), theIDs_() {
16  for (std::vector<ParameterSet>::const_iterator i = vpset.begin(), e = vpset.end(); i != e; ++i) {
17  theVPSet_->push_back(*i);
18  }
19  }
20 
22  : tracked_(rep[0] == '+'), theVPSet_(), theIDs_(new std::vector<ParameterSetID>) {
23  assert(rep[0] == '+' || rep[0] == '-');
24  std::vector<std::string> temp;
25  // need a substring that starts at the '{'
26  std::string bracketedRepr(rep.begin() + 2, rep.end());
27  split(std::back_inserter(temp), bracketedRepr, '{', ',', '}');
28  theIDs_->reserve(temp.size());
29  for (std::vector<std::string>::const_iterator i = temp.begin(), e = temp.end(); i != e; ++i) {
30  theIDs_->push_back(ParameterSetID(*i));
31  }
32  }
33 
35  assert(theIDs_);
36  result += tracked_ ? "+q" : "-q";
37  result += '{';
39  std::string const between(",");
40  for (std::vector<ParameterSetID>::const_iterator i = theIDs_->begin(), e = theIDs_->end(); i != e; ++i) {
41  result += start;
42  i->toString(result);
43  start = between;
44  }
45  result += '}';
46  }
47 
49  assert(theIDs_);
50  digest.append(tracked_ ? "+q{" : "-q{", 3);
51  bool started = false;
52  for (std::vector<ParameterSetID>::const_iterator i = theIDs_->begin(), e = theIDs_->end(); i != e; ++i) {
53  if (started)
54  digest.append(",", 1);
55  i->toDigest(digest);
56  started = true;
57  }
58  digest.append("}", 1);
59  }
60 
64  return result;
65  }
66 
67  std::vector<ParameterSet> const& VParameterSetEntry::vpset() const {
68  fillVPSet();
69  return *theVPSet_;
70  }
71 
72  // NOTE: This function, and other non-const functions of this class
73  // that expose internals, may be used in a way that causes the cached
74  // "theVPSet_" and "theIDs_" to be inconsistent.
75  // THIS PROBLEM NEEDS TO BE ADDRESSED
76  std::vector<ParameterSet>& VParameterSetEntry::vpsetForUpdate() {
77  fillVPSet();
78  return *theVPSet_;
79  }
80 
82  if (nullptr == theVPSet_.load()) {
83  auto tmp = std::make_unique<std::vector<ParameterSet>>();
84  tmp->reserve(theIDs_->size());
85  for (auto const& theID : *theIDs_) {
86  tmp->push_back(getParameterSet(theID));
87  }
88  VParameterSet* expected = nullptr;
89  if (theVPSet_.compare_exchange_strong(expected, tmp.get())) {
90  // theVPSet_ was equal to nullptr and now is equal to tmp.get()
91  tmp.release();
92  }
93  }
94  }
95 
96  // NOTE: This function, and other non-const functions of this class
97  // that expose internals, may be used in a way that causes the cached
98  // "theVPSet_" and "theIDs_" to be inconsistent.
99  // THIS PROBLEM NEEDS TO BE ADDRESSED
101  assert(theVPSet_);
102  return theVPSet_->at(i);
103  }
104 
106 
108  fillVPSet();
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 
121  std::ostringstream os;
122  std::vector<ParameterSet> const& vps = vpset();
123  os << "VPSet " << (isTracked() ? "tracked" : "untracked") << " = ({" << std::endl;
125  std::string const between(",\n");
126  for (std::vector<ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
127  os << start << indentation << i->dump(indent);
128  start = between;
129  }
130  if (!vps.empty()) {
131  os << std::endl;
132  }
133  os << indentation << "})";
134  return os.str();
135  }
136 
137  std::ostream& operator<<(std::ostream& os, VParameterSetEntry const& vpsetEntry) {
138  os << vpsetEntry.dump();
139  return os;
140  }
141 } // namespace edm
edm::VParameterSetEntry::tracked_
bool tracked_
Definition: VParameterSetEntry.h:58
edm::ParameterSetID
Hash< ParameterSetType > ParameterSetID
Definition: ParameterSetID.h:21
cms::Digest::append
void append(std::string const &s)
Definition: Digest.cc:161
mps_fire.i
i
Definition: mps_fire.py:428
start
Definition: start.py:1
funct::false
false
Definition: Factorize.h:29
edm::VParameterSetEntry::dump
std::string dump(unsigned int indent=0) const
Definition: VParameterSetEntry.cc:119
edm::VParameterSetEntry::size
std::vector< ParameterSet >::size_type size() const
Definition: VParameterSetEntry.cc:105
edm::VParameterSetEntry::vpsetForUpdate
std::vector< ParameterSet > & vpsetForUpdate()
Definition: VParameterSetEntry.cc:76
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::VParameterSetEntry::isTracked
bool isTracked() const
Definition: VParameterSetEntry.h:41
edm::VParameterSetEntry::psetInVector
ParameterSet & psetInVector(int i)
Definition: VParameterSetEntry.cc:100
split.h
cms::cuda::assert
assert(be >=bs)
edm::VParameterSet
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::VParameterSetEntry::VParameterSetEntry
VParameterSetEntry()
Definition: VParameterSetEntry.cc:12
edm::VParameterSetEntry::vpset
std::vector< ParameterSet > const & vpset() const
returns the VPSet
Definition: VParameterSetEntry.cc:67
edm::VParameterSetEntry::theIDs_
value_ptr< std::vector< ParameterSetID > > theIDs_
Definition: VParameterSetEntry.h:60
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
edm::VParameterSetEntry::theVPSet_
atomic_value_ptr< std::vector< ParameterSet > > theVPSet_
Definition: VParameterSetEntry.h:59
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
cms::Digest
Definition: Digest.h:46
edm::Hash
Definition: Hash.h:43
VParameterSetEntry.h
edm::VParameterSetEntry::fillVPSet
void fillVPSet() const
reconstitutes the VPSet from the registry
Definition: VParameterSetEntry.cc:81
edm::ParameterSet
Definition: ParameterSet.h:47
edm::value_ptr
Definition: value_ptr.h:63
cuy.rep
rep
Definition: cuy.py:1189
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Digest.h
edm::getParameterSet
ParameterSet const & getParameterSet(ParameterSetID const &id)
Definition: ParameterSet.cc:862
std
Definition: JetResolutionObject.h:76
util.rrClient.indent
indent
Definition: rrClient.py:41
edm::VParameterSetEntry
Definition: VParameterSetEntry.h:24
edm::VParameterSetEntry::toString
std::string toString() const
Definition: VParameterSetEntry.cc:61
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::VParameterSetEntry::toDigest
void toDigest(cms::Digest &digest) const
Definition: VParameterSetEntry.cc:48
edm::VParameterSetEntry::registerPsetsAndUpdateIDs
void registerPsetsAndUpdateIDs()
Definition: VParameterSetEntry.cc:107
mps_fire.result
result
Definition: mps_fire.py:311
command_line.start
start
Definition: command_line.py:167
ParameterSet.h
edm::split
bool split(OutIter result, std::string const &string_to_split, char first, char sep, char last)
Definition: split.h:68
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37