CMS 3D CMS Logo

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

#include <PixelTrimAllPixels.h>

Inheritance diagram for pos::PixelTrimAllPixels:
pos::PixelTrimBase pos::PixelConfigBase

Public Member Functions

void generateConfiguration (PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans, const PixelMaskBase &pixelMask) const override
 
PixelROCTrimBits getTrimBits (int ROCId) const override
 
PixelROCTrimBitsgetTrimBits (PixelROCName name) override
 
 PixelTrimAllPixels (std::string filename)
 
 PixelTrimAllPixels (std::vector< std::vector< std::string > > &tableMat)
 
void writeASCII (std::string filename) 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::PixelTrimBase
 PixelTrimBase (std::string description, std::string creator, std::string date)
 
void setOverride (PixelTrimOverrideBase *trimOverride)
 
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
 
 ~PixelTrimBase () 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< std::string > rocname_
 
std::vector< PixelROCTrimBitstrimbits_
 

Detailed Description

Definition at line 31 of file PixelTrimAllPixels.h.

Constructor & Destructor Documentation

◆ PixelTrimAllPixels() [1/2]

PixelTrimAllPixels::PixelTrimAllPixels ( std::string  filename)

Definition at line 80 of file PixelTrimAllPixels.cc.

References cms::cuda::assert(), DummyCfis::c, corrVsCorr::filename, mps_fire::i, recoMuon::in, AlCaHLTBitMon_QueryRunRegistry::string, createJobs::tmp, and trimbits_.

80  : PixelTrimBase("", "", "") {
81  if (filename[filename.size() - 1] == 't') {
82  std::ifstream in(filename.c_str());
83 
84  if (!in.good())
85  throw std::runtime_error("Failed to open file " + filename);
86  // std::cout << "filename =" << filename << std::endl;
87 
88  std::string s1;
89  in >> s1;
90 
91  trimbits_.clear();
92 
93  while (in.good()) {
94  std::string s2;
95  in >> s2;
96 
97  // std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read s1:"<<s1<< " s2:" << s2 << std::endl;
98 
99  assert(s1 == "ROC:");
100 
101  PixelROCName rocid(s2);
102 
103  //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read rocid:"<<rocid<<std::endl;
104 
106 
107  tmp.read(rocid, in);
108 
109  trimbits_.push_back(tmp);
110 
111  in >> s1;
112  }
113 
114  in.close();
115 
116  } else {
117  std::ifstream in(filename.c_str(), std::ios::binary);
118  if (!in.good())
119  throw std::runtime_error("Failed to open file " + filename);
120 
121  char nchar;
122 
123  in.read(&nchar, 1);
124 
125  std::string s1;
126 
127  //wrote these lines of code without ref. needs to be fixed
128  for (int i = 0; i < nchar; i++) {
129  char c;
130  in >> c;
131  s1.push_back(c);
132  }
133 
134  //std::cout << "READ ROC name:"<<s1<<std::endl;
135 
136  trimbits_.clear();
137 
138  while (!in.eof()) {
139  //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read s1:"<<s1<<std::endl;
140 
141  PixelROCName rocid(s1);
142 
143  //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read rocid:"<<rocid<<std::endl;
144 
146 
147  tmp.readBinary(rocid, in);
148 
149  trimbits_.push_back(tmp);
150 
151  in.read(&nchar, 1);
152 
153  s1.clear();
154 
155  if (in.eof())
156  continue;
157 
158  //wrote these lines of code without ref. needs to be fixed
159  for (int i = 0; i < nchar; i++) {
160  char c;
161  in >> c;
162  s1.push_back(c);
163  }
164  }
165 
166  in.close();
167  }
168 
169  //std::cout << "Read trimbits for "<<trimbits_.size()<<" ROCs"<<std::endl;
170 }
assert(be >=bs)
std::vector< PixelROCTrimBits > trimbits_
This class implements..
Definition: PixelROCName.h:23
This class implements..
PixelTrimBase(std::string description, std::string creator, std::string date)
tmp
align.sh
Definition: createJobs.py:716

◆ PixelTrimAllPixels() [2/2]

PixelTrimAllPixels::PixelTrimAllPixels ( std::vector< std::vector< std::string > > &  tableMat)

EXTENSION_TABLE_NAME: ROC_TRIMS (VIEW: CONF_KEY_ROC_TRIMS_V)

CONFIG_KEY NOT NULL VARCHAR2(80) KEY_TYPE NOT NULL VARCHAR2(80) KEY_ALIAS NOT NULL VARCHAR2(80) VERSION VARCHAR2(40) KIND_OF_COND NOT NULL VARCHAR2(40) ROC_NAME NOT NULL VARCHAR2(200) TRIM_BITS NOT NULL VARCHAR2(4000)

Definition at line 25 of file PixelTrimAllPixels.cc.

References cms::cuda::assert(), base64_decode, ALPAKA_ACCELERATOR_NAMESPACE::pixelClustering::pixelStatus::bits, DummyCfis::c, DMR_cfg::cerr, create_idmaps::n, AlCaHLTBitMon_QueryRunRegistry::string, createJobs::tmp, and trimbits_.

25  : PixelTrimBase("", "", "") {
26  std::string mthn = "]\t[PixelTrimAllPixels::PixelTrimAllPixels()]\t\t ";
27  std::stringstream currentRocName;
28  std::map<std::string, int> colM;
29  std::vector<std::string> colNames;
42  colNames.push_back("CONFIG_KEY");
43  colNames.push_back("KEY_TYPE");
44  colNames.push_back("KEY_ALIAS");
45  colNames.push_back("VERSION");
46  colNames.push_back("KIND_OF_COND");
47  colNames.push_back("ROC_NAME");
48  colNames.push_back("TRIM_BITS");
49 
50  for (unsigned int c = 0; c < tableMat[0].size(); c++) {
51  for (unsigned int n = 0; n < colNames.size(); n++) {
52  if (tableMat[0][c] == colNames[n]) {
53  colM[colNames[n]] = c;
54  break;
55  }
56  }
57  } //end for
58  for (unsigned int n = 0; n < colNames.size(); n++) {
59  if (colM.find(colNames[n]) == colM.end()) {
60  std::cerr << __LINE__ << mthn << "Couldn't find in the database the column with name " << colNames[n]
61  << std::endl;
62  assert(0);
63  }
64  }
65 
66  //unsigned char *bits ; /// supose to be " unsigned char bits[tableMat[1][colM["TRIM_BLOB"]].size()] ; "
67  //char c[2080];
69  trimbits_.clear();
70  for (unsigned int r = 1; r < tableMat.size(); r++) //Goes to every row of the Matrix
71  {
72  PixelROCName rocid(tableMat[r][colM["ROC_NAME"]]);
74  tmp.read(rocid, base64_decode(tableMat[r][colM["TRIM_BITS"]]));
75  trimbits_.push_back(tmp);
76  } //end for r
77  //std::cout<<trimbits_.size()<<std::endl;
78 } //end contructor with databasa table
#define base64_decode(in, inlen, out, outlen)
Definition: base64.h:52
assert(be >=bs)
std::vector< PixelROCTrimBits > trimbits_
This class implements..
Definition: PixelROCName.h:23
This class implements..
PixelTrimBase(std::string description, std::string creator, std::string date)
tmp
align.sh
Definition: createJobs.py:716

Member Function Documentation

◆ generateConfiguration()

void PixelTrimAllPixels::generateConfiguration ( PixelFECConfigInterface pixelFEC,
PixelNameTranslation trans,
const PixelMaskBase pixelMask 
) const
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 190 of file PixelTrimAllPixels.cc.

References cuy::col, pos::PixelNameTranslation::getHdwAddress(), pos::PixelMaskBase::getMaskBits(), pos::PixelHdwAddress::hubaddress(), mps_fire::i, pos::PixelROCMaskBits::mask(), pos::PixelHdwAddress::mfec(), pos::PixelHdwAddress::mfecchannel(), mergeVDriftHistosByStation::name, pos::PixelHdwAddress::portaddress(), pos::PixelHdwAddress::rocid(), pos::PixelFECConfigInterface::roctrimload(), createJobs::tmp, and trimbits_.

192  {
193  for (unsigned int i = 0; i < trimbits_.size(); i++) {
194  std::vector<unsigned char> trimAndMasks(4160);
195 
196  const PixelROCMaskBits &maskbits = pixelMask.getMaskBits(i);
197 
198  for (unsigned int col = 0; col < 52; col++) {
199  for (unsigned int row = 0; row < 80; row++) {
200  unsigned char tmp = trimbits_[i].trim(col, row);
201  if (maskbits.mask(col, row) != 0)
202  tmp |= 0x80;
203  trimAndMasks[col * 80 + row] = tmp;
204  }
205  }
206 
207  // the slow way, one pixel at a time
208  //pixelFEC->setMaskAndTrimAll(*(trans->getHdwAddress(trimbits_[i].name())),trimAndMasks);
209  // the fast way, a full roc in column mode (& block xfer)
210  const PixelHdwAddress *theROC = trans->getHdwAddress(trimbits_[i].name());
211  pixelFEC->roctrimload(theROC->mfec(),
212  theROC->mfecchannel(),
213  theROC->hubaddress(),
214  theROC->portaddress(),
215  theROC->rocid(),
216  trimAndMasks);
217  }
218 }
unsigned int mfec() const
unsigned int portaddress() const
virtual int roctrimload(int mfec, int fecchannel, int hubaddress, int portaddress, int rocid, const std::vector< unsigned char > &allPixels)=0
virtual const PixelROCMaskBits & getMaskBits(int ROCId) const =0
Store mfec, mfecchannel etc.
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
unsigned int mfecchannel() const
std::vector< PixelROCTrimBits > trimbits_
unsigned int rocid() const
This class implements..
col
Definition: cuy.py:1009
tmp
align.sh
Definition: createJobs.py:716
unsigned int hubaddress() const
unsigned int mask(unsigned int col, unsigned int row) const

◆ getTrimBits() [1/2]

PixelROCTrimBits PixelTrimAllPixels::getTrimBits ( int  ROCId) const
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 179 of file PixelTrimAllPixels.cc.

References trimbits_.

179 { return trimbits_[ROCId]; }
std::vector< PixelROCTrimBits > trimbits_

◆ getTrimBits() [2/2]

PixelROCTrimBits * PixelTrimAllPixels::getTrimBits ( PixelROCName  name)
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 181 of file PixelTrimAllPixels.cc.

References mps_fire::i, mergeVDriftHistosByStation::name, and trimbits_.

181  {
182  for (unsigned int i = 0; i < trimbits_.size(); i++) {
183  if (trimbits_[i].name() == name)
184  return &(trimbits_[i]);
185  }
186 
187  return nullptr;
188 }
std::vector< PixelROCTrimBits > trimbits_

◆ writeASCII()

void PixelTrimAllPixels::writeASCII ( std::string  filename) const
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 228 of file PixelTrimAllPixels.cc.

References DeadROC_duringRun::dir, corrVsCorr::filename, mps_fire::i, callgraph::module, mergeVDriftHistosByStation::name, MillePedeFileConverter_cfg::out, AlCaHLTBitMon_QueryRunRegistry::string, and trimbits_.

228  {
229  if (!dir.empty())
230  dir += "/";
231  PixelModuleName module(trimbits_[0].name().rocname());
232  std::string filename = dir + "ROC_Trims_module_" + module.modulename() + ".dat";
233 
234  std::ofstream out(filename.c_str());
235 
236  for (unsigned int i = 0; i < trimbits_.size(); i++) {
237  trimbits_[i].writeASCII(out);
238  }
239 }
std::vector< PixelROCTrimBits > trimbits_
This class implements..

◆ writeBinary()

void PixelTrimAllPixels::writeBinary ( std::string  filename) const
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 220 of file PixelTrimAllPixels.cc.

References corrVsCorr::filename, mps_fire::i, MillePedeFileConverter_cfg::out, and trimbits_.

220  {
221  std::ofstream out(filename.c_str(), std::ios::binary);
222 
223  for (unsigned int i = 0; i < trimbits_.size(); i++) {
224  trimbits_[i].writeBinary(out);
225  }
226 }
std::vector< PixelROCTrimBits > trimbits_

◆ writeXML() [1/2]

void pos::PixelTrimAllPixels::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const
inlineoverridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 46 of file PixelTrimAllPixels.h.

46 { ; }

◆ writeXML() [2/2]

void PixelTrimAllPixels::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 285 of file PixelTrimAllPixels.cc.

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

287  {
288  std::string mthn = "[PixelTrimAllPixels::writeXML()]\t\t\t ";
289 
290  for (unsigned int i = 0; i < trimbits_.size(); i++) {
291  trimbits_[i].writeXML(outstream);
292  }
293 }
std::vector< PixelROCTrimBits > trimbits_

◆ writeXMLHeader()

void PixelTrimAllPixels::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 241 of file PixelTrimAllPixels.cc.

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

246  {
247  std::string mthn = "[PixelTrimAllPixels::writeXMLHeader()]\t\t\t ";
248  std::stringstream maskFullPath;
249 
250  maskFullPath << path << "/Pixel_RocTrims_" << PixelTimeFormatter::getmSecTime() << ".xml";
251  std::cout << mthn << "Writing to: " << maskFullPath.str() << std::endl;
252 
253  outstream->open(maskFullPath.str().c_str());
254 
255  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
256  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
257  *outstream << "" << std::endl;
258  *outstream << " <HEADER>" << std::endl;
259  *outstream << " <TYPE>" << std::endl;
260  *outstream << " <EXTENSION_TABLE_NAME>ROC_TRIMS</EXTENSION_TABLE_NAME>" << std::endl;
261  *outstream << " <NAME>ROC Trim Bits</NAME>" << std::endl;
262  *outstream << " </TYPE>" << std::endl;
263  *outstream << " <RUN>" << std::endl;
264  *outstream << " <RUN_TYPE>ROC Trim Bits</RUN_TYPE>" << std::endl;
265  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
266  *outstream << " <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl;
267  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl;
268  *outstream << " </RUN>" << std::endl;
269  *outstream << " </HEADER>" << std::endl;
270  *outstream << "" << std::endl;
271  *outstream << " <DATA_SET>" << std::endl;
272  *outstream << "" << std::endl;
273  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl;
274  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl;
275  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl;
276  *outstream << "" << std::endl;
277  *outstream << " <PART>" << std::endl;
278  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
279  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
280  *outstream << " </PART>" << std::endl;
281  *outstream << "" << std::endl;
282 }
std::string getComment() const
static std::string getmSecTime(void)
static std::string getTime(void)
std::string getAuthor() const

◆ writeXMLTrailer()

void PixelTrimAllPixels::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 296 of file PixelTrimAllPixels.cc.

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

298  {
299  std::string mthn = "[PixelTrimAllPixels::writeXMLTrailer()]\t\t\t ";
300 
301  *outstream << " </DATA_SET>" << std::endl;
302  *outstream << "</ROOT>" << std::endl;
303 
304  outstream->close();
305  std::cout << mthn << "Data written " << std::endl;
306 }

Member Data Documentation

◆ rocname_

std::vector<std::string> pos::PixelTrimAllPixels::rocname_
private

Definition at line 63 of file PixelTrimAllPixels.h.

◆ trimbits_

std::vector<PixelROCTrimBits> pos::PixelTrimAllPixels::trimbits_
private