# Addition of Gaussian Smearing to 2D Projections and 1D histogram

Dear Experts

I need to add Gaussian Smearing Gx/Gy = (0, 0, 1, 1) [xbar, ybar, sigmax, sigmay] to 2D Projections and 1D histograms in the following code. Kindly help in this regard. Please update the code accordingly:
map<string,TH3*> h3;

``````float xmin = -50;
float xmax = 50;
int nx = 100;
float ymin = -50;
float ymax = 50;
int ny = 100;
float zmin = 66000;
float zmax = 66500;
int nz = 300;

h3["energy"] = new TH3F("energy", "Total Energy Deposit;x;y;z", nx, xmin, xmax, ny, ymin, ymax, nz, 0, zmax - zmin);

// Histograms
// *************************************************************************
// *************************************************************************
// Fill Histograms

int nev = 0;
vector<int> nphoton;
float xxx = 0;
float yyy = 0;
float zzz = 0;
{
nev++;
cout << "Event: " << nev << endl;
nphoton.push_back(0);
float tot_e = 0;

for (int i = 0; i < energy.GetSize(); i++)
{
nphoton.back()++;
tot_e += energy[i];
h3["energy"]->Fill(x[i],y[i],abs(z[i]) - zmin,energy[i]);

xxx = max(abs(x[i]), xxx);
yyy = max(abs(y[i]), yyy);
zzz = max(abs(z[i]), zzz);
}
}

cout << "Max-X: " << xxx << endl;
cout << "Max-Y: " << yyy << endl;
cout << "Max-Z: " << zzz << endl;
// Fill Histograms
// *************************************************************************

// *************************************************************************
// Draw Histograms
for (map<string,TH3*>::const_iterator itr = h3.begin(); itr != h3.end(); itr++)
{
//gStyle->SetOptStat(0);

string hname = itr->first;
TH3* h = (TH3*)itr->second->Clone();
h->Scale(1.0/float(h->Integral()));

TCanvas* c = new TCanvas("c", "", 1000, 1000);

//  c->cd();
// h->Draw("BOX2Z");
// h->Draw();
// ss.str(""); ss << "test_" << hname << ".png";
// c->SaveAs(TString(ss.str()));

TH2* h2yx = (TH2*)h->Project3D("yx")->Clone();
TH2* h2zx = (TH2*)h->Project3D("zx")->Clone();
TH2* h2zy = (TH2*)h->Project3D("zy")->Clone();
TH1* h1x = (TH2*)h->Project3D("x")->Clone();
TH1* h1y = (TH2*)h->Project3D("y")->Clone();
TH1* h1z = (TH2*)h->Project3D("z")->Clone();
//  THF* h1
//  h1->GetZaxis()->SetRangeUser(zmin, zmax);
//  h1 = (TH2*)h->Project3D("z slice")->Clone();

c->cd();
h2yx->Draw("colz");
h2yx->GetXaxis()->SetTitle("x (mm)");
h2yx->GetYaxis()->SetTitle("y (mm)");
ss.str(""); ss << "test2D_yx_" << hname << ".png";
c->SaveAs(TString(ss.str()));

h2zx->Draw("colz");
h2zx->GetXaxis()->SetTitle("x (mm)");
h2zx->GetYaxis()->SetTitle("z (mm)");
ss.str(""); ss << "test2D_zx_" << hname << ".png";
c->SaveAs(TString(ss.str()));

h2zy->Draw("colz");
h2zy->GetXaxis()->SetTitle("y (mm)");
h2zy->GetYaxis()->SetTitle("z (mm)");
ss.str(""); ss << "test2D_zy_" << hname << ".png";
c->SaveAs(TString(ss.str()));

h1x->Draw("colz");
h1x->GetXaxis()->SetTitle("x (mm)");
ss.str(""); ss << "test1D_x_" << hname << ".png";
c->SaveAs(TString(ss.str()));

h1y->Draw("colz");
h1y->GetXaxis()->SetTitle("y (mm)");
ss.str(""); ss << "test1D_y_" << hname << ".png";
c->SaveAs(TString(ss.str()));

h1z->Draw("colz");
h1z->GetXaxis()->SetTitle("z (mm)");
h1z->GetXaxis()->SetRangeUser(0., 200);
ss.str(""); ss << "test1D_z_" << hname << ".png";
c->SaveAs(TString(ss.str()));

// h1->Draw("colz");
//  ss.str(""); ss << "Z_slice" << hname << ".png";
//  c->SaveAs(TString(ss.str()));

c->Close();

}
// Draw Histograms
// *************************************************************************
``````