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 }
pos::PixelFECConfigInterface
This class implements..
Definition: PixelFECConfigInterface.h:23
mps_fire.i
i
Definition: mps_fire.py:428
pos::PixelROCMaskBits
This class implements..
Definition: PixelROCMaskBits.h:24
pos::PixelTrimCommon::writeBinary
void writeBinary(std::string filename) const override
Definition: PixelTrimCommon.cc:134
pos::PixelMaskBase
This is the documentation about PixelMaskBase...
Definition: PixelMaskBase.h:36
cuy.col
col
Definition: cuy.py:1009
pos
Definition: PixelAliasList.h:18
pos::PixelMaskBase::getMaskBits
virtual const PixelROCMaskBits & getMaskBits(int ROCId) const =0
PixelROCName.h
This class stores the name and related hardware mappings for a ROC.
cms::cuda::assert
assert(be >=bs)
pos::PixelTrimCommon::generateConfiguration
void generateConfiguration(PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans, const PixelMaskBase &pixelMask) const override
Definition: PixelTrimCommon.cc:113
pos::PixelFECConfigInterface::setMaskAndTrimAll
virtual void setMaskAndTrimAll(const PixelHdwAddress &theROC, const std::vector< unsigned char > &allPixels, const bool buffermode=false)=0
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
pos::PixelNameTranslation::getHdwAddress
const PixelHdwAddress * getHdwAddress(const PixelROCName &aROC) const
Definition: PixelNameTranslation.cc:449
pos::PixelTrimBase
This class implements..
Definition: PixelTrimBase.h:45
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
pos::PixelTrimCommon::trimbits_
std::vector< unsigned int > trimbits_
Definition: PixelTrimCommon.h:54
recoMuon::in
Definition: RecoMuonEnumerators.h:6
pos::PixelROCName
This class implements..
Definition: PixelROCName.h:23
pos::PixelTrimCommon::writeASCII
void writeASCII(std::string filename) const override
Definition: PixelTrimCommon.cc:143
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PixelTrimCommon.h
This class implements..
pos::PixelTrimCommon::PixelTrimCommon
PixelTrimCommon(std::string filename)
Definition: PixelTrimCommon.cc:19
pos::PixelTrimCommon::rocname_
std::vector< PixelROCName > rocname_
Definition: PixelTrimCommon.h:53
pos::PixelROCMaskBits::mask
unsigned int mask(unsigned int col, unsigned int row) const
Definition: PixelROCMaskBits.cc:143
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
pos::PixelNameTranslation
This is the documentation about PixelNameTranslation...
Definition: PixelNameTranslation.h:41