CMS 3D CMS Logo

ParameterCollector.cc
Go to the documentation of this file.
1 #include <ostream>
2 #include <cstdlib>
3 #include <vector>
4 #include <string>
5 #include <map>
6 
9 
11 
12 using namespace gen;
13 
15 
17  std::vector<std::string> names = pset.getParameterNamesForType<std::vector<std::string> >();
18 
19  for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
20  contents_[*it] = pset.getParameter<std::vector<std::string> >(*it);
21 }
22 
24 
26  std::vector<std::string>::const_iterator begin,
27  std::vector<std::string>::const_iterator end,
28  bool special,
29  std::ostream *dump)
30  : collector_(collector), dump_(dump), special_(special) {
31  if (begin != end)
32  iter_.push_back(IterPair(begin, end));
33 
34  next();
35 }
36 
38  if (++iter_.back().first == iter_.back().second)
39  iter_.pop_back();
40 
41  next();
42 }
43 
45  if (iter_.empty()) {
46  cache_.clear();
47  return;
48  }
49 
50  for (;;) {
51  const std::string &line = *iter_.back().first;
52 
53  bool special = special_ && iter_.size() == 1;
54  if ((!line.empty() && line[0] == '+') || special) {
55  if (++iter_.back().first == iter_.back().second) {
56  iter_.pop_back();
57  if (iter_.empty())
58  special_ = false;
59  }
60 
61  std::string block = special ? line : line.substr(1);
62 
63  std::map<std::string, std::vector<std::string> >::const_iterator pos = collector_->contents_.find(block);
64  if (pos == collector_->contents_.end())
65  throw edm::Exception(edm::errors::Configuration) << "ParameterCollector could not find configuration lines "
66  "block \""
67  << block << "\", included via plus sign.";
68 
69  if (dump_)
70  *dump_ << "\n####### " << block << " #######" << std::endl;
71 
72  if (!pos->second.empty())
73  iter_.push_back(IterPair(pos->second.begin(), pos->second.end()));
74  } else {
75  cache_ = collector_->resolve(line);
76  if (dump_)
77  *dump_ << cache_ << std::endl;
78  break;
79  }
80  }
81 }
82 
84  std::map<std::string, std::vector<std::string> >::const_iterator pos = contents_.find("parameterSets");
85  if (pos == contents_.end())
86  throw edm::Exception(edm::errors::Configuration) << "ParameterCollector could not find \"parameterSets\" block.";
87 
88  return const_iterator(this, pos->second.begin(), pos->second.end(), true);
89 }
90 
92  std::map<std::string, std::vector<std::string> >::const_iterator pos = contents_.find("parameterSets");
93  if (pos == contents_.end())
94  throw edm::Exception(edm::errors::Configuration) << "ParameterCollector could not find \"parameterSets\" block.";
95 
96  return const_iterator(this, pos->second.begin(), pos->second.end(), true, &dump);
97 }
98 
100  std::map<std::string, std::vector<std::string> >::const_iterator pos = contents_.find(block);
101  if (pos == contents_.end())
102  throw edm::Exception(edm::errors::Configuration) << "ParameterCollector could not find \"" << block << "\" block.";
103 
104  return const_iterator(this, pos->second.begin(), pos->second.end());
105 }
106 
108  std::map<std::string, std::vector<std::string> >::const_iterator pos = contents_.find(block);
109  if (pos == contents_.end())
110  throw edm::Exception(edm::errors::Configuration) << "ParameterCollector could not find \"" << block << "\" block.";
111 
112  dump << "\n####### " << block << " #######" << std::endl;
113 
114  return const_iterator(this, pos->second.begin(), pos->second.end(), false, &dump);
115 }
116 
119 
120  for (;;) {
121  std::string::size_type pos = result.find("${");
122  if (pos == std::string::npos)
123  break;
124 
125  std::string::size_type endpos = result.find('}', pos);
126  if (endpos == std::string::npos)
127  break;
128  else
129  ++endpos;
130 
131  std::string var = result.substr(pos + 2, endpos - pos - 3);
132  const char *path = std::getenv(var.c_str());
133 
134  result.replace(pos, endpos - pos, path ? path : "");
135  }
136 
137  return result;
138 }
gen::ParameterCollector::const_iterator::const_iterator
const_iterator()
Definition: ParameterCollector.h:38
pos
Definition: PixelAliasList.h:18
gen::ParameterCollector::const_iterator
Definition: ParameterCollector.h:35
gen::ParameterCollector::const_iterator::increment
void increment()
Definition: ParameterCollector.cc:37
end
#define end
Definition: vmac.h:39
gen::ParameterCollector
Definition: ParameterCollector.h:26
edm::Exception
Definition: EDMException.h:77
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
EDMException.h
gen::ParameterCollector::const_iterator::iter_
std::vector< IterPair > iter_
Definition: ParameterCollector.h:63
gen::ParameterCollector::ParameterCollector
ParameterCollector()
Definition: ParameterCollector.cc:14
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
gen::ParameterCollector::end
const_iterator end() const
Definition: ParameterCollector.h:76
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:122
gen::ParameterCollector::contents_
std::map< std::string, std::vector< std::string > > contents_
Definition: ParameterCollector.h:85
ParameterCollector.h
gen
Definition: PythiaDecays.h:13
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
gen::ParameterCollector::begin
const_iterator begin() const
Definition: ParameterCollector.cc:83
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
gen::ParameterCollector::~ParameterCollector
~ParameterCollector()
Definition: ParameterCollector.cc:23
gen::ParameterCollector::const_iterator::next
void next()
Definition: ParameterCollector.cc:44
gen::ParameterCollector::const_iterator::IterPair
std::pair< std::vector< std::string >::const_iterator, std::vector< std::string >::const_iterator > IterPair
Definition: ParameterCollector.h:58
mps_fire.result
result
Definition: mps_fire.py:303
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
ParameterSet.h
mps_splice.line
line
Definition: mps_splice.py:76
edm::errors::Configuration
Definition: EDMException.h:36
gen::ParameterCollector::resolve
static std::string resolve(const std::string &line)
Definition: ParameterCollector.cc:117
begin
#define begin
Definition: vmac.h:32
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
gen::ParameterCollector::const_iterator
friend class const_iterator
Definition: ParameterCollector.h:83