Dear All,
I’m running the macro file to make histogram from a root file. But I’m getting error. As this macro was running okay in ROOT5.34 but not working on ROOT 6.28. Can anyone help me?
void M1back(){
char name[20]="cut3823";
int maxnum = 3;
int maxeventnum=10000;
auto tr = new TChain("ge"); // treeNameという名のTTreeのchain
tr->Add(Form("%s.root",name)); // treeNameなTTreeを含むROOTファイル
for(int i=1;i<=maxnum;i++){ // 連番ファイルの連結の例
if(i<=9){
tr->Add(Form("%s_00%d.root",name,i));}
else{
tr->Add(Form("%s_0%d.root",name,i));}
}
tr->GetEntries();
auto h = new TH1D("h","h",16000,-0.5,15999.5);
tr->Draw("c16.E>>h","c29.E>1310&&c29.E<1350");
auto s = new TSpectrum();
s->Background(h,20,"");
auto h1 =new TH1D("h1","h1",16000,-0.5,15999.5);
h1->Add(h);
h1->Add(h_background,-1.); // >>> h_background should be defined !
}
Note: in your example h_background is not defined. You need to define it. See the comment