Wonderful thank you.
Here is the second try.
using namespace std;
struct Projection
{
struct Position { Float_t x,y; };
Position var1;
Position var2;
TLorentzVector v;
};
Bool_t test()
{
TFile *f = new TFile("test.root", "UPDATE");
TTree T("T","test list");
struct Projection p;
struct Projection p2;
T.Branch("var1.","Projection",&p, 32000, 1);
p.var1.x = 1;
p.var2.x = 1;
p.var1.y = 2;
p.var2.y = 2;
p.v.SetPxPyPzE(0,0,1,-1);
T.Fill();
p.var1.x = 10;
p.var2.x = 10;
p.var1.y = 20;
p.var2.y = 20;
p.v.SetPxPyPzE(0,0,100,-100);
T.Fill();
T.Print();
T.Write();
f->Close();
return 1;
}
From now this test.C script is generating warning messages, because of dictionary. This I understand.
It doesn’t know about my structure obviously.
But why do I get the following warning, when my file doesn’t exists ? And not if my test.root already exists ?
> root -l test.C
root [0]
Processing test.C...
Warning in <TStreamerInfo::Build>: Projection: Projection::Position has no streamer or dictionary, data member "var1" will not be saved
Warning in <TStreamerInfo::Build>: Projection: Projection::Position has no streamer or dictionary, data member "var2" will not be saved
******************************************************************************
*Tree :T : test list *
*Entries : 2 : Total = 3175 bytes File Size = 0 *
* : : Tree compression factor = 1.00 *
******************************************************************************
*Branch :p1. *
*Entries : 2 : BranchElement (see below) *
*............................................................................*
*Br 0 :p1.var1 : Projection::Position *
*Entries : 2 : Total Size= 703 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 1 :p1.var2 : Projection::Position *
*Entries : 2 : Total Size= 703 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 2 :p1.v : TLorentzVector *
*Entries : 2 : Total Size= 777 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
> root -l test.C
root [0]
Processing test.C...
******************************************************************************
*Tree :T : test list *
*Entries : 2 : Total = 3219 bytes File Size = 690 *
* : : Tree compression factor = 1.00 *
******************************************************************************
*Branch :p1. *
*Entries : 2 : BranchElement (see below) *
*............................................................................*
*Br 0 :p1.var1 : Projection::Position *
*Entries : 2 : Total Size= 703 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 1 :p1.var2 : Projection::Position *
*Entries : 2 : Total Size= 703 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 2 :p1.v : TLorentzVector *
*Entries : 2 : Total Size= 777 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
Futhermore, it seems to have some issues with the substructure I defined (Projection::Position). But in fact, data members are saved…
So is those messages harmless ?
Since my tree knows the structure when I read my test.root, is it possible to remove the following error messages ?
> root -l test.root
root [0]
Attaching file test.root as _file0...
Warning in <TClass::Init>: no dictionary for class Projection is available
Warning in <TClass::Init>: no dictionary for class Projection::Position is available
(TFile *) 0x563113728750
Thank you for your help !