CMS 3D CMS Logo

PixelLTCConfig.cc
Go to the documentation of this file.
1 //
2 // This class reads the LTC configuration file
3 //
4 //
5 //
6 
9 #include <sstream>
10 #include <cassert>
11 #include <stdexcept>
12 
13 using namespace pos;
14 using namespace std;
15 
16 PixelLTCConfig::PixelLTCConfig(vector<vector<string> > &tableMat) : PixelConfigBase(" ", " ", " ") {
17  std::string mthn = "[PixelLTCConfig::PixelLTCConfig()]\t\t\t ";
18  std::map<std::string, int> colM;
19  std::vector<std::string> colNames;
32  colNames.push_back("CONFIG_KEY");
33  colNames.push_back("KEY_TYPE");
34  colNames.push_back("KEY_ALIAS");
35  colNames.push_back("VERSION");
36  colNames.push_back("KIND_OF_COND");
37  colNames.push_back("LTC_OBJ_DATA_FILE");
38  colNames.push_back("LTC_OBJ_DATA_CLOB");
39 
40  for (unsigned int c = 0; c < tableMat[0].size(); c++) {
41  for (unsigned int n = 0; n < colNames.size(); n++) {
42  if (tableMat[0][c] == colNames[n]) {
43  colM[colNames[n]] = c;
44  break;
45  }
46  }
47  } //end for
48  for (unsigned int n = 0; n < colNames.size(); n++) {
49  if (colM.find(colNames[n]) == colM.end()) {
50  std::cerr << __LINE__ << "]\t" << mthn << "Couldn't find in the database the column with name " << colNames[n]
51  << std::endl;
52  assert(0);
53  }
54  }
55  ltcConfigStream_ << tableMat[1][colM["LTC_OBJ_DATA_CLOB"]];
56  // cout << "[PixelTTCciConfig::PixelTTCciConfig()]\tRead: "<< endl<< ttcConfigStream_.str() << endl ;
57 }
58 
60  std::string mthn = "[PixelLTCConfig::PixelLTCConfig()]\t\t\t ";
61  std::ifstream in(filename.c_str());
62 
63  if (!in.good()) {
64  std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
65  throw std::runtime_error("Failed to open file " + filename);
66  } else {
67  std::cout << __LINE__ << "]\t" << mthn << "Opened: " << filename << std::endl;
68  }
69 
70  //ltcConfigPath_ = filename;
71  string line;
72  while (!in.eof()) {
73  getline(in, line);
74  ltcConfigStream_ << line << endl;
75  }
76 }
77 
79  if (!dir.empty())
80  dir += "/";
81  std::string filename = dir + "LTCConfiguration.txt";
82  std::ofstream out(filename.c_str());
83 
84  //std::ifstream in(ltcConfigPath_.c_str());
85  //assert(in.good());
86 
87  string configstr = ltcConfigStream_.str();
88 
89  out << configstr << endl;
90 
91  out.close();
92 }
93 
94 //=============================================================================================
96  int version,
98  std::ofstream *outstream,
99  std::ofstream *out1stream,
100  std::ofstream *out2stream) const {
101  std::string mthn = "[PixelLTCConfig::writeXMLHeader()]\t\t\t ";
102  std::stringstream maskFullPath;
103 
104  writeASCII(path);
105 
106  maskFullPath << path << "/Pixel_LtcParameters_" << PixelTimeFormatter::getmSecTime() << ".xml";
107  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << maskFullPath.str() << std::endl;
108 
109  outstream->open(maskFullPath.str().c_str());
110 
111  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
112  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
113  *outstream << "" << std::endl;
114  *outstream << " <HEADER>" << std::endl;
115  *outstream << " <TYPE>" << std::endl;
116  *outstream << " <EXTENSION_TABLE_NAME>PIXEL_LTC_PARAMETERS</EXTENSION_TABLE_NAME>" << std::endl;
117  *outstream << " <NAME>LTC Configuration Parameters</NAME>" << std::endl;
118  *outstream << " </TYPE>" << std::endl;
119  *outstream << " <RUN>" << std::endl;
120  *outstream << " <RUN_TYPE>LTC Configuration Parameters</RUN_TYPE>" << std::endl;
121  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
122  *outstream << " <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl;
123  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl;
124  *outstream << " </RUN>" << std::endl;
125  *outstream << " </HEADER>" << std::endl;
126  *outstream << "" << std::endl;
127  *outstream << " <DATA_SET>" << std::endl;
128  *outstream << "" << std::endl;
129  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl;
130  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl;
131  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl;
132  *outstream << "" << std::endl;
133  *outstream << " <PART>" << std::endl;
134  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
135  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
136  *outstream << " </PART>" << std::endl;
137 }
138 
139 //=============================================================================================
140 void PixelLTCConfig::writeXML(std::ofstream *outstream, std::ofstream *out1stream, std::ofstream *out2stream) const {
141  std::string mthn = "[PixelLTCConfig::writeXML()]\t\t\t ";
142 
143  *outstream << " <DATA>" << std::endl;
144  *outstream << " <LTC_OBJ_DATA_FILE>./LTCConfiguration.txt</LTC_OBJ_DATA_FILE>" << std::endl;
145  *outstream << " </DATA>" << std::endl;
146 }
147 
148 //=============================================================================================
149 void PixelLTCConfig::writeXMLTrailer(std::ofstream *outstream,
150  std::ofstream *out1stream,
151  std::ofstream *out2stream) const {
152  std::string mthn = "[PixelLTCConfig::writeXMLTrailer()]\t\t\t ";
153 
154  *outstream << " </DATA_SET>" << std::endl;
155  *outstream << "</ROOT>" << std::endl;
156 
157  outstream->close();
158  std::cout << __LINE__ << "]\t" << mthn << "Data written " << std::endl;
159 }
pos::PixelLTCConfig::PixelLTCConfig
PixelLTCConfig(std::vector< std::vector< std::string > > &tableMat)
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
PixelTimeFormatter.h
This class provides utility methods to manipulate ASCII formatted timestamps.
pos::PixelLTCConfig::writeXMLTrailer
void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
Definition: PixelLTCConfig.cc:149
pos::PixelLTCConfig::writeXMLHeader
void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
Definition: PixelLTCConfig.cc:95
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
cms::cuda::assert
assert(be >=bs)
pos::PixelConfigBase
This file contains the base class for "pixel configuration data" management.
Definition: PixelConfigBase.h:32
pos::PixelLTCConfig::writeXML
void writeXML(pos::PixelConfigKey key, int version, std::string path) const override
Definition: PixelLTCConfig.h:37
pos::PixelTimeFormatter::getTime
static std::string getTime(void)
Definition: PixelTimeFormatter.h:60
pos::PixelLTCConfig::ltcConfigStream_
std::stringstream ltcConfigStream_
Definition: PixelLTCConfig.h:51
pos::PixelConfigBase::getAuthor
std::string getAuthor() const
Definition: PixelConfigBase.h:70
pos::PixelTimeFormatter::getmSecTime
static std::string getmSecTime(void)
Definition: PixelTimeFormatter.h:93
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pos::PixelConfigBase::getComment
std::string getComment() const
Definition: PixelConfigBase.h:71
pos::PixelConfigKey
This class implements..
Definition: PixelConfigKey.h:20
recoMuon::in
Definition: RecoMuonEnumerators.h:6
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
std
Definition: JetResolutionObject.h:76
pos::PixelLTCConfig::writeASCII
void writeASCII(std::string dir) const override
Definition: PixelLTCConfig.cc:78
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
mps_splice.line
line
Definition: mps_splice.py:76
crabWrapper.key
key
Definition: crabWrapper.py:19
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
PixelLTCConfig.h
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23