File indexing completed on 2024-04-06 11:58:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <iostream>
0013 #include <ios>
0014 #include "CalibFormats/SiPixelObjects/interface/PixelTrimCommon.h"
0015 #include "CalibFormats/SiPixelObjects/interface/PixelROCName.h"
0016
0017 using namespace pos;
0018
0019 PixelTrimCommon::PixelTrimCommon(std::string filename) : PixelTrimBase("", "", "") {
0020 if (filename[filename.size() - 1] == 't') {
0021 std::ifstream in(filename.c_str());
0022
0023 std::string s1;
0024 in >> s1;
0025
0026 trimbits_.clear();
0027
0028 while (!in.eof()) {
0029
0030
0031 PixelROCName rocid(in);
0032
0033
0034
0035 unsigned int trimbits;
0036
0037 in >> trimbits;
0038
0039 trimbits_.push_back(trimbits);
0040
0041 in >> s1;
0042 }
0043
0044 in.close();
0045
0046 } else {
0047 std::ifstream in(filename.c_str(), std::ios::binary);
0048
0049 char nchar;
0050
0051 in.read(&nchar, 1);
0052
0053 std::string s1;
0054
0055
0056 for (int i = 0; i < nchar; i++) {
0057 char c;
0058 in >> c;
0059 s1.push_back(c);
0060 }
0061
0062
0063
0064 trimbits_.clear();
0065
0066 while (!in.eof()) {
0067
0068
0069 PixelROCName rocid(s1);
0070
0071
0072
0073 unsigned int trimbits;
0074
0075 in >> trimbits;
0076
0077 trimbits_.push_back(trimbits);
0078
0079 in.read(&nchar, 1);
0080
0081 s1.clear();
0082
0083 if (in.eof())
0084 continue;
0085
0086
0087 for (int i = 0; i < nchar; i++) {
0088 char c;
0089 in >> c;
0090 s1.push_back(c);
0091 }
0092 }
0093
0094 in.close();
0095 }
0096
0097
0098 }
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 void PixelTrimCommon::generateConfiguration(PixelFECConfigInterface* pixelFEC,
0114 PixelNameTranslation* trans,
0115 const PixelMaskBase& pixelMask) const {
0116 for (unsigned int i = 0; i < trimbits_.size(); i++) {
0117 std::vector<unsigned char> trimAndMasks(4160);
0118
0119 const PixelROCMaskBits& maskbits = pixelMask.getMaskBits(i);
0120
0121 for (unsigned int col = 0; col < 52; col++) {
0122 for (unsigned int row = 0; row < 80; row++) {
0123 unsigned char tmp = trimbits_[i];
0124 if (maskbits.mask(col, row) != 0)
0125 tmp |= 0x80;
0126 trimAndMasks[col * 80 + row] = tmp;
0127 }
0128 }
0129
0130 pixelFEC->setMaskAndTrimAll(*(trans->getHdwAddress(rocname_[i])), trimAndMasks);
0131 }
0132 }
0133
0134 void PixelTrimCommon::writeBinary(std::string filename) const {
0135 std::ofstream out(filename.c_str(), std::ios::binary);
0136
0137 for (unsigned int i = 0; i < trimbits_.size(); i++) {
0138 assert(0);
0139
0140 }
0141 }
0142
0143 void PixelTrimCommon::writeASCII(std::string filename) const {
0144 std::ofstream out(filename.c_str());
0145
0146 for (unsigned int i = 0; i < trimbits_.size(); i++) {
0147 assert(0);
0148
0149 }
0150 }