41 VectorConfig() =
default;
42 VectorConfig(
const VectorConfig&) =
default;
43 explicit VectorConfig(
const MapType& map) : map_(map), size_(map.size()) {}
44 VectorConfig(VectorConfig&&)
noexcept(std::is_nothrow_move_constructible<MapType>::value) =
default;
45 VectorConfig& operator=(VectorConfig&&)
noexcept(std::is_nothrow_move_assignable<MapType>::value) =
default;
46 VectorConfig& operator=(
const VectorConfig&) =
default;
47 virtual ~VectorConfig() =
default;
49 virtual void AddField(
const std::string& name,
const std::string& title) {
50 map_.insert(std::make_pair(name,
ConfigElement(size_++, title)));
52 virtual void AddField(
const std::string& name, ShortInt_t
id,
const std::string& title) {
55 void AddField(
const std::string& name,
const ConfigElement& field) {
56 map_.insert(std::make_pair(name, field));
58 virtual void AddFields(
const std::vector<std::string>& names,
const std::string& title) {
59 for (
const auto& name : names) {
60 map_.insert(std::make_pair(name,
ConfigElement(size_++, title)));
64 ANALYSISTREE_ATTR_NODISCARD ShortInt_t GetId(
const std::string& sField)
const {
65 auto search = map_.find(sField);
66 if (search != map_.end()) {
67 return search->second.id_;
69 return UndefValueShort;
73 ANALYSISTREE_ATTR_NODISCARD
virtual const MapType& GetMap()
const {
return map_; }
74 ANALYSISTREE_ATTR_NODISCARD
virtual ShortInt_t GetSize()
const {
return size_; }
79 void RemoveField(
const std::string& name,
int id);
82 ClassDef(VectorConfig, 2)
89class BranchConfig :
public VectorConfig<int>,
public VectorConfig<float>,
public VectorConfig<bool> {
92 BranchConfig() =
default;
93 BranchConfig(
const BranchConfig&) =
default;
94 BranchConfig(BranchConfig&&) =
default;
95 BranchConfig& operator=(BranchConfig&&) =
default;
96 BranchConfig& operator=(
const BranchConfig&) =
default;
97 ~BranchConfig()
override =
default;
99 BranchConfig(std::string name, DetType type, std::string title =
"");
103 void PrintBranchId()
const;
105 ANALYSISTREE_ATTR_NODISCARD Types GetFieldType(
const std::string& sField)
const;
106 ANALYSISTREE_ATTR_NODISCARD ShortInt_t GetFieldId(
const std::string& sField)
const;
110 void AddField(
const std::string& name,
const std::string& title =
"") {
111 GuaranteeFieldNameVacancy(name);
112 VectorConfig<T>::AddField(name, title);
115 void AddFields(
const std::vector<std::string>& names,
const std::string& title =
"") {
116 for (
auto& n : names) {
117 GuaranteeFieldNameVacancy(n);
119 VectorConfig<T>::AddFields(names, title);
122 void AddField(
const std::string& name, ShortInt_t
id,
const std::string& title =
"") {
123 GuaranteeFieldNameVacancy(name);
124 VectorConfig<T>::AddField(name,
id, title);
127 void RemoveField(
const std::string& name);
129 void RemoveFields(
const std::vector<std::string>& names) {
130 for (
auto& n : names) {
135 void SetTitle(std::string title) { title_ = std::move(title); }
139 ANALYSISTREE_ATTR_NODISCARD
const MapType& GetMap()
const {
return VectorConfig<T>::GetMap(); }
141 ANALYSISTREE_ATTR_NODISCARD ShortInt_t GetSize()
const {
return VectorConfig<T>::GetSize(); }
143 ANALYSISTREE_ATTR_NODISCARD std::string GetName()
const {
return name_; }
144 ANALYSISTREE_ATTR_NODISCARD std::string GetTitle()
const {
return title_; }
147 ANALYSISTREE_ATTR_NODISCARD std::vector<std::string> GetFieldsNamesT()
const {
148 std::vector<std::string> result;
149 std::transform(begin(GetMap<T>()), end(GetMap<T>()), back_inserter(result),
150 [](
const typename MapType::value_type& elem) {
return elem.first; });
153 ANALYSISTREE_ATTR_NODISCARD
size_t GetId()
const {
return id_; }
154 ANALYSISTREE_ATTR_NODISCARD DetType GetType()
const {
return type_; }
161 ANALYSISTREE_ATTR_NODISCARD BranchConfig
Clone(
const std::string& name, DetType type)
const;
163 ANALYSISTREE_ATTR_NODISCARD BranchConfig CloneAndMerge(
const BranchConfig& attached)
const;
165 bool HasField(
const std::string& field)
const {
return GetFieldId(field) != UndefValueShort; }
170 void GuaranteeFieldNameVacancy(
const std::string& name)
const;
175 DetType type_{DetType(UndefValueShort)};
177 ClassDefOverride(BranchConfig, 4);
ANALYSISTREE_ATTR_NODISCARD BranchConfig Clone(const std::string &name, DetType type) const
Creates a copy with different name and/or detector type.
Definition BranchConfig.cpp:90