CMS 3D CMS Logo

PixelTrimCommon.cc
Go to the documentation of this file.
1 //
2 // This class provide an implementation for
3 // pixel trim data where all pixels have the
4 // same settings.
5 //
6 //
7 // All applications should just use this
8 // interface and not care about the specific
9 // implementation
10 //
11 
12 #include <iostream>
13 #include <ios>
16 
17 using namespace pos;
18 
20  if (filename[filename.size() - 1] == 't') {
21  std::ifstream in(filename.c_str());
22 
23  std::string s1;
24  in >> s1;
25 
26  trimbits_.clear();
27 
28  while (!in.eof()) {
29  //std::cout << "PixelTrimCommon::PixelTrimCommon read s1:"<<s1<<std::endl;
30 
31  PixelROCName rocid(in);
32 
33  //std::cout << "PixelTrimCommon::PixelTrimCommon read rocid:"<<rocid<<std::endl;
34 
35  unsigned int trimbits;
36 
37  in >> trimbits;
38 
39  trimbits_.push_back(trimbits);
40 
41  in >> s1;
42  }
43 
44  in.close();
45 
46  } else {
47  std::ifstream in(filename.c_str(), std::ios::binary);
48 
49  char nchar;
50 
51  in.read(&nchar, 1);
52 
53  std::string s1;
54 
55  //wrote these lines of code without ref. needs to be fixed
56  for (int i = 0; i < nchar; i++) {
57  char c;
58  in >> c;
59  s1.push_back(c);
60  }
61 
62  //std::cout << "READ ROC name:"<<s1<<std::endl;
63 
64  trimbits_.clear();
65 
66  while (!in.eof()) {
67  //std::cout << "PixelTrimCommon::PixelTrimCommon read s1:"<<s1<<std::endl;
68 
69  PixelROCName rocid(s1);
70 
71  //std::cout << "PixelTrimCommon::PixelTrimCommon read rocid:"<<rocid<<std::endl;
72 
73  unsigned int trimbits;
74 
75  in >> trimbits;
76 
77  trimbits_.push_back(trimbits);
78 
79  in.read(&nchar, 1);
80 
81  s1.clear();
82 
83  if (in.eof())
84  continue;
85 
86  //wrote these lines of code without ref. needs to be fixed
87  for (int i = 0; i < nchar; i++) {
88  char c;
89  in >> c;
90  s1.push_back(c);
91  }
92  }
93 
94  in.close();
95  }
96 
97  //std::cout << "Read trimbits for "<<trimbits_.size()<<" ROCs"<<std::endl;
98 }
99 
100 //std::string PixelTrimCommon::getConfigCommand(PixelMaskBase& pixelMask){
101 //
102 // std::string s;
103 // return s;
104 //
105 //}
106 
107 //PixelROCTrimBits PixelTrimCommon::getTrimBits(int ROCId) const {
108 //
109 // return trimbits_[ROCId];
110 //
111 //}
112 
114  PixelNameTranslation* trans,
115  const PixelMaskBase& pixelMask) const {
116  for (unsigned int i = 0; i < trimbits_.size(); i++) {
117  std::vector<unsigned char> trimAndMasks(4160);
118 
119  const PixelROCMaskBits& maskbits = pixelMask.getMaskBits(i);
120 
121  for (unsigned int col = 0; col < 52; col++) {
122  for (unsigned int row = 0; row < 80; row++) {
123  unsigned char tmp = trimbits_[i];
124  if (maskbits.mask(col, row) != 0)
125  tmp |= 0x80;
126  trimAndMasks[col * 80 + row] = tmp;
127  }
128  }
129 
130  pixelFEC->setMaskAndTrimAll(*(trans->getHdwAddress(rocname_[i])), trimAndMasks);
131  }
132 }
133 
135  std::ofstream out(filename.c_str(), std::ios::binary);
136 
137  for (unsigned int i = 0; i < trimbits_.size(); i++) {
138  assert(0);
139  //trimbits_[i].writeBinary(out);
140  }
141 }
142 
144  std::ofstream out(filename.c_str());
145 
146  for (unsigned int i = 0; i < trimbits_.size(); i++) {
147  assert(0);
148  //trimbits_[i].writeASCII(out);
149  }
150 }
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
std::vector< unsigned int > trimbits_
virtual void setMaskAndTrimAll(const PixelHdwAddress &theROC, const std::vector< unsigned char > &allPixels, const bool buffermode=false)=0
void writeBinary(std::string filename) const override
PixelTrimCommon(std::string filename)
std::vector< PixelROCName > rocname_
virtual const PixelROCMaskBits & getMaskBits(int ROCId) const =0
This class implements..
void generateConfiguration(PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans, const PixelMaskBase &pixelMask) const override
void writeASCII(std::string filename) const override
This is the documentation about PixelMaskBase...
Definition: PixelMaskBase.h:36
This class implements..
This is the documentation about PixelNameTranslation...
This class implements..
Definition: PixelROCName.h:23
unsigned int mask(unsigned int col, unsigned int row) const
col
Definition: cuy.py:1010
This class implements..
Definition: PixelTrimBase.h:45
tmp
align.sh
Definition: createJobs.py:716
This class stores the name and related hardware mappings for a ROC.