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.

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 }

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

◆ 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.

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];
68  std::string bits;
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

References cms::cuda::assert(), base64_decode, c, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, dqmiodumpmetadata::n, alignCSCRings::r, AlCaHLTBitMon_QueryRunRegistry::string, createJobs::tmp, and trimbits_.

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.

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 }

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

◆ getTrimBits() [1/2]

PixelROCTrimBits PixelTrimAllPixels::getTrimBits ( int  ROCId) const
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 179 of file PixelTrimAllPixels.cc.

179 { return trimbits_[ROCId]; }

References trimbits_.

◆ getTrimBits() [2/2]

PixelROCTrimBits * PixelTrimAllPixels::getTrimBits ( PixelROCName  name)
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 181 of file PixelTrimAllPixels.cc.

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 }

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

◆ writeASCII()

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

Implements pos::PixelTrimBase.

Definition at line 228 of file PixelTrimAllPixels.cc.

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 }

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

◆ writeBinary()

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

Implements pos::PixelTrimBase.

Definition at line 220 of file PixelTrimAllPixels.cc.

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 }

References corrVsCorr::filename, mps_fire::i, MillePedeFileConverter_cfg::out, and 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.

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 }

References mps_fire::i, AlCaHLTBitMon_QueryRunRegistry::string, and 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.

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 }

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

◆ 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.

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 }

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

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
mps_fire.i
i
Definition: mps_fire.py:428
pos::PixelROCMaskBits
This class implements..
Definition: PixelROCMaskBits.h:24
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
cuy.col
col
Definition: cuy.py:1009
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos::PixelMaskBase::getMaskBits
virtual const PixelROCMaskBits & getMaskBits(int ROCId) const =0
pos::PixelModuleName
This class implements..
Definition: PixelModuleName.h:26
cms::cuda::assert
assert(be >=bs)
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
pos::PixelHdwAddress::hubaddress
unsigned int hubaddress() const
Definition: PixelHdwAddress.h:40
pos::PixelHdwAddress::mfecchannel
unsigned int mfecchannel() const
Definition: PixelHdwAddress.h:39
pos::PixelROCTrimBits
This class implements..
Definition: PixelROCTrimBits.h:23
pos::PixelNameTranslation::getHdwAddress
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
Definition: PixelNameTranslation.cc:449
pos::PixelTimeFormatter::getTime
static std::string getTime(void)
Definition: PixelTimeFormatter.h:60
pos::PixelHdwAddress::rocid
unsigned int rocid() const
Definition: PixelHdwAddress.h:42
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::PixelHdwAddress::portaddress
unsigned int portaddress() const
Definition: PixelHdwAddress.h:41
pos::PixelConfigBase::getComment
std::string getComment() const
Definition: PixelConfigBase.h:71
recoMuon::in
Definition: RecoMuonEnumerators.h:6
pos::PixelHdwAddress
Store mfec, mfecchannel etc.
Definition: PixelHdwAddress.h:23
pos::PixelROCName
This class implements..
Definition: PixelROCName.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
alignCSCRings.r
r
Definition: alignCSCRings.py:93
callgraph.module
module
Definition: callgraph.py:61
base64_decode
#define base64_decode(in, inlen, out, outlen)
Definition: base64.h:52
pos::PixelTrimBase::PixelTrimBase
PixelTrimBase(std::string description, std::string creator, std::string date)
Definition: PixelTrimBase.cc:20
pos::PixelROCMaskBits::mask
unsigned int mask(unsigned int col, unsigned int row) const
Definition: PixelROCMaskBits.cc:143
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
pos::PixelTrimAllPixels::trimbits_
std::vector< PixelROCTrimBits > trimbits_
Definition: PixelTrimAllPixels.h:64
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
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
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
pos::PixelHdwAddress::mfec
unsigned int mfec() const
Definition: PixelHdwAddress.h:38
pos::PixelFECConfigInterface::roctrimload
virtual int roctrimload(int mfec, int fecchannel, int hubaddress, int portaddress, int rocid, const std::vector< unsigned char > &allPixels)=0