CMS 3D CMS Logo

PixelConfigList.h
Go to the documentation of this file.
1 #ifndef PixelConfigList_h
2 #define PixelConfigList_h
3 
10 
11 #include <cassert>
12 #include <iostream>
13 #include <stdlib.h>
14 #include <string>
15 
16 namespace pos {
23  public:
24  void writefile() {
25  std::string directory = std::getenv("PIXELCONFIGURATIONBASE");
26  /* directory+="/PixelConfigDataExamples/"; */
27  directory += "/";
28 
29  std::string filename = directory + "/configurations.txt";
30 
31  std::ofstream out(filename.c_str());
32  assert(out.good());
33 
34  for (unsigned int i = 0; i < configs.size(); i++) {
35  //std::cout << "key "<<i<<std::endl;
36  out << "key " << i << std::endl;
37  configs[i].write(out);
38  out << std::endl;
39  //std::cout <<std::endl;
40  }
41  }
42 
44  std::ifstream in(filename.c_str());
45 
47 
48  in >> tag;
49  while (tag.substr(0, 1) == "#") {
50  in.ignore(4096, '\n'); //skips to endl;
51  in >> tag;
52  }
53 
54  unsigned int version = 0;
55 
56  while (!in.eof()) {
57  if (tag != "key") {
58  std::cout << "PixelConfigDB: tag=" << tag << std::endl;
59  assert(0);
60  }
61  unsigned int tmp_version;
62  in >> tmp_version;
63  if (version != tmp_version) {
64  std::cout << "PixelConfigDB: read version: " << tmp_version << " while expected " << version << std::endl;
65  assert(0);
66  }
67 
68  in >> tag;
69  while (tag.substr(0, 1) == "#") {
70  in.ignore(4096, '\n'); //skips to endl;
71  in >> tag;
72  }
73 
74  PixelConfig aConfig;
75  while (tag != "key" && in.good()) {
76  unsigned int tmp;
77  in >> tmp;
78  //std::cout << "adding: "<<tag<<" "<<tmp<<std::endl;
79  aConfig.add(tag, tmp);
80  in >> tag;
81  while (tag.substr(0, 1) == "#") {
82  in.ignore(4096, '\n'); //skips to endl;
83  in >> tag;
84  }
85  }
86 
87  configs.push_back(aConfig);
88  version++;
89  };
90 
91  in.close();
92  }
93 
94  //Method will return new key
95  unsigned int clone(unsigned int oldkey, std::string path, unsigned int version) {
96  PixelConfig aConfig = configs[oldkey];
97 
98  unsigned int oldversion;
99 
100  if (-1 == aConfig.update(path, oldversion, version)) {
101  std::cout << "Old version not found for path=" << path << " in config " << oldkey << std::endl;
102  assert(0);
103  }
104 
105  configs.push_back(aConfig);
106 
107  return configs.size() - 1;
108  }
109 
110  //Method will return new key
111  unsigned int add(PixelConfig& aConfig) {
112  configs.push_back(aConfig);
113 
114  return configs.size() - 1;
115  }
116 
117  unsigned int size() { return configs.size(); }
118 
119  PixelConfig& operator[](unsigned int i) { return configs[i]; }
120 
122  configs.clear();
124  }
125 
126  unsigned int numberOfConfigs() { return configs.size(); }
127 
128  private:
129  std::vector<PixelConfig> configs;
130  };
131 } // namespace pos
132 #endif
pos::PixelConfigList::size
unsigned int size()
Definition: PixelConfigList.h:117
mps_fire.i
i
Definition: mps_fire.py:428
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
cms::cuda::assert
assert(be >=bs)
pos::PixelConfigList::operator[]
PixelConfig & operator[](unsigned int i)
Definition: PixelConfigList.h:119
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
pos::PixelConfig::add
void add(std::string dir, unsigned int version)
Definition: PixelConfig.h:30
pos::PixelConfigList
This class implements..
Definition: PixelConfigList.h:22
pos::PixelConfigList::readfile
void readfile(std::string filename)
Definition: PixelConfigList.h:43
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
pos::PixelConfigList::add
unsigned int add(PixelConfig &aConfig)
Definition: PixelConfigList.h:111
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pos::PixelConfigList::writefile
void writefile()
Definition: PixelConfigList.h:24
recoMuon::in
Definition: RecoMuonEnumerators.h:6
pos::PixelConfig::update
int update(std::string dir, unsigned int &version, unsigned int newversion)
Definition: PixelConfig.h:49
pos::PixelConfigList::numberOfConfigs
unsigned int numberOfConfigs()
Definition: PixelConfigList.h:126
createBeamHaloJobs.directory
string directory
Definition: createBeamHaloJobs.py:211
pos::PixelConfigList::configs
std::vector< PixelConfig > configs
Definition: PixelConfigList.h:129
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
PixelConfig.h
This class implements..
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
pos::PixelConfigList::reload
void reload(std::string filename)
Definition: PixelConfigList.h:121
pos::PixelConfig
This class implements..
Definition: PixelConfig.h:20
pos::PixelConfigList::clone
unsigned int clone(unsigned int oldkey, std::string path, unsigned int version)
Definition: PixelConfigList.h:95