12 PixelFEDTestDAC::PixelFEDTestDAC(
std::vector<std::vector<std::string> > &tableMat) {
13 std::string mthn =
"[PixelFEDTestDAC::PixelFEDTestDAC()]\t\t\t ";
14 const unsigned long int UB = 200;
15 const unsigned long int B = 500;
16 const unsigned long int offset = 0;
17 vector<unsigned int> pulseTrain(256), pixelDCol(1), pixelPxl(2), pixelTBMHeader(3), pixelTBMTrailer(3);
18 unsigned int DCol, LorR,
start = 15;
21 unsigned long int npos = std::string::npos;
24 std::map<std::string, int> colM;
25 std::vector<std::string> colNames;
40 colNames.push_back(
"CONFIG_KEY");
41 colNames.push_back(
"KEY_TYPE");
42 colNames.push_back(
"KEY_ALIAS");
43 colNames.push_back(
"VERSION");
44 colNames.push_back(
"KIND_OF_COND");
45 colNames.push_back(
"CALIB_TYPE");
46 colNames.push_back(
"CALIB_OBJ_DATA_FILE");
47 colNames.push_back(
"CALIB_OBJ_DATA_CLOB");
49 for (
unsigned int c = 0;
c < tableMat[0].size();
c++) {
50 for (
unsigned int n = 0;
n < colNames.size();
n++) {
51 if (tableMat[0][
c] == colNames[
n]) {
52 colM[colNames[
n]] =
c;
57 for (
unsigned int n = 0;
n < colNames.size();
n++) {
58 if (colM.find(colNames[
n]) == colM.end()) {
59 std::cerr << __LINE__ <<
"]\t" << mthn <<
"Couldn't find in the database the column with name " << colNames[
n]
65 std::istringstream
fin;
66 fin.str(tableMat[1][colM[
"CALIB_OBJ_DATA_CLOB"]]);
69 for (
unsigned int i = 0;
i < pulseTrain.size(); ++
i) {
77 assert(mode_ ==
"EmulatedPhysics" || mode_ ==
"FEDBaselineWithTestDACs" || mode_ ==
"FEDAddressLevelWithTestDACs");
82 if (
line.find(
"TBMHeader") != npos) {
83 loc1 =
line.find(
'(');
85 cout << __LINE__ <<
"]\t" << mthn <<
"'(' not found after TBMHeader.\n";
88 loc2 =
line.find(
')', loc1 + 1);
90 cout << __LINE__ <<
"]\t" << mthn <<
"')' not found after TBMHeader.\n";
93 int TBMHeader = atoi(
line.substr(loc1 + 1, loc2 - loc1 - 1).c_str());
104 pixelTBMHeader = decimalToBaseX(TBMHeader, 4, 4);
106 pulseTrain[
i] = levelEncoder(pixelTBMHeader[3]);
108 pulseTrain[
i] = levelEncoder(pixelTBMHeader[2]);
110 pulseTrain[
i] = levelEncoder(pixelTBMHeader[1]);
112 pulseTrain[
i] = levelEncoder(pixelTBMHeader[0]);
114 }
else if (
line.find(
"ROCHeader") != std::string::npos) {
115 loc1 =
line.find(
'(');
117 cout << __LINE__ <<
"]\t" << mthn <<
"'(' not found after ROCHeader.\n";
120 loc2 =
line.find(
')', loc1 + 1);
122 cout << __LINE__ <<
"]\t" << mthn <<
"')' not found after ROCHeader.\n";
125 int LastDAC = atoi(
line.substr(loc1 + 1, loc2 - loc1 - 1).c_str());
127 std::cout <<
"--------------" << std::endl;
133 pulseTrain[
i] = levelEncoder(LastDAC);
135 }
else if (
line.find(
"PixelHit") != std::string::npos) {
136 loc1 =
line.find(
'(');
138 cout << __LINE__ <<
"]\t" << mthn <<
"'(' not found after PixelHit.\n";
141 loc2 =
line.find(
',', loc1 + 1);
143 cout << __LINE__ <<
"]\t" << mthn <<
"',' not found after the first argument of PixelHit.\n";
146 loc3 =
line.find(
',', loc2 + 1);
148 cout << __LINE__ <<
"]\t" << mthn <<
"'.' not found after the second argument of PixelHit.\n";
151 loc4 =
line.find(
')', loc3 + 1);
153 cout << __LINE__ <<
"]\t" << mthn <<
"')' not found after the third argument of PixelHit.\n";
156 int column = atoi(
line.substr(loc1 + 1, loc2 - loc1 - 1).c_str());
157 int row = atoi(
line.substr(loc2 + 1, loc3 - loc2 - 1).c_str());
158 int charge = atoi(
line.substr(loc3 + 1, loc4 - loc3 - 1).c_str());
160 DCol =
int(column / 2);
161 LorR =
int(column - DCol * 2);
162 pixelDCol = decimalToBaseX(DCol, 6, 2);
163 pixelPxl = decimalToBaseX((80 - row) * 2 + LorR, 6, 3);
165 std::cout <<
"Pxl = " << pixelPxl[2] << pixelPxl[1] << pixelPxl[0] <<
", DCol= " << pixelDCol[1] << pixelDCol[0]
168 pulseTrain[
i] = levelEncoder(pixelDCol[1]);
170 pulseTrain[
i] = levelEncoder(pixelDCol[0]);
172 pulseTrain[
i] = levelEncoder(pixelPxl[2]);
174 pulseTrain[
i] = levelEncoder(pixelPxl[1]);
176 pulseTrain[
i] = levelEncoder(pixelPxl[0]);
181 }
else if (
line.find(
"TBMTrailer") != std::string::npos) {
182 loc1 =
line.find(
'(');
184 cout << __LINE__ <<
"]\t" << mthn <<
"'(' not found after TBMTrailer.\n";
187 loc2 =
line.find(
')', loc1 + 1);
189 cout << __LINE__ <<
"]\t" << mthn <<
"')' not found after TBMTrailer.\n";
192 int TBMTrailer = atoi(
line.substr(loc1 + 1, loc2 - loc1 - 1).c_str());
203 pixelTBMTrailer = decimalToBaseX(TBMTrailer, 4, 4);
204 pulseTrain[
i] = levelEncoder(pixelTBMTrailer[3]);
206 pulseTrain[
i] = levelEncoder(pixelTBMTrailer[2]);
208 pulseTrain[
i] = levelEncoder(pixelTBMTrailer[1]);
210 pulseTrain[
i] = levelEncoder(pixelTBMTrailer[0]);
219 std::string mthn =
"[PixelFEDTestDAC::PixelFEDTestDAC()]\t\t\t\t ";
220 const unsigned long int UB = 200;
221 const unsigned long int B = 500;
222 const unsigned long int offset = 0;
223 vector<unsigned int> pulseTrain(256), pixelDCol(1), pixelPxl(2), pixelTBMHeader(3), pixelTBMTrailer(3);
224 unsigned int DCol, LorR,
start = 15;
227 unsigned long int npos = std::string::npos;
231 for (
unsigned int i = 0;
i < pulseTrain.size(); ++
i) {
241 assert(mode_ ==
"EmulatedPhysics" || mode_ ==
"FEDBaselineWithTestDACs" || mode_ ==
"FEDAddressLevelWithTestDACs");
246 if (
line.find(
"TBMHeader") != npos) {
247 loc1 =
line.find(
'(');
249 cout << __LINE__ <<
"]\t" << mthn <<
"'(' not found after TBMHeader.\n";
252 loc2 =
line.find(
')', loc1 + 1);
254 cout << __LINE__ <<
"]\t" << mthn <<
"')' not found after TBMHeader.\n";
257 int TBMHeader = atoi(
line.substr(loc1 + 1, loc2 - loc1 - 1).c_str());
268 pixelTBMHeader = decimalToBaseX(TBMHeader, 4, 4);
270 pulseTrain[
i] = levelEncoder(pixelTBMHeader[3]);
272 pulseTrain[
i] = levelEncoder(pixelTBMHeader[2]);
274 pulseTrain[
i] = levelEncoder(pixelTBMHeader[1]);
276 pulseTrain[
i] = levelEncoder(pixelTBMHeader[0]);
278 }
else if (
line.find(
"ROCHeader") != std::string::npos) {
279 loc1 =
line.find(
'(');
281 cout << __LINE__ <<
"]\t" << mthn <<
"'(' not found after ROCHeader.\n";
284 loc2 =
line.find(
')', loc1 + 1);
286 cout << __LINE__ <<
"]\t" << mthn <<
"')' not found after ROCHeader.\n";
289 int LastDAC = atoi(
line.substr(loc1 + 1, loc2 - loc1 - 1).c_str());
291 std::cout <<
"--------------" << std::endl;
297 pulseTrain[
i] = levelEncoder(LastDAC);
299 }
else if (
line.find(
"PixelHit") != std::string::npos) {
300 loc1 =
line.find(
'(');
302 cout << __LINE__ <<
"]\t" << mthn <<
"'(' not found after PixelHit.\n";
305 loc2 =
line.find(
',', loc1 + 1);
307 cout << __LINE__ <<
"]\t" << mthn <<
"',' not found after the first argument of PixelHit.\n";
310 loc3 =
line.find(
',', loc2 + 1);
312 cout << __LINE__ <<
"]\t" << mthn <<
"'.' not found after the second argument of PixelHit.\n";
315 loc4 =
line.find(
')', loc3 + 1);
317 cout << __LINE__ <<
"]\t" << mthn <<
"')' not found after the third argument of PixelHit.\n";
320 int column = atoi(
line.substr(loc1 + 1, loc2 - loc1 - 1).c_str());
321 int row = atoi(
line.substr(loc2 + 1, loc3 - loc2 - 1).c_str());
322 int charge = atoi(
line.substr(loc3 + 1, loc4 - loc3 - 1).c_str());
324 DCol =
int(column / 2);
325 LorR =
int(column - DCol * 2);
326 pixelDCol = decimalToBaseX(DCol, 6, 2);
327 pixelPxl = decimalToBaseX((80 - row) * 2 + LorR, 6, 3);
329 std::cout <<
"Pxl = " << pixelPxl[2] << pixelPxl[1] << pixelPxl[0] <<
", DCol= " << pixelDCol[1] << pixelDCol[0]
332 pulseTrain[
i] = levelEncoder(pixelDCol[1]);
334 pulseTrain[
i] = levelEncoder(pixelDCol[0]);
336 pulseTrain[
i] = levelEncoder(pixelPxl[2]);
338 pulseTrain[
i] = levelEncoder(pixelPxl[1]);
340 pulseTrain[
i] = levelEncoder(pixelPxl[0]);
345 }
else if (
line.find(
"TBMTrailer") != std::string::npos) {
346 loc1 =
line.find(
'(');
348 cout << __LINE__ <<
"]\t" << mthn <<
"'(' not found after TBMTrailer.\n";
351 loc2 =
line.find(
')', loc1 + 1);
353 cout << __LINE__ <<
"]\t" << mthn <<
"')' not found after TBMTrailer.\n";
356 int TBMTrailer = atoi(
line.substr(loc1 + 1, loc2 - loc1 - 1).c_str());
367 pixelTBMTrailer = decimalToBaseX(TBMTrailer, 4, 4);
368 pulseTrain[
i] = levelEncoder(pixelTBMTrailer[3]);
370 pulseTrain[
i] = levelEncoder(pixelTBMTrailer[2]);
372 pulseTrain[
i] = levelEncoder(pixelTBMTrailer[1]);
374 pulseTrain[
i] = levelEncoder(pixelTBMTrailer[0]);
382 unsigned int PixelFEDTestDAC::levelEncoder(
int level) {
412 vector<unsigned int> PixelFEDTestDAC::decimalToBaseX(
unsigned int a,
unsigned int x,
unsigned int length) {
413 vector<unsigned int> ans(100, 0);
435 std::ofstream *outstream,
436 std::ofstream *out1stream,
437 std::ofstream *out2stream)
const {
438 std::string mthn =
"[PixelFEDTestDAC::writeXMLHeader()]\t\t\t ";
439 std::stringstream maskFullPath;
443 maskFullPath <<
path <<
"/PixelCalib_Test_" << PixelTimeFormatter::getmSecTime() <<
".xml";
444 std::cout << __LINE__ <<
"]\t" << mthn <<
"Writing to: " << maskFullPath.str() << std::endl;
446 outstream->open(maskFullPath.str().c_str());
448 *outstream <<
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" << std::endl;
449 *outstream <<
"<ROOT xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" << std::endl;
450 *outstream <<
"" << std::endl;
451 *outstream <<
" <HEADER>" << std::endl;
452 *outstream <<
" <TYPE>" << std::endl;
453 *outstream <<
" <EXTENSION_TABLE_NAME>PIXEL_CALIB_CLOB</EXTENSION_TABLE_NAME>" << std::endl;
454 *outstream <<
" <NAME>Calibration Object Clob</NAME>" << std::endl;
455 *outstream <<
" </TYPE>" << std::endl;
456 *outstream <<
" <RUN>" << std::endl;
457 *outstream <<
" <RUN_TYPE>PixelFEDTestDAC</RUN_TYPE>" << std::endl;
458 *outstream <<
" <RUN_NUMBER>1</RUN_NUMBER>" << std::endl;
460 *outstream <<
" <LOCATION>CERN P5</LOCATION>" << std::endl;
461 *outstream <<
" </RUN>" << std::endl;
462 *outstream <<
" </HEADER>" << std::endl;
463 *outstream <<
"" << std::endl;
464 *outstream <<
" <DATA_SET>" << std::endl;
465 *outstream <<
"" << std::endl;
466 *outstream <<
" <VERSION>" <<
version <<
"</VERSION>" << std::endl;
467 *outstream <<
" <COMMENT_DESCRIPTION>No comment defined: this class does NOT inherit from " 468 "PixelCalibBase</COMMENT_DESCRIPTION>" 470 *outstream <<
" <CREATED_BY_USER>Unknown user</CREATED_BY_USER>" << std::endl;
471 *outstream <<
"" << std::endl;
472 *outstream <<
" <PART>" << std::endl;
473 *outstream <<
" <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>" << std::endl;
474 *outstream <<
" <KIND_OF_PART>Detector ROOT</KIND_OF_PART>" << std::endl;
475 *outstream <<
" </PART>" << std::endl;
479 void PixelFEDTestDAC::writeXML(std::ofstream *outstream, std::ofstream *out1stream, std::ofstream *out2stream)
const {
480 std::string mthn =
"[PixelFEDTestDAC::writeXML()]\t\t\t ";
482 *outstream <<
" " << std::endl;
483 *outstream <<
" <DATA>" << std::endl;
484 *outstream <<
" <CALIB_OBJ_DATA_FILE>./fedtestdac.dat</CALIB_OBJ_DATA_FILE>" << std::endl;
485 *outstream <<
" <CALIB_TYPE>fedtestdac</CALIB_TYPE>" << std::endl;
486 *outstream <<
" </DATA>" << std::endl;
487 *outstream <<
" " << std::endl;
491 void PixelFEDTestDAC::writeXMLTrailer(std::ofstream *outstream,
492 std::ofstream *out1stream,
493 std::ofstream *out2stream)
const {
494 std::string mthn =
"[PixelFEDTestDAC::writeXMLTrailer()]\t\t\t ";
496 *outstream <<
" </DATA_SET>" << std::endl;
497 *outstream <<
"</ROOT>" << std::endl;
500 std::cout << __LINE__ <<
"]\t" << mthn <<
"Data written " << std::endl;
double pulse(double x, double y, double z, double t)