Q3D-Calibration/main.cpp

49 lines
1.2 KiB
C++

#include "BlockHandler.h"
#include "CsvReader.h"
#include "FileHandler.h"
#include "utils.h"
#include <iostream>
using namespace std;
int main() {
int n, id, E;
string run;
FileHandler *FH;
BlockHandler *BH;
CsvReader CR("config1.csv");
CR.readData();
n = CR.rows();
E = stoi(CR(0, 3));
FH = new FileHandler[n - 1];
BH = new BlockHandler[5];
for (int i = 0; i < 5; i++) BH[i] = BlockHandler(i);
for (int i = 1; i < n; i++) {
run = CR(i, 0);
FH[i - 1] = FileHandler("2016Q3D/root/raw/201609Q3D" + run + ".root", 5);
FH[i - 1].pX = stoi(CR(i, 2));
FH[i - 1].readData();
BH[stoi(CR(i, 1))].addData(FH[i - 1]);
}
for (int i = 0; i < 5; i++) BH[i].splitData();
string s;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 8; j++) {
s = "result/bind/" + to_string(E) + "-" + to_string(i) + "-" + to_string(j) + ".txt";
std::ofstream ofs(s);
for (int k = 0; k < BH[i].bind[j].data.size(); k++) {
auto p = BH[i].bind[j].data.at(k);
ofs << p(0) << " " << p(1) << std::endl;
}
}
}
return 0;
}