|
51 | 51 | // void CalibCorrScale(infile, oufile, scale) |
52 | 52 | // Scales all contents of correction factors by "scale" from "infile" |
53 | 53 | // to "outfile" |
| 54 | +// void CalibCorrScale2(infile, oufile, scaleB, scaleT, scaleE) |
| 55 | +// Scales all contents of correction factors in the barrel, transition and |
| 56 | +// endcap regions by "scaleB", "scaleT", "scaleE" from "infile" and writes |
| 57 | +// them to "outfile" |
54 | 58 | ////////////////////////////////////////////////////////////////////////////// |
55 | 59 | #ifndef CalibrationHcalCalibAlgosCalibCorr_h |
56 | 60 | #define CalibrationHcalCalibAlgosCalibCorr_h |
@@ -144,6 +148,13 @@ unsigned int truncateId(unsigned int detId, int truncateFlag, bool debug = false |
144 | 148 | //Ignore depth index for depth > 1 in HB and HE |
145 | 149 | if (depth > 1) |
146 | 150 | depth = 2; |
| 151 | + } else if (truncate0 == 6) { |
| 152 | + //Ignore depth index for depth > 2 in HB and HE and |
| 153 | + // depthe 1, 2 are considered as depth 1 |
| 154 | + if (depth <= 2) |
| 155 | + depth = 1; |
| 156 | + else |
| 157 | + depth = 2; |
147 | 158 | } |
148 | 159 | id = (subdet << 25) | (0x1000000) | ((depth & 0xF) << 20) | ((zside > 0) ? (0x80000 | (ieta << 10)) : (ieta << 10)); |
149 | 160 | if (debug) { |
@@ -1353,4 +1364,58 @@ void CalibCorrScale(const char* infile, const char* outfile, double scale) { |
1353 | 1364 | myfile.close(); |
1354 | 1365 | } |
1355 | 1366 | } |
| 1367 | + |
| 1368 | +void CalibCorrScale2(const char* infile, const char* outfile, double scaleB, double scaleT, double scaleE) { |
| 1369 | + int ietasL[3] = {0, 13, 17}; |
| 1370 | + int ietasH[3] = {14, 18, 29}; |
| 1371 | + double scale[3] = {scaleB, scaleT, scaleE}; |
| 1372 | + std::ofstream myfile; |
| 1373 | + myfile.open(outfile); |
| 1374 | + if (!myfile.is_open()) { |
| 1375 | + std::cout << "** ERROR: Can't open '" << outfile << std::endl; |
| 1376 | + } else { |
| 1377 | + if (std::string(infile) != "") { |
| 1378 | + std::ifstream fInput(infile); |
| 1379 | + if (!fInput.good()) { |
| 1380 | + std::cout << "Cannot open file " << infile << std::endl; |
| 1381 | + } else { |
| 1382 | + char buffer[1024]; |
| 1383 | + unsigned int all(0), good(0), comment(0); |
| 1384 | + while (fInput.getline(buffer, 1024)) { |
| 1385 | + ++all; |
| 1386 | + if (buffer[0] == '#') { |
| 1387 | + myfile << buffer << std::endl; |
| 1388 | + ++comment; |
| 1389 | + continue; //ignore comment |
| 1390 | + } |
| 1391 | + std::vector<std::string> items = splitString(std::string(buffer)); |
| 1392 | + if (items.size() != 5) { |
| 1393 | + std::cout << "Ignore line: " << buffer << std::endl; |
| 1394 | + } else { |
| 1395 | + ++good; |
| 1396 | + int ieta = std::atoi(items[1].c_str()); |
| 1397 | + int depth = std::atoi(items[2].c_str()); |
| 1398 | + int jp(-1); |
| 1399 | + for (int j = 0; j < 3; ++j) { |
| 1400 | + if (std::abs(ieta) > ietasL[j] && std::abs(ieta) <= ietasH[j]) { |
| 1401 | + if (jp < 0) |
| 1402 | + jp = j; |
| 1403 | + } |
| 1404 | + } |
| 1405 | + if (jp < 0) |
| 1406 | + jp = 2; |
| 1407 | + float corrf = scale[jp] * std::atof(items[3].c_str()); |
| 1408 | + float dcorr = scale[jp] * std::atof(items[4].c_str()); |
| 1409 | + myfile << std::setw(10) << items[0] << std::setw(10) << std::dec << ieta << std::setw(10) << depth |
| 1410 | + << std::setw(10) << corrf << " " << std::setw(10) << dcorr << std::endl; |
| 1411 | + } |
| 1412 | + } |
| 1413 | + fInput.close(); |
| 1414 | + std::cout << "Reads total of " << all << ", " << comment << " and " << good << " good records from " << infile |
| 1415 | + << " and copied to " << outfile << std::endl; |
| 1416 | + } |
| 1417 | + } |
| 1418 | + myfile.close(); |
| 1419 | + } |
| 1420 | +} |
1356 | 1421 | #endif |
0 commit comments