Plot angular probability - polar histogram

Our TPies have a bug: they paint lines even when they’re not supposed to - I think because of a fill area miscalculation. That makes the result less nice - I’ll need @couet to have a look. But this is what I have for now:

void pies()
{
  // theta upper bin borders:
  std::array<double, 12> thetaBinBorders
    = {0., 1., 2., 3., 4., 5., 10., 15., 30., 60., 90., 180.};
  std::array<double, 11> prob
    = {6.39622E-02, 1.61721E-01, 1.55263E-01, 1.25615E-01, 9.57030E-02, 2.21926E-01, 6.93081E-02, 6.31371E-02, 3.30873E-02, 8.34649E-03, 1.93071E-03};

  // Pie values are the theta bin borders.
  // Pie radii are the probabilities.

  std::array<TPie*,11> pies{};

  for (std::size_t i = 0; i < prob.size(); ++i) {
    std::string name("pie");
    name += std::to_string(i);
    std::vector<float> vals;
    int theSlice = 0;
    if (i > 0) {
      vals.emplace_back(thetaBinBorders[i]);
      theSlice = 1;
    }
    vals.emplace_back(thetaBinBorders[i + 1] - thetaBinBorders[i]);
    vals.emplace_back(360. - thetaBinBorders[i + 1]);
    pies[i] = new TPie(name.c_str(), name.c_str(), vals.size(), vals.data());
    for (int slice = 0; slice < vals.size(); ++slice) {
      if (slice == theSlice)
	pies[i]->SetEntryFillColor(slice, 20+i);
      else {
	pies[i]->SetEntryFillColor(slice, kWhite);
	pies[i]->SetEntryFillStyle(slice, 4000);
      }
    }
    pies[i]->SetRadius(prob[i]);
    pies[i]->SetLabelFormat("");
    if (i == 0)
      pies[i]->Draw("nol");
    else
      pies[i]->Draw("nol SAME");
  }
}

1 Like