Commit 5bd9be41 authored by Marijus Ambrozas's avatar Marijus Ambrozas
Browse files

Update LDACLINCalibration.C

parent 520265b1
// ROOT macro to find the best LDAC_LIN value for threshold tuning after running the shell script LDAC_LIN_measurement.sh
// ROOT macro to find the best LDAC_LIN value for threshold tuning after running the shell script LDACLINMeasurement.sh
// Created by Marijus Ambrozas (marijus.ambrozas@cern.ch)
// Aug. 30 2021
......@@ -14,7 +14,13 @@
#include <TSystemDirectory.h>
#include <TSystemFile.h>
void LDAC_LIN_calibration(TString measurementSet="ChipX_1", TString option="")
// Useful function to compare strings as numbers
bool cmp(TString a, TString b)
{
return a.Atoi() < b.Atoi();
}
void LDACLINCalibration(TString measurementSet="ChipX_1", TString option="")
{
TString Option = option;
Option.ToUpper();
......@@ -75,6 +81,12 @@ void LDAC_LIN_calibration(TString measurementSet="ChipX_1", TString option="")
return;
}
// Sorting the vectors in case GetListOfFiles does not provide them in correct order
sort(values_threqu.begin(), values_threqu.end(), less<int>());
sort(filenames_threqu.begin(), filenames_threqu.end(), cmp);
sort(values_scurve.begin(), values_scurve.end(), less<int>());
sort(filenames_scurve.begin(), filenames_scurve.end(), cmp);
TH1D *h_efficiency[values_threqu.size()];
TH1D *h_ThrSpread[values_scurve.size()];
TGraph *g_effSigma_vs_LDACLIN = new TGraph(values_threqu.size());
......@@ -86,7 +98,7 @@ void LDAC_LIN_calibration(TString measurementSet="ChipX_1", TString option="")
if (Option == "")
{
ifstream t_in;
t_in.open("./Results/"+measurementSet+"/LDAC_LIN_candidates.txt");
t_in.open("./Results/"+measurementSet+"/LDACLINCandidates.txt");
if (t_in.is_open())
{
double read;
......@@ -96,7 +108,7 @@ void LDAC_LIN_calibration(TString measurementSet="ChipX_1", TString option="")
}
else
{
std::cerr << "Error: could not open the file Results/"+measurementSet+"/LDAC_LIN_candidates.txt!" << std::endl;
std::cerr << "Error: could not open the file Results/"+measurementSet+"/LDACLINCandidates.txt!" << std::endl;
std::cout << "Maybe you need to create it first? If so, run the macro with the \"S\" argument" << std::endl;
return;
}
......@@ -218,7 +230,7 @@ void LDAC_LIN_calibration(TString measurementSet="ChipX_1", TString option="")
if (Option == "S" || Option == "SHORT")
{
ofstream t_out;
t_out.open("./Results/"+measurementSet+"/LDAC_LIN_candidates.txt");
t_out.open("./Results/"+measurementSet+"/LDACLINCandidates.txt");
if (t_out.is_open())
{
Int_t i_min = best_i-2 >= 0 ? best_i-2 : 0;
......@@ -227,7 +239,7 @@ void LDAC_LIN_calibration(TString measurementSet="ChipX_1", TString option="")
t_out << values_threqu[i] << std::endl;
t_out.close();
}
else std::cerr << "Error: failed to open the output file \"Results/"+measurementSet+"/LDAC_LIN_candidates.txt\"!" << std::endl;
else std::cerr << "Error: failed to open the output file \"Results/"+measurementSet+"/LDACLINCandidates.txt\"!" << std::endl;
}
// Removing empty points if only 7 s-curve points exist
......@@ -242,10 +254,10 @@ void LDAC_LIN_calibration(TString measurementSet="ChipX_1", TString option="")
// Drawing
g_effSigma_vs_LDACLIN->SetName("g_effSigma_vs_LDACLIN");
g_effSigma_vs_LDACLIN->SetTitle("Efficiency effSigma vs LDAC_LIN");
g_effSigma_vs_LDACLIN->SetTitle("Efficiency spread vs LDAC_LIN");
g_effSigma_vs_LDACLIN->SetMarkerStyle(kFullDotLarge);
g_effSigma_vs_LDACLIN->GetXaxis()->SetTitle("LDAC_LIN");
g_effSigma_vs_LDACLIN->GetYaxis()->SetTitle("effSigma(Efficiency)");
g_effSigma_vs_LDACLIN->GetYaxis()->SetTitle("Efficiency spread sigma");
g_effSigma_vs_LDACLIN->GetXaxis()->SetNoExponent(1);
g_effSigma_vs_LDACLIN->GetXaxis()->SetMoreLogLabels(1);
g_effSigma_vs_LDACLIN->GetXaxis()->SetTitleOffset(1.2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment