// // Intersection Tests // // Created by Morten Dam Jørgensen on 2011-01-27. // http://mdj.dk // // Copyright (c) 2011 Niels Bohr Institute. All rights reserved. // #include #include #include #include #include #include #include void linetest(){ TCanvas *can = new TCanvas("can", "can", 1000, 800); TCutG *cutg = new TCutG("band_pdf_central_cteq_10000",20); cutg->SetVarX(""); cutg->SetVarY(""); cutg->SetTitle("band_pdf_central_cteq_10000"); // TCutG Region Int_t ci; // for color index setting ci = TColor::GetColor("#00ff00"); cutg->SetFillColor(ci); cutg->SetPoint(0,100,22000); cutg->SetPoint(1,200,644); cutg->SetPoint(2,300,63); cutg->SetPoint(3,400,10.4); cutg->SetPoint(4,500,2.34); cutg->SetPoint(5,600,0.634); cutg->SetPoint(6,700,0.194); cutg->SetPoint(7,800,0.0651); cutg->SetPoint(8,900,0.0233); cutg->SetPoint(9,1000,0.00867); cutg->SetPoint(10,1000,0.00695); cutg->SetPoint(11,900,0.0195); cutg->SetPoint(12,800,0.0571); cutg->SetPoint(13,700,0.177); cutg->SetPoint(14,600,0.596); cutg->SetPoint(15,500,2.27); cutg->SetPoint(16,400,10.4); cutg->SetPoint(17,300,62.1); cutg->SetPoint(18,200,625); cutg->SetPoint(19,100,21200); // TGraph line (blue) TGraph *graph = new TGraph(10); graph->SetName("central_band_cteq_10000"); graph->SetTitle("central_band_cteq_10000"); graph->SetFillColor(1); graph->SetPoint(0,100,21200); graph->SetPoint(1,200,62); graph->SetPoint(2,300,61.1); graph->SetPoint(3,400,9.4); graph->SetPoint(4,500,2.3); graph->SetPoint(5,600,0.632); graph->SetPoint(6,700,0.16); graph->SetPoint(7,800,0.05); graph->SetPoint(8,900,0.02); graph->SetPoint(9,1000,0.007); // TGraph line (red) TGraph *graphc = new TGraph(10); graphc->SetName("c"); graphc->SetTitle("c"); graphc->SetFillColor(2); graphc->SetLineColor(2); graphc->SetPoint(0,100, 1.45); graphc->SetPoint(1,200, 1.45); graphc->SetPoint(2,300, 1.45); graphc->SetPoint(3,400, 1.45); graphc->SetPoint(4,500, 1.45); graphc->SetPoint(5,600, 1.45); graphc->SetPoint(6,700, 1.45); graphc->SetPoint(7,800, 1.45); graphc->SetPoint(8,900, 1.45); graphc->SetPoint(9,1000, 1.45); cutg->Draw("AFP"); graph->Draw("LP"); cutg->SetMarkerSize(2.2); graph->SetLineColor(kBlue); graph->SetLineWidth(2); graphc->Draw("LP"); cutg->GetYaxis()->SetRangeUser(1.37, 1.47); cutg->GetXaxis()->SetRangeUser(540, 560); // TCutG region intersect TGraph *interg2 = graphc->GetIntersections(*cutg); interg2->Draw("P"); interg2->SetMarkerStyle(21); interg2->SetMarkerColor(kRed); // TGraph intersect TGraph *interg = graphc->GetIntersections(*graph); interg->Draw("P"); interg->SetMarkerStyle(21); cutg->SetTitle("Intersections"); cutg->GetXaxis()->SetTitle("x"); cutg->GetYaxis()->SetTitle("y"); TLatex l; l.SetTextSize(0.015); l.SetTextColor(kRed); for(size_t i = 0; i < interg2->GetN(); ++i) { Double_t x, y = 0; interg2->GetPoint(i, x, y); printf("inter2g x=%f, y=%f\n", x, y); l.DrawLatex(x - 1, y + 0.003, TString::Format("(%0.2f,%0.2f)", x, y)); } TLatex ll; ll.SetTextSize(0.015); ll.SetTextColor(kBlack); for(size_t i = 0; i < interg->GetN(); ++i) { Double_t x, y = 0; interg->GetPoint(i, x, y); printf("x=%f, y=%f\n", x, y); ll.DrawLatex(x - 2, y - 0.003, TString::Format("(%0.2f,%0.2f)", x, y)); } }