22 PixelMaxVsf::PixelMaxVsf(std::vector< std::vector< std::string > > &tableMat):
PixelConfigBase(
"",
"",
"")
24 std::string mthn =
"[PixelMaxVsf::PixelMaxVsf()]\t\t\t\t " ;
25 std::map<std::string , int > colM;
26 std::vector<std::string > colNames;
40 colNames.push_back(
"CONFIG_KEY" );
41 colNames.push_back(
"KEY_TYPE" );
42 colNames.push_back(
"KEY_ALIAS" );
43 colNames.push_back(
"VERSION" );
44 colNames.push_back(
"KIND_OF_COND");
45 colNames.push_back(
"ROC_NAME" );
46 colNames.push_back(
"MAXVSF" );
48 for(
unsigned int c = 0 ;
c < tableMat[0].size() ;
c++)
50 for(
unsigned int n=0;
n<colNames.size();
n++)
52 if(tableMat[0][
c] == colNames[
n])
54 colM[colNames[
n]] =
c;
59 for(
unsigned int n=0;
n<colNames.size();
n++)
61 if(colM.find(colNames[
n]) == colM.end())
63 std::cerr << __LINE__ <<
"]\t" << mthn <<
"Couldn't find in the database the column with name " << colNames[
n] << std::endl;
70 for(
unsigned int r = 1 ;
r < tableMat.size() ;
r++)
74 vsf = atoi(tableMat[
r][colM[
"MAXVSF"]].c_str());
84 std::string mthn =
"[PixelMaxVsf::PixelMaxVsf()]\t\t\t\t " ;
86 if (filename[filename.size()-1]==
't'){
88 std::ifstream
in(filename.c_str());
91 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open: " << filename << std::endl;
92 throw std::runtime_error(
"Failed to open file "+filename);
95 std::cout << __LINE__ <<
"]\t" << mthn <<
"Opened: " << filename << std::endl;
99 std::cout << __LINE__ <<
"]\t" << mthn <<
"eof before reading anything!" << std::endl;
100 throw std::runtime_error(
"File appears to be empty: "+filename);
127 std::map<PixelROCName,unsigned int>::const_iterator itr =
rocs_.find(roc);
129 if (itr==
rocs_.end()) {
150 std::string mthn =
"[PixelMaxVsf::writeASCII()]\t\t\t\t " ;
151 if (dir!=
"") dir+=
"/";
156 std::cout << __LINE__ <<
"]\t" << mthn <<
"Could not open file " << filename <<
" for write" << std::endl ;
161 std::map<PixelROCName, unsigned int>::const_iterator irocs =
rocs_.begin();
162 for(; irocs !=
rocs_.end() ; irocs++){
163 out << (irocs->first).rocname() <<
" " << irocs->second << endl ;
174 std::ofstream *outstream,
175 std::ofstream *out1stream,
176 std::ofstream *out2stream)
const
178 std::string mthn =
"[PixelMaxVsf::writeXMLHeader()]\t\t\t " ;
179 std::stringstream maskFullPath ;
182 std::cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " << maskFullPath.str() << std::endl ;
184 outstream->open(maskFullPath.str().c_str()) ;
186 *outstream <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl ;
187 *outstream <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl ;
188 *outstream <<
"" << std::endl ;
189 *outstream <<
" <HEADER>" << std::endl ;
190 *outstream <<
" <TYPE>" << std::endl ;
191 *outstream <<
" <EXTENSION_TABLE_NAME>ROC_MAXVSF</EXTENSION_TABLE_NAME>" << std::endl ;
192 *outstream <<
" <NAME>ROC MaxVsf Setting</NAME>" << std::endl ;
193 *outstream <<
" </TYPE>" << std::endl ;
194 *outstream <<
" <RUN>" << std::endl ;
195 *outstream <<
" <RUN_TYPE>ROC MaxVsf Settings</RUN_TYPE>" << std::endl ;
196 *outstream <<
" <RUN_NUMBER>1</RUN_NUMBER>" << std::endl ;
198 *outstream <<
" <LOCATION>CERN P5</LOCATION>" << std::endl ;
199 *outstream <<
" </RUN>" << std::endl ;
200 *outstream <<
" </HEADER>" << std::endl ;
201 *outstream <<
"" << std::endl ;
202 *outstream <<
" <DATA_SET>" << std::endl ;
203 *outstream <<
"" << std::endl ;
204 *outstream <<
" <VERSION>" << version <<
"</VERSION>" << std::endl ;
205 *outstream <<
" <COMMENT_DESCRIPTION>" <<
getComment() <<
"</COMMENT_DESCRIPTION>" << std::endl ;
206 *outstream <<
" <CREATED_BY_USER>" <<
getAuthor() <<
"</CREATED_BY_USER>" << std::endl ;
207 *outstream <<
"" << std::endl ;
208 *outstream <<
" <PART>" << std::endl ;
209 *outstream <<
" <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl ;
210 *outstream <<
" <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl ;
211 *outstream <<
" </PART>" << std::endl ;
217 std::ofstream *out1stream,
218 std::ofstream *out2stream)
const
220 std::string mthn =
"[PixelMaxVsf::writeXML()]\t\t\t " ;
222 std::map<PixelROCName, unsigned int>::const_iterator irocs =
rocs_.begin();
223 for(; irocs !=
rocs_.end() ; irocs++){
224 *outstream <<
" <DATA>" << std::endl ;
225 *outstream <<
" <ROC_NAME>" << (irocs->first).rocname() <<
"</ROC_NAME>" << std::endl ;
226 *outstream <<
" <MAXVSF>" << irocs->second <<
"</MAXVSF>" << std::endl ;
227 *outstream <<
" </DATA>" << std::endl ;
228 *outstream << std::endl ;
234 std::ofstream *out1stream,
235 std::ofstream *out2stream )
const
237 std::string mthn =
"[PixelMaxVsf::writeXMLTrailer()]\t\t\t " ;
239 *outstream <<
" </DATA_SET>" << std::endl ;
240 *outstream <<
"</ROOT>" << std::endl ;
243 std::cout << __LINE__ <<
"]\t" << mthn <<
"Data written " << std::endl ;
This file contains the base class for "pixel configuration data" management.
void setVsf(PixelROCName roc, unsigned int Vsf)
virtual void writeXMLTrailer(std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
std::string getComment() const
PixelMaxVsf(std::vector< std::vector< std::string > > &tableMat)
std::map< PixelROCName, unsigned int > rocs_
std::string getAuthor() const
bool getVsf(PixelROCName roc, unsigned int &Vsf) const
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
This class specifies the maximum Vsf setting that should be used for each ROC.
virtual void writeXMLHeader(pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
void writeXML(pos::PixelConfigKey key, int version, std::string path) const
void writeASCII(std::string dir="") const