6 #include <TDirectory.h>
10 #include "Math/VectorUtil.h"
14 #include <boost/exception/all.hpp>
27 template<
typename TTreePtr>
bool branchExists (
const TTreePtr& tree, TString brName)
29 auto brList = tree->GetListOfBranches();
31 for (
auto it = brList->begin(); it != brList->end(); ++it) {
32 TString
name = (*it)->GetName();
33 if (
name == brName) brFound =
true;
40 template<
typename T> std::vector<T*>
GetObjects (TDirectory * dir)
43 BOOST_THROW_EXCEPTION( std::runtime_error(
"Trying to access inexistent `TDirectory`") );
44 std::vector<T*> objects;
45 for (
const auto&& element: *(dir->GetListOfKeys())) {
46 auto key =
dynamic_cast<TKey*
>(element);
47 if (
auto obj =
dynamic_cast<T*
>(
key->ReadObj()); obj)
48 objects.push_back(obj);
55 inline TDirectory *
GetDirectory (TDirectory * dir,
const std::vector<const char *>& names)
57 for (
const char *
name: names) {
58 TDirectory * subdir = dir->GetDirectory(
name);
60 BOOST_THROW_EXCEPTION( std::invalid_argument(
61 Form(
"`%s` could not be found in `%s`",
name, dir->GetName())) );
67 using ROOT::Math::VectorUtil::DeltaPhi;
68 using ROOT::Math::VectorUtil::DeltaR;