TH2F problem


I define a a TH2F by:

TH2F *moje[2][16]:

         for (int sl=0; sl <2; sl++)
	    for (int ch=0; ch<16; ch++)
	    TString symname1 = "rdift_vs_tot_pl";
	    symname1 += sl+1; symname1 += "_el"; symname1 += ch+1;
	    TString symname2 = "CUT_rdift_vs_tot_pl";
	    symname2 += sl+1; symname1 += "_el"; symname2 += ch+1;
            moje[sl][ch] = new TH2F (symname1,symname1,500,0,0.6,500,0,300);
	   // totvdrift1[sl][ch] = new TH2F (symname2,symname2,500,0,0.6,500,0,300);


// fill it

moje[fpl-1][fel-1]-> Fill(rdrift[nt],tot_track[nt]);

// Write it to a TFile

TFile *output = new TFile("tracking_2_tot.root", "RECREATE");



after running this:

gcc -L/home/j/root/lib -I/home/j/root/include -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lMinuit -lThread -pthread -lm -ldl -rdynamic -m64 -march=k8 -msse3 -O3 -pipe  tracking_0507.C -o tracking_0507

I get this:

tracking_0507.C: In function ‘int main()’:
tracking_0507.C:1641: error: request for member ‘Write’ in ‘*(TH2F* (*)[16])(& moje)’, which is of non-class type ‘TH2F* [16]’

I added #include “TH2F.h” , “TFile.h” etc

I have no idea what might be the problem.

The problem was it was needed to write it in a loop.



I see you marked your question as solved. Anyway, you were calling ‘Write’ method on a built-in array so I hope you found this (I did not check the remaining part of your code).

Yes, it looks like moje[ch][sl]->Write(); .