Getting TH1 out of canvas


I want to “read” the TH1 from a saved Canvas… How to do that ? What I do is

[code]vector NameOfHisto;

TH1F htemp = (TH1F) _file0->Get(NameOfHisto[i].c_str());[/code]

but when I am trying to pass this htemp to another function, it gives segmentation fault…

Thanks in advance

Instead of

TH1F *htemp = (TH1F*) _file0->Get(NameOfHisto[i].c_str()); do

TH1F *htemp = (TH1F*) gPad->GetPrimitive(NameOfHisto[i].c_str());