Hi Suvayu,
*first* load the TTree's entry, *then* access its data, not the other way around :-)
Cheers, Axel.
Suvayu Ali wrote on 11/24/2009 08:30 AM:
> Hi everyone,
>
> I think I am missing some extremely simple step, but I can't figure this
> one out. :(
>
> I am creating some TLorentzVectors from a flat ntuple and saving them in
> a TTree using TClonesArray using a class originally created by
> TTree::MakeClass(). I have only edited the Loop() method. This is how I
> am attempting it.
>
>> TFile fout("ttbar-dil.root","recreate");
>> TTree *fEventsTree = new TTree("EventCollection", "Zprime-->ttbar");
>> TClonesArray jetsLV("TLorentzVector", 2);
>> TClonesArray lepLV("TLorentzVector", 2);
>> TClonesArray metLV("TLorentzVector", 2);
>> ...
>> fEventsTree->Branch( "Jets", &jetsLV);
>> fEventsTree->Branch( "Leptons", &lepLV);
>> fEventsTree->Branch( "MET", &metLV);
>> ...
>> // code to implement cuts and fill the Tree,
>> ...
>> fout.Write();
>> fout.Close();
>> TFile *fin1 = new TFile("ttbar-dil.root", "read");
>> TTree *fEvents1 = (TTree*) fin1->Get("EventCollection");
>> TClonesArray *jetsLV1 = new TClonesArray("TLorentzVector");
>> TClonesArray *lepLV1 = new TClonesArray("TLorentzVector");
>> ...
>> fEvents1->SetBranchAddress("Jets", &jetsLV1);
>> fEvents1->SetBranchAddress("Leptons", &lepLV1);
>> Int_t njets = jetsLV1->GetEntriesFast(); >> Int_t nlep = lepLV1->GetEntriesFast();
This archive was generated by hypermail 2.2.0 : Tue Nov 24 2009 - 23:50:01 CET