15#include <FairLogger.h>
22#include <fairlogger/Logger.h>
43 template <
typename... Types>
50 template <
typename Type,
typename>
53 template <
typename Type,
typename... BaseTypes>
56 template <
typename Type>
59 template <
typename RootType,
typename... Args>
63 return new RootType(std::forward<Args>(args)...);
69 template <
typename Hist,
typename... Args>
72 static_assert(std::is_base_of_v<TH1, Hist>,
"make_hist: not a histogram type!");
73 auto hist = std::make_unique<Hist>(std::forward<Args>(args)...);
74 hist->SetDirectory(
nullptr);
84 LOG(debug2) <<
"Closing file " << rootfile->GetName();
93 template <
typename... Args>
103 template <
typename DataType, std::
size_t size>
104 constexpr std::size_t
GetSize(
const DataType (&)[size])
139 template <
typename DataType>
152 auto left() const -> const DataType& {
return data_.first; }
153 auto right() const -> const DataType& {
return data_.second; }
160 std::pair<DataType, DataType>
data_;
170 template <u
int8_t iterations = DEFAULT_ITERATION>
173 auto exp = 1.F + (val / (1U << iterations));
174 for (
auto i = 0; i < iterations; ++i)
183 namespace fs = std::filesystem;
186 auto path = fs::path{ filename };
187 auto parent_folder = path.parent_path();
188 if (parent_folder.empty())
193 if (not fs::exists(parent_folder))
196 R
"(Cannot get the parent folder of the regex path "{}"! Setting it to the current folder)",
201 return parent_folder;
206 if (filename_regex.empty())
210 auto regex_path = fs::path{ filename_regex };
212 const auto regex_string = regex_path.filename().string();
213 auto filelist = std::vector<std::string>{};
214 for (
const auto& dir_entry : fs::directory_iterator(parent_folder))
216 if (std::regex_match(dir_entry.path().filename().string(), std::regex{ regex_string }))
218 filelist.emplace_back(fs::absolute(dir_entry.path()));
221 if (filelist.empty())
223 LOGP(error, R
"(Cannot find any files with regex "{}")", regex_string);
225 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)