#include #include #include #include int main() { TFile *hfile = new TFile("hsimple.root","RECREATE"); // Create some histograms, a profile histogram and an ntuple TH1F *hpx = new TH1F("hpx","This is the px distribution",100,-4,4); TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4); TNtuple *ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i"); TRandom r; Float_t px, py, pz; for (Int_t i = 0; i < 25000; i++) { r.Rannor(px,py); pz = px*px + py*py; Float_t random = r.Rndm(1); hpx->Fill(px); hpxpy->Fill(px,py); ntuple->Fill(px,py,pz,random,i); } hfile->Write(); }