Segmentation violation, Root 6

Hello everyone!
I’ve got a very simple code for now but somehow I’ve got a problem with it.
There is my code:

void fun()
{
        gROOT->Reset();
        TChain* Bchain = new TChain("TauTree");
        Bchain->Add("/home/Tau.root");
        TTree* BDK_tree = Bchain;
       
	Double_t        Muon_eta;
        long NBINS = 100;

        BDK_tree->SetBranchAddress("muon_eta", &Muon_eta);

        TH1D* muon_eta_h = new TH1D("muon_eta", "muon_eta", NBINS, -3, 3);

	Int_t Evt_tot = Bchain->GetEntries();

        for(Int_t i = 0; i <Evt_tot; ++i)
        {
                Bchain->GetEvent(i);
                muon_eta_h->Fill(Muon_eta);
        }
        muon_eta_h->Draw();
        muon_eta_h->SaveAs("muon_eta_h");
}

The error message is “segmentation violation”.
I am using Root 6.
Do you have any ideas where the problem is?
Cheers
Caroline

gROOT->cd();
TH1D *muon_eta_h = new TH1D("muon_eta_h", "muon_eta;eta;#counts", NBINS, -3., 3.);
Bchain->Draw("muon_eta >> muon_eta_h");

Thank You very much! :slight_smile:

Sorry for interrupting but do you know why my code didn’t work?

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.