Re: 2dim correllations with TClonesArray

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Mar 27 1999 - 19:46:39 MET


Hi Leszek,
I already reported a few times that you cannot compare
using TTree::Draw branches having a priori different loop indices.
This is like comparing apples and oranges.
I understand that in your case, this comparison may make sense.
You cannot use directly TTree::Draw in this case, but organize
yourself the loop in the analysis code. You can generate a skeleton
function analysis code via TTree::MakeClass

Rene Brun


On Thu, 25 Mar 1999, Leszek Kidon wrote:

> Hi
> We have problems to draw 2 dimensional correlations using TTree with
> branches based on TClonesArray.
> We have 2 branches with 2 arrays . One has 3 elements another 2 elements
> (For example one branch could be a detector with 3 hits and another a
> detector with 2 hits).We would like to draw 2 dimensional
> correlation between hits on these 2 detectors (for example positions
> measured on both detectors).
> We have expected ROOT to draw all possible combinations of these hits
> (6=3x2). We get different results depending on order we put in Draw
> command  these 2 elements of branches.
> How one can get these 2-dimensional correlations without writing a
> dedicated macros?
> 
> Best regards
> Leszek
> 
> We inlcude a simple macro with the definition of this TTree.
> 
> {
>    TFile *f = new TFile("test.root", "RECREATE");
> 
>    TClonesArray  *atab = new TClonesArray("AAA", 16);
>    TClonesArray  *btab = new TClonesArray("BBB", 16);
> 
>    TTree *tree = new TTree("T", "test");
> 
>    tree->Branch("AAA", &atab, 64000, 1);
>    tree->Branch("BBB", &btab, 64000, 1);
> 
>    new((*atab)[0]) AAA(5, 6);
>    new((*atab)[1]) AAA(4, 5);
>    new((*atab)[2]) AAA(3, 4);
> 
> 
>    new((*btab)[0]) BBB(7, 4);
>    new((*btab)[1]) BBB(6, 3);
> 
> 
>    tree->Fill();
> 
>    f->Write();
>    f->Close();
> 
>    delete f;
> }
> 
> Class definition:
> 
> 
> #include <TObject.h>
> #include <TClonesArray.h>
> 
> class AAA : public TObject
> {
> public:
>   AAA(){A1 = 0; A2 = 0;}
>   AAA(int a1, int a2){A1 = a1; A2 = a2;}
> 
>   int A1;
>   int A2;
> 
>   ClassDef(AAA, 1)
> };
> 
> class BBB : public TObject {
> public:
>   BBB(){B1 = 0; B2 = 0;}
>   BBB(int b1, int b2){B1 = b1; B2 = b2;}
> 
>   int B1;
>   int B2;
> 
>   ClassDef(BBB, 1)
> };
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:30 MET