45 TFile f(
"tree104.root",
"recreate");
46 TTree t1(
"t1",
"a simple Tree with simple variables");
50 t1.Branch(
"px", &px,
"px/F");
51 t1.Branch(
"py", &py,
"py/F");
52 t1.Branch(
"pz", &pz,
"pz/F");
53 t1.Branch(
"random", &random,
"random/D");
54 t1.Branch(
"ev", &ev,
"ev/I");
57 for (
Int_t i=0; i<10000; i++) {
59 pz = px * px + py * py;
81 t1->SetBranchAddress(
"py", &py);
82 t1->SetBranchAddress(
"pz", &pz);
83 t1->SetBranchAddress(
"random", &random);
84 t1->SetBranchAddress(
"ev", &ev);
87 auto hpx =
new TH1F(
"hpx",
"px distribution", 100, -3, 3);
88 auto hpxpy =
new TH2F(
"hpxpy",
"py vs px", 30, -3, 3, 30, -3, 3);
100 if (
gROOT->IsBatch())
109 t1->ResetBranchAddresses();
R__EXTERN TRandom * gRandom
Using a TBrowser one can browse all ROOT objects.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
1-D histogram with a float per channel (see TH1 documentation)
2-D histogram with a float per channel (see TH1 documentation)
Double_t Rndm() override
Machine independent random number generator.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
A TTree represents a columnar dataset.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=nullptr)
Change branch address, dealing with clone trees properly.