CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pos::PixelMaskAllPixels Class Reference

This is the documentation about PixelMaskAllPixels... More...

#include <PixelMaskAllPixels.h>

Inheritance diagram for pos::PixelMaskAllPixels:
pos::PixelMaskBase pos::PixelConfigBase

Public Member Functions

void addROCMaskBits (const PixelROCMaskBits &)
 
const PixelROCMaskBitsgetMaskBits (int ROCId) const override
 
PixelROCMaskBitsgetMaskBits (PixelROCName name) override
 
 PixelMaskAllPixels (std::string filename)
 
 PixelMaskAllPixels (std::vector< std::vector< std::string > > &tableMat)
 
 PixelMaskAllPixels ()
 
void writeASCII (std::string dir) const override
 
void writeBinary (std::string filename) const override
 
void writeXML (pos::PixelConfigKey key, int version, std::string path) const override
 
void writeXML (std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
void writeXMLTrailer (std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
- Public Member Functions inherited from pos::PixelMaskBase
 PixelMaskBase (std::string description, std::string creator, std::string date)
 
void setOverride (PixelMaskOverrideBase *)
 
void writeXML (pos::PixelConfigKey key, int version, std::string path) const override
 
void writeXML (std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
void writeXMLTrailer (std::ofstream *out, std::ofstream *out1=nullptr, std::ofstream *out2=nullptr) const override
 
 ~PixelMaskBase () override
 
- Public Member Functions inherited from pos::PixelConfigBase
std::string creator ()
 
std::string date ()
 
std::string description ()
 
std::string getAuthor () const
 
std::string getComment () const
 
 PixelConfigBase (std::string description, std::string creator, std::string date)
 
void setAuthor (std::string author)
 
void setComment (std::string comment)
 
virtual void writeXML (std::ofstream *out) const
 
virtual void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out) const
 
virtual void writeXMLTrailer (std::ofstream *out) const
 
virtual ~PixelConfigBase ()
 

Private Attributes

std::vector< PixelROCMaskBitsmaskbits_
 

Detailed Description

This is the documentation about PixelMaskAllPixels...

" "

Definition at line 23 of file PixelMaskAllPixels.h.

Constructor & Destructor Documentation

PixelMaskAllPixels::PixelMaskAllPixels ( std::string  filename)

Definition at line 95 of file PixelMaskAllPixels.cc.

References EnergyCorrector::c, gather_cfg::cout, mps_fire::i, recoMuon::in, maskbits_, pos::PixelROCMaskBits::read(), pos::PixelROCMaskBits::readBinary(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and tmp.

95  :
96  PixelMaskBase("","",""){
97 
98  std::string mthn = "[PixelMaskAllPixels::PixelMaskAllPixels()]\t\t " ;
99 
100  if (filename[filename.size()-1]=='t'){
101 
102 
103  std::ifstream in(filename.c_str());
104 
105  if (!in.good()){
106  std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
107  throw std::runtime_error("Failed to open file "+filename);
108  }
109 
111  in >> tag;
112 
113  maskbits_.clear();
114 
115  while (!in.eof()) {
116 
117  PixelROCName rocid(in);
118 
120 
121  tmp.read(rocid,in);
122 
123  maskbits_.push_back(tmp);
124 
125  in >> tag;
126 
127  }
128 
129  in.close();
130 
131  }
132  else{
133 
134  std::ifstream in(filename.c_str(),std::ios::binary);
135 
136  char nchar;
137 
138  in.read(&nchar,1);
139 
140  //in >> nchar;
141 
142  std::string s1;
143 
144  //wrote these lines of code without ref. needs to be fixed
145  for(int i=0;i< nchar; i++){
146  char c;
147  in >>c;
148  s1.push_back(c);
149  }
150 
151  //std::cout << __LINE__ << "]\t" << mthn << "READ ROC name: " << s1 << std::endl;
152 
153  maskbits_.clear();
154 
155 
156  while (!in.eof()){
157 
158  //std::cout << __LINE__ << "]\t" << mthn << "read s1: " << s1 << std::endl;
159 
160  PixelROCName rocid(s1);
161 
162  //std::cout << __LINE__ << "]\t" << mthn << "read rocid: " << rocid << std::endl;
163 
165 
166  tmp.readBinary(rocid, in);
167 
168  maskbits_.push_back(tmp);
169 
170 
171  in.read(&nchar,1);
172 
173  s1.clear();
174 
175  if (in.eof()) continue;
176 
177  //std::cout << __LINE__ << "]\t" << mthn << "Will read: " << (int)nchar << " characters." <<std::endl;
178 
179  //wrote these lines of code without ref. needs to be fixed
180  for(int i=0;i< nchar; i++){
181  char c;
182  in >>c;
183  //std::cout << " " <<c;
184  s1.push_back(c);
185  }
186  //std::cout << std::endl;
187 
188 
189  }
190 
191  in.close();
192 
193 
194 
195  }
196 
197 
198  //std::cout << __LINE__ << "]\t" << mthn << "Read maskbits for " << maskbits_.size() << " ROCs" << std::endl;
199 
200  }
int read(const PixelROCName &rocid, std::string in)
PixelMaskBase(std::string description, std::string creator, std::string date)
std::vector< PixelROCMaskBits > maskbits_
This class implements..
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
This class implements..
Definition: PixelROCName.h:23
int readBinary(const PixelROCName &rocid, std::ifstream &in)
PixelMaskAllPixels::PixelMaskAllPixels ( std::vector< std::vector< std::string > > &  tableMat)

Definition at line 27 of file PixelMaskAllPixels.cc.

References base64_decode, EnergyCorrector::c, MessageLogger_cfi::cerr, cuy::ins, maskbits_, gen::n, alignCSCRings::r, pos::PixelROCMaskBits::read(), AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

27  : PixelMaskBase("","","")
28 {
29  std::string mthn = "[PixelMaskAllPixels::PixelMaskAllPixels()]\t\t " ;
30  //std::cout << __LINE__ << "]\t" << mthn << "Table Size in const: " << tableMat.size() << std::endl;
31 
32  std::vector< std::string > ins = tableMat[0];
33  std::map<std::string , int > colM;
34  std::vector<std::string > colNames;
35 
36 /*
37  EXTENSION_TABLE_NAME: ROC_MASKS (VIEW: CONF_KEY_ROC_MASKS_V)
38 
39  CONFIG_KEY NOT NULL VARCHAR2(80)
40  KEY_TYPE NOT NULL VARCHAR2(80)
41  KEY_ALIAS NOT NULL VARCHAR2(80)
42  VERSION VARCHAR2(40)
43  KIND_OF_COND NOT NULL VARCHAR2(40)
44  ROC_NAME NOT NULL VARCHAR2(200)
45  KILL_MASK NOT NULL VARCHAR2(4000) colNames.push_back("CONFIG_KEY_ID" );
46 */
47  colNames.push_back("CONFIG_KEY" );
48  colNames.push_back("KEY_TYPE" );
49  colNames.push_back("KEY_ALIAS" );
50  colNames.push_back("VERSION" );
51  colNames.push_back("KIND_OF_COND");
52  colNames.push_back("ROC_NAME" );
53  colNames.push_back("KILL_MASK" );
54 
55  for(unsigned int c = 0 ; c < ins.size() ; c++)
56  {
57  for(unsigned int n=0; n<colNames.size(); n++)
58  {
59  if(tableMat[0][c] == colNames[n])
60  {
61  colM[colNames[n]] = c;
62  break;
63  }
64  }
65  }//end for
66  for(unsigned int n=0; n<colNames.size(); n++)
67  {
68  if(colM.find(colNames[n]) == colM.end())
69  {
70  std::cerr << mthn << "Couldn't find in the database the column with name " << colNames[n] << std::endl;
71  assert(0);
72  }
73  }
74  maskbits_.clear() ;
75  for(unsigned int r = 1 ; r < tableMat.size() ; r++){ //Goes to every row of the Matrix
76  std::string currentRocName = tableMat[r][colM["ROC_NAME"]] ;
77  PixelROCName rocid(currentRocName);
79  tmp.read(rocid,base64_decode(tableMat[r][colM["KILL_MASK"]])) ; // decode back from specially base64-encoded data for XML
80  maskbits_.push_back(tmp);
81  } //end for r
82 }
int read(const PixelROCName &rocid, std::string in)
#define base64_decode(in, inlen, out, outlen)
Definition: base64.h:57
ins
Definition: cuy.py:314
PixelMaskBase(std::string description, std::string creator, std::string date)
std::vector< PixelROCMaskBits > maskbits_
This class implements..
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
This class implements..
Definition: PixelROCName.h:23
PixelMaskAllPixels::PixelMaskAllPixels ( )

Definition at line 86 of file PixelMaskAllPixels.cc.

86 :PixelMaskBase("","",""){;}
PixelMaskBase(std::string description, std::string creator, std::string date)

Member Function Documentation

void PixelMaskAllPixels::addROCMaskBits ( const PixelROCMaskBits bits)

Definition at line 89 of file PixelMaskAllPixels.cc.

References maskbits_.

90 {
91  maskbits_.push_back(bits);
92 }
std::vector< PixelROCMaskBits > maskbits_
const PixelROCMaskBits & PixelMaskAllPixels::getMaskBits ( int  ROCId) const
overridevirtual

Implements pos::PixelMaskBase.

Definition at line 203 of file PixelMaskAllPixels.cc.

References maskbits_.

Referenced by writeXML().

203  {
204 
205  return maskbits_[ROCId];
206 
207 }
std::vector< PixelROCMaskBits > maskbits_
PixelROCMaskBits * PixelMaskAllPixels::getMaskBits ( PixelROCName  name)
overridevirtual

Implements pos::PixelMaskBase.

Definition at line 210 of file PixelMaskAllPixels.cc.

References mps_fire::i, maskbits_, and dataset::name.

210  {
211 
212  for(unsigned int i=0;i<maskbits_.size();i++){
213  if (maskbits_[i].name()==name) return &(maskbits_[i]);
214  }
215 
216  return nullptr;
217 
218 }
std::vector< PixelROCMaskBits > maskbits_
void PixelMaskAllPixels::writeASCII ( std::string  dir) const
overridevirtual

Implements pos::PixelMaskBase.

Definition at line 234 of file PixelMaskAllPixels.cc.

References corrVsCorr::filename, mps_fire::i, maskbits_, pos::PixelModuleName::modulename(), dataset::name, MillePedeFileConverter_cfg::out, and AlCaHLTBitMon_QueryRunRegistry::string.

234  {
235 
236  if (dir!="") dir+="/";
237  PixelModuleName module(maskbits_[0].name().rocname());
238  std::string filename=dir+"ROC_Masks_module_"+module.modulename()+".dat";
239 
240  std::ofstream out(filename.c_str());
241 
242  for(unsigned int i=0;i<maskbits_.size();i++){
243  maskbits_[i].writeASCII(out);
244  }
245 
246 
247 }
std::vector< PixelROCMaskBits > maskbits_
This class implements..
dbl *** dir
Definition: mlp_gen.cc:35
Definition: vlib.h:208
void PixelMaskAllPixels::writeBinary ( std::string  filename) const
overridevirtual

Implements pos::PixelMaskBase.

Definition at line 221 of file PixelMaskAllPixels.cc.

References mps_fire::i, maskbits_, and MillePedeFileConverter_cfg::out.

221  {
222 
223 
224  std::ofstream out(filename.c_str(),std::ios::binary);
225 
226  for(unsigned int i=0;i<maskbits_.size();i++){
227  maskbits_[i].writeBinary(out);
228  }
229 
230 
231 }
std::vector< PixelROCMaskBits > maskbits_
void pos::PixelMaskAllPixels::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const
inlineoverridevirtual
void PixelMaskAllPixels::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 295 of file PixelMaskAllPixels.cc.

References mps_fire::i, maskbits_, and AlCaHLTBitMon_QueryRunRegistry::string.

298 {
299  std::string mthn = "[PixelMaskAllPixels::writeXML()]\t\t\t " ;
300 
301  for(unsigned int i=0;i<maskbits_.size();i++){
302  maskbits_[i].writeXML(outstream);
303  }
304 }
std::vector< PixelROCMaskBits > maskbits_
void PixelMaskAllPixels::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 250 of file PixelMaskAllPixels.cc.

References gather_cfg::cout, pos::PixelConfigBase::getAuthor(), pos::PixelConfigBase::getComment(), pos::PixelTimeFormatter::getmSecTime(), pos::PixelTimeFormatter::getTime(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by writeXML().

256 {
257  std::string mthn = "[PixelMaskAllPixels::writeXMLHeader()]\t\t\t " ;
258  std::stringstream maskFullPath ;
259 
260  maskFullPath << path << "/Pixel_RocMasks_" << PixelTimeFormatter::getmSecTime() << ".xml";
261  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << maskFullPath.str() << std::endl ;
262 
263  outstream->open(maskFullPath.str().c_str()) ;
264 
265  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl ;
266  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl ;
267  *outstream << "" << std::endl ;
268  *outstream << " <HEADER>" << std::endl ;
269  *outstream << " <TYPE>" << std::endl ;
270  *outstream << " <EXTENSION_TABLE_NAME>ROC_MASKS</EXTENSION_TABLE_NAME>" << std::endl ;
271  *outstream << " <NAME>ROC Mask Bits</NAME>" << std::endl ;
272  *outstream << " </TYPE>" << std::endl ;
273  *outstream << " <RUN>" << std::endl ;
274  *outstream << " <RUN_TYPE>ROC Mask Bits</RUN_TYPE>" << std::endl ;
275  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl ;
276  *outstream << " <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl ;
277  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl ;
278  *outstream << " </RUN>" << std::endl ;
279  *outstream << " </HEADER>" << std::endl ;
280  *outstream << "" << std::endl ;
281  *outstream << " <DATA_SET>" << std::endl ;
282  *outstream << "" << std::endl ;
283  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl ;
284  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl ;
285  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl ;
286  *outstream << "" << std::endl ;
287  *outstream << " <PART>" << std::endl ;
288  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl ;
289  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl ;
290  *outstream << " </PART>" << std::endl ;
291  *outstream << " " << std::endl ;
292 
293 }
static std::string getmSecTime(void)
static std::string getTime(void)
std::string getComment() const
std::string getAuthor() const
void PixelMaskAllPixels::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 306 of file PixelMaskAllPixels.cc.

References gather_cfg::cout, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by writeXML().

309 {
310  std::string mthn = "[PixelMaskAllPixels::writeXMLTrailer()]\t\t\t " ;
311 
312  *outstream << " " << std::endl ;
313  *outstream << " </DATA_SET>" << std::endl ;
314  *outstream << "</ROOT>" << std::endl ;
315 
316  outstream->close() ;
317  std::cout << __LINE__ << "]\t" << mthn << "Data written " << std::endl ;
318 
319 }

Member Data Documentation

std::vector<PixelROCMaskBits> pos::PixelMaskAllPixels::maskbits_
private