wavecatcher-analysis
Loading...
Searching...
No Matches
Helpers.h
Go to the documentation of this file.
1
2#ifndef _Helpers
3#define _Helpers
4
5#include <TSystemDirectory.h>
6#include <TList.h>
7#include <TObjString.h>
8#include <TCanvas.h>
9#include <TH1.h>
10#include <TMath.h>
11
12#include <iostream>
13#include <sstream>
14#include <vector>
15#include <algorithm>
16
17using namespace std;
18
19class Helpers {
20public:
21 // find data files
22 static string ListFiles(const char*, const char*);
23
24 // progress bar
25 static void PrintProgressBar(int, int);
26
27 // use in loop, skips some poorly visible root colors (like white on white)
28 static int rcolor(unsigned int);
29
30 // set consistent ranges
31 static void SetRangeCanvas(TCanvas*&, double, double, double = -999, double = -999);
32 // check if user input makes sense
33 static void filterChannelUserInput(vector<int>&, const vector<int>);
34 // split canvas into pads to display all active channels on one canvas
35 static void SplitCanvas(TCanvas*&, vector<int>, vector<int>);
36
37 // get y values of a histogram
38 template <typename HistType>
39 static double* gety(HistType* his);
40
41 // get y values of a histogram for a dedicated x range
42 template <typename HistType>
43 static double* gety(HistType*, int, int);
44 static double* gety(const vector<float>&, int, int);
45
46 // shift a TH1 in x
47 template <typename HistType>
48 static void ShiftTH1(HistType*&, int);
49
54 template<typename T>
55 static bool Contains(const vector<T>& vec, const T& val) {
56 return find(vec.begin(), vec.end(), val) != vec.end();
57 }
58};
59#endif
static void SplitCanvas(TCanvas *&, vector< int >, vector< int >)
Helper to split canvas according to the number of channels to be plotted.
Definition Helpers.cc:121
static double * gety(HistType *his)
Get array of y values for a histogram.
Definition Helpers.cc:138
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.
Definition Helpers.cc:59
static int rcolor(unsigned int)
Translate a random number into a useful root color https://root.cern.ch/doc/master/classTColor....
Definition Helpers.cc:44
static void filterChannelUserInput(vector< int > &, const vector< int >)
Check if user input exists in data and remove channels that are not there.
Definition Helpers.cc:97
static bool Contains(const vector< T > &vec, const T &val)
Returns true if vector vec contains value val.
Definition Helpers.h:55
static void ShiftTH1(HistType *&, int)
Shift a histogram in x The histogram will be cycled, so bins at the end will be attached at the fron...
Definition Helpers.cc:199
static void PrintProgressBar(int, int)
Print progress bar for a loop in steps of 10 percent.
Definition Helpers.cc:28
static string ListFiles(const char *, const char *)
Helper. Creates a list of .bin data files in data folder to be read in.
Definition Helpers.cc:7