I’m pulling my hair out trying to use an array to plot a th2f:
I define a histogram:
int ROWS = 16;
int COLUMNS = 50;
double a[ROWS][COLUMNS];
TH2F *optimizationSlice = new TH2F("optimizationSlice","optimizationSlice", COLUMNS, 0.3, 1.28, ROWS, 0.1454, 0.147);
I read my file and fill in my array with:
a[currentrow][currentcolumn] = currentsignificance;
if(currentrow == ROWS-1){
currentrow = 0;
currentcolumn++;
}
else{
currentrow++;
}
I fill the TH2F:
for(Int_t i = 0;i<ROWS;i++){
cout << endl;
for(Int_t j = 0;j<COLUMNS;j++){
currentbin = optimizationSlice->GetBin(j,i);
cout << "Filling: " << currentbin << "with.." << endl;
cout << "a["<<i<<"]["<<j<<"]=" << a[i][j] << endl;
optimizationSlice->SetBinContent(currentbin,a[i][j]);
}
}
And my Result is appended. I figured filling an array would be the most straighforward way of doing this, but you’ll notice that I seem to be missing a row and column, and I think the results are wrong. I know that the 0th bin should be 0.9, and based on the scale, it doesn’t seem to be correct. Does anyone have a snippet that performs this task?
Thanks,
James