opentrees.cxx 1.05 KB
Newer Older
Vratislav Chudoba's avatar
Vratislav Chudoba committed
1 2 3 4 5 6 7 8 9
#include "TFile.h"
#include "TTree.h"
#include "TCanvas.h"
#include "TF1.h"
#include "TH1F.h"

void opentrees()
{

Vratislav Chudoba's avatar
Vratislav Chudoba committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23
	TString fName = "simevents.root";
	TString fName1 = "simevents-1.root";
	TString fName2 = "simevents-2.root";

	//open files
	TFile *fr1 = new TFile(fName1.Data());
	if (fr1->IsZombie()) {
		Error("opentrees", "File %s not found.", fName1.Data());
		return;
	}
	TFile *fr2 = new TFile(fName2.Data());
	TFile *fr = new TFile(fName.Data());

	//get trees
Vratislav Chudoba's avatar
Vratislav Chudoba committed
24 25 26 27
	TTree *tr1 = (TTree*)fr1->Get("simevents");
	TTree *tr2 = (TTree*)fr2->Get("simevents");
	TTree *tr = (TTree*)fr->Get("simevents");

Vratislav Chudoba's avatar
Vratislav Chudoba committed
28 29 30 31 32

	//first Canvas
	TCanvas *c1 = new TCanvas();
	//	TCanvas *c1 = new TCanvas("name1", "title of canvas");
	//	TCanvas *c1 = new TCanvas("name1", "title of canvas", 0, 0, 950, 700);
Vratislav Chudoba's avatar
Vratislav Chudoba committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
	c1->Divide(2,2);

	c1->cd(1);
	tr->Draw("E", "E>0");

	c1->cd(2);
	tr1->Draw("E", "E>0");

	c1->cd(3);
	tr2->Draw("E", "E>0");


	c1->cd(4);
	tr->Draw("E", "E>0.95");
	tr1->SetLineColor(kRed);
	tr1->Draw("E", "E>0", "same");
	tr2->SetLineColor(kBlue);
	tr2->Draw("E", "E>0", "same");

}