showBeam.cxx 4.35 KB
Newer Older
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
#include "TSystem.h"
#include "TFile.h"
#include "TTree.h"
#include "TChain.h"
#include "TCanvas.h"

using std::cout;
using std::endl;

void showBeam(const Long64_t drawEntries = 100000)
{

	TChain *tr = new TChain("AnalysisxTree");
//	tr->Add("~/data/exp1804/h5_14_0?.root");
//	tr->Add("~/data/exp1804/output.root");
	tr->Add("~/data/exp1804/h5_12.root");


	TChain *trCal = new TChain("cal");
//	trCal->Add("~/data/exp1804/h5_11_0?_calib.root");
//	trCal->Add("~/data/exp1804/h5_14_0?_calib.root");
//	trCal->Add("~/data/exp1804/h5_14_0?_calib.root");

//	tr->AddFriend(trCal);

//	const Int_t drawEntries = 6000000;
//	const Int_t drawEntries = tr->GetEntries();

	tr->GetListOfFiles()->Print();
	trCal->GetListOfFiles()->Print();

	cout << tr->GetEntries() << " events." << endl;
	cout << trCal->GetEntries() << " calibrated events." << endl;

	TString varName;
	TString condition;

//	cout << drawEntries << " entries in input chain will be processed." << endl;


//	TCanvas *c1 = new TCanvas("c1", "R: 0-7", 1600, 800);
//	c1->Divide(4,2);
	TCanvas *c1 = new TCanvas("beam", "beam info", 1200, 1200);
	c1->Divide(2,2);

	c1->cd(1);
//	tr->Draw("trigger", "", "", drawEntries);

	c1->cd(3);

//	af5 = (NeEvent->F5[0]+NeEvent->F5[1]+NeEvent->F5[2]+NeEvent->F5[3]+4.*gRandom->Uniform())/4.
//	tf5 = (NeEvent->tF5[0]+NeEvent->tF5[1]+NeEvent->tF5[2]+NeEvent->tF5[3]+4.*gRandom->Uniform())/4.;
//	tf3 = (NeEvent->tF3[0]+NeEvent->tF3[1]+NeEvent->tF3[2]+NeEvent->tF3[3]+4.*gRandom->Uniform())/4.;
//	ToF = (tf5 - tf3)*0.125+89.165;
//	af5:TOF
//	tr->Draw("(NeEvent->F5[0]+NeEvent->F5[1]+NeEvent->F5[2]+NeEvent->F5[3])/4.", "", "", drawEntries);
//	tr->Draw("(F5[0]+F5[1]+F5[2]+F5[3])/4.", "", "", drawEntries);
//	tr->Draw("(tF5[0]+tF5[1]+tF5[2]+tF5[3])/4.;", "", "", drawEntries);
//	tr->Draw("( (tF5[0]+tF5[1]+tF5[2]+tF5[3]) - (tF3[0]+tF3[1]+tF3[2]+tF3[3]) )/4.*0.125+89.165;",
//			"tF5[0]>0 && tF5[1]>0 && tF5[2]>0 && tF5[3]>0 && tF3[0]>0 && tF3[1]>0 && tF3[2]>0 && tF3[3]>0", "", drawEntries);
	tr->Draw("(F5[0]+F5[1]+F5[2]+F5[3])/4.:( (tF5[0]+tF5[1]+tF5[2]+tF5[3]) - (tF3[0]+tF3[1]+tF3[2]+tF3[3]) )/4.*0.125+89.165;",
			"tF5[0]>0 && tF5[1]>0 && tF5[2]>0 && tF5[3]>0 "
			"&& tF3[0]>0 && tF3[1]>0 && tF3[2]>0 && tF3[3]>0 "
			"&& F5[0]>0 && F5[1]>0 && F5[2]>0 && F5[3]>0"
			"&& ( (tF5[0]+tF5[1]+tF5[2]+tF5[3]) - (tF3[0]+tF3[1]+tF3[2]+tF3[3]) )/4.*0.125+89.165<200 "
			"&& ( (tF5[0]+tF5[1]+tF5[2]+tF5[3]) - (tF3[0]+tF3[1]+tF3[2]+tF3[3]) )/4.*0.125+89.165>100"
			"&& (F5[0]+F5[1]+F5[2]+F5[3])/4. < 2500"
			"&& trigger==1",
			"col", drawEntries);
	TH2F *hTOF = (TH2F*)gPad->GetPrimitive("htemp");
	hTOF->SetStats(0);
	hTOF->SetTitle("");
	hTOF->SetXTitle("TOF (ns)");
	hTOF->SetYTitle("dE (a.u.)");
	hTOF->GetXaxis()->CenterTitle();
	hTOF->GetXaxis()->SetTitleSize(0.06);
	hTOF->GetXaxis()->SetTitleOffset(0.75);
	hTOF->GetYaxis()->CenterTitle();
	hTOF->GetYaxis()->SetTitleSize(0.06);
	hTOF->GetYaxis()->SetTitleOffset(0.75);

	c1->cd(2);
	tr->Draw("(y1[0]-16)*1.25:(x1[0]-16.)*1.25>>hXY1(32, -20., 20., 32, -20., 20.)", "x1[1]<1000 && y1[1]<1000 && trigger==1 && nx1==1 && ny1==1", "col", drawEntries);
//	tr->Draw("x2[0]", "x2[0]<1000 && nx2==1", "", drawEntries);
	TH2F *h1 = (TH2F*)gPad->GetPrimitive("hXY1");
	h1->SetStats(0);
	h1->SetTitle("");
	h1->SetXTitle("x1 (mm)");
	h1->SetYTitle("y1 (mm)");
	h1->GetXaxis()->CenterTitle();
	h1->GetXaxis()->SetTitleSize(0.06);
	h1->GetXaxis()->SetTitleOffset(0.75);
	h1->GetYaxis()->CenterTitle();
	h1->GetYaxis()->SetTitleSize(0.06);
	h1->GetYaxis()->SetTitleOffset(0.75);

	c1->cd(4);
	tr->Draw("(y2[0]-16)*1.25:(x2[0]-16.)*1.25>>hXY2(32, -20., 20., 32, -20., 20.)", "x2[0]<1000 && y2[0]<1000 && trigger==1", "col", drawEntries);
	TH2F *h2 = (TH2F*)gPad->GetPrimitive("hXY2");
	h2->SetStats(0);
	h2->SetTitle("");
	h2->SetXTitle("x2 (mm)");
	h2->SetYTitle("y2 (mm)");
	h2->GetXaxis()->CenterTitle();
	h2->GetXaxis()->SetTitleSize(0.06);
	h2->GetXaxis()->SetTitleOffset(0.75);
	h2->GetYaxis()->CenterTitle();
	h2->GetYaxis()->SetTitleSize(0.06);
	h2->GetYaxis()->SetTitleOffset(0.75);


	TCanvas *c2 = new TCanvas("c2", "Bugs in MWPC", 1200, 1200);
	c2->Divide(2,2);

	c2->cd(1);
//	tr->Draw("")
	tr->Draw("x1[0]", "x2[0]<1000 && nx2==1", "", drawEntries);
	tr->Draw("x1[0]", "nx1==0", "", drawEntries);

	c2->cd(2);
	tr->Draw("y1[0]", "ny1==0", "", drawEntries);

	c2->cd(3);
	tr->Draw("x2[0]", "nx2==0", "", drawEntries);

	c2->cd(4);
	tr->Draw("y2[0]", "ny2==0", "", drawEntries);


	return;

}