Skip to content

TElectronEfficiency : Replace usage of TObjArray with vector<std::unique_ptr<TH1>>

TElectronEfficiency : Replace usage of TObjArray with vector<std::unique_ptr>

The main difference comes

  std::vector<std::vector< TObjArray > > m_histList;
  std::vector< std::vector< TObjArray > > m_sysList;

becomes

  using HistArray = std::vector<std::unique_ptr<TH1>>;
  std::vector<std::vector<HistArray>> m_histList;
  std::vector<std::vector<HistArray>> m_sysList;

The d-tor now can be default

In the intermediate methods we pass around plain ptr (or vector<TH1*>) which then we push to unique_ptr vectors at the end after we also do SetDirectory(nullptr)

This was similar before but basically now happens around

HistArray tmpArray;
  for (auto& hist : hists) {
    tmpHist = static_cast<TH1*>(hist);
    tmpHist->SetDirectory(nullptr);
    tmpArray.emplace_back(tmpHist);
  }
  histList.emplace_back(std::move(tmpArray));

ping @psommer

Edited by Christos Anastopoulos

Merge request reports