CMS 3D CMS Logo

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