1 #ifndef RDFAnalysis_Helpers_H 2 #define RDFAnalysis_Helpers_H 5 #include <TDirectory.h> 6 #include <ROOT/RDataFrame.hxx> 21 template <
typename Iterator>
32 Iterator
begin()
const {
return m_begin; }
34 Iterator
end()
const {
return m_end; }
36 std::size_t
size()
const {
return std::distance(
begin(),
end() ); }
38 const Iterator m_begin;
43 template <
typename Container>
45 return range_t<std::decay_t<decltype(container.begin() )>>(
46 std::begin(container),
47 std::end(container) );
51 template <
typename Container>
53 return range_t<std::decay_t<decltype(container.begin() )>>(
54 std::begin(container),
55 std::end(container) );
67 const std::string& name,
70 TDirectory* newDir = dir->GetDirectory(name.c_str() );
73 newDir = dir->mkdir(name.c_str() );
74 if (!newDir && doThrow)
75 throw std::runtime_error(
"Failed to get/make directory " + name);
79 return dir->GetDirectory(name.c_str() );
93 template <
typename Map>
96 const typename Map::key_type& key,
97 const typename Map::key_type& defaultKey)
99 auto itr = theMap.find(key);
100 if (itr == theMap.end() )
101 return theMap.at(defaultKey);
108 unsigned int poolSize = ROOT::GetImplicitMTPoolSize();
109 return poolSize == 0 ? 1 : poolSize;
113 template <
typename F,
typename T>
131 template <
typename F>
134 template <
typename R,
typename... Ts>
139 #endif //> !RDFAnalysis_Helpers_H Map::mapped_type getDefaultKey(const Map &theMap, const typename Map::key_type &key, const typename Map::key_type &defaultKey)
Get a value by key, defaulting to a backup key if it is not there.
Definition: Helpers.h:94
Helper class to allow iterating through a container without allowing users to modify that container...
Definition: Helpers.h:22
Iterator itr_t
The templated iterator type.
Definition: Helpers.h:25
unsigned int getNSlots()
Get the number of slots used in this session.
Definition: Helpers.h:107
std::enable_if_t<!std::is_convertible< F, std::string >{}, T > enable_ifn_string_t
Reduce size of enable_if statements.
Definition: Helpers.h:114
Definition: CutflowDetail.h:11
auto as_range(Container &container)
Make a range_t from a container.
Definition: Helpers.h:44
Iterator end() const
The end of the range.
Definition: Helpers.h:34
Iterator begin() const
The start of the range.
Definition: Helpers.h:32
range_t(Iterator begin, Iterator end)
Construct the range from two iterators.
Definition: Helpers.h:27
Definition: Helpers.h:132
std::size_t size() const
The size of the wrapped range.
Definition: Helpers.h:36
TDirectory * getMkdir(TDirectory *dir, const std::string &name, bool doThrow=true)
Get a directory, making it if it isn't there already.
Definition: Helpers.h:65
std::string uniqueBranchName(const std::string &stub="GenBranch")
Could perhaps be more natural in the IBranchNamer?
Definition: Helpers.cxx:4