Hello everyone,
Now, i’m try to make 2-d fit using my simulation data. and i already fitting 1-d histogram and Gaussian graph.
when i fit my 1-d(TH1) histogram, i’m used ‘Fill’ function. And i’m also try same method to 2-d figure. but TH2 class doesn’t have similar function ‘Fill’. Does anyone know kind of ‘fill’ function in 2-d histogram class?
here is my code.
Double_t String,DOM,theta,phi,avg_y,avg_x;
T->SetBranchAddress("String_ID",&String);
T->SetBranchAddress("DOM_ID",&DOM);
T->SetBranchAddress("Arrival_theta",&theta);
T->SetBranchAddress("Arrival_phi",&phi);
nentries = (Int_t)T->GetEntries();
TF2 *image1 = new TF2("image1","[0]*TMath::Gaus(x,[1],[2])*TMath::Gaus(y,[3],[4])",0,10,0,10);
for(k=0;k<nentries;k++){
T->GetEntry(k);
avg_x+=abs(phi);
//avg_y+=abs(theta);
}
avg_x = avg_x / nentries;
//avg_y = avg_y / nentries;
for(i=0;i<nentries;i++)
{
T->GetEntry(i);
if(String==2&&DOM==60)
{
if((avg_x-M_PI)<phi&&phi<M_PI) {
phi = phi - avg_x;
}
else if(-M_PI < phi &&phi < (avg_x-M_PI)) {
phi = phi+(2*M_PI)-avg_x;
}
/*if( (avg_y-(0.5*M_PI)) < theta && theta < M_PI ){
theta = theta - avg_y +(0.5*M_PI);
}
else if(0<theta && theta <(avg_y-(0.5*M_PI))){
theta = theta +(1.5*M_PI) - avg_y;
}*/
//image1->Fill(phi,theta);
}
}
image1->SetParameters(0,0,0,0);
//image1->SetOption("c");
image1->Draw();
//image1->Fit("gaus");
First, I`m searched user tutorial and follow the similar topic in root user forum. but doesn’t work.
How can i fix this. Thank you for your help.
best regard.
Zee