#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; }