21#include <fairlogger/Logger.h>
42 template <
typename... Types>
49 template <
typename Type,
typename>
52 template <
typename Type,
typename... BaseTypes>
55 template <
typename Type>
58 template <
typename RootType,
typename... Args>
62 return new RootType(std::forward<Args>(args)...);
68 template <
typename Hist,
typename... Args>
71 static_assert(std::is_base_of_v<TH1, Hist>,
"make_hist: not a histogram type!");
72 auto hist = std::make_unique<Hist>(std::forward<Args>(args)...);
73 hist->SetDirectory(
nullptr);
83 LOG(debug2) <<
"Closing file " << rootfile->GetName();
92 template <
typename... Args>
102 template <
typename DataType, std::
size_t size>
103 constexpr std::size_t
GetSize(
const DataType (&)[size])
138 template <
typename DataType>
151 auto left() const -> const DataType& {
return data_.first; }
152 auto right() const -> const DataType& {
return data_.second; }
159 std::pair<DataType, DataType>
data_;
169 template <u
int8_t iterations = DEFAULT_ITERATION>
172 auto exp = 1.F + (val / (1U << iterations));
173 for (
auto i = 0; i < iterations; ++i)
182 namespace fs = std::filesystem;
185 auto path = fs::path{ filename };
186 auto parent_folder = path.parent_path();
187 if (parent_folder.empty())
192 if (not fs::exists(parent_folder))
195 R
"(Cannot get the parent folder of the regex path "{}"! Setting it to the current folder)",
200 return parent_folder;
205 if (filename_regex.empty())
209 auto regex_path = fs::path{ filename_regex };
211 const auto regex_string = regex_path.filename().string();
212 auto filelist = std::vector<std::string>{};
213 for (
const auto& dir_entry : fs::directory_iterator(parent_folder))
215 if (std::regex_match(dir_entry.path().filename().string(), std::regex{ regex_string }))
217 filelist.emplace_back(fs::absolute(dir_entry.path()));
220 if (filelist.empty())
222 LOGP(error, R
"(Cannot find any files with regex "{}")", regex_string);
224 std::sort(filelist.begin(), filelist.end());
void set_left(const DataType &value)
auto right() const -> const DataType &
std::pair< DataType, DataType > data_
LRPair(const DataType &left, const DataType &right)
auto left() const -> const DataType &
auto get(Side side) const -> const DataType &
auto left() -> DataType &
void set_right(const DataType &value)
auto get(Side side) -> DataType &
auto right() -> DataType &
auto make_hist(Args &&... args)
auto make_rootfile(Args &&... args)
static const uint8_t DEFAULT_ITERATION
auto GetParentDir(std::string_view filename) -> fs::path
constexpr bool is_root_owned
constexpr std::size_t GetSize(const DataType(&)[size])
auto GetFilesFromRegex(std::string_view filename_regex) -> std::vector< std::string >
constexpr auto toIndex(Side side) -> size_t
auto FastExp(const float val) -> float
TypeCollection< TF1, TH1, TTree > RootTypes
constexpr bool is_based_on
auto root_owned(Args &&... args)
constexpr auto IndexToSide(size_t index) -> Side
std::unique_ptr< TFile, TFileDeleter > unique_rootfile
void operator()(TFile *rootfile)