TNtuple* LikelihoodSpace::get_contour(float delta) { TNtuple* contour = (TNtuple*) this->samples->Clone("lscontour"); contour->Reset(); // Get list of branch names std::vector<std::string> names; for (int i=0; i<this->samples->GetListOfBranches()->GetEntries(); i++) { std::string name = this->samples->GetListOfBranches()->At(i)->GetName(); if (name == "likelihood") { continue; } names.push_back(name); } float* params_branch = new float[names.size()]; for (size_t i=0; i<names.size(); i++) { this->samples->SetBranchAddress(names[i].c_str(), ¶ms_branch[i]); } float ml_branch; this->samples->SetBranchAddress("likelihood", &ml_branch); // Build a new TNtuple with samples inside the contour float* v = new float[names.size() + 1]; for (int i=0; i<this->samples->GetEntries(); i++) { this->samples->GetEntry(i); if (ml_branch < this->ml + delta) { for (size_t j=0; j<names.size(); j++) { v[j] = params_branch[j]; } v[names.size()] = ml_branch; contour->Fill(v); } } this->samples->ResetBranchAddresses(); delete[] v; return contour; }