Segmentation fault while plotting from TTree into TH1F*

Hello!
As stated in the title I have a following problem: when I try to plot my TTree into previously created TH1F I get segmentation fault. My root version is 5.34/23 and below is exact code and output:

Minimal code for error reproduction:

[code]#include
#include <TFile.h>
#include <TTree.h>
#include <Riostream.h>

class Argonaut {

public:
Argonaut();
TH1F* Argonaut::GetFitZ(int event_cuts_changed);

private:
TFile* f_events;
TTree* t_events;

    TCut C_FitZ;

};

Argonaut::Argonaut()
{
string dir = “/home/yourdirectorypath/”;
stringstream ss;
ss.str("");
ss << dir << “/events.root”;
f_events = new TFile(ss.str().c_str());
t_events = (TTree*)f_events->Get(“TreeEvents”);
}

TH1F* Argonaut::GetFitZ()
{
Int_t nbinsx=8000;
Double_t xlow=-800.;
Double_t xup=200.;
TH1F *hist = new TH1F(“fitz”,“Main Vtx Z-pos”,nbinsx,xlow,xup);

    t_events->Print();
    t_events->Draw("FitZ>>fitz","","");
    return hist;

}

void Execute()
{
Argonaut test;
test.GetFitZ()->Draw();
}[/code]

Output:
[size=85][code]


*Tree :TreeEvents: Event characteristics *
*Entries : 2400 : Total = 575269 bytes File Size = 463208 *

  •    :          : Tree compression factor =   1.24                       *
    

*Br 0 :evN : EventIndex/I *
*Entries : 2400 : Total Size= 10163 bytes File Size = 3579 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.70 *

*Br 1 :S5 : S5/I *
*Entries : 2400 : Total Size= 10137 bytes File Size = 2323 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 4.16 *

*Br 2 :FitZ : FitZ/F *
*Entries : 2400 : Total Size= 10147 bytes File Size = 6366 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.52 *

*Br 3 :WFA : vector *
*Entries : 2400 : Total Size= 62010 bytes File Size = 14113 *
*Baskets : 3 : Basket Size= 32000 bytes Compression= 4.36 *

*Br 4 :PSD : PSDModulesArray[44]/F *
*Entries : 2400 : Total Size= 424074 bytes File Size = 382763 *
*Baskets : 14 : Basket Size= 32000 bytes Compression= 1.11 *

*Br 5 :BPD : BPDPlanesArray[6]/F *
*Entries : 2400 : Total Size= 58257 bytes File Size = 52882 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.09 *

*** Break *** segmentation violation
[/code][/size]

Do you have any idea what might be a source of the problem?
I already was given an answer, that it might be due to deleting a histogram along with the file. But I cannot really figure it out.
Necessary file is in the attachment.

Regards,
Maciej Lewicki
events.root (458 KB)

Always try to precompile your macro using ACLiC, in order to find source code problems, e.g. try something like:
root [0] .L MyMacro.cxx++

[code]#include “TH1.h”
#include “TFile.h”
#include “TTree.h”
#include “TCut.h”

#include
#include
// …
public:
Argonaut();
TH1F *GetFitZ();
// …[/code]

Problem solved. Thank you!