forked from cms-analysis/HiggsAnalysis-HiggsToTauTau
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mlfit_result.C
25 lines (22 loc) · 956 Bytes
/
mlfit_result.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
double
read_value(const char* path, const char* value, bool isBG)
{
TFile* file = new TFile(TString::Format("%s/out/mlfit.root", path));
TTree* tree = (TTree*) file->FindObjectAny(isBG ? "tree_fit_b" : "tree_fit_sb");
double val = 0; tree->SetBranchAddress(value, &val); tree->GetEntry(0);
return val;
}
void
mlfit_result(const char* path, const char* value="nll_min")
{
TFile* outFile = new TFile(TString::Format("%s/mlfit_result.root", path),"RECREATE");
TTree *outTree = new TTree("limit","limit");
char* output_value = (value =="nll_min") ? "limit" : value;
double val_s = 0; outTree->Branch(output_value, &val_s, TString::Format("%s/D", output_value));
double val_b = 0; outTree->Branch(TString::Format("%s_b", output_value), &val_b, TString::Format("%s_b/D", output_value));
val_s = read_value(path, value, false);
val_b = read_value(path, value, true );
outFile->cd();
outTree->Fill ();
outTree->Write();
}