Hello,
I have a different set of histograms and I want to store them in separate folders. I am new to ROOT, so I don’t know how to do this.
The following code is the pseudo-code for what I want to do. Please help me with this.
void test()
{
TFile *fout = new TFile("test.root","RECREATE");
TTree *tree = new TTree("tree","tree");
Double_t X;
Double_t Y;
tree->Branch("X", &X, "X/D");
tree->Branch("Y", &X, "Y/D");
// I want these histograms in different folders
TH1F *hist_X = new TH1F("hist_X", "X", 20, 0, 10); // folder name: Many_hist_X
TH1F *hist_Y = new TH1F("hist_Y", "Y", 20, 0, 10); // folder name: Many_hist_Y
for (int i=0; i<10; i++)
{
X = i;
Y = i;
hist_X->Fill(X);
hist_Y->Fill(Y);
tree->Fill();
}
fout->Write();
fout->Close();
}
Thank you,
Divyang.