Re: [ROOT] How to use vector in Event?

From: Alexander Bürger (buerger@hiskp.uni-bonn.de)
Date: Wed Sep 03 2003 - 15:31:16 MEST


Hi Rene,

No, I did not use MakeClass. I have a small program reading events from 
a file and putting them into a TTree. To analyze the tree, I only use 
tree viewer, either by clicking or with

	T->Draw("time");

Saying this with the

	float* time; //[count]

gives me a spectrum of all the time values of the time array in all the 
events in the tree. When I use

	vector<float> time; //[count]

(or without //[...]) the spectrum just shows entries at channel zero 
after calling

	T->Draw("time");

What I would like to have is vector<> and still a nice time spectrum 
when doubleclicking in the tree viewer.

Best wishes,

Alexander

> It looks like you have generated an analysis function via 
> TTree::MakeClass or MakeSelector.
> The maximum dimension for [count] in the generated header file
> is based on the maximum value of count for the file used to generate the 
> code. Simply extend this dimension when using it with a TChain
> such that the maximum value of [count] can be digested.

>>to put my Events into a Tree I have a class similar to the following:
>>
>>class TEvent {
>>	int count;
>>	float *time; //[count];
>>};
>>
>>I like this, because in the tree viewer I can click and I get a nice time
>>spectrum. Unfortunately, I made some mistake in memory allocation so that
>>when I used TChain to chain several files, I did not get spectra, but only
>>segfaults, while with a single TFile it was working.
>>
>>Before fixing the problem I tried to use a class like
>>
>>class TEvent {
>>	int count;
>>	std::vector<float> time; //[count]
>>};
>>
>>to circumvent manual memory allocation and also to avoid re-allocation of
>>the array for each event in reading from the tree. But I did not get this
>>to work in the tree viewer: the time spectrum just showed zeroes.
>>
>>How can I use the vector<> in a way compatible with the tree viewer?



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET