How to correct the error: use of undeclared identifier 'plot_histogram'

const Int_t NEntry = 10000;
const double meanvalue = 1;
const double meanvalue2 = 1;
const double rmsvalue = 0.1;
const double rmsvalue2 = 0.1;

TMatrixD* produceSqrtMat( const TMatrixD& covMat )
{
Double_t sum = 0;
Int_t size = covMat.GetNrows();;
TMatrixD* sqrtMat = new TMatrixD( size, size );

``````for (Int_t i=0; i< size; i++) {

sum = 0;
for (Int_t j=0;j< i; j++) sum += (*sqrtMat)(i,j) * (*sqrtMat)(i,j);

(*sqrtMat)(i,i) = TMath::Sqrt(TMath::Abs(covMat(i,i) - sum));

for (Int_t k=i+1 ;k<size; k++) {

sum = 0;
for (Int_t l=0; l<i; l++) sum += (*sqrtMat)(k,l) * (*sqrtMat)(i,l);

(*sqrtMat)(k,i) = (covMat(k,i) - sum) / (*sqrtMat)(i,i);

}
}
return sqrtMat;
``````

}

void getGaussRnd( TArrayD& v, const TMatrixD& sqrtMat, TRandom& R )
{
// generate â€śsizeâ€ť correlated Gaussian random numbers

``````// sanity check
const Int_t size = sqrtMat.GetNrows();
if (size != v.GetSize())
cout << "<getGaussRnd> too short input vector: " << size << " " << v.GetSize() << endl;

Double_t* tmpVec = new Double_t[size];

for (Int_t i=0; i<size; i++) {
Double_t x, y, z;
y = R.Rndm();
z = R.Rndm();
x = 2*TMath::Pi()*z;
tmpVec[i] = TMath::Sin(x) * TMath::Sqrt(-2.0*TMath::Log(y));
}

for (Int_t i=0; i<size; i++) {
v[i] = 0;
for (Int_t j=0; j<=i; j++) v[i] += sqrtMat(i,j) * tmpVec[j];
}

delete[] tmpVec;
``````

}

void generate_2parameter(){
gROOT->ProcessLine(".x â€¦/rootlogon.C");
ofstream opfile(â€śdata4histogram_2d.txtâ€ť);

``````opfile<<"#entry #value1 #value2"<<endl;
//covariance matrix
TMatrixD* covmatrix = new TMatrixD(2,2);
/*Float_t offaxisVal = 0.45*rmsvalue*rmsvalue2;*/
Float_t offaxisVal = 0.0*rmsvalue*rmsvalue2;
(*covmatrix)(0,0) = rmsvalue*rmsvalue;
(*covmatrix)(1,1) = rmsvalue2*rmsvalue2;
(*covmatrix)(0,1) = offaxisVal*offaxisVal;
(*covmatrix)(1,0) = (*covmatrix)(0,1);
cout << "covariance matrix: " << endl;
covmatrix->Print();

//square-root matrix
TMatrixD* sqrtMatrix = produceSqrtMat(  *covmatrix );
cout << "Square root of covariance matrix: " << endl;
sqrtMatrix->Print();

TArrayD* v = new TArrayD( 2 );
Float_t xvar[2];
double_t xS[2] = {  meanvalue,  meanvalue2 };

//covariance matrix
TRandom R( 100 );
for (Int_t ientry=0; ientry<NEntry; ++ientry) {
getGaussRnd( *v, *sqrtMatrix, R );
for (Int_t ivar=0; ivar<2; ivar++) xvar[ivar] = (*v)[ivar] + xS[ivar];
opfile<<ientry<<" "<<xvar[0]<<" "<<xvar[1]<<endl;
}
opfile.close();
plot_histogram_2d();
``````

}

It looks like â€ś`plot_histogram_2d();`â€ť is a function call, so you need to talk to the author of your macro (who should be able to give you this function).

The later part of the code is:

void plot_histogram_2d(){
ifstream cfile(â€śdata4histogram_2d.txtâ€ť);
string dummyline;
getline(cfile,dummyline);
Int_t ithentry;
double ithvalue;
double ithvaluey;
double maxvalue = meanvalue+4rmsvalue;
double minvalue = meanvalue-4
rmsvalue;
double maxvaluey = meanvalue2+4rmsvalue2;
double minvaluey = meanvalue2-4
rmsvalue2;
TH2F* hhisto = new TH2F( â€śHistogramâ€ť, " " ,50,minvalue,maxvalue,50,minvaluey,maxvaluey);
TH1F* hhisto_effect = new TH1F( â€śHistogram_effectâ€ť, " " ,100,0.5,1.5);
for (Int_t ientry=0; ientry<NEntry; ++ientry) {
cfile >> ithentry >> ithvalue>>ithvaluey;
//cout<<"entry â€ś<<ithentry<<â€ť values "<<ithvalue<<endl;
hhisto->Fill(ithvalue,ithvaluey);
hhisto_effect->Fill(ithvalue*ithvaluey);
}
hhisto->GetXaxis()->SetTitle(â€śValues of variable Xâ€ť);
hhisto->GetYaxis()->SetTitle(â€śValues of variable Yâ€ť);
TH1D * projh2X = hhisto->ProjectionX();
TH1D * projh2Y = hhisto->ProjectionY();

``````TCanvas *c1 = new TCanvas("c1", "c1",900,900);
gStyle->SetOptStat(0);

``````

In the beginning of your macro file, add the declaration: `void plot_histogram_2d();`