Creating a root file containing only one histogram

From: Michelle Mesquita Medeiros <michelle_mmed_at_yahoo.com.br>
Date: Thu, 17 Mar 2011 09:50:58 -0700


Hello ROOTers,

I'm trying to create a root file containing only one histogram with 100 bins and errors bars using a variable I have in a lot of others root files. Does someone knows how to do this? I wrote the script below, but it's not working...

void separ()
{
gROOT->Reset();
TChain *chain = new TChain("sim");

chain->Add("/home/michelle/Documents/NEWERFILES/newer46.root"); chain->Add("/home/michelle/Documents/NEWERFILES/newer47.root"); [...]

   chain->SetBranchStatus("*",0);
   chain->SetBranchStatus("varzen",1);

   TTree *varzen = 0;
   chain->SetBranchAddress("varzen",&varzen);

   TFile *var = new TFile("var.root","recreate");
   TTree *tree_moon = chain->CloneTree(0);

   TH1F *hvar = new TH1F("hvar","var",100,0.0,10.0);
   tree_moon->Branch("hvar",&hvar);

   for (Int_t i=0; i < chain->GetEntries(); i++)

    {
         chain->GetEvent(i);              
         hvar->Fill(varzen->GetEntries());           
         tree_moon->Fill();

   }
   hvar->Draw("E");

   tree_moon->Print();
   var->Write();
   delete chain;
   delete var;

}

When I compile it I have the error:

 *** Break *** segmentation violation
Root > Function separ() busy flag cleared

Thanks in advance,



Michelle Mesquita de Medeiros
Instituto de Física - UFG
e-mail: medeiros_at_fnal.gov
medeiros_at_posgrad.ufg.br Received on Thu Mar 17 2011 - 17:51:05 CET

This archive was generated by hypermail 2.2.0 : Thu Mar 17 2011 - 23:50:02 CET