Re: Re: Problem with CloneTree

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Fri, 16 Sep 2011 10:54:28 -0500


Hi Francesco,

Copying a TTree that has been set in MakeClass mode is not supported at the moment.

You would need to either load the shared library defining the class EventData or use MakeProxy insted of MakeClass.

Cheers,
Philippe.

> On 16/09/2011 09:33, perfetto_at_na.infn.it wrote:

>> Hi Rooters,
>>
>> I have the following problem (I use root 5.30/01 on osx):
>>
>> Using MakeClass I have had 2 files, .C and a .h.
>> Now in the .C within the Loop() function, I open a root file, get the
>> tree, open a new file and in this new file I clone it.
>> After I create other variables that I would add to this new file; but
>> after the Fill() command, my new tree has the double of entries.
>> Where do I do a mistake ?
>>
>> For clarity I attach a piece of code:
>>
>>
>> void analysis_fra::Loop()
>> {
>> if (fChain == 0) return;
>>
>> Long64_t nentries = fChain->GetEntriesFast();
>>
>> Long64_t nbytes = 0, nb = 0;
>>
>> Double_t sum_min;
>> Bool_t is_cut;
>> Int_t n_pmt;
>>
>> TFile *oldfile = new TFile("run3008.root");<------- In this file there
>> are 23760 entries
>> TTree *oldtree = (TTree*) oldfile->Get("Events");
>> TFile *newfile = new TFile("analisi.root","recreate");
>> TTree *newtree = oldtree->CloneTree();
>>
>> // Some variables that I would add to newtree
>> newtree->Branch("sum_min",&sum_min, "sum_min/D");
>> newtree->Branch("run_id",&run_id, "run_id/I");
>> newtree->Branch("is_cut",&is_cut, "is_cut/B");
>> newtree->Branch("n_pmt",&n_pmt, "n_pmt/I");
>> ....
>>
>> for (Long64_t jentry=0; jentry<nentries;jentry++) {
>> ...
>> sum_min = 0.;
>> n_pmt = 0;
>> for ( Int_t i = 0; i< 35; i++ ) {
>> if (channels_npulses[i]> 0) {
>> is_cut = kTRUE;
>> sum_min = sum_min - channels_minimum[i] + channels_baseline_mean[i]; n_pmt
>> = n_pmt + 1;
>> ...
>> }
>> }
>>
>> newtree->Fill();<------- If I comment this line I have the correct
>> entries 23760, but obviously I don't have the new variables in the tree. }
>> newtree->Write();
>> newfile->Write();
>> newfile->Close();
>> delete oldfile;
>> delete newfile;
>> }
>> When open newtree this has 47520 entries.
>>
>> Thank in advance
>> Francesco.
>>
>>
>>

> Received on Fri Sep 16 2011 - 17:54:38 CEST

This archive was generated by hypermail 2.2.0 : Fri Sep 16 2011 - 23:50:01 CEST