Re: Plot time series from TTree

From: Eduard Avetisyan <Eduard.Avetisyan_at_desy.de>
Date: Mon, 18 Oct 2010 22:53:26 +0200

Hi Benjamin,

On Mon, 18 Oct 2010, Benjamin Bannier wrote:

> Dear ROOT experts,
>
> I would like to plot the development of a TTree variable over time and
> was wondeing if there was a shortcut for that build into TTree::Draw.
>
> I have a TTree `t` with one branch `x` and would essentially like to do
> something like
>
> t.Draw("x:MAGIC_DUMMY_VAR_FOR_ENTRY_NUM", "", "col");

This magic dummy would then be Entry$ (see http://root.cern.ch/root/html526/TTree.html#TTree:Draw for more magic with entry numbers and all)...

Cheers

        Eduard

>
> where the resulting TH2 would have `x` averaged over some default
> "number-of-entries" bin.
>
> What I do now is
>
> float x;
> t.SetBranchAddress("x", &x);
> std::vector<float> xv;
> std::vector<float> iv;
> const size_t n = t.GetEntries();
> for (int i=0; i<n; ++i) {
> t.GetEntry(i);
> xv.push_back(x);
> iv.push_back(i);
> }
>
> TGraph g(n, &iv[0], &xv[0]);
> // etc
>
> but this makes it hard to see overall structure for large `n`.
>
>
> Thanks,
>
> Benjamin
>
Received on Mon Oct 18 2010 - 22:53:32 CEST

This archive was generated by hypermail 2.2.0 : Tue Oct 19 2010 - 17:50:02 CEST