CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::ParameterSetConverter Class Reference

#include <ParameterSetConverter.h>

Inheritance diagram for edm::ParameterSetConverter:

Public Types

typedef std::map< ParameterSetID, ParameterSetIDParameterSetIdConverter
 
typedef std::list< std::string > StringList
 
typedef std::map< std::string, std::string > StringMap
 
typedef std::list< std::pair< std::string, ParameterSetID > > StringWithIDList
 

Public Member Functions

 ParameterSetConverter (ParameterSetMap const &psetMap, ParameterSetIdConverter &idConverter, bool alreadyByReference)
 
ParameterSetIdConverter const & parameterSetIdConverter () const
 
 ~ParameterSetConverter ()
 

Private Member Functions

void convertParameterSets ()
 
void noConvertParameterSets ()
 

Private Attributes

std::vector< MainParameterSetmainParameterSets_
 
ParameterSetIdConverterparameterSetIdConverter_
 
StringWithIDList parameterSets_
 
StringMap replace_
 
std::vector< TriggerPathtriggerPaths_
 

Detailed Description

Definition at line 41 of file ParameterSetConverter.h.

Member Typedef Documentation

Definition at line 46 of file ParameterSetConverter.h.

Definition at line 43 of file ParameterSetConverter.h.

typedef std::map<std::string, std::string> edm::ParameterSetConverter::StringMap

Definition at line 44 of file ParameterSetConverter.h.

Definition at line 45 of file ParameterSetConverter.h.

Constructor & Destructor Documentation

edm::ParameterSetConverter::ParameterSetConverter ( ParameterSetMap const &  psetMap,
ParameterSetIdConverter idConverter,
bool  alreadyByReference 
)

Definition at line 62 of file ParameterSetConverter.cc.

References convertParameterSets(), mps_fire::i, edm::ParameterSet::id(), mainParameterSets_, noConvertParameterSets(), parameterSetIdConverter_, parameterSets_, muonDTDigis_cfi::pset, edm::ParameterSet::registerIt(), replace_, AlCaHLTBitMon_QueryRunRegistry::string, and triggerPaths_.

64  :
67  triggerPaths_(),
68  replace_(),
69  parameterSetIdConverter_(idConverter)
70  {
71  for (ParameterSetMap::const_iterator i = psetMap.begin(), iEnd = psetMap.end(); i != iEnd; ++i) {
72  parameterSets_.push_back(std::make_pair(i->second.pset(), i->first));
73  }
74  if (alreadyByReference) {
76  } else {
77  replace_.insert(std::make_pair(std::string("=+p({})"), std::string("=+q({})")));
79  }
80  for (std::vector<MainParameterSet>::iterator j = mainParameterSets_.begin(), jEnd = mainParameterSets_.end(); j != jEnd; ++j) {
81  for (std::vector<TriggerPath>::iterator i = triggerPaths_.begin(), iEnd = triggerPaths_.end(); i != iEnd; ++i) {
82  if (i->triggerPaths_ == j->triggerPaths_) {
83  j->parameterSet_.addParameter("@trigger_paths", i->parameterSet_);
84  break;
85  }
86  }
87  }
88  for (std::vector<MainParameterSet>::iterator i = mainParameterSets_.begin(), iEnd = mainParameterSets_.end(); i != iEnd; ++i) {
89  ParameterSet& pset = i->parameterSet_;
90  pset.registerIt();
91  ParameterSetID newID(pset.id());
92  if (i->oldID_ != newID && i->oldID_ != ParameterSetID()) {
93  parameterSetIdConverter_.insert(std::make_pair(i->oldID_, newID));
94  }
95  }
96  }
ParameterSetIdConverter & parameterSetIdConverter_
std::vector< MainParameterSet > mainParameterSets_
std::vector< TriggerPath > triggerPaths_
Hash< ParameterSetType > ParameterSetID
edm::ParameterSetConverter::~ParameterSetConverter ( )

Definition at line 98 of file ParameterSetConverter.cc.

98 {}

Member Function Documentation

void edm::ParameterSetConverter::convertParameterSets ( )
private

Definition at line 117 of file ParameterSetConverter.cc.

References StringMap::begin(), findQualityFiles::comma, MillePedeFileConverter_cfg::e, StringMap::end(), f, mps_fire::i, edm::ParameterSet::id(), mainParameterSets_, parameterSetIdConverter_, parameterSets_, csvLumiCalc::pieces, muonDTDigis_cfi::pset, edm::ParameterSet::registerIt(), replace_, edm::split(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, edm::Hash< I >::toString(), and triggerPaths_.

Referenced by ParameterSetConverter().

117  {
118  std::string const comma(",");
119  std::string const rparam(")");
120  std::string const rvparam("})");
121  std::string const loldparam("=+P(");
122  std::string const loldvparam("=+p({");
123  std::string const lparam("=+Q(");
124  std::string const lvparam("=+q({");
125  bool doItAgain = false;
126  for (StringMap::const_iterator j = replace_.begin(), jEnd = replace_.end(); j != jEnd; ++j) {
127  for (StringWithIDList::iterator i = parameterSets_.begin(), iEnd = parameterSets_.end(); i != iEnd; ++i) {
128  for (std::string::size_type it = i->first.find(j->first); it != std::string::npos; it = i->first.find(j->first)) {
129  i->first.replace(it, j->first.size(), j->second);
130  doItAgain = true;
131  }
132  }
133  }
134  for (StringWithIDList::iterator i = parameterSets_.begin(), iEnd = parameterSets_.end(); i != iEnd; ++i) {
135  if (i->first.find("+P") == std::string::npos && i->first.find("+p") == std::string::npos) {
136  if (i->first.find("@all_sources") != std::string::npos) {
137  mainParameterSets_.push_back(MainParameterSet(i->second, i->first));
138  } else {
139  ParameterSet pset(i->first);
140  pset.registerIt();
141  std::string& from = i->first;
142  std::string to;
143  ParameterSetID newID(pset.id());
144  newID.toString(to);
145  insertIntoReplace(replace_, loldparam, from, rparam, lparam, to, rparam);
146  insertIntoReplace(replace_, comma, from, comma, comma, to, comma);
147  insertIntoReplace(replace_, comma, from, rvparam, comma, to, rvparam);
148  insertIntoReplace(replace_, loldvparam, from, comma, lvparam, to, comma);
149  insertIntoReplace(replace_, loldvparam, from, rvparam, lvparam, to, rvparam);
150  if (i->second != newID && i->second != ParameterSetID()) {
151  parameterSetIdConverter_.insert(std::make_pair(i->second, newID));
152  }
153  if (i->first.find("@trigger_paths") != std::string::npos) {
154  triggerPaths_.push_back(pset);
155  }
156  }
157  StringWithIDList::iterator icopy = i;
158  ++i;
159  parameterSets_.erase(icopy);
160  --i;
161  doItAgain = true;
162  }
163  }
164  if (!doItAgain && !parameterSets_.empty()) {
165  for (StringWithIDList::iterator i = parameterSets_.begin(), iEnd = parameterSets_.end(); i != iEnd; ++i) {
166  std::list<std::string> pieces;
167  split(std::back_inserter(pieces), i->first, '<', ';', '>');
168  for (std::list<std::string>::iterator i= pieces.begin(), e = pieces.end(); i != e; ++i) {
169  std::string removeName = i->substr(i->find('+'));
170  if (removeName.size() >= 4) {
171  if (removeName[1] == 'P') {
172  std::string psetString(removeName.begin()+3, removeName.end()-1);
173  parameterSets_.push_back(std::make_pair(psetString, ParameterSetID()));
174  doItAgain = true;
175  } else if (removeName[1] == 'p') {
176  std::string pvec = std::string(removeName.begin()+3, removeName.end()-1);
178  split(std::back_inserter(temp), pvec, '{', ',', '}');
179  for (StringList::const_iterator j = temp.begin(), f = temp.end(); j != f; ++j) {
180  parameterSets_.push_back(std::make_pair(*j, ParameterSetID()));
181  }
182  doItAgain = true;
183  }
184  }
185  }
186  }
187  }
188  if (doItAgain) {
190  }
191  }
const_iterator end() const
Definition: StringMap.h:32
const_iterator begin() const
Definition: StringMap.h:31
ParameterSetIdConverter & parameterSetIdConverter_
uint16_t size_type
std::vector< MainParameterSet > mainParameterSets_
std::vector< TriggerPath > triggerPaths_
vector_type::const_iterator const_iterator
Definition: StringMap.h:12
double f[11][100]
bool split(OutIter result, std::string const &string_to_split, char first, char sep, char last)
Definition: split.h:88
Hash< ParameterSetType > ParameterSetID
void toString(std::string &result) const
Definition: Hash.h:193
std::list< std::string > StringList
void edm::ParameterSetConverter::noConvertParameterSets ( )
private

Definition at line 101 of file ParameterSetConverter.cc.

References mps_fire::i, edm::pset::Registry::insertMapped(), edm::pset::Registry::instance(), mainParameterSets_, parameterSets_, muonDTDigis_cfi::pset, edm::ParameterSet::setID(), and triggerPaths_.

Referenced by ParameterSetConverter().

101  {
102  for (StringWithIDList::iterator i = parameterSets_.begin(), iEnd = parameterSets_.end(); i != iEnd; ++i) {
103  if (i->first.find("@all_sources") != std::string::npos) {
104  mainParameterSets_.push_back(MainParameterSet(i->second, i->first));
105  } else {
106  ParameterSet pset(i->first);
107  pset.setID(i->second);
109  if (i->first.find("@trigger_paths") != std::string::npos) {
110  triggerPaths_.push_back(pset);
111  }
112  }
113  }
114  }
std::vector< MainParameterSet > mainParameterSets_
std::vector< TriggerPath > triggerPaths_
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:35
static Registry * instance()
Definition: Registry.cc:12
ParameterSetIdConverter const& edm::ParameterSetConverter::parameterSetIdConverter ( ) const
inline

Definition at line 49 of file ParameterSetConverter.h.

ParameterSetIdConverter & parameterSetIdConverter_

Member Data Documentation

std::vector<MainParameterSet> edm::ParameterSetConverter::mainParameterSets_
private
ParameterSetIdConverter& edm::ParameterSetConverter::parameterSetIdConverter_
private

Definition at line 57 of file ParameterSetConverter.h.

Referenced by convertParameterSets(), and ParameterSetConverter().

StringWithIDList edm::ParameterSetConverter::parameterSets_
private
StringMap edm::ParameterSetConverter::replace_
private

Definition at line 56 of file ParameterSetConverter.h.

Referenced by convertParameterSets(), and ParameterSetConverter().

std::vector<TriggerPath> edm::ParameterSetConverter::triggerPaths_
private