Hi, experts
I am modifying codes from TMVAClassification.C. The code shown below is at the part before the invocation of TMVA::Factory
, and I want to select only some numbers of entries from the S/B tree (without generating extra root file), so I did it with CopyTree.
However, if the CopyTree
code is put right after getting the original tree (the commented part), (in some situation, like Nselect
is large) the following error will be thrown
Error in <TSystem::ExpandFileName>: input: $HOME/.root.mimes, output: $HOME/.root.mimes
Error in <TBranch::TBranch::WriteBasketImpl>: basket's WriteBuffer failed.
On the other hand, if the ``CopyTreecode is put in its current location in the code, only the first error was thrown, and the output of the training result contains an extra Tree (I believe it was the mix of my S&B tree). But I did not code to
Write()``` the cloned tree whatsoever.
//Register the tree
TTree *sigTreeOri = (TTree*)inputSigFile->Get("tree");
TTree *bkgTreeOri = (TTree*)inputBkgFile->Get("tree");
// int Nselect = 25000;
// TTree *sigTree = sigTreeOri->CopyTree("", "", Nselect , 0);
// TTree *bkgTree = bkgTreeOri->CopyTree("", "", Nselect , 0);
//Create output file for the tmva training results
TString outfileName("TMVA.root");
TFile* outputFile = TFile::Open(outfileName, "RECREATE");
int Nselect = 25000;
TTree *sigTree = sigTreeOri->CopyTree("", "", Nselect , 0);
TTree *bkgTree = bkgTreeOri->CopyTree("", "", Nselect , 0);
could you point out what could possibly went wrong ?
Also, some doubts:
- could I possibly prevent the cloned tree to be written by some functions ?
- Is CloneTree better, if i just want to select a number of events from the original tree ?
- I just found
TTree->SetEntries()
. Does that function does the same job ?
Thanks in advance.
_ROOT Version: 6.24 (PyROOT via conda)
_Platform:Centos7
_Compiler: gcc9