CMS 3D CMS Logo

PixelAliasList.h
Go to the documentation of this file.
1 #ifndef PixelAliasList_h
2 #define PixelAliasList_h
3 
12 
13 #include <cassert>
14 #include <iostream>
15 #include <stdlib.h>
16 #include <map>
17 
18 namespace pos {
23  // Added by Dario, May 20th, 2008 =====================================================================
24  typedef std::pair<unsigned int, std::string> versionAliasPair;
25  typedef std::vector<versionAliasPair> vectorVAPairs;
26  typedef std::map<std::string, vectorVAPairs> pathVersionAliasMmap;
27  typedef std::map<std::string, std::string> pathAliasPair;
28  typedef std::map<std::string, pathAliasPair> pathAliasMmap;
29  // End of Dario's addition ============================================================================
31  public:
32  void writefile() {
33  std::string directory = std::getenv("PIXELCONFIGURATIONBASE");
34 
35  std::string filename = directory + "/aliases.txt";
36 
37  std::ofstream out(filename.c_str());
38 
39  out << "ConfigurationAliases" << std::endl;
40  for (unsigned int i = 0; i < pixelConfigAliases_.size(); i++) {
42  out << theAlias.name() << " " << theAlias.key() << " ";
43 
44  unsigned int n = theAlias.nVersionAliases();
45  for (unsigned int j = 0; j < n; j++) {
46  out << theAlias.versionAliasesPath(j) << " ";
47  out << theAlias.versionAliasesAlias(j) << " ";
48  }
49 
50  out << ";" << std::endl;
51  }
52 
53  out << "VersionAliases" << std::endl;
54  for (unsigned int i = 0; i < pixelVersionAliases_.size(); i++) {
56 
57  out << theAlias.path() << " " << theAlias.version() << " " << theAlias.alias() << " ;" << std::endl;
58  }
59  }
60 
62  std::ifstream in(filename.c_str());
63  if (!in.good()) {
64  std::cout << "[PixelAliasList::readfile()]\t\tCould not open file:" << filename << std::endl;
65  }
66  assert(in.good());
67 
68  // Added by Dario, May 28th, 2008 =====================================================================
69  pixelConfigAliases_.clear();
70  pixelVersionAliases_.clear();
71  aliasMmap.clear();
72  versionMmap.clear();
73  // End of Dario's addition ============================================================================
74 
76 
77  in >> tag;
78  while (tag.substr(0, 1) == "#") {
79  in.ignore(4096, '\n'); //skips to endl;
80  in >> tag;
81  }
82 
83  assert(tag == "ConfigurationAliases");
84 
85  in >> tag;
86 
87  while (tag != "VersionAliases") {
89 
90  unsigned int key;
91  in >> key;
92 
93  //std::cout << "[PixelAliasList::readfile()] Alias, key:"<<alias<<" "<<key<<std::endl;
94 
95  PixelConfigAlias anAlias(alias, key);
96 
97  in >> tag;
98  std::string theAlias = alias;
99 
100  // Added by Dario, May 20th, 2008 =====================================================================
101  pathAliasPair tmpPAPair;
102  if (tag == ";") {
103  tmpPAPair[""] = " ";
104  aliasMmap[theAlias] = tmpPAPair;
105  }
106  // End of Dario's addition ============================================================================
107  while (tag != ";") {
110 
111  path = tag;
112  in >> alias;
113  //std::cout << "[PixelAliasList::readfile()] path, alias:"<<path<<" "<<alias<<std::endl;
114 
115  anAlias.addVersionAlias(path, alias);
116  // Added by Dario, May 20th, 2008 =====================================================================
117  tmpPAPair[path] = alias;
118  aliasMmap[theAlias] = tmpPAPair;
119  // End of Dario's addition ============================================================================
120  in >> tag;
121  }
122 
123  pixelConfigAliases_.push_back(anAlias);
124 
125  in >> tag;
126  }
127 
128  assert(tag == "VersionAliases");
129 
132  unsigned int version;
133 
134  in >> path;
135  in >> version;
136  in >> alias;
137  in >> tag;
138 
139  //std::cout << "path version alias tag:"<<path<<" "<<version
140  // <<" "<<alias<<" "<<tag<<std::endl;
141 
142  // Added by Dario, May 23rd, 2008 =====================================================================
143  versionAliasPair tmpVAPair;
144  // End of Dario's addition ============================================================================
145  while (!in.eof()) {
146  assert(tag == ";");
147  PixelVersionAlias aVersionAlias(path, version, alias);
148  pixelVersionAliases_.push_back(aVersionAlias);
149 
150  // Added by Dario, May 23rd, 2008 =====================================================================
151  tmpVAPair.first = version;
152  tmpVAPair.second = alias;
153  versionMmap[path].push_back(tmpVAPair);
154  // End of Dario's addition ============================================================================
155 
156  in >> path;
157  in >> version;
158  in >> alias;
159  in >> tag;
160  }
161 
162  in.close();
163  }
164 
165  void insertAlias(PixelConfigAlias& anAlias) {
166  for (unsigned int i = 0; i < pixelConfigAliases_.size(); i++) {
167  if (pixelConfigAliases_[i].name() == anAlias.name()) {
168  std::cout << "[PixelAliasList::insertAlias()]\t\t\tReplacing existing alias:" << anAlias.name() << std::endl;
169  pixelConfigAliases_[i] = anAlias;
170  return;
171  }
172  }
173  pixelConfigAliases_.push_back(anAlias);
174  }
175 
177  for (unsigned int i = 0; i < pixelConfigAliases_.size(); i++) {
178  if (pixelConfigAliases_[i].name() == aliasName) {
179  return &(pixelConfigAliases_[i]);
180  }
181  }
182  return 0;
183  }
184 
186  for (unsigned int i = 0; i < pixelVersionAliases_.size(); i++) {
187  if (pixelVersionAliases_[i].alias() == anAlias.alias() && pixelVersionAliases_[i].path() == anAlias.path()) {
188  std::cout << "[PixelAliasList::insertVersionAlias()]\t\tReplacing existing version alias:" << anAlias.path()
189  << " " << anAlias.alias() << std::endl;
190  pixelVersionAliases_[i] = anAlias;
191  return;
192  }
193  }
194  pixelVersionAliases_.push_back(anAlias);
195  }
196 
198  //first loop over configuration aliases
199  for (unsigned int i = 0; i < pixelConfigAliases_.size(); i++) {
200  //std::cout << "Looping over aliases:"<<i<<std::endl;
201  for (unsigned int j = 0; j < pixelConfigAliases_[i].nVersionAliases(); j++) {
202  //std::cout << "Looping over versionAliases:"<<j<<std::endl;
203  if (path == pixelConfigAliases_[i].versionAliasesPath(j) &&
204  alias == pixelConfigAliases_[i].versionAliasesAlias(j)) {
205  //std::cout << "Making clone!"<<std::endl;
206  unsigned int newkey = config.clone(pixelConfigAliases_[i].key(), path, version);
207  pixelConfigAliases_[i].setKey(newkey);
208  }
209  }
210  }
211  }
212 
213  std::vector<std::string> getVersionAliases(std::string path) {
214  std::vector<std::string> tmp;
215  for (unsigned int i = 0; i < pixelVersionAliases_.size(); i++) {
216  //std::cout << "path alias:"<<pixelVersionAliases_[i].path()
217  // << pixelVersionAliases_[i].alias() << std::endl;
218  if (pixelVersionAliases_[i].path() == path) {
219  tmp.push_back(pixelVersionAliases_[i].alias());
220  }
221  }
222  return tmp;
223  }
224 
226  for (unsigned int i = 0; i < pixelVersionAliases_.size(); i++) {
227  if (pixelVersionAliases_[i].alias() == alias && pixelVersionAliases_[i].path() == path) {
228  return pixelVersionAliases_[i].version();
229  }
230  }
231  assert(0);
232  return 0;
233  }
234 
235  // Added by Dario, May 20th, 2008 =====================================================================
237 
240  for (pathVersionAliasMmap::iterator it = versionMmap.begin(); it != versionMmap.end(); it++) {
241  if ((*it).first.find(koc) != std::string::npos) {
242  result[(*it).first] = (*it).second;
243  }
244  }
245  return result;
246  }
247 
248  std::vector<pathAliasPair> getConfigAliases(std::string path) {
249  std::vector<pathAliasPair> configAliasVector;
250  for (pathAliasMmap::iterator it = aliasMmap.begin(); it != aliasMmap.end(); it++) {
251  if ((*it).first == path) {
252  configAliasVector.push_back((*it).second);
253  }
254  }
255  return configAliasVector;
256  }
257  // End of Dario's addition ============================================================================
258 
259  unsigned int nAliases() { return pixelConfigAliases_.size(); }
260  std::string name(unsigned int i) { return pixelConfigAliases_[i].name(); }
261  unsigned int key(unsigned int i) { return pixelConfigAliases_[i].key(); }
262  PixelConfigAlias operator[](unsigned int i) { return pixelConfigAliases_[i]; }
263 
264  unsigned int nVersionAliases() { return pixelVersionAliases_.size(); }
265  std::string path(unsigned int i) { return pixelVersionAliases_[i].path(); }
266  unsigned int version(unsigned int i) { return pixelVersionAliases_[i].version(); }
267  std::string alias(unsigned int i) { return pixelVersionAliases_[i].alias(); }
268 
269  private:
270  std::vector<PixelConfigAlias> pixelConfigAliases_;
271  std::vector<PixelVersionAlias> pixelVersionAliases_;
272  // Added by Dario, May 20th, 2008 =====================================================================
275  // End of Dario's addition ============================================================================
276  };
277 } // namespace pos
278 
279 #endif
pos::PixelAliasList::nAliases
unsigned int nAliases()
Definition: PixelAliasList.h:259
pos::PixelConfigAlias
Definition: PixelConfigAlias.h:17
mps_fire.i
i
Definition: mps_fire.py:355
pos::PixelAliasList::writefile
void writefile()
Definition: PixelAliasList.h:32
pos::PixelAliasList::version
unsigned int version(unsigned int i)
Definition: PixelAliasList.h:266
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
pos::versionAliasPair
std::pair< unsigned int, std::string > versionAliasPair
Definition: PixelAliasList.h:24
pos::PixelConfigAlias::versionAliasesAlias
std::string versionAliasesAlias(unsigned int i)
Definition: PixelConfigAlias.h:34
pos::PixelConfigAlias::name
std::string name()
Definition: PixelConfigAlias.h:29
pos::PixelAliasList::path
std::string path(unsigned int i)
Definition: PixelAliasList.h:265
pos::PixelConfigAlias::versionAliasesPath
std::string versionAliasesPath(unsigned int i)
Definition: PixelConfigAlias.h:33
pos::PixelConfigAlias::key
unsigned int key()
Definition: PixelConfigAlias.h:30
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
pos::PixelAliasList::aliasMmap
pathAliasMmap aliasMmap
Definition: PixelAliasList.h:273
pos::PixelAliasList::pixelConfigAliases_
std::vector< PixelConfigAlias > pixelConfigAliases_
Definition: PixelAliasList.h:270
pos::PixelVersionAlias::version
unsigned int version()
Definition: PixelVersionAlias.h:17
pos::PixelAliasList::updateConfigAlias
void updateConfigAlias(std::string path, unsigned int version, std::string alias, PixelConfigList &config)
Definition: PixelAliasList.h:197
cms::cuda::assert
assert(be >=bs)
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
PixelConfigList.h
This class implements the configuration key which actually just is an integer.
pos::PixelAliasList::getVersionData
pathVersionAliasMmap getVersionData()
Definition: PixelAliasList.h:236
pos::vectorVAPairs
std::vector< versionAliasPair > vectorVAPairs
Definition: PixelAliasList.h:25
pos::PixelAliasList::operator[]
PixelConfigAlias operator[](unsigned int i)
Definition: PixelAliasList.h:262
config
Definition: config.py:1
pos::PixelAliasList::insertVersionAlias
void insertVersionAlias(PixelVersionAlias &anAlias)
Definition: PixelAliasList.h:185
pos::PixelAliasList::versionAliases
PixelConfigAlias * versionAliases(std::string aliasName)
Definition: PixelAliasList.h:176
pos::PixelConfigList
This class implements..
Definition: PixelConfigList.h:22
pos::PixelAliasList::readfile
void readfile(std::string filename)
Definition: PixelAliasList.h:61
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
PixelConfigAlias.h
This class implements the steps that are used in a scan over Threshold and CalDelay.
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
pos::PixelAliasList::getVersionData
pathVersionAliasMmap getVersionData(std::string koc)
Definition: PixelAliasList.h:238
pos::PixelAliasList::pixelVersionAliases_
std::vector< PixelVersionAlias > pixelVersionAliases_
Definition: PixelAliasList.h:271
pos::PixelAliasList::getVersion
unsigned int getVersion(std::string path, std::string alias)
Definition: PixelAliasList.h:225
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pos::PixelAliasList
Definition: PixelAliasList.h:30
pos::PixelAliasList::getConfigAliases
std::vector< pathAliasPair > getConfigAliases(std::string path)
Definition: PixelAliasList.h:248
pos::PixelAliasList::nVersionAliases
unsigned int nVersionAliases()
Definition: PixelAliasList.h:264
pos::pathAliasMmap
std::map< std::string, pathAliasPair > pathAliasMmap
Definition: PixelAliasList.h:28
recoMuon::in
Definition: RecoMuonEnumerators.h:6
pos::PixelAliasList::alias
std::string alias(unsigned int i)
Definition: PixelAliasList.h:267
pos::pathVersionAliasMmap
std::map< std::string, vectorVAPairs > pathVersionAliasMmap
Definition: PixelAliasList.h:26
pos::PixelAliasList::versionMmap
pathVersionAliasMmap versionMmap
Definition: PixelAliasList.h:274
pos::pathAliasPair
std::map< std::string, std::string > pathAliasPair
Definition: PixelAliasList.h:27
PixelVersionAlias.h
pos::PixelAliasList::name
std::string name(unsigned int i)
Definition: PixelAliasList.h:260
pos::PixelAliasList::getVersionAliases
std::vector< std::string > getVersionAliases(std::string path)
Definition: PixelAliasList.h:213
pos::PixelConfigAlias::nVersionAliases
unsigned int nVersionAliases()
Definition: PixelConfigAlias.h:32
pos::PixelConfigAlias::addVersionAlias
void addVersionAlias(std::string path, std::string alias)
Definition: PixelConfigAlias.h:24
createBeamHaloJobs.directory
string directory
Definition: createBeamHaloJobs.py:211
pos::PixelAliasList::insertAlias
void insertAlias(PixelConfigAlias &anAlias)
Definition: PixelAliasList.h:165
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
pos::PixelVersionAlias::alias
std::string alias()
Definition: PixelVersionAlias.h:18
mps_fire.result
result
Definition: mps_fire.py:303
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
pos::PixelVersionAlias
Definition: PixelVersionAlias.h:7
pos::PixelVersionAlias::path
std::string path()
Definition: PixelVersionAlias.h:16
pos::PixelAliasList::key
unsigned int key(unsigned int i)
Definition: PixelAliasList.h:261