Skip to content

Commit 8954d69

Browse files
committed
PlainTreeFiller - add warning when try to ignore or preserve absent field
1 parent 2b64796 commit 8954d69

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

infra/PlainTreeFiller.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,23 @@ void PlainTreeFiller::Init() {
7979

8080
if (vars_.size() != vars.size()) throw std::runtime_error("PlainTreeFiller::Init(): vars_.size() != vars.size()");
8181

82+
std::vector<std::string> leafNames;
83+
for (int iVar = 0, nVars = vars.size(); iVar < nVars; ++iVar) {
84+
leafNames.emplace_back(vars[iVar].GetName());
85+
}
86+
87+
for (const auto& fti : fields_to_ignore_) {
88+
if (std::find(leafNames.begin(), leafNames.end(), fti) == leafNames.end()) {
89+
std::cout << "WARNING PlainTreeFiller::Init(): field " << fti << " is set to be ignored, but it is absent among input fields\n";
90+
}
91+
}
92+
93+
for (const auto& ftp : fields_to_preserve_) {
94+
if (std::find(leafNames.begin(), leafNames.end(), ftp) == leafNames.end()) {
95+
std::cout << "WARNING PlainTreeFiller::Init(): field " << ftp << " is set to be preserved, but it is absent among input fields\n";
96+
}
97+
}
98+
8299
file_ = TFile::Open(file_name_.c_str(), "recreate");
83100
plain_tree_ = new TTree(tree_name_.c_str(), "Plain Tree");
84101
plain_tree_->SetAutoSave(0);

0 commit comments

Comments
 (0)