00001 void dirs() {
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 TFile *top = new TFile("top.root","recreate");
00028
00029
00030 TDirectory *cdtof = top->mkdir("tof");
00031 cdtof->cd();
00032
00033
00034 const Int_t nplanes = 10;
00035 const Int_t ncounters = 100;
00036 char dirname[50];
00037 char hname[20];
00038 char htitle[80];
00039 Int_t i,j,k;
00040 TDirectory *cdplane[nplanes];
00041 TH1F *hn[nplanes][ncounters];
00042 TH1F *hs[nplanes][ncounters];
00043 for (i=0;i<nplanes;i++) {
00044 sprintf(dirname,"plane%d",i);
00045 cdplane[i] = cdtof->mkdir(dirname);
00046 cdplane[i]->cd();
00047
00048 for (j=0;j<ncounters;j++) {
00049 sprintf(hname,"h%d_%dN",i,j);
00050 sprintf(htitle,"hist for counter:%d in plane:%d North",j,i);
00051 hn[i][j] = new TH1F(hname,htitle,100,0,100);
00052 sprintf(hname,"h%d_%dS",i,j);
00053 sprintf(htitle,"hist for counter:%d in plane:%d South",j,i);
00054 hs[i][j] = new TH1F(hname,htitle,100,0,100);
00055 }
00056 cdtof->cd();
00057 }
00058
00059
00060 TRandom r;
00061 for (i=0;i<nplanes;i++) {
00062 cdplane[i]->cd();
00063 for (j=0;j<ncounters;j++) {
00064 for (k=0;k<100;k++) {
00065 hn[i][j]->Fill(100*r.Rndm(),i+j);
00066 hs[i][j]->Fill(100*r.Rndm(),i+j+k);
00067 }
00068 }
00069 }
00070
00071
00072 top->Write();
00073 delete top;
00074 }
00075