9 TSystemDirectory dir(dirname, dirname);
10 TList* files = dir.GetListOfFiles();
13 TObjString* objString;
14 while ((objString = (TObjString*)next())) {
15 const char* fileName = objString->GetString().Data();
17 if (fileName[0] ==
'.')
continue;
19 if (strstr(fileName, ext) !=
nullptr) ss << fileName <<
"\n";
21 if (ss.str().empty())
throw runtime_error(
"Error: No .bin files found in " +
static_cast<string>(dirname) +
"\n");
46 int rclrs[nclrs] = { 1, 2, 3, 4, 6, 8, 9, 13, 20, 28, 30, 34, 38, 40, 31, 46, 49 };
47 return rclrs[i -
static_cast<int>(floor(i / nclrs)) * nclrs];
59void Helpers::SetRangeCanvas(TCanvas*& c,
double x_range_min,
double x_range_max,
double y_range_min,
double y_range_max) {
62 auto setAxisRanges = [&](TH1* his) {
63 if (x_range_min != x_range_max) his->GetXaxis()->SetRangeUser(x_range_min, x_range_max);
64 if (y_range_min != y_range_max) his->GetYaxis()->SetRangeUser(y_range_min, y_range_max);
68 TList* pads = c->GetListOfPrimitives();
71 while ((
object = nextPad())) {
72 if (object->InheritsFrom(TPad::Class())) {
73 TPad* pad =
static_cast<TPad*
>(object);
76 TList* primitives = pad->GetListOfPrimitives();
77 TIter nextPrimitive(primitives);
79 while ((primitive = nextPrimitive())) {
80 if (primitive->InheritsFrom(TH1::Class())) {
81 setAxisRanges(
static_cast<TH1*
>(primitive));
85 else if (object->InheritsFrom(TH1::Class())) {
86 setAxisRanges(
static_cast<TH1*
>(
object));
100 for (
int i = 0; i < static_cast<int>(plot_active_channels.size()); i++) {
101 if (find(active_channels.begin(), active_channels.end(), plot_active_channels[i]) == active_channels.end()) {
102 cout <<
"\n\n\n ------------ WARNING ------------\n";
103 cout <<
"YOUR SELECTED CHANNEL " << plot_active_channels[i] <<
" DOES NOT EXIST IN DATA\n";
104 cout <<
"PLEASE CHANGE plot_active_channels\n\n\n";
105 rmv.push_back(plot_active_channels[i]);
109 for (
int i = 0; i < static_cast<int>(rmv.size()); i++) {
110 auto it = find(plot_active_channels.begin(), plot_active_channels.end(), rmv[i]);
111 if (it != plot_active_channels.end()) plot_active_channels.erase(it);
114 if (plot_active_channels.empty()) {
115 c->Divide(TMath::Min(
static_cast<double>(active_channels.size()), 4.), TMath::Max(TMath::Ceil(
static_cast<double>(active_channels.size()) / 4.), 1.), 0, 0);
117 else if (
static_cast<int>(plot_active_channels.size()) > 1) {
118 c->Divide(TMath::Min(
static_cast<double>(plot_active_channels.size()), 4.), TMath::Max(ceil(
static_cast<double>(plot_active_channels.size()) / 4.), 1.), 0, 0);
158 int nbins = his->GetNbinsX();
159 shift_bins = shift_bins % nbins;
162 for (
int i = 0; i < nbins; i++) {
164 if (i + shift_bins >= nbins) icycle = -1 * nbins;
165 else if (i + shift_bins < 0) icycle = nbins;
166 his->SetBinContent(i + 1, yvals[i + shift_bins + icycle]);
static void SplitCanvas(TCanvas *&, vector< int >, vector< int >)
Helper to split canvas according to the number of channels to be plotted.
static void SetRangeCanvas(TCanvas *&, double, double, double=-999, double=-999)
Set consistent x-axis and y-axis range for all TH1 histograms on a canvas.