The “median” is just the “0.5 quantile”:
{
// create, fill and draw the histogram
TF1 *f = new TF1("f", "TMath::Gaus(x, 5, 1)", 0, 10);
TH1D *h = new TH1D("h", "h", 100, 0, 10);
h->FillRandom("f");
h->Draw();
// calculate and print the "median"
Double_t x, q;
q = 0.5; // 0.5 for "median"
h->ComputeIntegral(); // just a precaution
h->GetQuantiles(1, &x, &q);
std::cout << "median = " << x << std::endl;
}