TTree with several branches

Hi,

I’m trying to generate a tree with 64 branches.
I read from 64 different files the values and trying to fill the tree like this

[code]
TFile *f = new TFile(“LVnt.root”,“RECREATE”);
TTree *tree = new TTree(“DCS Tree”,“LVPS data retrieved from Oracle”);
TBranch *branch;
ifstream dataFile;
LVPS_var var;

for(int moduleNumber=1; moduleNumber<65; moduleNumber++)
{
sprintf(branch_name,"%s%02i", drawer.c_str(),moduleNumber);
sprintf(tmpFiles_name,".%s%02i", drawer.c_str(),moduleNumber);
dataFile.open(tmpFiles_name);

//this line is not broken in the original code
branch=tree->Branch(branch_name,&var.P3VDIG_INPUT_V,
“P3VDIG_INPUT_V/D:P3VDIG_INPUT_I:P3VDIG_OUTPUT_V:P3VDIG_OUTPUT_I:P3VDIG_SENSES:P3VDIG_TEMP3:P5VDIG_INPUT_V:P5VDIG_INPUT_I:P5VDIG_OUTPUT_V:
P5VDIG_OUTPUT_I:P5VDIG_SENSES:P5VDIG_TEMP3:P5VMB_INPUT_V:P5VMB_INPUT_I:P5VMB_OUTPUT_V:P5VMB_OUTPUT_I:P5VMB_SENSES:
P5VMB_TEMP3:P15VMB_INPUT_V:P15VMB_INPUT_I:P15VMB_OUTPUT_V:P15VMB_OUTPUT_I:P15VMB_SENSES:P15VMB_TEMP3:P5VHV_INPUT_V:
P5VHV_INPUT_I:P5VHV_OUTPUT_V:P5VHV_OUTPUT_I:P5VHV_SENSES:P5VHV_TEMP3:P15VHV_INPUT_V:P15VHV_INPUT_I:P15VHV_OUTPUT_V:P15VHV_OUTPUT_I:
P15VHV_SENSES:P15VHV_TEMP3:M5VMB_INPUT_V:M5VMB_INPUT_I:M5VMB_OUTPUT_V:M5VMB_OUTPUT_I:M5VMB_SENSES:M5VMB_TEMP3:M15VHV_INPUT_V:
M15VHV_INPUT_I:M15VHV_OUTPUT_V:M15VHV_OUTPUT_I:M15VHV_SENSES:M15VHV_TEMP3:
STATES_FORDAQ_MB:STATES_FORDAQ_HV:time/I”, 1);

	while(!dataFile.eof())
	{
		dataFile>>var->time>>var.P3VDIG_INPUT_I>>var.P3VDIG_INPUT_V
		>>var.P3VDIG_OUTPUT_I>>var.P3VDIG_OUTPUT_V>>var.P3VDIG_SENSES
		>>var.P3VDIG_TEMP3>>var.P5VDIG_INPUT_I>>var.P5VDIG_INPUT_V
		>>var.P5VDIG_OUTPUT_I>>var.P5VDIG_OUTPUT_V>>var.P5VDIG_SENSES
		>>var.P5VDIG_TEMP3>>var.P5VHV_INPUT_I>>var.P5VHV_INPUT_V
		>>var.P5VHV_OUTPUT_I >>var.P5VHV_OUTPUT_V>>var.P5VHV_TEMP3
		>>var.P5VMB_INPUT_I>>var.P5VMB_INPUT_V>>var.P5VMB_OUTPUT_I
		>>var.P5VMB_OUTPUT_V>>var.P5VMB_SENSES>>var.P5VMB_TEMP3
		>>var.M5VMB_INPUT_I>>var.M5VMB_INPUT_V>>var.M5VMB_OUTPUT_I
		>>var.M5VMB_OUTPUT_V >>var.M5VMB_SENSES>>var.M5VMB_TEMP3
		>>var.P15VMB_INPUT_I>>var.P15VMB_INPUT_V>>var.P15VMB_OUTPUT_I 
		>>var.P15VMB_OUTPUT_V>>var.P15VMB_SENSES>>var.P15VMB_TEMP3
		>>var.P15VHV_INPUT_I >>var.P15VHV_INPUT_V>>var.P15VHV_OUTPUT_I 
		>>var.P15VHV_OUTPUT_V>>var.P15VHV_TEMP3	>>var.M15VHV_INPUT_I
		>>var.M15VHV_INPUT_V>>var.M15VHV_OUTPUT_I>>var.M15VHV_OUTPUT_V
		>>var.M15VHV_TEMP3>>var.STATES_FORDAQ_MB>>var.STATES_FORDAQ_HV;
		
		var.P5VHV_SENSES=0.;
		var.P15VHV_SENSES=0.;
		var.M15VHV_SENSES=0.;
		tree->Fill();
		
	}
	dataFile.close();
}

f->Write();
f->Close();[/code]

All branches are being created but just the first one is filled when I run this program code.

What am I doing wrong?

Cheers

[quote]What am I doing wrong? [/quote]You may (or may not) have made a typo or type error in transcribing the list of datamembers. More likely you hit a limitation of the TTree Branch method taking a leaflist, which is unable to know if the compiler (or CINT) has added padding between the data members (which happens very often especially if you alternate data member of various sizes).

I recommend that instead you compile you script (including the definition of LVPS_var) and use the ‘object’ branch syntax:

LVPS_var *var = new LVPS_var; .... tree->Branch(branch_name,&var);

If for some reason this is not an option, I then recommend that you create 64 separate branches instead.

Cheers,
Philippe