-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetMassRanges.C
More file actions
26 lines (22 loc) · 872 Bytes
/
getMassRanges.C
File metadata and controls
26 lines (22 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void getMassRanges(const char* inputFile="subTree_-1.root", const char* tag="allSkimmed", float massMin=0, float massMax=10) {
TFile *infile = new TFile(inputFile);
TFile *outfile = new TFile(Form("%s_min%g_max%g.root", tag, massMin, massMax), "recreate");
TTree *fullTree = (TTree*) infile->Get("tree");
TString cut = Form("mass>%g&&mass<%g", massMin, massMax);
cout << "Min mass: " << massMin << endl;
cout << "Max mass: " << massMax << endl;
cout << "Cut: " << cut << endl;
TTree *cutTree = fullTree->CopyTree(cut);
TCanvas *c = new TCanvas("c", "c", 800, 700);
c->cd();
cutTree->Draw("mass");
c->SetLogy();
c->SaveAs(Form("%s_min%g_max%g.png", tag, massMin, massMax));
outfile->cd();
cutTree->Write();
outfile->Close();
delete c;
delete fullTree;
delete infile;
delete outfile;
}