I have been using root version 5.34 for many years now.
Today I had to switch to version 6.22 and I am trying to use the same program that I used with root v5.34. However I am getting an error. Could you point out how to fix the error?
The error when I call the function is:
Error in TRint::HandleTermInput(): cling::InvalidDerefException caught: Trying to dereference null pointer or trying to call routine taking non-null arguments
void make_proj(string title, string tree_name, string hist_name, Int_t proj_axis, Double_t b1, Double_t b2){
// Projection axis
// proj_axis=0: x axis
// proj_axis=1: y axis
TFile *ftree = new TFile(tree_name.c_str(),"UPDATE");
TH2I *h_2d = (TH2I*)ftree->Get(hist_name.c_str());
cout << proj_axis << "\n";
if(proj_axis==0){
TAxis *yaxis = h_2d->GetYaxis();
TH1D *h1 = h_2d->ProjectionX(title.c_str(),yaxis->FindBin(b1),yaxis->FindBin(b2));
}
if(proj_axis==1){
TAxis *xaxis = h_2d->GetXaxis();
TH1D *h1 = h_2d->ProjectionY(title.c_str(),xaxis->FindBin(b1),xaxis->FindBin(b2));
}
h1->Write();
ftree->Close();
return;
}
Looking forward for your answer.
Thank you very much.
Please read tips for efficient and successful posting and posting code
_ROOT Version:_6.22
_Platform:_Ubuntu 20.04
Compiler: Not Provided