Skip to content

Commit 3157325

Browse files
author
Andreas Pettersson
committed
bugfix and moved class init to header
1 parent a9f05cd commit 3157325

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

app/tool/tasks/inv_vref_scan.cxx

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,6 @@ double median(std::vector<T>& val) {
2222
return 0.5 * (*mid + *mid2);
2323
}
2424

25-
// Class
26-
27-
class DataFitter
28-
{
29-
public:
30-
DataFitter();
31-
32-
// Member functions
33-
34-
void sort_and_append(std::vector<int>& inv_vrefs,
35-
std::vector<int>& pedestals);
36-
37-
// Member variables
38-
39-
struct Point {
40-
int x_;
41-
int y_;
42-
double LH_;
43-
double RH_;
44-
};
45-
std::vector<Point> linear_;
46-
std::vector<Point> nonlinear_;
47-
48-
};
49-
5025
void DataFitter::sort_and_append(std::vector<int>& inv_vrefs, std::vector<int>& pedestals) {
5126
static auto the_log_{::pflib::logging::get("inv_vref_scan")};
5227
// We ignore first and last elements since they miss derivs
@@ -66,7 +41,7 @@ void DataFitter::sort_and_append(std::vector<int>& inv_vrefs, std::vector<int>&
6641

6742
// Threshold check. CMS uses 0.05
6843
if (std::abs(LH) <= flat_threshold || std::abs(RH) <= flat_threshold) { // flat regime
69-
nonlinear_.push_back(inv_vrefs[i], pedestals[i], LH, RH)
44+
nonlinear_.push_back({inv_vrefs[i], pedestals[i], LH, RH});
7045
} else { // we're in a linear regime or there's an outlier
7146
slope_points.push_back({i, LH, RH});
7247
LH_derivs.push_back(LH);
@@ -79,7 +54,7 @@ void DataFitter::sort_and_append(std::vector<int>& inv_vrefs, std::vector<int>&
7954

8055
for (const auto& p : slope_points) {
8156
if (std::abs(p.LH - LH_median) < 0.3 * LH_median) { // Linear regime. implement RH_median here as well?
82-
linear_.push_back(inv_vrefs[p.i], pedestals[p.i], p.LH, p.RH);
57+
linear_.push_back({inv_vrefs[p.i], pedestals[p.i], p.LH, p.RH});
8358
}
8459
}
8560

@@ -149,9 +124,9 @@ static void inv_vref_scan_writer(Target* tgt, pflib::ROC& roc, size_t nevents,
149124
// increment inv_vref in increments of 20. 10 bit value but only scanning to
150125
// 600
151126
int range = 10; // defines range of inv_vref values (x-range)
152-
std::vector<double> pedestals_l0;
153-
std::vector<double> pedestals_l1;
154-
std::vector<double> inv_vrefs;
127+
std::vector<int> pedestals_l0;
128+
std::vector<int> pedestals_l1;
129+
std::vector<int> inv_vrefs;
155130

156131
for (inv_vref = 300; inv_vref <= 310; inv_vref += 1) {
157132
pflib_log(info) << "Running INV_VREF = " << inv_vref;

app/tool/tasks/inv_vref_scan.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,26 @@
99
* used to trim adc pedestals between two links
1010
*/
1111
void inv_vref_scan(Target* tgt);
12+
13+
class DataFitter
14+
{
15+
public:
16+
void DataFitter();
17+
18+
// Member functions
19+
20+
void sort_and_append(std::vector<int>& inv_vrefs,
21+
std::vector<int>& pedestals);
22+
23+
// Member variables
24+
25+
struct Point {
26+
int x_;
27+
int y_;
28+
double LH_;
29+
double RH_;
30+
};
31+
std::vector<Point> linear_;
32+
std::vector<Point> nonlinear_;
33+
34+
};

0 commit comments

Comments
 (0)