//========= Macro generated from object: mycut1/Graph //========= by ROOT version6.28/04 #include "Riostream.h" #include "TFile.h" #include "TH1.h" #include "TNtuple.h" #include "TTree.h" #include "TBrowser.h" #include "TH2.h" #include "TRandom.h" #include "TClassTable.h" #include "TSystem.h" #include "TROOT.h" void mycut1() { gROOT->Reset(); const Char_t* fdata0="hz001.txt"; const Char_t* froot0="targetout_raw.root"; ifstream in; Double_t clk,clk2,clk3,spill,scint_trigger,scint_dedx1,scint_dedx2; Double_t scint_dedx3,scint_dedx4,Cal,clock; Int_t nlines = 0; in.open(fdata0, ios::in); TFile *f0 = new TFile(froot0,"RECREATE"); TTree* tree_targetout = new TTree("tree_targetout","raw data imported from NSRL"); tree_targetout->Branch("clock",&clock,"clock/D"); tree_targetout->Branch("spill",&spill,"spill/D"); tree_targetout->Branch("scint_trigger",&scint_trigger,"scint_trigger/D"); tree_targetout->Branch("scint_dedx1",&scint_dedx1,"scint_dedx1/D"); tree_targetout->Branch("scint_dedx2",&scint_dedx2,"scint_dedx2/D"); tree_targetout->Branch("scint_dedx3",&scint_dedx3,"scint_dedx3/D"); tree_targetout->Branch("scint_dedx4",&scint_dedx4,"scint_dedx4/D"); tree_targetout->Branch("Cal",&Cal,"Cal/D"); tree_targetout->Branch("clk",&clk,"clk/D"); tree_targetout->Branch("clk2",&clk2,"clk2/D"); tree_targetout->Branch("clk3",&clk3,"clk3/D"); //histogram for fitting around the primary peak TH1F *trigger = new TH1F("scint_trigger","",1000000,0,1500); TH1F *det1 = new TH1F("det1","",500,0,2500); TH1F *det2 = new TH1F("det2","",500,0,2500); TH1F *det3 = new TH1F("det3","",500,0,2500); TH1F *det4 = new TH1F("det4","",500,0,2500); TH1F *cal = new TH1F("cal","",500,0,2500); while (in.good()) { in >> clock >> spill >> scint_trigger >> scint_dedx1 >> scint_dedx2 >> scint_dedx3 >> scint_dedx4 >> Cal >> clk >> clk2 >> clk3; if (in.good()) { tree_targetout->Fill(); //Fill the histogram for the x and y axis (det1 and det2) trigger->Fill(scint_trigger); det1->Fill(scint_dedx1); det2->Fill(scint_dedx2); det3->Fill(scint_dedx3); det4->Fill(scint_dedx4); cal->Fill(Cal); nlines++; } } in.close(); cout << "Events found: " << nlines << endl; f0->Write(); //Plot dE1 vs dE2 for graphical cut TCanvas *c = new TCanvas("c", "canvas", 1000, 800); TPad *pad1 = new TPad("pad1","This is pad1",0.02,0.52,0.48,0.98,21); c->SetGrid(); //c->SetTitle("02"); tree_targetout->SetMarkerStyle(20); tree_targetout->SetMarkerSize(0.08); tree_targetout->SetMarkerColor(kRed); tree_targetout->SetTitle("dec4:dec3"); tree_targetout->SetFillColor(45); tree_targetout->Draw("scint_dedx4:scint_dedx3"); TGraph *graph = (TGraph*)gPad->GetPrimitive("Graph"); TCanvas *c2 = new TCanvas("c2", "canvas", 1000, 800); TPad *pad2 = new TPad("pad2","This is pad2",0.02,0.52,0.48,0.98,21); c2->SetGrid(); //c2->SetTitle("01"); TAxis *axisx = graph->GetXaxis(); axisx->SetLimits(0.,4400); // along X graph->SetMaximum(4400); // along Y graph->SetMinimum(0.); // along Y graph->SetTitle("dec2:dec1"); graph->GetXaxis()->SetTitleOffset(0.96); graph->GetXaxis()->SetTitleFont(132); graph->GetXaxis()->SetLabelFont(132); graph->GetXaxis()->SetLabelSize(.03); graph->GetXaxis()->SetTitleSize(.05); graph->GetXaxis()->CenterTitle(); graph->GetXaxis()->SetTitle("scint_dedx1"); graph->GetYaxis()->SetLabelSize(.025); graph->GetYaxis()->SetTitle("scint_dedx2"); graph->GetYaxis()->SetTitleFont(132); graph->GetYaxis()->SetLabelFont(132); graph->GetYaxis()->SetTitleOffset(0.97); graph->GetYaxis()->CenterTitle(); graph->GetYaxis()->SetTitleSize(.05); graph->GetYaxis()->SetLabelSize(.03); graph->Draw("AP"); gPad->Print("lastrun.pdf"); // set up histogram for trigger TFile* fich1 = new TFile("targetout_raw.root"); fich1->ls(); TH1F* histo_trigger = (TH1F*) fich1->Get("trigger"); //set up histogram for dedx1 TFile* fich2 = new TFile("targetout_raw.root"); fich2->ls(); TH1F* histo_det1 = (TH1F*) fich2->Get("scint_dedx1"); //set up histogram for dedx2 TFile* fich3 = new TFile("targetout_raw.root"); fich3->ls(); TH1F* histo_det2 = (TH1F*) fich3->Get("scint_dedx2"); //set up histogram for dedx3 TFile* fich4 = new TFile("targetout_raw.root"); fich4->ls(); TH1F* histo_det3 = (TH1F*) fich4->Get("scint_dedx3"); //set up histogram for dedx4 TFile* fich5 = new TFile("targetout_raw.root"); fich5->ls(); TH1F* histo_det4 = (TH1F*) fich5->Get("scint_dedx4"); TFile* fich6 = new TFile("targetout_raw.root"); fich6->ls(); TH1F* histo_cal = (TH1F*) fich6->Get("cal"); //f0->Close(); TCutG *cutg = new TCutG("mycut1",6); cutg->SetVarX("scint_dedx1"); cutg->SetVarY("scint_dedx2"); cutg->SetTitle("Graph"); cutg->SetFillStyle(1000); cutg->SetPoint(0,1307.13,1580.92); cutg->SetPoint(1,2330.59,2492.76); cutg->SetPoint(2,2612.64,1948.03); cutg->SetPoint(3,1524.71,1107.24); cutg->SetPoint(4,1371.6,1616.45); cutg->SetPoint(5,1307.13,1580.92); //cutg->Draw(""); // Double_t *x, *y; Int_t np; TAxis *xaxis = graph->GetXaxis(); TAxis *yaxis = graph->GetYaxis(); np = graph->GetN(); //for (Int_t j=1; j<=np; j++){ // printf(" x[%d] = %graph y[%d] = %graph\n",j,x[j],j,y[j]);} cout<GetXaxis()->GetN(); // Int_t biny = graph->GetYaxis()->GetNBins(); // graph->GetHistogram()->GetMinimumBin(ix,iy,iz); // double xmin=graph->GetHistogram()->GetXaxis()->GetBinCenter(ix); // double ymin=graph->GetHistogram()->GetYaxis()->GetBinCenter(iy); // cout<GetBinCenter(biny); for (binx=1; binxGetBinCenter(binx); if(!cutg->IsInside(x,y)) continue; else break; cout << "x=" << x << "y=" << y <