I can see it showing up as Tag.fTag, but when trying to use it in a Filter:
auto myLYHisto = df.Filter("Tag.fTag > 1").Histo1D(...);
I get a segmentation violation:
Tag.fTag
bdtDiscr
Total number of events: 1598010
Error in <TTreeCache::AddBranch>: unknown branch -> Tag.fTag
Error in <TBranchProxy::Read>: Unable to initialize Tag.fTag
*** Break *** segmentation violation
Error in <TTreeCache::AddBranch>: unknown branch -> Tag.fTag
Error in <TBranchProxy::Read>: Unable to initialize Tag.fTag
...
Any ideas?
Thanks,
Balint
_ROOT Version: 6.16.00
_Platform: Mac OS 10.14.3 Compiler: Not Provided
Hi,
thanks a lot for taking a look. Please find a few events attached.
For fTag I get this error:
input_line_73:1:46: error: use of undeclared identifier 'fTag'
namespace __tdf_0{ auto tdf_f = []() {return fTag > 1
^
Error in <TRint::HandleTermInput()>: std::runtime_error caught: Cannot interpret the following expression:
fTag > 1
Make sure it is valid C++.
Hi,
thank you for the file. I can reproduce the problem, and this is now jira ticket 10046. You can follow the development there.
As a partial workaround, at least if you don’t enable multi-threading with EnableImplicitMT(), you can read that branch if you construct the RDataFrame by passing the TTree object directly:
thanks a lot for creating a jira ticket and taking a look at the issue.
In the meantime I have used the temporary workaround suggested by Enrico, and the following works:
TFile f("test.root");
TTree *tree = nullptr;
f.GetObject("miniTree", tree);
ROOT::RDataFrame df(*tree, {"Tag.fTag"});
std::vector<std::string> colNames = df.GetColumnNames();
for(int i = 0; i < colNames.size(); i++){
std::cout << colNames[i] << std::endl;
}
// Cut
auto cutb1 = [](int tag) { return tag == 1; };
// Get number of events:
auto c_totevents = df.Count();
std::cout << "Total number of events: " << *c_totevents << std::endl;
//---------------------------------------------------
auto c1 = new TCanvas("c1", "c1", 100, 100, 800, 600);
auto myCut = df.Filter(cutb1, "Tag.fTag");
auto myCutCount = df.Filter(cutb1, "Tag.fTag").Count();
auto myVec = myCut.Take<int>();
std::cout << "N of entries: " << *myCutCount << std::endl;
std::cout << "Selected entries" << std::endl;
for (auto my_entry : *myVec)
std::cout << my_entry << " ";
std::cout << std::endl;
But if in addition, I want to make a Hist1D out of another variable, using the cut
on this Tag.fTag, then it crashes again, or creates empty histo…
auto myLYHisto = df.Filter("Tag.fTag == 1").Histo1D("LYTotal");
myLYHisto->DrawClone();