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::PixelTrimAllPixels ( std::string  filename)

Definition at line 88 of file PixelTrimAllPixels.cc.

References EnergyCorrector::c, mps_fire::i, recoMuon::in, pos::PixelROCTrimBits::read(), pos::PixelROCTrimBits::readBinary(), indexGen::s2, AlCaHLTBitMon_QueryRunRegistry::string, tmp, and trimbits_.

88  :
89  PixelTrimBase("","",""){
90 
91  if (filename[filename.size()-1]=='t'){
92 
93  std::ifstream in(filename.c_str());
94 
95  if (!in.good()) throw std::runtime_error("Failed to open file "+filename);
96  // std::cout << "filename =" << filename << std::endl;
97 
98  std::string s1;
99  in >> s1;
100 
101  trimbits_.clear();
102 
103 
104  while (in.good()){
105 
106  std::string s2;
107  in>>s2;
108 
109  // std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read s1:"<<s1<< " s2:" << s2 << std::endl;
110 
111  assert( s1 == "ROC:" );
112 
113  PixelROCName rocid(s2);
114 
115  //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read rocid:"<<rocid<<std::endl;
116 
118 
119  tmp.read(rocid, in);
120 
121  trimbits_.push_back(tmp);
122 
123  in >> s1;
124 
125  }
126 
127  in.close();
128 
129  }
130  else{
131 
132  std::ifstream in(filename.c_str(),std::ios::binary);
133  if (!in.good()) throw std::runtime_error("Failed to open file "+filename);
134 
135  char nchar;
136 
137  in.read(&nchar,1);
138 
139  std::string s1;
140 
141  //wrote these lines of code without ref. needs to be fixed
142  for(int i=0;i< nchar; i++){
143  char c;
144  in >>c;
145  s1.push_back(c);
146  }
147 
148  //std::cout << "READ ROC name:"<<s1<<std::endl;
149 
150  trimbits_.clear();
151 
152 
153  while (!in.eof()){
154 
155  //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read s1:"<<s1<<std::endl;
156 
157  PixelROCName rocid(s1);
158 
159  //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read rocid:"<<rocid<<std::endl;
160 
162 
163  tmp.readBinary(rocid, in);
164 
165  trimbits_.push_back(tmp);
166 
167 
168  in.read(&nchar,1);
169 
170  s1.clear();
171 
172  if (in.eof()) continue;
173 
174  //wrote these lines of code without ref. needs to be fixed
175  for(int i=0;i< nchar; i++){
176  char c;
177  in >>c;
178  s1.push_back(c);
179  }
180 
181 
182  }
183 
184  in.close();
185 
186 
187 
188  }
189 
190  //std::cout << "Read trimbits for "<<trimbits_.size()<<" ROCs"<<std::endl;
191 
192  }
int read(PixelROCName rocid, std::string in)
int readBinary(PixelROCName rocid, std::ifstream &in)
std::vector< PixelROCTrimBits > trimbits_
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
This class implements..
Definition: PixelROCName.h:23
This class implements..
PixelTrimBase(std::string description, std::string creator, std::string date)
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 base64_decode, bits, EnergyCorrector::c, MessageLogger_cfi::cerr, gen::n, alignCSCRings::r, pos::PixelROCTrimBits::read(), AlCaHLTBitMon_QueryRunRegistry::string, tmp, and trimbits_.

25  :
26  PixelTrimBase("","","")
27 {
28  std::string mthn = "]\t[PixelTrimAllPixels::PixelTrimAllPixels()]\t\t " ;
29  std::stringstream currentRocName;
30  std::map<std::string , int > colM;
31  std::vector<std::string > colNames;
44  colNames.push_back("CONFIG_KEY" );
45  colNames.push_back("KEY_TYPE" );
46  colNames.push_back("KEY_ALIAS" );
47  colNames.push_back("VERSION" );
48  colNames.push_back("KIND_OF_COND");
49  colNames.push_back("ROC_NAME" );
50  colNames.push_back("TRIM_BITS" );
51 
52 
53  for(unsigned int c = 0 ; c < tableMat[0].size() ; c++)
54  {
55  for(unsigned int n=0; n<colNames.size(); n++)
56  {
57  if(tableMat[0][c] == colNames[n])
58  {
59  colM[colNames[n]] = c;
60  break;
61  }
62  }
63  }//end for
64  for(unsigned int n=0; n<colNames.size(); n++)
65  {
66  if(colM.find(colNames[n]) == colM.end())
67  {
68  std::cerr << __LINE__ << mthn << "Couldn't find in the database the column with name " << colNames[n] << std::endl;
69  assert(0);
70  }
71  }
72 
73  //unsigned char *bits ; /// supose to be " unsigned char bits[tableMat[1][colM["TRIM_BLOB"]].size()] ; "
74  //char c[2080];
76  trimbits_.clear() ;
77  for(unsigned int r = 1 ; r < tableMat.size() ; r++) //Goes to every row of the Matrix
78  {
79  PixelROCName rocid( tableMat[r][colM["ROC_NAME"]] );
81  tmp.read(rocid, base64_decode(tableMat[r][colM["TRIM_BITS"]])) ;
82  trimbits_.push_back(tmp);
83  }//end for r
84  //std::cout<<trimbits_.size()<<std::endl;
85 } //end contructor with databasa table
int read(PixelROCName rocid, std::string in)
#define base64_decode(in, inlen, out, outlen)
Definition: base64.h:57
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
std::vector< PixelROCTrimBits > trimbits_
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
This class implements..
Definition: PixelROCName.h:23
This class implements..
PixelTrimBase(std::string description, std::string creator, std::string date)

Member Function Documentation

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

Implements pos::PixelTrimBase.

Definition at line 220 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(), dataset::name, pos::PixelHdwAddress::portaddress(), pos::PixelHdwAddress::rocid(), pos::PixelFECConfigInterface::roctrimload(), tmp, and trimbits_.

222  {
223 
224  for(unsigned int i=0;i<trimbits_.size();i++){
225 
226  std::vector<unsigned char> trimAndMasks(4160);
227 
228  const PixelROCMaskBits& maskbits=pixelMask.getMaskBits(i);
229 
230  for (unsigned int col=0;col<52;col++){
231  for (unsigned int row=0;row<80;row++){
232  unsigned char tmp=trimbits_[i].trim(col,row);
233  if (maskbits.mask(col,row)!=0) tmp|=0x80;
234  trimAndMasks[col*80+row]=tmp;
235  }
236  }
237 
238  // the slow way, one pixel at a time
239  //pixelFEC->setMaskAndTrimAll(*(trans->getHdwAddress(trimbits_[i].name())),trimAndMasks);
240  // the fast way, a full roc in column mode (& block xfer)
241  const PixelHdwAddress* theROC = trans->getHdwAddress(trimbits_[i].name());
242  pixelFEC->roctrimload(theROC->mfec(),
243  theROC->mfecchannel(),
244  theROC->hubaddress(),
245  theROC->portaddress(),
246  theROC->rocid(),
247  trimAndMasks);
248  }
249 }
unsigned int mfec() const
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
unsigned int portaddress() const
virtual const PixelROCMaskBits & getMaskBits(int ROCId) const =0
unsigned int rocid() const
unsigned int mfecchannel() const
virtual int roctrimload(int mfec, int fecchannel, int hubaddress, int portaddress, int rocid, const std::vector< unsigned char > &allPixels)=0
unsigned int hubaddress() const
Store mfec, mfecchannel etc.
std::vector< PixelROCTrimBits > trimbits_
This class implements..
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
unsigned int mask(unsigned int col, unsigned int row) const
col
Definition: cuy.py:1009
PixelROCTrimBits PixelTrimAllPixels::getTrimBits ( int  ROCId) const
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 202 of file PixelTrimAllPixels.cc.

References trimbits_.

Referenced by writeXML().

202  {
203 
204  return trimbits_[ROCId];
205 
206 }
std::vector< PixelROCTrimBits > trimbits_
PixelROCTrimBits * PixelTrimAllPixels::getTrimBits ( PixelROCName  name)
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 208 of file PixelTrimAllPixels.cc.

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

208  {
209 
210  for(unsigned int i=0;i<trimbits_.size();i++){
211  if (trimbits_[i].name()==name) return &(trimbits_[i]);
212  }
213 
214  return nullptr;
215 
216 }
std::vector< PixelROCTrimBits > trimbits_
void PixelTrimAllPixels::writeASCII ( std::string  filename) const
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 264 of file PixelTrimAllPixels.cc.

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

264  {
265 
266  if (dir!="") dir+="/";
267  PixelModuleName module(trimbits_[0].name().rocname());
268  std::string filename=dir+"ROC_Trims_module_"+module.modulename()+".dat";
269 
270 
271  std::ofstream out(filename.c_str());
272 
273  for(unsigned int i=0;i<trimbits_.size();i++){
274  trimbits_[i].writeASCII(out);
275  }
276 
277 
278 }
std::vector< PixelROCTrimBits > trimbits_
This class implements..
dbl *** dir
Definition: mlp_gen.cc:35
Definition: vlib.h:208
void PixelTrimAllPixels::writeBinary ( std::string  filename) const
overridevirtual

Implements pos::PixelTrimBase.

Definition at line 251 of file PixelTrimAllPixels.cc.

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

251  {
252 
253 
254  std::ofstream out(filename.c_str(),std::ios::binary);
255 
256  for(unsigned int i=0;i<trimbits_.size();i++){
257  trimbits_[i].writeBinary(out);
258  }
259 
260 
261 }
std::vector< PixelROCTrimBits > trimbits_
void pos::PixelTrimAllPixels::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const
inlineoverridevirtual
void PixelTrimAllPixels::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 326 of file PixelTrimAllPixels.cc.

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

329 {
330  std::string mthn = "[PixelTrimAllPixels::writeXML()]\t\t\t " ;
331 
332  for(unsigned int i=0;i<trimbits_.size();i++){
333  trimbits_[i].writeXML(outstream);
334  }
335 }
std::vector< PixelROCTrimBits > trimbits_
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 280 of file PixelTrimAllPixels.cc.

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

Referenced by writeXML().

286 {
287  std::string mthn = "[PixelTrimAllPixels::writeXMLHeader()]\t\t\t " ;
288  std::stringstream maskFullPath ;
289 
290  maskFullPath << path << "/Pixel_RocTrims_" << PixelTimeFormatter::getmSecTime() << ".xml";
291  std::cout << mthn << "Writing to: " << maskFullPath.str() << std::endl ;
292 
293  outstream->open(maskFullPath.str().c_str()) ;
294 
295  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl ;
296  *outstream << "<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl ;
297  *outstream << "" << std::endl ;
298  *outstream << " <HEADER>" << std::endl ;
299  *outstream << " <TYPE>" << std::endl ;
300  *outstream << " <EXTENSION_TABLE_NAME>ROC_TRIMS</EXTENSION_TABLE_NAME>" << std::endl ;
301  *outstream << " <NAME>ROC Trim Bits</NAME>" << std::endl ;
302  *outstream << " </TYPE>" << std::endl ;
303  *outstream << " <RUN>" << std::endl ;
304  *outstream << " <RUN_TYPE>ROC Trim Bits</RUN_TYPE>" << std::endl ;
305  *outstream << " <RUN_NUMBER>1</RUN_NUMBER>" << std::endl ;
306  *outstream << " <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl ;
307  *outstream << " <LOCATION>CERN P5</LOCATION>" << std::endl ;
308  *outstream << " </RUN>" << std::endl ;
309  *outstream << " </HEADER>" << std::endl ;
310  *outstream << "" << std::endl ;
311  *outstream << " <DATA_SET>" << std::endl ;
312  *outstream << "" << std::endl ;
313  *outstream << " <VERSION>" << version << "</VERSION>" << std::endl ;
314  *outstream << " <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>" << std::endl ;
315  *outstream << " <CREATED_BY_USER>" << getAuthor() << "</CREATED_BY_USER>" << std::endl ;
316  *outstream << "" << std::endl ;
317  *outstream << " <PART>" << std::endl ;
318  *outstream << " <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl ;
319  *outstream << " <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl ;
320  *outstream << " </PART>" << std::endl ;
321  *outstream << "" << std::endl ;
322 
323 }
static std::string getmSecTime(void)
static std::string getTime(void)
std::string getComment() const
std::string getAuthor() const
void PixelTrimAllPixels::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = nullptr,
std::ofstream *  out2 = nullptr 
) const
overridevirtual

Reimplemented from pos::PixelConfigBase.

Definition at line 338 of file PixelTrimAllPixels.cc.

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

Referenced by writeXML().

341 {
342  std::string mthn = "[PixelTrimAllPixels::writeXMLTrailer()]\t\t\t " ;
343 
344  *outstream << " </DATA_SET>" << std::endl ;
345  *outstream << "</ROOT>" << std::endl ;
346 
347  outstream->close() ;
348  std::cout << mthn << "Data written " << std::endl ;
349 
350 }

Member Data Documentation

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

Definition at line 71 of file PixelTrimAllPixels.h.

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