CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  PixelTrimBase("","",""){
21 
22  if (filename[filename.size()-1]=='t'){
23 
24  std::ifstream in(filename.c_str());
25 
26  std::string s1;
27  in >> s1;
28 
29  trimbits_.clear();
30 
31 
32  while (!in.eof()){
33 
34  //std::cout << "PixelTrimCommon::PixelTrimCommon read s1:"<<s1<<std::endl;
35 
36  PixelROCName rocid(in);
37 
38  //std::cout << "PixelTrimCommon::PixelTrimCommon read rocid:"<<rocid<<std::endl;
39 
40  unsigned int trimbits;
41 
42  in >> trimbits;
43 
44  trimbits_.push_back(trimbits);
45 
46  in >> s1;
47 
48  }
49 
50  in.close();
51 
52  }
53  else{
54 
55  std::ifstream in(filename.c_str(),std::ios::binary);
56 
57  char nchar;
58 
59  in.read(&nchar,1);
60 
61  std::string s1;
62 
63  //wrote these lines of code without ref. needs to be fixed
64  for(int i=0;i< nchar; i++){
65  char c;
66  in >>c;
67  s1.push_back(c);
68  }
69 
70  //std::cout << "READ ROC name:"<<s1<<std::endl;
71 
72  trimbits_.clear();
73 
74 
75  while (!in.eof()){
76 
77  //std::cout << "PixelTrimCommon::PixelTrimCommon read s1:"<<s1<<std::endl;
78 
79  PixelROCName rocid(s1);
80 
81  //std::cout << "PixelTrimCommon::PixelTrimCommon read rocid:"<<rocid<<std::endl;
82 
83  unsigned int trimbits;
84 
85  in >> trimbits;
86 
87  trimbits_.push_back(trimbits);
88 
89 
90  in.read(&nchar,1);
91 
92  s1.clear();
93 
94  if (in.eof()) continue;
95 
96  //wrote these lines of code without ref. needs to be fixed
97  for(int i=0;i< nchar; i++){
98  char c;
99  in >>c;
100  s1.push_back(c);
101  }
102 
103 
104  }
105 
106  in.close();
107 
108 
109 
110  }
111 
112  //std::cout << "Read trimbits for "<<trimbits_.size()<<" ROCs"<<std::endl;
113 
114 }
115 
116 
117 //std::string PixelTrimCommon::getConfigCommand(PixelMaskBase& pixelMask){
118 //
119 // std::string s;
120 // return s;
121 //
122 //}
123 
124 //PixelROCTrimBits PixelTrimCommon::getTrimBits(int ROCId) const {
125 //
126 // return trimbits_[ROCId];
127 //
128 //}
129 
130 
132  PixelNameTranslation* trans,
133  const PixelMaskBase& pixelMask) const{
134 
135  for(unsigned int i=0;i<trimbits_.size();i++){
136 
137  std::vector<unsigned char> trimAndMasks(4160);
138 
139  const PixelROCMaskBits& maskbits=pixelMask.getMaskBits(i);
140 
141  for (unsigned int col=0;col<52;col++){
142  for (unsigned int row=0;row<80;row++){
143  unsigned char tmp=trimbits_[i];
144  if (maskbits.mask(col,row)!=0) tmp|=0x80;
145  trimAndMasks[col*80+row]=tmp;
146  }
147  }
148 
149  pixelFEC->setMaskAndTrimAll(*(trans->getHdwAddress(rocname_[i])),trimAndMasks);
150 
151  }
152 }
153 
154 void PixelTrimCommon::writeBinary(std::string filename) const{
155 
156 
157  std::ofstream out(filename.c_str(),std::ios::binary);
158 
159  for(unsigned int i=0;i<trimbits_.size();i++){
160  assert(0);
161  //trimbits_[i].writeBinary(out);
162  }
163 
164 
165 }
166 
167 
168 void PixelTrimCommon::writeASCII(std::string filename) const{
169 
170  std::ofstream out(filename.c_str());
171 
172  for(unsigned int i=0;i<trimbits_.size();i++){
173  assert(0);
174  //trimbits_[i].writeASCII(out);
175  }
176 
177 
178 }
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
std::vector< unsigned int > trimbits_
int i
Definition: DBlmapReader.cc:9
virtual void setMaskAndTrimAll(const PixelHdwAddress &theROC, const std::vector< unsigned char > &allPixels, const bool buffermode=false)=0
void writeBinary(std::string filename) const
PixelTrimCommon(std::string filename)
std::vector< PixelROCName > rocname_
void writeASCII(std::string filename) const
This class implements..
virtual const PixelROCMaskBits & getMaskBits(int ROCId) const =0
This is the documentation about PixelMaskBase...
Definition: PixelMaskBase.h:36
tuple out
Definition: dbtoconf.py:99
void generateConfiguration(PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans, const PixelMaskBase &pixelMask) const
This class implements..
This is the documentation about PixelNameTranslation...
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
This class implements..
Definition: PixelROCName.h:23
unsigned int mask(unsigned int col, unsigned int row) const
tuple filename
Definition: lut2db_cfg.py:20
This class implements..
Definition: PixelTrimBase.h:46
This class stores the name and related hardware mappings for a ROC.