This example illustrates how to make a Tree from variables or arrays in a C struct - without a dictionary, by creating the branches for builtin types (int, float, double) and arrays explicitly.
See tree2a.C for the same example using a class with dictionary instead of a C-struct.
In this example, we are mapping a C struct to one of the Geant3 common blocks /gctrak/. In the real life, this common will be filled by Geant3 at each step and only the Tree Fill function should be called. The example emulates the Geant3 step routines.
to run the example, do:
typedef struct {
{
}
{
TFile f(
"tree2.root",
"recreate");
TTree t2(
"t2",
"a Tree with data from a fake Geant3");
t2.Branch(
"vect",
gstep.vect,
"vect[7]/F");
t2.Branch(
"lmec",
gstep.lmec,
"lmec[nmec]/I");
for (
Int_t i=0;i<10000;i++) {
}
}
}
{
}
t2->Draw(
"vect[0]:vect[1]:vect[2]");
t2->ResetBranchAddresses();
}
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
R__EXTERN TRandom * gRandom
A TTree is a list of TBranches.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
1-D histogram with a float per channel (see TH1 documentation)
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Double_t Rndm() override
Machine independent random number generator.
A TTree represents a columnar dataset.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
- Author
- Rene Brun
Definition in file tree2.C.