Hi Eduard
thanks. The selections I want to apply are much complex and cannot be expressed in char *.
Margar
On Tue, Apr 12, 2011 at 3:16 PM, Eduard Avetisyan
<Eduard.Avetisyan_at_desy.de> wrote:
>
> Hi Margar,
>
> I used to successfully achieve what you are aiming now via the
> TTree::CopyTree method. An additional benefit is that you may impose
> selection cuts to reduce your tree size by stripping useless entries off.
>
> Hope this helps,
> Eduard
>
> P.S. A short example below:
>
> {
> TChain h1("h1");
> h1.Add("../h_hdunpol_00d0.root");
> h1.Add("../h_unpol_00d0.root");
> h1.Add("../../98/h_unpol_98d0.root");
>
> //Create a new file + a clone of old tree in new file
> TFile *newfile = new TFile("h_9800d0" "_pi+.root","recreate");
> TTree *newtree = h1.CopyTree("pos>0 && ph>0");
>
> newtree->SetName("piplus");
> newtree->SetTitle("98/2000 unpol H pi+");
> newtree->Print();
> newfile->Write();
> delete newfile;
> }
>
> On Tue, 12 Apr 2011, Philippe Canal wrote:
>
>> Hi Margar,
>>
>> Then all the ingredients are there and it should work ... unless their
>> ordering
>> and calls are wrongly set (I would need more code to know).
>>
>> Cheers,
>> Philippe.
>>
>> On 4/12/11 8:02 AM, Margar Simonyan wrote:
>> > Hi Philippe
>> >
>> > sorry, that was a typo in the e-mail, I have
>> > chain->SetBranchStatus("*", 1) in the code, as well as LoadEntry,
>> > GetEntry etc.
>> >
>> > Margar
>> >
>> >
>> >
>> > On Tue, Apr 12, 2011 at 2:58 PM, Philippe Canal<pcanal_at_fnal.gov> wrote:
>> > > Hi Margar,
>> > >
>> > > (Besides the missing LoadEntry, GetEntry and SetBranchAddress which I
>> > > assume
>> > > are in the routines
>> > > you did no show), it seems that the problem is the 2nd argument of the 2nd
>> > > SetBranchStatus,
>> > > I think it should read:
>> > >
>> > > chain->SetBranchStatus("*", 1);
>> > >
>> > > Cheers,
>> > > Philippe.
>> > >
>> > > On 4/12/11 2:43 AM, Margar Simonyan wrote:
>> > > > Hello ROOTTalk
>> > > >
>> > > > I would like to copy selected entries of some branches of TChain to
>> > > > another tree. So far my attempt work for single tree but not for a
>> > > > chain. Simplified logic looks like this:
>> > > >
>> > > > type var1;
>> > > > TBranch * b1=0;
>> > > > chain->SetBranchAddress("var1",&var1,&b)
>> > > >
>> > > > chain->SetBranchStatus("*", 0)
>> > > > chain->SetBranchStatus("var1", 1);
>> > > >
>> > > > f = TFile::Open("file.root", "UPDATE");
>> > > > newTree = chain->CloneTree(0);
>> > > >
>> > > > now have to enable all branches since they are needed for event
>> > > > selection
>> > > > chain->SetBranchStatus("*", 0);
>> > > > for(; ; )
>> > > > if(selection_function())
>> > > > newTree->Fill()
>> > > >
>> > > >
>> > > > The trees are connected and when a new file is opened in chain things
>> > > > go wrong. I tried reseting the branch addresses, but it didn't work.
>> > > > Is there any way to get it working?
>> > > >
>> > > > Thanks,
>> > > > Margar
>> > > > -------------------------------------------------------------------------
>> > > > Dr Margar Simonyan, post-doctoral researcher
>> > > > Niels Bohr Institute, Copenhagen University
>> > > > -------------------------------------------------------------------------
>> > > >
>>
>>
>
Received on Tue Apr 12 2011 - 15:22:23 CEST
This archive was generated by hypermail 2.2.0 : Tue Apr 12 2011 - 17:50:01 CEST