diff --git a/core/BranchConfig.hpp b/core/BranchConfig.hpp index 9782909f..2140e261 100644 --- a/core/BranchConfig.hpp +++ b/core/BranchConfig.hpp @@ -85,7 +85,7 @@ class VectorConfig { int name_strlen{0}; for (const auto& entry : map_) { - name_strlen = std::max(name_strlen, (int)entry.first.length()); + name_strlen = std::max(name_strlen, (int) entry.first.length()); } name_strlen += 4; diff --git a/infra/AnalysisEntry.cpp b/infra/AnalysisEntry.cpp index a99deaad..69808c1d 100644 --- a/infra/AnalysisEntry.cpp +++ b/infra/AnalysisEntry.cpp @@ -9,7 +9,7 @@ namespace AnalysisTree { AnalysisEntry::~AnalysisEntry() { - for(auto& br : branches_) { + for (auto& br : branches_) { delete br.first; } } @@ -24,7 +24,7 @@ bool AnalysisEntry::ApplyCutOnBranch(const Branch& br, Cuts* cuts, int i_channel } bool AnalysisEntry::ApplyCutOnBranches(std::vector& br, std::vector& cuts, std::vector& ch) const { - if(br.size() != cuts.size() || cuts.size() != ch.size()) { + if (br.size() != cuts.size() || cuts.size() != ch.size()) { throw std::runtime_error("AnalysisTree::AnalysisEntry::ApplyCutOnBranches() - Branch, Cuts and Ch vectors must have the same size"); } bool ok{true}; @@ -32,10 +32,10 @@ bool AnalysisEntry::ApplyCutOnBranches(std::vector& br, std::vect std::vector id_vec; bch_vec.reserve(br.size()); id_vec.reserve(br.size()); - for(int i=0; iApply(*bchptr)) { + if (cuts.at(i) != nullptr) { + if (!cuts.at(i)->Apply(*bchptr)) { ok = false; delete bchptr; break; @@ -45,7 +45,7 @@ bool AnalysisEntry::ApplyCutOnBranches(std::vector& br, std::vect id_vec.emplace_back(br.at(i)->GetId()); } bool result = ok && (!cuts_ || cuts_->Apply(bch_vec, id_vec)); - for(auto& bv : bch_vec) { + for (auto& bv : bch_vec) { delete bv; } return result; @@ -64,20 +64,20 @@ bool AnalysisEntry::ApplyCutOnBranches(const Branch& br1, Cuts* cuts1, int ch1, } double AnalysisEntry::FillVariable(const Variable& var, std::vector& br, std::vector& id) { - if(br.size() != id.size()) { + if (br.size() != id.size()) { throw std::runtime_error("AnalysisTree::AnalysisEntry::FillVariable() - Branch and Id vectors must have the same size"); } std::vector bch_vec; std::vector id_vec; bch_vec.reserve(br.size()); id_vec.reserve(br.size()); - for(int i=0; iGetId()); } double result = var.GetValue(bch_vec, id_vec); - for(auto& bv : bch_vec) { + for (auto& bv : bch_vec) { delete bv; } return result; @@ -116,7 +116,7 @@ void AnalysisEntry::FillFromEveHeaders() { br_vec.reserve(branches_.size()); cuts_vec.reserve(branches_.size()); id_vec.reserve(branches_.size()); - for(auto& br : branches_) { + for (auto& br : branches_) { br_vec.emplace_back(br.first); cuts_vec.emplace_back(br.second); id_vec.emplace_back(0); @@ -150,11 +150,11 @@ void AnalysisEntry::FillFromOneChannalizedBranch() { br_vec.reserve(branches_.size()); cuts_vec.reserve(branches_.size()); id_vec.resize(branches_.size()); - for(const auto& br : branches_) { + for (const auto& br : branches_) { br_vec.emplace_back(br.first); cuts_vec.emplace_back(br.second); } - for(auto& ehi : eve_header_indices_) { + for (auto& ehi : eve_header_indices_) { id_vec.at(ehi) = 0; } @@ -178,7 +178,7 @@ void AnalysisEntry::FillFromOneChannalizedBranch() { * It iterates over registered matches and fills variables */ void AnalysisEntry::FillFromTwoChannalizedBranches() { - if(matching_ == nullptr) { + if (matching_ == nullptr) { throw std::runtime_error("AnalysisEntry::FillFromTwoChannalizedBranches() - Matching between non-EventHeader branches must be set"); } @@ -191,11 +191,11 @@ void AnalysisEntry::FillFromTwoChannalizedBranches() { br_vec.reserve(branches_.size()); cuts_vec.reserve(branches_.size()); id_vec.resize(branches_.size()); - for(const auto& br : branches_) { + for (const auto& br : branches_) { br_vec.emplace_back(br.first); cuts_vec.emplace_back(br.second); } - for(auto& ehi : eve_header_indices_) { + for (auto& ehi : eve_header_indices_) { id_vec.at(ehi) = 0; } @@ -236,22 +236,22 @@ void AnalysisEntry::Init(const Configuration& conf, const std::map 2) { + if (non_eve_header_indices_.size() > 2) { throw std::runtime_error("AnalysisEntry::Init() - 2 non-EventHeader branches are allowed as maximum"); } - if(non_eve_header_indices_.size() == 2) { + if (non_eve_header_indices_.size() == 2) { auto match_info = conf.GetMatchInfo(*std::next(branch_names_.begin(), non_eve_header_indices_.at(0)), *std::next(branch_names_.begin(), non_eve_header_indices_.at(1))); SetIsInvertedMatching(match_info.second); SetMatching((Matching*) matches.find(match_info.first)->second); diff --git a/infra/AnalysisEntry.hpp b/infra/AnalysisEntry.hpp index 9f8fad1e..19d08265 100644 --- a/infra/AnalysisEntry.hpp +++ b/infra/AnalysisEntry.hpp @@ -26,9 +26,9 @@ class AnalysisEntry { AnalysisEntry() = default; virtual ~AnalysisEntry(); - explicit AnalysisEntry(std::vector vars, Cuts* cuts = nullptr, Variable vars4weight={}) : vars_(std::move(vars)), - var4weight_(std::move(vars4weight)), - cuts_(cuts) { + explicit AnalysisEntry(std::vector vars, Cuts* cuts = nullptr, Variable vars4weight = {}) : vars_(std::move(vars)), + var4weight_(std::move(vars4weight)), + cuts_(cuts) { var4weight_.IfEmptyVariableConvertToOnes(vars_.at(0)); FillBranchNames(); }; @@ -77,7 +77,7 @@ class AnalysisEntry { Matching* matching_{nullptr};///< non-owning bool is_inverted_matching_{false}; - array2D values_{};///< channels + array2D values_{}; ///< channels array1D weights_{};///< channels ClassDef(AnalysisEntry, 1); diff --git a/infra/BranchChannel.cpp b/infra/BranchChannel.cpp index 3c09d32d..01856cde 100644 --- a/infra/BranchChannel.cpp +++ b/infra/BranchChannel.cpp @@ -44,16 +44,18 @@ void BranchChannel::MergeContentFromTwoChannels(const BranchChannel& first, cons int matching_case{-1}; bool first_channel_active = !first.IsNullChannel(); bool second_channel_active = !second.IsNullChannel(); - if(first_channel_active) { - if(second_channel_active) matching_case = 0; - else matching_case = 1; + if (first_channel_active) { + if (second_channel_active) matching_case = 0; + else + matching_case = 1; } else { - if(second_channel_active) matching_case = 2; - else throw std::runtime_error("BranchChannel::MergeContentFromTwoChannels() : both channels are null"); + if (second_channel_active) matching_case = 2; + else + throw std::runtime_error("BranchChannel::MergeContentFromTwoChannels() : both channels are null"); } - if(first_channel_active) CopyContent(first); - if(second_channel_active) CopyContent(second, second.branch_->GetBranchName()); + if (first_channel_active) CopyContent(first); + if (second_channel_active) CopyContent(second, second.branch_->GetBranchName()); this->SetValue(branch_->GetField("matching_case"), matching_case); } @@ -69,14 +71,14 @@ double BranchChannel::Value(const Field& v) const { // assert(v.GetBranchId() == branch_->GetId()); // TODO assert(v.IsInitialized()); - if(v.GetName() == "ones") return 1; + if (v.GetName() == "ones") return 1; using AnalysisTree::Types; switch (v.GetFieldType()) { case Types::kFloat: return ANALYSISTREE_UTILS_VISIT(get_field_struct(v.GetFieldId()), data_ptr_); case Types::kInteger: return ANALYSISTREE_UTILS_VISIT(get_field_struct(v.GetFieldId()), data_ptr_); case Types::kBool: return ANALYSISTREE_UTILS_VISIT(get_field_struct(v.GetFieldId()), data_ptr_); - default: throw std::runtime_error("Field type is not correct!"); //NOTE commented because of Ones field NOTE now commented again + default: throw std::runtime_error("Field type is not correct!");//NOTE commented because of Ones field NOTE now commented again } } diff --git a/infra/Chain.cpp b/infra/Chain.cpp index 0d4b6228..c5b7254c 100644 --- a/infra/Chain.cpp +++ b/infra/Chain.cpp @@ -260,7 +260,7 @@ Configuration* Chain::CloneConfiguration() const { const int Nbranches = lob->GetEntries(); for (int i = 0; i < Nbranches; i++) { std::string name_i = lob->At(i)->GetName(); - if(name_i.back() == '.') { + if (name_i.back() == '.') { name_i.pop_back(); } result->RemoveBranchConfig(name_i); diff --git a/infra/Chain.hpp b/infra/Chain.hpp index 69d4ef35..cb2bc794 100644 --- a/infra/Chain.hpp +++ b/infra/Chain.hpp @@ -96,7 +96,7 @@ class Chain : public TChain { /** * @brief Clones tree without friends */ - TTree* CloneChain(int nentries=0); + TTree* CloneChain(int nentries = 0); /** * @brief Clones Configuration of input Chain without friends diff --git a/infra/Cuts.cpp b/infra/Cuts.cpp index 35ff951e..df595ce0 100644 --- a/infra/Cuts.cpp +++ b/infra/Cuts.cpp @@ -44,7 +44,7 @@ bool Cuts::Apply(std::vector& bch, std::vector& id if (!is_init_) { throw std::runtime_error("Cuts::Apply - cut is not initialized!!"); } - if(bch.size() != id.size()) { + if (bch.size() != id.size()) { throw std::runtime_error("AnalysisTree::Cuts::Apply() - BranchChannel and Id vectors must have the same size"); } // std::all_of(cuts_.begin(), cuts_.end(), Apply(a, a_id, b, b_id)); //TODO diff --git a/infra/Field.cpp b/infra/Field.cpp index 1427cffc..9b05551c 100644 --- a/infra/Field.cpp +++ b/infra/Field.cpp @@ -46,7 +46,7 @@ void Field::Init(const BranchConfig& branch_conf) { branch_type_ = branch_conf.GetType(); field_id_ = branch_conf.GetFieldId(field_); field_type_ = branch_conf.GetFieldType(field_); - if (field_id_ == UndefValueInt && field_!="ones") { + if (field_id_ == UndefValueInt && field_ != "ones") { std::cout << "WARNING!! Field::Init - " << field_ << " is not found in branch " << branch_ << std::endl; } is_init_ = true; diff --git a/infra/PlainTreeFiller.cpp b/infra/PlainTreeFiller.cpp index e39d3e00..e7e4585a 100644 --- a/infra/PlainTreeFiller.cpp +++ b/infra/PlainTreeFiller.cpp @@ -5,8 +5,8 @@ #include "TTree.h" -#include "TaskManager.hpp" #include "PlainTreeFiller.hpp" +#include "TaskManager.hpp" namespace AnalysisTree { @@ -57,8 +57,8 @@ void PlainTreeFiller::Init() { plain_tree_->Branch(leaf_name.c_str(), &(vars_.at(i)), Form("%s/F", leaf_name.c_str())); } - for(auto& cm : cuts_map_) { - if(cm.second != nullptr) { + for (auto& cm : cuts_map_) { + if (cm.second != nullptr) { cm.second->Init(*(TaskManager::GetInstance()->GetChain()->GetConfiguration())); } } diff --git a/infra/SimpleCut.cpp b/infra/SimpleCut.cpp index 78000f17..50db3a2b 100644 --- a/infra/SimpleCut.cpp +++ b/infra/SimpleCut.cpp @@ -54,7 +54,7 @@ SimpleCut::SimpleCut(const Variable& var, double min, double max, std::string ti } bool SimpleCut::Apply(std::vector& bch, std::vector& id) const { - if(bch.size() != id.size()) { + if (bch.size() != id.size()) { throw std::runtime_error("AnalysisTree::SimpleCut::Apply() - BranchChannel and Id vectors must have the same size"); } std::vector variables; diff --git a/infra/TaskManager.cpp b/infra/TaskManager.cpp index dcf54915..cfe423cf 100644 --- a/infra/TaskManager.cpp +++ b/infra/TaskManager.cpp @@ -122,8 +122,8 @@ void TaskManager::Finish() { std::cout << "Output file is " << out_file_name_ << std::endl; std::cout << "Output tree is " << out_tree_name_ << std::endl; out_file_->cd(); - if(out_tree_->GetListOfFriends() != nullptr) { - if(out_tree_->GetListOfFriends()->GetEntries() != 0) { + if (out_tree_->GetListOfFriends() != nullptr) { + if (out_tree_->GetListOfFriends()->GetEntries() != 0) { std::cout << "Warining: TaskManager::Finish() - out_tree_ has friends which can be wrongly read from the output file\n"; } } diff --git a/infra/Variable.cpp b/infra/Variable.cpp index 290e5ec8..df32559a 100644 --- a/infra/Variable.cpp +++ b/infra/Variable.cpp @@ -73,20 +73,20 @@ double Variable::GetValue(const BranchChannel& object) const { double Variable::GetValue(std::vector& bch, std::vector& id) const { assert(is_init_); - if(bch.size() != id.size()) { + if (bch.size() != id.size()) { throw std::runtime_error("AnalysisTree::Variable::GetValue() - BranchChannel and Id vectors must have the same size"); } vars_.clear(); for (const auto& field : fields_) { bool success{false}; - for(int i=0; iValue(field)); success = true; break; } } - if(!success) { + if (!success) { throw std::runtime_error("Variable::Fill - Cannot fill value from branch " + field.GetBranchName()); } }