TTree with variable length array

Hi,
I really appreciate the job you do here.
And I have a small problem.

I create a TTree with variable length array based on the manual
and everything is ok. I have int arrays chan[] and val[] as channel and value.
With this
nEmcPhotons->Draw(“chan:val”,“chan[Iteration$]==2”,“col”)
I plot values for channel 2.

But, is there possible to draw 2D histogram, where x==values from channel 1
and y==values from channel 2?

It means probably to iterate two arrays separately…?

thank you
jaromir

[quote]But, is there possible to draw 2D histogram, where x==values from channel 1
and y==values from channel 2? [/quote]If you want to do so for specific indices you could do:nEmcPhotons->Draw("val[1]:val[2]","","col")

To do what you want you probably need to do: nEmcPhotons->SetEstimate(nEmcPhotons->GetEntries()); nEmcPhotons->Draw("val","chan==1","goff"); double *val1 = new double[nEmcPhotons->GetEntries()]; memcpy(val1, nEmcPhotons->GetV1(), nEmcPhotons->GetEntries()*sizeof(double)); nEmcPhotons->Draw("val","chan==2","goff"); TGraph *g = new TGraph(nEmcPhotons->GetEntries(),val1, nEmcPhotons->GetV1());[This assumes that every event has both a chan==1 and a chan==2]

Cheers,
Philippe

Thank you, to see exactly what I have:

[ul]
void vartree(){

Int_t nPhot=0;
Float_t E[500];
int chan[500]; //new test
int val[500];

TFile f=new TFile(“w.root”, “RECREATE”);
TTree
nEmcPhotons = new TTree(“nEmcPhotons”,“EMC Photons”);
nEmcPhotons->Branch(“nPhot”,&nPhot,“nPhot/I”);
nEmcPhotons->Branch(“E”,E,“E[nPhot]/F”);

// channel - value pair: <<<< this is my data
nEmcPhotons->Branch(“chan”,chan,“chan[nPhot]/I”);
nEmcPhotons->Branch(“val”, val, “val[nPhot]/I”);


[/ul]

I have in general 1000 parameters, but I really use just few. The idea was to
keep in the variable field just parameter number in chan[] and parameter value in val[].
I see that it is not possible to something very simple like
ttree->Draw(“val[Iteration1$]:val[Iteration2$]”,“chan[Iteration1$]==1 && chan[[Iteration2$]==2”)

Thank you anyway, I will try to store all array to see how much memory it will take…

best regards

jaromir