Continuing the discussion from Tree->Draw("var>>hist"):
_ROOT Version:5.34.36
Platform: Not Provided
Compiler: Not Provided
Dear ROOT,
I declare many histograms in a loop, e.g.
for(Int_t j=0; j<20; j++){
hists[j] = new TH1F(Form("hist_%d",j),Form("hist_%d",j),200,0.,3.0);
}
and I am trying to draw a branch stored in a TChain
TChain *ch = new TChain("tree1");
ch->Add(Form("smeared_%s.root",kin));
onto each of these histograms in a loop:
for (Int_t nx=0;nx<binx;nx++){
if(x<x_high[nx]&&x>x_low[nx]){
for (Int_t ny=0;ny<biny;ny++){
if(y<y_high[ny]&&y>y_low[ny]){
// ch->Draw("missingmass>>hists[biny*nx+ny]",CUTS); //doesnt work
ch->Draw(Form("missingmass>>%s",hists[biny*nx+ny]->GetName()),CUTS); //doesnt work
}
}
}
}
Is there some other way to cast the string into the "missing_mass >> hist " or do I have to “SetBranchAddress” on each of the variables on the TChain and proceed with filling the histograms via hists[j]->Fill(missingmass) way? (I have way more branches to define and set cuts on…so I wanted to see if there was an easier way…such as this that can work/is shorter).
Thanks!!