Skip to content
Snippets Groups Projects
Commit 5ce1a1d8 authored by Oliver Kirsebom's avatar Oliver Kirsebom
Browse files

read calibration coeff from files

parent 03eaa3d2
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
#include <unistd.h>
#include <getopt.h>
#include <algorithm> // std::find
#include <fstream>
#include <ausa/util/memory>
#include <ausa/util/FileUtil.h>
......@@ -21,7 +22,8 @@
using namespace std;
using namespace VEIKONKONE;
void findFiles(int run, vector<string>& input);
void findFiles(int run, vector<string>& input, vector<bool>& found);
void readCalib(string file, double& a0, double& a1, double& a2);
void parseCommandline(int argc, char* argv[]);
void printUsage(char* argv[]);
void printLongUsage(char* argv[]);
......@@ -44,7 +46,8 @@ int main( int argc, char* argv[] ){
for (int run = runs[0]; run <= runs[1]; run++)
{
vector<string> input;
findFiles(run, input);
vector<bool> found;
findFiles(run, input, found);
if (input.size() == 0) {
cout << " *** ERROR: Unable to find any files with run number " << run << endl;
......@@ -64,18 +67,31 @@ int main( int argc, char* argv[] ){
string output = Form("%ssorted/new/s%04d_00.root", datadir.data(), run);
auto sorter = make_unique<VKSorter>(readers, output, window);
// SIGNAL energy calibration
// double a0 = 30.0, a1 = 1.252, a2 = 0; // old calibration
double a0 = 24.0, a1 = 1.226, a2 = 0; // calibration based on runs 286 and 294
// adjut energy calibration to fit high-B field spectra
//ccc a0 += -411;
//ccc a1 *= 1.13;
sorter->setCalibration(0, a0, a1, a2);
// energy calibration coefficients
double a0, a1, a2;
cout << "Calibration coefficients:" << endl;
// LaBr energy calibration
a0 = -53; a1 = 1.30; a2 = 0; // elog entry #3
sorter->setCalibration(2, a0, a1, a2);
// SIGNAL energy calibration
readCalib("ch0.calib", a0, a1, a2);
if (found[0]) {
sorter->setCalibration(0, a0, a1, a2);
cout << "Ch0: " << a0 << ", " << a1 << ", " << a2 << endl;
}
// VETO energy calibration
readCalib("ch1.calib", a0, a1, a2);
if (found[1]) {
sorter->setCalibration(0, a0, a1, a2);
cout << "Ch1: " << a0 << ", " << a1 << ", " << a2 << endl;
}
// LaBr energy calibration
readCalib("ch2.calib", a0, a1, a2);
if (found[2]) {
sorter->setCalibration(2, a0, a1, a2);
cout << "Ch2: " << a0 << ", " << a1 << ", " << a2 << endl;
}
// set software trigger
if (trigger.size() > 0) {
for (size_t i = 0; i < readers.size(); i++) sorter->setTrigger(i, false);
......@@ -178,8 +194,10 @@ void printLongUsage(char* argv[]) {
}
void findFiles(int run, vector<string>& input)
void findFiles(int run, vector<string>& input, vector<bool>& found)
{
found.resize(3, false);
TString path = datadir + "raw/";
TSystemDirectory dir(path, path);
TList *files = dir.GetListOfFiles();
......@@ -193,17 +211,40 @@ void findFiles(int run, vector<string>& input)
if (fname.EndsWith(Form("%04d_ch000.txt", run))) {
if (input.size() < 1) input.resize(1);
input[0] = fname.Data();
found[0] = true;
}
else if (fname.EndsWith(Form("%04d_ch001.txt", run))) {
if (input.size() < 2) input.resize(2);
input[1] = fname.Data();
found[1] = true;
}
else if (fname.EndsWith(Form("%04d_ch002.txt", run))) {
if (input.size() < 3) input.resize(3);
input[2] = fname.Data();
found[2] = true;
}
}
}
}
for (auto& i : input) i = datadir + "raw/" + i;
}
void readCalib(string file, double& a0, double& a1, double& a2)
{
ifstream fin(file);
if (fin.is_open())
{
double x = 0;
int i = 0;
while (i < 3)
{
fin >> x;
if (i == 0) a0 = x;
else if (i == 1) a1 = x;
else if (i == 2) a2 = x;
i++;
}
fin.close();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment