Manage TNtuple

Hi there,
I get an ntuple (pjmca) made by ch0:ch1:ch2:ch3 from the rootfile of the experiment.
I’ve got three linear functions to calibrate ch0 ch1 ch2 and ch3 and I need to create a new ntuple starting from the channels of the old one because in data analysis I’d like to work with calibrated quantities and not with the number of ADC’s channel.

//open file
TFile *f = new TFile("myrootfile.root");
//get ntuple
TNtuple *old_ntuple = (TNtuple*)f->Get("pjmca");
new_ntuple = new TNtuple("new_ntuple", "calibrated channel", "cch0:cch1:cch2:cch3");

Now, how can I fill new_ntuple with expression like:

new_ntuple->Fill(ch0*a+b,ch1*a+b,ch2*a+b,ch3); 

Thank you

Do:[code]
struct Data {
Float_t cch0;
Float_t cch1;
Float_t cch2;
Float_t cch3;
}

//open file
TFile f = new TFile(“myrootfile.root”);
//get ntuple
TNtuple old_ntuple = (TNtuple)f->Get(“pjmca”);
Data data = (Data)old_ntuple->GetArgs();
new_ntuple = new TNtuple(“new_ntuple”, “calibrated channel”, “cch0:cch1:cch2:cch3”);
For(Long64_t entry = 0; entry < old_ntuple->GetEntries(); ++entry) {
old_ntuple->GetEntry(entry);
new_tuple->Fill(data->cch0
a+b,data->cch1a+b,data->cch2a+b,data->cch3);
}
f->Write();[/code]Cheers,
Philippe.

Well done. Thank you.
Cheers
m