A macro is a .C or a .cxx or a .cpp (or whatever) file with the following content (which also fixes the issue you are seeing). Please note this is not tested!
void myMacro()
{
TFile* f1 = TFile::Open("aluminium.root", "READ");
TH1* h_first = static_cast<TH1>(f1->Get("h1"));
h_first->SetLineWidth(2);
h_first->SetLineColor(kBlack);
h_first->SetMarkerColor(kBlack);
h_first->SetMarkerStyle(2);
TFile* f2 = TFile::Open("glass.root", "READ");
TH1* h_second = static_cast<TH1>(f2->Get("h1"));
h_second->SetLineWidth(2);
h_second->SetLineColor(kGreen);
h_second->SetMarkerColor(kGreen);
h_second->SetMarkerStyle(2);
TFile* f3 = TFile::Open("bakelite.root", "READ");
TH1* h_third = static_cast<TH1>(f3->Get("h1"));
h_third->SetLineWidth(2);
h_third->SetLineColor(kRed);
h_third->SetMarkerColor(kRed);
h_third->SetMarkerStyle(2);
h_first->Scale(1/h_first->Integral());
h_second->Scale(1/h_second->Integral());
h_third->Scale(1/h_third->Integral());
h_first->Draw("hist");
h_second->Draw("hist same");
h_third->Draw("hist same");
TLegend* legend = new TLegend(0.1,0.7,0.48,0.9);
legend->AddEntry(h_first, "aluminium");
legend->AddEntry(h_second, "glass");
legend->AddEntry(h_third, "bakelite");
legend->Draw();
f1->Close();
f2->Close();
f3->Close();
return;
}