ROOT logo

From $ROOTSYS/tutorials/io/testMergeCont.C

TFile *f;

void testMergeCont()
{
   // Macro to test merging of containers.
   TString tutdir = gROOT->GetTutorialsDir();
   gROOT->LoadMacro(tutdir+"/hsimple.C");
   TList *list = GetCollection();
   TList *inputs = new TList();
   for (Int_t i=0; i<10; i++) {
      inputs->AddAt(GetCollection(),0);
      list->Merge(inputs);
      inputs->Delete();
      f->Close();
   }
   delete inputs;
   TH1F *hpx = (TH1F*)(((TList*)list->At(1))->At(0));
   printf("============================================\n");
   printf("Total  hpx: %d entries\n", hpx->GetEntries());
   hpx->Draw();
   list->Delete();
   delete list;
}


TSeqCollection *GetCollection()
{
   TObject *obj;
   f = TFile::Open("hsimple.root");
   if ( !f ) f = hsimple(1);
   gROOT->cd();
   TList *l0 = new TList();
   TList *l01 = new TList();
   TH1 *hpx = (TH1*)f->Get("hpx");
   printf("Adding hpx: %d entries\n", hpx->GetEntries());
   l01->Add(hpx);
   TH1 *hpxpy = (TH1*)f->Get("hpxpy");
   l01->Add(hpxpy);
   TH1 *hprof = (TH1*)f->Get("hprof");
   l0->Add(hprof);
   l0->Add(l01);
   return l0;
}
 testMergeCont.C:1
 testMergeCont.C:2
 testMergeCont.C:3
 testMergeCont.C:4
 testMergeCont.C:5
 testMergeCont.C:6
 testMergeCont.C:7
 testMergeCont.C:8
 testMergeCont.C:9
 testMergeCont.C:10
 testMergeCont.C:11
 testMergeCont.C:12
 testMergeCont.C:13
 testMergeCont.C:14
 testMergeCont.C:15
 testMergeCont.C:16
 testMergeCont.C:17
 testMergeCont.C:18
 testMergeCont.C:19
 testMergeCont.C:20
 testMergeCont.C:21
 testMergeCont.C:22
 testMergeCont.C:23
 testMergeCont.C:24
 testMergeCont.C:25
 testMergeCont.C:26
 testMergeCont.C:27
 testMergeCont.C:28
 testMergeCont.C:29
 testMergeCont.C:30
 testMergeCont.C:31
 testMergeCont.C:32
 testMergeCont.C:33
 testMergeCont.C:34
 testMergeCont.C:35
 testMergeCont.C:36
 testMergeCont.C:37
 testMergeCont.C:38
 testMergeCont.C:39
 testMergeCont.C:40
 testMergeCont.C:41
 testMergeCont.C:42
 testMergeCont.C:43
 testMergeCont.C:44