Could you please let me know if there is a way to draw elements of a TMatrixT using TTree::Draw?
Obvious guesses
root [2] t->Draw("x[0][0]");
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
Warning in <TSelectorDraw::ProcessFillObject>: Not implemented for TMatrixT<float>
root [3] t->Draw("x(0,0)");
Error in <TTreeFormula::Compile>: Bad numerical expression : "x(0,0)"
Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {x(0,0),}
root [4] t->Draw("x->GetMatrixArray()[0]"); // All elements are drawn as zeros
if you have the possibility to use a ROOT development release, this might be an opportunity to try the TDataFrame.
You can formulate the “query” like this:
ROOT::Experimental::TDataFrame tdf("myTree","myFile.root");
auto h = tdf.AddColumn("el_00","x(0,0)",{"x"}).Histo1D<float>("el_00") ; // in the master: tdf.Define("el_00", "x(0,0)").Histo1D("el_00");
h->Draw();
$ root.exe
------------------------------------------------------------
| Welcome to ROOT 6.09/02 http://root.cern.ch |
| (c) 1995-2016, The ROOT Team |
| Built for linuxx8664gcc |
| From tag v6-09-02, 8 March 2017 |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------
root [0] ROOT::Experimental::TDataFrame tdf("t", "file.root");
ROOT_prompt_0:1:21: error: no member named 'TDataFrame' in namespace 'ROOT::Experimental'
ROOT::Experimental::TDataFrame tdf("t", "file.root");
Please, let me know if I need to compile ROOT with some special option to enable the experimental code.
root [0] #include "ROOT/TDataFrame.hxx"
root [1] ROOT::Experimental::TDataFrame tdf("tree", "file.root");
root [2] auto h = tdf.AddColumn("el_00", "tree(0,0)", {"tree"}).Histo1D<float>("el_00");
In file included from input_line_11:21:
In file included from .../root-6.09.02.build/etc/dictpch/allHeaders.h:1041:
In file included from .../root-6.09.02.build/include/ROOT/TDFOperations.hxx:14:
.../root-6.09.02.build/include/ROOT/TDFTraitsUtils.hxx:31:54: error: type 'const char *' cannot be used prior to '::' because it has no members
using Args_t = typename TFunctionTraits<decltype(&T::operator())>::Args_t;
^
.../root-6.09.02/include/ROOT/TDataFrame.hxx:483:52: note: in instantiation of template class 'ROOT::Internal::TDFTraitsUtils::TFunctionTraits<const char *>' requested here
auto nArgs = ROOT::Internal::TDFTraitsUtils::TFunctionTraits<F>::Args_t::fgSize;
^
ROOT_prompt_2:1:14: note: in instantiation of function template specialization 'ROOT::Experimental::TDataFrameInterface<ROOT::Detail::TDataFrameImpl>::AddColumn<const char *>' requested here
auto h = tdf.AddColumn("el_00", "tree(0,0)", {"tree"}).Histo1D<float>("el_00");
^
In file included from input_line_11:21:
In file included from .../root-6.09.02.build/etc/dictpch/allHeaders.h:1041:
In file included from .../root-6.09.02.build/include/ROOT/TDFOperations.hxx:14:
.../root-6.09.02.build/include/ROOT/TDFTraitsUtils.hxx:32:61: error: type 'const char *' cannot be used prior to '::' because it has no members
using ArgsNoDecay_t = typename TFunctionTraits<decltype(&T::operator())>::ArgsNoDecay_t;
^
.../root-6.09.02.build/include/ROOT/TDFTraitsUtils.hxx:33:53: error: type 'const char *' cannot be used prior to '::' because it has no members
using Ret_t = typename TFunctionTraits<decltype(&T::operator())>::Ret_t;
^
*** Break *** segmentation violation