10 int dim = histo->GetDimension();
11 int nbins = histo->GetNbinsX();
14 int nbinsx = histo->GetNbinsX();
16 nbinsy = histo->GetNbinsY();
20 nbinsz = histo->GetNbinsZ();
24 int ibinX(0), ibinY(0), ibinZ(0);
26 int ibinG = TMath::BinarySearch(nbins, histo->GetIntegral(),
fFlat.
fire());
31 if (dim == 1) ibinX = ibinG + 1;
33 ibinY = (ibinG /
nbinsx) + 1;
34 ibinX = (ibinG %
nbinsx) + 1;
37 ibinZ = ibinG / (nbinsx*nbinsy);
38 ibinY = ((ibinG - (nbinsx*nbinsy*ibinZ)) /
nbinsx) + 1;
39 ibinX = ((ibinG - (nbinsx*nbinsy*ibinZ)) %
nbinsx) + 1;
45 double xCenter = histo->GetXaxis()->GetBinCenter(ibinX);
46 double xWidth = histo->GetXaxis()->GetBinWidth(ibinX);
47 x = (xCenter-0.5*xWidth) + xWidth*
fFlat.
fire();
52 double yCenter = histo->GetYaxis()->GetBinCenter(ibinY);
53 double yWidth = histo->GetYaxis()->GetBinWidth(ibinY);
54 y = (yCenter-0.5*yWidth) + yWidth*
fFlat.
fire();
60 double zCenter = histo->GetZaxis()->GetBinCenter(ibinZ);
61 double zWidth = histo->GetZaxis()->GetBinWidth(ibinZ);
62 z = (zCenter-0.5*zWidth) + zWidth*
fFlat.
fire();
void GetRandom(TH1 *histo, double &x, double &y, double &z)
RandHisto(CLHEP::HepRandomEngine &engine)