diff --git a/tutorials/visualisation/graphs/gr001_basic.C b/tutorials/visualisation/graphs/gr001_basic.C index f26b2c8b512f7..10d9acc72f833 100644 --- a/tutorials/visualisation/graphs/gr001_basic.C +++ b/tutorials/visualisation/graphs/gr001_basic.C @@ -1,38 +1,77 @@ /// \file /// \ingroup tutorial_graphs /// \notebook -/// Draw a simple graph. +/// +/// This tutorial demonstrates how to create simple graphs in ROOT. The example is divided into two sections: +/// - The first section plots data generated from arrays. +/// - The second section plots data read from a text file. /// /// \macro_image /// \macro_code -/// +/// /// \author Rene Brun -void graph() -{ - TCanvas *c1 = new TCanvas("c1", "A Simple Graph Example", 200, 10, 700, 500); +#include //Include the library for reading the data file + +void gr001_basic() { + TCanvas *c1 = new TCanvas("c1","Two simple graphs",200,10,700,500); + + c1->Divide(2,1); //Dividing the canvas in subpads for distinguishing the two examples, [See documentation](https://root.cern/doc/master/classTCanvas.html) - c1->SetGrid(); + //FIRST EXAMPLE (Available data) + c1->cd(1); - const Int_t n = 20; + const Int_t n = 20; //Fill the arrays x and y with the data points Double_t x[n], y[n]; - for (Int_t i = 0; i < n; i++) { - x[i] = i * 0.1; - y[i] = 10 * sin(x[i] + 0.2); - printf(" i %i %f %f \n", i, x[i], y[i]); + for (Int_t i=0;iSetLineColor(2); + gr1->SetLineWidth(4); + gr1->SetMarkerColor(4); + gr1->SetMarkerStyle(21); + gr1->SetTitle("Graph from available data"); //Choose title for the graph + gr1->GetXaxis()->SetTitle("X title"); //Choose title for the axis + gr1->GetYaxis()->SetTitle("Y title"); + + //Uncomment the following line to set a custom range for the x-axis (respectivly for the y-axis): + //gr1->GetXaxis()->SetRangeUser(0, 1.8); + + gr1->Draw("ACP"); //"A" draw axes, "C" = draw a smooth line through the markers (optional) and "P" = draw markers for data points + //Optional customization can be done on a ROOT interactive session + + + //SECOND EXAMPLE (Data stored in a text file) + c1->cd(2); + + const Int_t m = 20; //Known number of data points in the file + Double_t w[m], z[m]; + + std::ifstream file("data_basic.txt"); // Open the data file + + // Use a for loop to read the data + for (Int_t i = 0; i < m; i++) { + file >> w[i] >> z[i]; //Fill the arrays with the data from the file } - TGraph *gr = new TGraph(n, x, y); - gr->SetLineColor(2); - gr->SetLineWidth(4); - gr->SetMarkerColor(4); - gr->SetMarkerStyle(21); - gr->SetTitle("a simple graph"); - gr->GetXaxis()->SetTitle("X title"); - gr->GetYaxis()->SetTitle("Y title"); - gr->Draw("ACP"); - - // TCanvas::Update() draws the frame, after which one can change it - c1->Update(); - c1->GetFrame()->SetBorderSize(12); - c1->Modified(); + file.close(); //Close the file after reading + + + TGraph *gr2 = new TGraph(m, w, z); //Create a TGraph object for the file data + gr2->SetLineColor(4); + gr2->SetLineWidth(2); + gr2->SetMarkerColor(2); + gr2->SetMarkerStyle(20); + gr2->SetTitle("Graph from data file"); + gr2->GetXaxis()->SetTitle("W title"); + gr2->GetYaxis()->SetTitle("Z title"); + + + gr2->Draw("ACP"); } + diff --git a/tutorials/visualisation/graphs/gr006_scatter.C b/tutorials/visualisation/graphs/gr006_scatter.C index 6c2b4b00d7f55..5742a857882e0 100644 --- a/tutorials/visualisation/graphs/gr006_scatter.C +++ b/tutorials/visualisation/graphs/gr006_scatter.C @@ -21,15 +21,6 @@ void gr006_scatter() double c[n]; double s[n]; -<<<<<<<< HEAD:tutorials/visualisation/graphs/scatter.C - // Define four random data set - auto r = new TRandom(); - for (int i = 0; i < n; i++) { - x[i] = 100 * r->Rndm(i); - y[i] = 200 * r->Rndm(i); - c[i] = 300 * r->Rndm(i); - s[i] = 400 * r->Rndm(i); -======== // Define four random data sets auto r = new TRandom(); for (int i=0; iRndm(i); c[i] = 300*r->Rndm(i); s[i] = 400*r->Rndm(i); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr006_scatter.C } auto scatter = new TScatter(n, x, y, c, s); scatter->SetMarkerStyle(20); scatter->SetTitle("Scatter plot title;X title;Y title;Z title"); - scatter->GetXaxis()->SetRangeUser(20., 90.); - scatter->GetYaxis()->SetRangeUser(55., 90.); - scatter->GetZaxis()->SetRangeUser(10., 200.); + scatter->GetXaxis()->SetRangeUser(20.,90.); + scatter->GetYaxis()->SetRangeUser(55.,90.); + scatter->GetZaxis()->SetRangeUser(10.,200.); scatter->Draw("A"); } diff --git a/tutorials/visualisation/graphs/gr008_multierrors.C b/tutorials/visualisation/graphs/gr008_multierrors.C index 946107647c691..1df6092ae01e2 100644 --- a/tutorials/visualisation/graphs/gr008_multierrors.C +++ b/tutorials/visualisation/graphs/gr008_multierrors.C @@ -15,18 +15,17 @@ void gr008_multierrors() { c1->GetFrame()->SetBorderSize(12); const Int_t np = 5; - Double_t x[np] = {0, 1, 2, 3, 4}; - Double_t y[np] = {0, 2, 4, 1, 3}; - Double_t exl[np] = {0.3, 0.3, 0.3, 0.3, 0.3}; - Double_t exh[np] = {0.3, 0.3, 0.3, 0.3, 0.3}; - Double_t eylstat[np] = {1, 0.5, 1, 0.5, 1}; - Double_t eyhstat[np] = {0.5, 1, 0.5, 1, 0.5}; - Double_t eylsys[np] = {0.5, 0.4, 0.8, 0.3, 1.2}; - Double_t eyhsys[np] = {0.6, 0.7, 0.6, 0.4, 0.8}; + Double_t x[np] = {0, 1, 2, 3, 4}; + Double_t y[np] = {0, 2, 4, 1, 3}; + Double_t exl[np] = {0.3, 0.3, 0.3, 0.3, 0.3}; //Lower x errors + Double_t exh[np] = {0.3, 0.3, 0.3, 0.3, 0.3}; //Higher x errors + Double_t eylstat[np] = {1, 0.5, 1, 0.5, 1}; //Lower y statistical errors + Double_t eyhstat[np] = {0.5, 1, 0.5, 1, 0.5}; //Higher y statistical errors + Double_t eylsys[np] = {0.5, 0.4, 0.8, 0.3, 1.2}; //Lower y systematic errors + Double_t eyhsys[np] = {0.6, 0.7, 0.6, 0.4, 0.8}; //Higher y systematic errors - TGraphMultiErrors *gme = - new TGraphMultiErrors("gme", "TGraphMultiErrors Example", np, x, y, exl, exh, eylstat, eyhstat); - gme->AddYError(np, eylsys, eyhsys); + TGraphMultiErrors *gme = new TGraphMultiErrors("gme", "TGraphMultiErrors Example", np, x, y, exl, exh, eylstat, eyhstat); //Create the TGraphMultiErrors object + gme->AddYError(np, eylsys, eyhsys); //Add the systematic y-errors to the graph gme->SetMarkerStyle(20); gme->SetLineColor(kRed); gme->GetAttLine(0)->SetLineColor(kRed); //Color for statistical error bars diff --git a/tutorials/visualisation/graphs/gr011_2Derrorsfit.C b/tutorials/visualisation/graphs/gr011_2Derrorsfit.C index 732ffe9aa7e8c..3d3b68a19568c 100644 --- a/tutorials/visualisation/graphs/gr011_2Derrorsfit.C +++ b/tutorials/visualisation/graphs/gr011_2Derrorsfit.C @@ -24,43 +24,33 @@ void gr011_2Derrorsfit() // To generate some random data to put into the graph TRandom r; -<<<<<<<< HEAD:tutorials/visualisation/graphs/graph2derrorsfit.C - TF2 *f2 = new TF2("f2", "1000*(([0]*sin(x)/x)*([1]*sin(y)/y))+200", -6, 6, -6, 6); - f2->SetParameters(1, 1); -======== TF2 *f2 = new TF2("f2","1000*(([0]*sin(x)/x)*([1]*sin(y)/y))+200",-6,6,-6,6); f2->SetParameters(1,1); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr011_2Derrorsfit.C TGraph2DErrors *dte = new TGraph2DErrors(nd); // Fill the 2D graph. It was created only specifying the number of points, so all // elements are empty. We now "fill" the values and errors with SetPoint and SetPointError. // Note that the first point has index zero Double_t zmax = 0; - for (Int_t i = 0; i < nd; i++) { - f2->GetRandom2(x, y); - rnd = r.Uniform(-e, e); // Generate a random number in [-e,e] - z = f2->Eval(x, y) * (1 + rnd); - if (z > zmax) - zmax = z; - dte->SetPoint(i, x, y, z); - ex = 0.05 * r.Rndm(); - ey = 0.05 * r.Rndm(); - ez = TMath::Abs(z * rnd); - dte->SetPointError(i, ex, ey, ez); + for (Int_t i=0; iGetRandom2(x,y); + rnd = r.Uniform(-e,e); // Generate a random number in [-e,e] + z = f2->Eval(x,y)*(1+rnd); + if (z>zmax) zmax = z; + dte->SetPoint(i,x,y,z); + ex = 0.05*r.Rndm(); + ey = 0.05*r.Rndm(); + ez = TMath::Abs(z*rnd); + dte->SetPointError(i,ex,ey,ez); } // If the fit is not needed, just draw dte here and skip the lines below // dte->Draw("A p0"); -<<<<<<<< HEAD:tutorials/visualisation/graphs/graph2derrorsfit.C - f2->SetParameters(0.5, 1.5); -======== // To do the fit we use a function, in this example the same f2 from above f2->SetParameters(0.5,1.5); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr011_2Derrorsfit.C dte->Fit(f2); - TF2 *fit2 = (TF2 *)dte->FindObject("f2"); + TF2 *fit2 = (TF2*)dte->FindObject("f2"); fit2->SetTitle("Minuit fit result on the Graph2DErrors points"); fit2->SetMaximum(zmax); gStyle->SetHistTopMargin(0); diff --git a/tutorials/visualisation/graphs/gr014_polar3.C b/tutorials/visualisation/graphs/gr014_polar3.C index 515960415be93..3a82319240fab 100644 --- a/tutorials/visualisation/graphs/gr014_polar3.C +++ b/tutorials/visualisation/graphs/gr014_polar3.C @@ -13,20 +13,20 @@ void gr014_polar3() { - TCanvas *CPol = new TCanvas("CPol", "TGraphPolar Examples", 500, 500); + TCanvas *CPol = new TCanvas("CPol","TGraphPolar Examples",500,500); Double_t rmin = 0; - Double_t rmax = TMath::Pi() * 2; + Double_t rmax = TMath::Pi()*2; Double_t r[1000]; Double_t theta[1000]; - TF1 fp1("fplot", "cos(x)", rmin, rmax); + TF1 *fp1 = new TF1("fplot","cos(x)",rmin,rmax); for (Int_t ipt = 0; ipt < 1000; ipt++) { - r[ipt] = ipt * (rmax - rmin) / 1000 + rmin; - theta[ipt] = fp1.Eval(r[ipt]); + r[ipt] = ipt*(rmax-rmin)/1000+rmin; + theta[ipt] = fp1->Eval(r[ipt]); } - auto grP1 = new TGraphPolar(1000, r, theta); + TGraphPolar *grP1 = new TGraphPolar(1000, r, theta); grP1->SetTitle(""); grP1->SetLineColor(2); grP1->Draw("AOL"); diff --git a/tutorials/visualisation/graphs/gr017_time.C b/tutorials/visualisation/graphs/gr017_time.C index e1968a565f67f..51a7ec47ad491 100644 --- a/tutorials/visualisation/graphs/gr017_time.C +++ b/tutorials/visualisation/graphs/gr017_time.C @@ -17,8 +17,7 @@ void gr017_time(Int_t nsteps = 500, Int_t np = 100) { - if (np > 1000) - np = 1000; + if (np > 1000) np = 1000; std::vector color(np); std::vector rr(np), phi(np), dr(np), size(np); TRandom3 r; @@ -62,20 +61,14 @@ void gr017_time(Int_t nsteps = 500, Int_t np = 100) // g->SaveAnimatedGif("gr17_time.gif"); // save object to a file -<<<<<<<< HEAD:tutorials/visualisation/graphs/gtime.C - auto f = TFile::Open("gtime.root", "recreate"); -======== auto f = TFile::Open("gr17_time.root","recreate"); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr017_time.C f->WriteObject(g, "g"); delete f; // to view this object in another session do -<<<<<<<< HEAD:tutorials/visualisation/graphs/gtime.C - // TFile::Open("gtime.root"); - // g->Draw(); -======== // TFile::Open("gr17_time.root"); // g->Draw(); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr017_time.C } + + + diff --git a/tutorials/visualisation/graphs/gr018_time2.C b/tutorials/visualisation/graphs/gr018_time2.C index d0c1aa59a817f..517ee00263fa6 100644 --- a/tutorials/visualisation/graphs/gr018_time2.C +++ b/tutorials/visualisation/graphs/gr018_time2.C @@ -20,15 +20,14 @@ void gr018_time2(Int_t nsteps = 200, Int_t np = 5000) { - if (np > 5000) - np = 5000; + if (np > 5000) np = 5000; std::vector color(np); std::vector cosphi(np), sinphi(np), speed(np); TRandom3 r; Double_t xmin = 0, xmax = 10, ymin = -10, ymax = 10; - TGraphTime *g = new TGraphTime(nsteps, xmin, ymin, xmax, ymax); + TGraphTime *g = new TGraphTime(nsteps,xmin,ymin,xmax,ymax); g->SetTitle("TGraphTime demo 2;X;Y"); - Double_t fact = xmax / Double_t(nsteps); + Double_t fact = xmax/Double_t(nsteps); for (Int_t i = 0; i < np; i++) { // calculate some object parameters speed[i] = r.Uniform(0.5, 1); Double_t phi = r.Gaus(0, TMath::Pi() / 6.); @@ -36,23 +35,20 @@ void gr018_time2(Int_t nsteps = 200, Int_t np = 5000) sinphi[i] = fact * speed[i] * TMath::Sin(phi); Double_t rc = r.Rndm(); color[i] = kRed; - if (rc > 0.3) - color[i] = kBlue; - if (rc > 0.7) - color[i] = kYellow; + if (rc > 0.3) color[i] = kBlue; + if (rc > 0.7) color[i] = kYellow; } for (Int_t s = 0; s < nsteps; s++) { // fill the TGraphTime step by step for (Int_t i = 0; i < np; i++) { - Double_t xx = s * cosphi[i]; - if (xx < xmin) - continue; - Double_t yy = s * sinphi[i]; - TMarker *m = new TMarker(xx, yy, 25); + Double_t xx = s*cosphi[i]; + if (xx < xmin) continue; + Double_t yy = s*sinphi[i]; + TMarker *m = new TMarker(xx,yy,25); m->SetMarkerColor(color[i]); - m->SetMarkerSize(1.5 - s / (speed[i] * nsteps)); + m->SetMarkerSize(1.5 -s/(speed[i]*nsteps)); g->Add(m, s); } - g->Add(new TPaveLabel(.70, .92, .98, .99, TString::Format("shower at %5.3f nsec", 3. * s / nsteps), "brNDC"), s); + g->Add(new TPaveLabel(.70,.92,.98,.99,TString::Format("shower at %5.3f nsec",3.*s/nsteps),"brNDC"),s); } g->Draw(); @@ -63,3 +59,6 @@ void gr018_time2(Int_t nsteps = 200, Int_t np = 5000) // start animation, can be stopped with g->Animate(kFALSE); // g->Animate(); } + + + diff --git a/tutorials/visualisation/graphs/gr102_reverse_axis.C b/tutorials/visualisation/graphs/gr102_reverse_axis.C index b141e86d18597..ed45b20823cff 100644 --- a/tutorials/visualisation/graphs/gr102_reverse_axis.C +++ b/tutorials/visualisation/graphs/gr102_reverse_axis.C @@ -22,6 +22,7 @@ void gr102_reverse_axis() { gr->SetPoint(1,9,9); gr->SetPoint(2,14,14); + c->cd(1); gPad->SetGrid(); gr->Draw("a pl "); //Plot with axis ("a") and line+points ("pl") @@ -29,4 +30,5 @@ void gr102_reverse_axis() { c->cd(2); gPad->SetGrid(); gr->Draw("a pl rx ry "); //Plot with axis ("a") and line+points ("pl") with reverse X and Y axes + } diff --git a/tutorials/visualisation/graphs/gr103_zones.C b/tutorials/visualisation/graphs/gr103_zones.C index 711acf6441b53..d5bf51f3d9104 100644 --- a/tutorials/visualisation/graphs/gr103_zones.C +++ b/tutorials/visualisation/graphs/gr103_zones.C @@ -24,20 +24,14 @@ /// \macro_code /// \author Rene Brun -<<<<<<<< HEAD:tutorials/visualisation/graphs/zones.C -void zones() -{ - TCanvas *c1 = new TCanvas("c1", "multipads", 900, 700); -======== void gr103_zones() { TCanvas *c1 = new TCanvas("c1","multipads",900,700); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr103_zones.C gStyle->SetOptStat(0); - c1->Divide(2, 2, 0, 0); - TH2F *h1 = new TH2F("h1", "test1", 10, 0, 1, 20, 0, 20); - TH2F *h2 = new TH2F("h2", "test2", 10, 0, 1, 20, 0, 100); - TH2F *h3 = new TH2F("h3", "test3", 10, 0, 1, 20, -1, 1); - TH2F *h4 = new TH2F("h4", "test4", 10, 0, 1, 20, 0, 1000); + c1->Divide(2,2,0,0); + TH2F *h1 = new TH2F("h1","test1",10,0,1,20,0,20); + TH2F *h2 = new TH2F("h2","test2",10,0,1,20,0,100); + TH2F *h3 = new TH2F("h3","test3",10,0,1,20,-1,1); + TH2F *h4 = new TH2F("h4","test4",10,0,1,20,0,1000); c1->cd(1); gPad->SetTickx(2); diff --git a/tutorials/visualisation/graphs/gr104_palettecolor.C b/tutorials/visualisation/graphs/gr104_palettecolor.C index 64fe9d235a234..c52bd92832a1c 100644 --- a/tutorials/visualisation/graphs/gr104_palettecolor.C +++ b/tutorials/visualisation/graphs/gr104_palettecolor.C @@ -19,44 +19,29 @@ /// \macro_code /// \author Olivier Couet -<<<<<<<< HEAD:tutorials/visualisation/graphs/graphpalettecolor.C -void graphpalettecolor() -{ -======== void gr104_palettecolor () { ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr104_palettecolor.C gStyle->SetOptTitle(kFALSE); gStyle->SetPalette(kSolar); - double x[5] = {1, 2, 3, 4, 5}; - double y1[5] = {1.0, 2.0, 1.0, 2.5, 3.0}; - double y2[5] = {1.1, 2.1, 1.1, 2.6, 3.1}; - double y3[5] = {1.2, 2.2, 1.2, 2.7, 3.2}; - double y4[5] = {1.3, 2.3, 1.3, 2.8, 3.3}; - double y5[5] = {1.4, 2.4, 1.4, 2.9, 3.4}; + double x[5] = {1,2,3,4,5}; + double y1[5] = {1.0,2.0,1.0,2.5,3.0}; + double y2[5] = {1.1,2.1,1.1,2.6,3.1}; + double y3[5] = {1.2,2.2,1.2,2.7,3.2}; + double y4[5] = {1.3,2.3,1.3,2.8,3.3}; + double y5[5] = {1.4,2.4,1.4,2.9,3.4}; - TGraph *g1 = new TGraph(5, x, y1); - g1->SetTitle("Graph with a red star"); - TGraph *g2 = new TGraph(5, x, y2); - g2->SetTitle("Graph with a circular marker"); - TGraph *g3 = new TGraph(5, x, y3); - g3->SetTitle("Graph with an open square marker"); - TGraph *g4 = new TGraph(5, x, y4); - g4->SetTitle("Graph with a blue star"); - TGraph *g5 = new TGraph(5, x, y5); - g5->SetTitle("Graph with a full square marker"); + TGraph *g1 = new TGraph(5,x,y1); g1->SetTitle("Graph with a red star"); + TGraph *g2 = new TGraph(5,x,y2); g2->SetTitle("Graph with a circular marker"); + TGraph *g3 = new TGraph(5,x,y3); g3->SetTitle("Graph with an open square marker"); + TGraph *g4 = new TGraph(5,x,y4); g4->SetTitle("Graph with a blue star"); + TGraph *g5 = new TGraph(5,x,y5); g5->SetTitle("Graph with a full square marker"); - g1->SetLineWidth(3); - g1->SetMarkerColor(kRed); - g2->SetLineWidth(3); - g2->SetMarkerStyle(kCircle); - g3->SetLineWidth(3); - g3->SetMarkerStyle(kOpenSquare); - g4->SetLineWidth(3); - g4->SetMarkerColor(kBlue); - g5->SetLineWidth(3); - g5->SetMarkerStyle(kFullSquare); + g1->SetLineWidth(3); g1->SetMarkerColor(kRed); + g2->SetLineWidth(3); g2->SetMarkerStyle(kCircle); + g3->SetLineWidth(3); g3->SetMarkerStyle(kOpenSquare); + g4->SetLineWidth(3); g4->SetMarkerColor(kBlue); + g5->SetLineWidth(3); g5->SetMarkerStyle(kFullSquare); // The Draw option "A" (draw axes) is needed (only) for the first drawn graph g1->Draw("CA* PLC PFC"); diff --git a/tutorials/visualisation/graphs/gr105_multigraphpalettecolor.C b/tutorials/visualisation/graphs/gr105_multigraphpalettecolor.C index 6c05a0681893c..d15791ae904bb 100644 --- a/tutorials/visualisation/graphs/gr105_multigraphpalettecolor.C +++ b/tutorials/visualisation/graphs/gr105_multigraphpalettecolor.C @@ -17,32 +17,28 @@ void gr105_multigraphpalettecolor() { - auto mg = new TMultiGraph(); + auto mg = new TMultiGraph(); - auto gr1 = new TGraph(); - gr1->SetMarkerStyle(20); - auto gr2 = new TGraph(); - gr2->SetMarkerStyle(21); - auto gr3 = new TGraph(); - gr3->SetMarkerStyle(23); - auto gr4 = new TGraph(); - gr4->SetMarkerStyle(24); + auto gr1 = new TGraph(); gr1->SetMarkerStyle(20); + auto gr2 = new TGraph(); gr2->SetMarkerStyle(21); + auto gr3 = new TGraph(); gr3->SetMarkerStyle(23); + auto gr4 = new TGraph(); gr4->SetMarkerStyle(24); - Double_t dx = 6.28 / 100; - Double_t x = -3.14; + Double_t dx = 6.28/100; + Double_t x = -3.14; - for (int i = 0; i <= 100; i++) { - x = x + dx; - gr1->SetPoint(i, x, 2. * TMath::Sin(x)); - gr2->SetPoint(i, x, TMath::Cos(x)); - gr3->SetPoint(i, x, TMath::Cos(x * x)); - gr4->SetPoint(i, x, TMath::Cos(x * x * x)); + for (int i=0; i<=100; i++) { + x = x+dx; + gr1->SetPoint(i,x,2.*TMath::Sin(x)); + gr2->SetPoint(i,x,TMath::Cos(x)); + gr3->SetPoint(i,x,TMath::Cos(x*x)); + gr4->SetPoint(i,x,TMath::Cos(x*x*x)); } - mg->Add(gr4, "PL"); - mg->Add(gr3, "PL"); - mg->Add(gr2, "*L"); - mg->Add(gr1, "PL"); + mg->Add(gr4,"PL"); + mg->Add(gr3,"PL"); + mg->Add(gr2,"*L"); + mg->Add(gr1,"PL"); mg->Draw("A pmc plc"); } diff --git a/tutorials/visualisation/graphs/gr106_exclusiongraph.C b/tutorials/visualisation/graphs/gr106_exclusiongraph.C index 54ff656a5c609..ae8ef9f929ef8 100644 --- a/tutorials/visualisation/graphs/gr106_exclusiongraph.C +++ b/tutorials/visualisation/graphs/gr106_exclusiongraph.C @@ -12,14 +12,8 @@ /// \macro_code /// \author Olivier Couet -<<<<<<<< HEAD:tutorials/visualisation/graphs/exclusiongraph.C -TCanvas *exclusiongraph() -{ - TCanvas *c1 = new TCanvas("c1", "Exclusion graphs examples", 200, 10, 600, 400); -======== void gr106_exclusiongraph() { TCanvas *c1 = new TCanvas("c1","Exclusion graph examples",200,10,600,400); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr106_exclusiongraph.C c1->SetGrid(); TMultiGraph *mg = new TMultiGraph(); @@ -27,32 +21,28 @@ void gr106_exclusiongraph() { const Int_t n = 35; Double_t xvalues1[n], xvalues2[n], xvalues3[n], yvalues1[n], yvalues2[n], yvalues3[n]; - for (Int_t i = 0; i < n; i++) { - xvalues1[i] = i * 0.1; - xvalues2[i] = xvalues1[i]; - xvalues3[i] = xvalues1[i] + .5; - yvalues1[i] = 10 * sin(xvalues1[i]); - yvalues2[i] = 10 * cos(xvalues1[i]); - yvalues3[i] = 10 * sin(xvalues1[i]) - 2; + for (Int_t i=0;i>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr106_exclusiongraph.C gr1->SetLineColor(2); gr1->SetLineWidth(1504); gr1->SetFillStyle(3005); - TGraph *gr2 = new TGraph(n, xvalues2, yvalues2); + TGraph *gr2 = new TGraph(n,xvalues2,yvalues2); gr2->SetLineColor(4); gr2->SetLineWidth(-2002); gr2->SetFillStyle(3004); gr2->SetFillColor(9); - TGraph *gr3 = new TGraph(n, xvalues3, yvalues3); + TGraph *gr3 = new TGraph(n,xvalues3,yvalues3); gr3->SetLineColor(5); gr3->SetLineWidth(-802); gr3->SetFillStyle(3002); diff --git a/tutorials/visualisation/graphs/gr108_timeSeriesFromCSV.C b/tutorials/visualisation/graphs/gr108_timeSeriesFromCSV.C index 789702c160dc2..3d22c13bbfd59 100644 --- a/tutorials/visualisation/graphs/gr108_timeSeriesFromCSV.C +++ b/tutorials/visualisation/graphs/gr108_timeSeriesFromCSV.C @@ -15,7 +15,7 @@ void gr108_timeSeriesFromCSV() // service, SWAN, during two weeks. We would like to plot this data with // ROOT to draw some conclusions from it. TString dir = gROOT->GetTutorialDir(); - dir.Append("/visualisation/graphs/"); + dir.Append("/graphs/"); dir.ReplaceAll("/./", "/"); FILE *f = fopen(Form("%sSWAN2017.dat", dir.Data()), "r"); diff --git a/tutorials/visualisation/graphs/gr108_timeSeriesFromCSV.py b/tutorials/visualisation/graphs/gr108_timeSeriesFromCSV.py index c678659553cb5..3663c3a282d7d 100644 --- a/tutorials/visualisation/graphs/gr108_timeSeriesFromCSV.py +++ b/tutorials/visualisation/graphs/gr108_timeSeriesFromCSV.py @@ -15,7 +15,7 @@ # service, SWAN, during two weeks. We would like to plot this data with # ROOT to draw some conclusions from it. dirName = str(ROOT.gROOT.GetTutorialDir()) -dirName += "/visualisation/graphs/" +dirName += "/graphs/" dirName= dirName.replace("/./", "/") inputFileName = "%s/SWAN2017.dat" %dirName @@ -39,7 +39,7 @@ c.SetRightMargin(0.04) c.SetGrid() g.SetLineWidth(3) -g.SetLineColor("kBlue") +g.SetLineColor(ROOT.kBlue) g.Draw("al") g.GetYaxis().CenterTitle() diff --git a/tutorials/visualisation/graphs/gr109_timeSeriesFromCSV_TDF.C b/tutorials/visualisation/graphs/gr109_timeSeriesFromCSV_TDF.C index 49be1f566b966..442848f8c7948 100644 --- a/tutorials/visualisation/graphs/gr109_timeSeriesFromCSV_TDF.C +++ b/tutorials/visualisation/graphs/gr109_timeSeriesFromCSV_TDF.C @@ -16,7 +16,7 @@ void timeSeriesFromCSV_TDF() // service, SWAN, during two weeks. We would like to plot this data with // ROOT to draw some conclusions from it. TString dir = gROOT->GetTutorialDir(); - dir.Append("/visualisation/graphs/"); + dir.Append("/graphs/"); dir.ReplaceAll("/./", "/"); // Read the data from the file using TDataFrame. We do not have headers and diff --git a/tutorials/visualisation/graphs/gr201_waves.C b/tutorials/visualisation/graphs/gr201_waves.C index fd2c499c9ccb7..ef56338ec0976 100644 --- a/tutorials/visualisation/graphs/gr201_waves.C +++ b/tutorials/visualisation/graphs/gr201_waves.C @@ -20,46 +20,41 @@ #include "TStyle.h" //______________________________________________________________ -Double_t interference(Double_t *x, Double_t *par) +Double_t interference( Double_t *x, Double_t *par) { Double_t x_p2 = x[0] * x[0]; Double_t d_2 = 0.5 * par[2]; Double_t ym_p2 = (x[1] - d_2) * (x[1] - d_2); Double_t yp_p2 = (x[1] + d_2) * (x[1] + d_2); - Double_t tpi_l = TMath::Pi() / par[1]; - Double_t amplitude = par[0] * (cos(tpi_l * sqrt(x_p2 + ym_p2)) + par[3] * cos(tpi_l * sqrt(x_p2 + yp_p2))); + Double_t tpi_l = TMath::Pi() / par[1]; + Double_t amplitude = par[0] * (cos(tpi_l * sqrt(x_p2 + ym_p2)) + + par[3] * cos(tpi_l * sqrt(x_p2 + yp_p2))); return amplitude * amplitude; } + //_____________________________________________________________ -Double_t result(Double_t *x, Double_t *par) +Double_t result( Double_t *x, Double_t *par) { Double_t xint[2]; - Double_t maxintens = 0, xcur = 14; + Double_t maxintens = 0, xcur = 14; Double_t dlambda = 0.1 * par[1]; - for (Int_t i = 0; i < 10; i++) { + for(Int_t i=0; i<10; i++){ xint[0] = xcur; xint[1] = x[1]; - Double_t intens = interference(xint, par); - if (intens > maxintens) - maxintens = intens; + Double_t intens = interference(xint, par); + if(intens > maxintens) maxintens = intens; xcur -= dlambda; } return maxintens; } + //_____________________________________________________________ -<<<<<<<< HEAD:tutorials/visualisation/graphs/waves.C -void waves(Double_t d = 3, Double_t lambda = 1, Double_t amp = 10) -{ - TCanvas *c1 = new TCanvas("waves", "A double slit experiment", 300, 40, 1004, 759); - c1->Range(0, -10, 30, 10); -======== void gr201_waves( Double_t d = 3, Double_t lambda = 1, Double_t amp = 10) { TCanvas *c1 = new TCanvas("gr201_waves", "A double slit experiment", 300, 40, 1004, 759); c1->Range(0, -10, 30, 10); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr201_waves.C c1->SetFillColor(0); TPad *pad = new TPad("pr", "pr", 0.5, 0, 1., 1); pad->Range(0, -10, 15, 10); @@ -68,30 +63,21 @@ void gr201_waves( Double_t d = 3, Double_t lambda = 1, Double_t amp = 10) const Int_t colNum = 30; Int_t palette[colNum]; for (Int_t i = 0; i < colNum; i++) { -<<<<<<<< HEAD:tutorials/visualisation/graphs/waves.C - Float_t level = 1. * i / colNum; - palette[i] = - TColor::GetColor((Float_t)TMath::Power(level, 0.3), (Float_t)TMath::Power(level, 0.3), (Float_t)0.5 * level); -======== Float_t level = 1.*i/colNum; palette[i] = TColor::GetColor((Float_t) TMath::Power(level,0.3), (Float_t) TMath::Power(level,0.3), (Float_t) 0.5*level); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr201_waves.C // palette[i] = 1001+i; } gStyle->SetPalette(colNum, palette); c1->cd(); -<<<<<<<< HEAD:tutorials/visualisation/graphs/waves.C -======== // For the incoming waves, on the left side, we use a TF2 and increase the number // of points used for drawing to 200 (default is 100) for better resolution ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr201_waves.C TF2 *f0 = new TF2("ray_source", interference, 0.02, 15, -8, 8, 4); f0->SetParameters(amp, lambda, 0, 0); f0->SetNpx(200); f0->SetNpy(200); - f0->SetContour(colNum - 2); + f0->SetContour(colNum-2); f0->Draw("samecol"); TLatex title; @@ -119,17 +105,6 @@ void gr201_waves( Double_t d = 3, Double_t lambda = 1, Double_t amp = 10) graph->SetPoint(3, 0, -0.1); graph->Draw("F"); -<<<<<<<< HEAD:tutorials/visualisation/graphs/waves.C - TLine *line = new TLine(15, -10, 15, 0 - 0.5 * d - 0.2); - line->SetLineWidth(10); - line->Draw(); - - line = new TLine(15, 0 - 0.5 * d + 0.2, 15, 0 + 0.5 * d - 0.2); - line->SetLineWidth(10); - line->Draw(); - - line = new TLine(15, 0 + 0.5 * d + 0.2, 15, 10); -======== // To represent the wall with 2 openings, we draw 3 black vertical lines TLine * line = new TLine(15,-10, 15, 0 - 0.5*d - 0.2); line->SetLineWidth(10); @@ -140,22 +115,17 @@ void gr201_waves( Double_t d = 3, Double_t lambda = 1, Double_t amp = 10) line->Draw(); line = new TLine(15, 0 + 0.5*d + 0.2, 15, 10); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr201_waves.C line->SetLineWidth(10); line->Draw(); pad->cd(); -<<<<<<<< HEAD:tutorials/visualisation/graphs/waves.C - TF2 *finter = new TF2("interference", interference, 0.01, 14, -10, 10, 4); -======== // Interference plot, on the centre-right side TF2 *finter = new TF2("interference",interference, 0.01, 14, -10, 10, 4); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr201_waves.C finter->SetParameters(amp, lambda, d, 1); finter->SetNpx(200); finter->SetNpy(200); - finter->SetContour(colNum - 2); + finter->SetContour(colNum-2); finter->Draw("samecol"); // Some lines @@ -165,35 +135,24 @@ void gr201_waves( Double_t d = 3, Double_t lambda = 1, Double_t amp = 10) arc.SetLineColor(5); Float_t r = 0.5 * lambda, dr = lambda; for (Int_t i = 0; i < 16; i++) { - arc.DrawArc(0, 0.5 * d, r, 0., 360., "only"); - arc.DrawArc(0, -0.5 * d, r, 0., 360., "only"); + arc.DrawArc(0, 0.5*d, r, 0., 360., "only"); + arc.DrawArc(0, -0.5*d, r, 0., 360., "only"); r += dr; } pad->cd(); -<<<<<<<< HEAD:tutorials/visualisation/graphs/waves.C - TF2 *fresult = new TF2("result", result, 14, 15, -10, 10, 4); -======== // Result, on the right edge TF2 *fresult = new TF2("result",result, 14, 15, -10, 10, 4); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr201_waves.C fresult->SetParameters(amp, lambda, d, 1); fresult->SetNpx(300); fresult->SetNpy(300); - fresult->SetContour(colNum - 2); + fresult->SetContour(colNum-2); fresult->Draw("samecol"); -<<<<<<<< HEAD:tutorials/visualisation/graphs/waves.C - line = new TLine(13.8, -10, 14, 10); - line->SetLineWidth(10); - line->SetLineColor(0); - line->Draw(); -======== // Vertical white line on the right side line = new TLine(14,-10, 14, 10); line->SetLineWidth(10); line->SetLineColor(0); line->Draw(); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr201_waves.C c1->Modified(kTRUE); c1->Update(); c1->SetEditable(kTRUE); diff --git a/tutorials/visualisation/graphs/gr202_textmarkers.C b/tutorials/visualisation/graphs/gr202_textmarkers.C index 3e5adcc8abe82..84f6981d7af30 100644 --- a/tutorials/visualisation/graphs/gr202_textmarkers.C +++ b/tutorials/visualisation/graphs/gr202_textmarkers.C @@ -10,43 +10,30 @@ /// \macro_code /// \author Olivier Couet -<<<<<<<< HEAD:tutorials/visualisation/graphs/graphtext.C -void graphtext() -{ - TCanvas *c = new TCanvas("c", "A Simple Graph Example with Text", 700, 500); -======== void gr202_textmarkers() { TCanvas *c = new TCanvas("c","A Simple Graph Example with Text",700,500); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr202_textmarkers.C c->SetGrid(); const Int_t n = 10; auto gr = new TGraph(n); gr->SetTitle("A Simple Graph Example with Text"); gr->SetMarkerStyle(20); - auto ex = new TExec("ex", "drawtext();"); + auto ex = new TExec("ex","drawtext();"); gr->GetListOfFunctions()->Add(ex); Double_t x, y; -<<<<<<<< HEAD:tutorials/visualisation/graphs/graphtext.C - for (Int_t i = 0; i < n; i++) { - x = i * 0.1; - y = 10 * sin(x + 0.2); - gr->SetPoint(i, x, y); -======== for (Int_t i=0;iSetPoint(i,x,y); ->>>>>>>> 021c32da2b (Rename and comment graphs tutorials):tutorials/visualisation/graphs/gr202_textmarkers.C } gr->Draw("ALP"); } void drawtext() { - Int_t i, n; - Double_t x, y; + Int_t i,n; + Double_t x,y; TLatex l; l.SetTextSize(0.025); @@ -54,11 +41,12 @@ void drawtext() l.SetTextAlign(21); l.SetTextColor(kBlue); - auto g = (TGraph *)gPad->GetListOfPrimitives()->FindObject("Graph"); + auto g = (TGraph*)gPad->GetListOfPrimitives()->FindObject("Graph"); n = g->GetN(); - for (i = 0; i < n; i++) { - g->GetPoint(i, x, y); - l.PaintText(x, y + 0.2, Form("(%4.2f,%4.2f)", x, y)); + for (i=0; iGetPoint(i,x,y); + l.PaintText(x,y+0.2,Form("(%4.2f,%4.2f)",x,y)); } } + diff --git a/tutorials/visualisation/graphs/gr301_highlight1.C b/tutorials/visualisation/graphs/gr301_highlight1.C index a6c1495afd271..960aeff8a83c2 100644 --- a/tutorials/visualisation/graphs/gr301_highlight1.C +++ b/tutorials/visualisation/graphs/gr301_highlight1.C @@ -12,8 +12,7 @@ TList *l = nullptr; void HighlightHisto(TVirtualPad *pad, TObject *obj, Int_t ihp, Int_t y) { auto Pad = (TVirtualPad *)pad->FindObject("Pad"); - if (!Pad) - return; + if (!Pad) return; if (ihp == -1) { // after highlight disabled Pad->Clear(); @@ -50,7 +49,7 @@ void gr301_highlight1() g->Draw("AP"); auto Pad = new TPad("Pad", "Pad", 0.3, 0.4, 1.0, 1.0); - Pad->SetFillColor(kBlue - 10); + Pad->SetFillColor(kBlue-10); Pad->Draw(); Pad->cd(); auto info = new TText(0.5, 0.5, "please move the mouse over the graPad"); diff --git a/tutorials/visualisation/graphs/gr302_highlight2.C b/tutorials/visualisation/graphs/gr302_highlight2.C index 25551a430c586..461110a5115a0 100644 --- a/tutorials/visualisation/graphs/gr302_highlight2.C +++ b/tutorials/visualisation/graphs/gr302_highlight2.C @@ -12,17 +12,15 @@ TNtuple *ntuple = nullptr; void HighlightBinId(TVirtualPad *pad, TObject *obj, Int_t ihp, Int_t y) { auto Canvas2 = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("Canvas2"); - if (!Canvas2) - return; + if (!Canvas2) return; auto histo = (TH1F *)Canvas2->FindObject("histo"); - if (!histo) - return; + if (!histo) return; Double_t px = ntuple->GetV1()[ihp]; Double_t py = ntuple->GetV2()[ihp]; Double_t pz = ntuple->GetV3()[ihp]; - Double_t i = ntuple->GetV4()[ihp]; - Double_t p = TMath::Sqrt(px * px + py * py + pz * pz); + Double_t i = ntuple->GetV4()[ihp]; + Double_t p = TMath::Sqrt(px*px + py*py + pz*pz); Int_t hbin = histo->FindBin(p); Bool_t redraw = kFALSE; @@ -48,7 +46,8 @@ void HighlightBinId(TVirtualPad *pad, TObject *obj, Int_t ihp, Int_t y) th->SetBit(kCanDelete); redraw = kTRUE; } - th->SetText(histo->GetXaxis()->GetXmax() * 0.75, histo->GetMaximum() * 0.5, TString::Format("id = %d", (Int_t)i)); + th->SetText(histo->GetXaxis()->GetXmax()*0.75, histo->GetMaximum()*0.5, + TString::Format("id = %d", (Int_t)i)); if (ihp == -1) { // after highlight disabled delete bh; @@ -56,8 +55,7 @@ void HighlightBinId(TVirtualPad *pad, TObject *obj, Int_t ihp, Int_t y) } Canvas2->Modified(); Canvas2->Update(); - if (!redraw) - return; + if (!redraw) return; auto savepad = gPad; Canvas2->cd(); @@ -71,16 +69,13 @@ void gr302_highlight2() { auto dir = gROOT->GetTutorialDir(); dir.Append("/hsimple.C"); - dir.ReplaceAll("/./", "/"); - if (!gInterpreter->IsLoaded(dir.Data())) - gInterpreter->LoadMacro(dir.Data()); - auto file = (TFile *)gROOT->ProcessLineFast("hsimple(1)"); - if (!file) - return; + dir.ReplaceAll("/./","/"); + if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data()); + auto file = (TFile*)gROOT->ProcessLineFast("hsimple(1)"); + if (!file) return; file->GetObject("ntuple", ntuple); - if (!ntuple) - return; + if (!ntuple) return; TCanvas *Canvas1 = new TCanvas("Canvas1", "Canvas1", 0, 0, 500, 500); Canvas1->HighlightConnect("HighlightBinId(TVirtualPad*,TObject*,Int_t,Int_t)"); @@ -92,7 +87,7 @@ void gr302_highlight2() auto info = new TText(0.0, 4.5, "please move the mouse over the graph"); info->SetTextAlign(22); info->SetTextSize(0.03); - info->SetTextColor(kRed + 1); + info->SetTextColor(kRed+1); info->SetBit(kCannotPick); info->Draw(); diff --git a/tutorials/visualisation/graphs/gr303_zdemo.C b/tutorials/visualisation/graphs/gr303_zdemo.C index fe140c1cdb0fb..66e0a08cc3bc4 100644 --- a/tutorials/visualisation/graphs/gr303_zdemo.C +++ b/tutorials/visualisation/graphs/gr303_zdemo.C @@ -15,7 +15,6 @@ /// /// \macro_image /// \macro_code -/// /// \authors Michael Tokarev, Elena Potrebenikova (JINR Dubna) #include "TCanvas.h" @@ -47,13 +46,13 @@ void gr303_zdemo() Float_t delp; // Create a new canvas. - TCanvas *c1 = new TCanvas("zdemo", "Monte Carlo Study of Z scaling", 10, 40, 800, 600); - c1->Range(0, 0, 25, 18); + TCanvas *c1 = new TCanvas("zdemo", + "Monte Carlo Study of Z scaling",10,40,800,600); + c1->Range(0,0,25,18); c1->SetFillColor(40); - TPaveLabel *pl = new TPaveLabel(1, 16.3, 24, 17.5, "Z-scaling of \ - Direct Photon Productions in pp Collisions at RHIC Energies", - "br"); + TPaveLabel *pl = new TPaveLabel(1,16.3,24,17.5,"Z-scaling of \ + Direct Photon Productions in pp Collisions at RHIC Energies","br"); pl->SetFillColor(18); pl->SetTextFont(32); pl->SetTextColor(49); @@ -64,33 +63,33 @@ void gr303_zdemo() t0.SetTextColor(1); t0.SetTextSize(0.03); t0.SetTextAlign(12); - t0.DrawLatex(3.1, 15.5, "M.Tokarev, E.Potrebenikova "); - t0.DrawLatex(14., 15.5, "JINR preprint E2-98-64, Dubna, 1998 "); + t0.DrawLatex(3.1,15.5,"M.Tokarev, E.Potrebenikova "); + t0.DrawLatex(14.,15.5,"JINR preprint E2-98-64, Dubna, 1998 "); - TPad *pad1 = new TPad("pad1", "This is pad1", 0.02, 0.02, 0.48, 0.83, 33); - TPad *pad2 = new TPad("pad2", "This is pad2", 0.52, 0.02, 0.98, 0.83, 33); + TPad *pad1 = new TPad("pad1","This is pad1",0.02,0.02,0.48,0.83,33); + TPad *pad2 = new TPad("pad2","This is pad2",0.52,0.02,0.98,0.83,33); pad1->Draw(); pad2->Draw(); - // - // Cross-section of direct photon production in pp collisions - // at 500 GeV vs Pt - // +// +// Cross-section of direct photon production in pp collisions +// at 500 GeV vs Pt +// energ = 63; - dens = 1.766; + dens = 1.766; tgrad = 90.; ptmin = 4.; ptmax = 24.; - delp = 2.; + delp = 2.; hz_calc(energ, dens, tgrad, ptmin, ptmax, delp); pad1->cd(); - pad1->Range(-0.255174, -19.25, 2.29657, -6.75); + pad1->Range(-0.255174,-19.25,2.29657,-6.75); pad1->SetLogx(); pad1->SetLogy(); // create a 2-d histogram to define the range - pad1->DrawFrame(1, 1e-18, 110, 1e-8); + pad1->DrawFrame(1,1e-18,110,1e-8); pad1->GetFrame()->SetFillColor(19); TLatex t1; @@ -99,28 +98,28 @@ void gr303_zdemo() t1.SetTextColor(36); t1.SetTextSize(0.08); t1.SetTextAlign(12); - t1.DrawLatex(0.6, 0.85, "p - p"); + t1.DrawLatex(0.6,0.85,"p - p"); t1.SetTextSize(0.05); - t1.DrawLatex(0.6, 0.79, "Direct #gamma"); - t1.DrawLatex(0.6, 0.75, "#theta = 90^{o}"); + t1.DrawLatex(0.6,0.79,"Direct #gamma"); + t1.DrawLatex(0.6,0.75,"#theta = 90^{o}"); - t1.DrawLatex(0.20, 0.45, "Ed^{3}#sigma/dq^{3}"); - t1.DrawLatex(0.18, 0.40, "(barn/Gev^{2})"); + t1.DrawLatex(0.20,0.45,"Ed^{3}#sigma/dq^{3}"); + t1.DrawLatex(0.18,0.40,"(barn/Gev^{2})"); t1.SetTextSize(0.045); t1.SetTextColor(kBlue); - t1.DrawLatex(0.22, 0.260, "#sqrt{s} = 63(GeV)"); + t1.DrawLatex(0.22,0.260,"#sqrt{s} = 63(GeV)"); t1.SetTextColor(kRed); - t1.DrawLatex(0.22, 0.205, "#sqrt{s} = 200(GeV)"); + t1.DrawLatex(0.22,0.205,"#sqrt{s} = 200(GeV)"); t1.SetTextColor(6); - t1.DrawLatex(0.22, 0.15, "#sqrt{s} = 500(GeV)"); + t1.DrawLatex(0.22,0.15,"#sqrt{s} = 500(GeV)"); t1.SetTextSize(0.05); t1.SetTextColor(1); - t1.DrawLatex(0.6, 0.06, "q_{T} (Gev/c)"); + t1.DrawLatex(0.6,0.06,"q_{T} (Gev/c)"); - TGraph *gr1 = new TGraph(NLOOP, PT, INVSIG); + TGraph *gr1 = new TGraph(NLOOP,PT,INVSIG); gr1->SetLineColor(38); gr1->SetMarkerColor(kBlue); @@ -128,39 +127,39 @@ void gr303_zdemo() gr1->SetMarkerSize(1.1); gr1->Draw("LP"); - // - // Cross-section of direct photon production in pp collisions - // at 200 GeV vs Pt - // +// +// Cross-section of direct photon production in pp collisions +// at 200 GeV vs Pt +// energ = 200; - dens = 2.25; + dens = 2.25; tgrad = 90.; ptmin = 4.; ptmax = 64.; - delp = 6.; + delp = 6.; hz_calc(energ, dens, tgrad, ptmin, ptmax, delp); - TGraph *gr2 = new TGraph(NLOOP, PT, INVSIG); + TGraph *gr2 = new TGraph(NLOOP,PT,INVSIG); gr2->SetLineColor(38); gr2->SetMarkerColor(kRed); gr2->SetMarkerStyle(29); gr2->SetMarkerSize(1.5); gr2->Draw("LP"); - // - // Cross-section of direct photon production in pp collisions - // at 500 GeV vs Pt - // +// +// Cross-section of direct photon production in pp collisions +// at 500 GeV vs Pt +// energ = 500; - dens = 2.73; + dens = 2.73; tgrad = 90.; ptmin = 4.; ptmax = 104.; - delp = 10.; + delp = 10.; hz_calc(energ, dens, tgrad, ptmin, ptmax, delp); - TGraph *gr3 = new TGraph(NLOOP, PT, INVSIG); + TGraph *gr3 = new TGraph(NLOOP,PT,INVSIG); gr3->SetLineColor(38); gr3->SetMarkerColor(6); @@ -169,36 +168,36 @@ void gr303_zdemo() gr3->Draw("LP"); Float_t *dum = nullptr; - TGraph *graph = new TGraph(1, dum, dum); + TGraph *graph = new TGraph(1,dum,dum); graph->SetMarkerColor(kBlue); graph->SetMarkerStyle(21); graph->SetMarkerSize(1.1); - graph->SetPoint(0, 1.7, 1.e-16); + graph->SetPoint(0,1.7,1.e-16); graph->Draw("LP"); - graph = new TGraph(1, dum, dum); + graph = new TGraph(1,dum,dum); graph->SetMarkerColor(kRed); graph->SetMarkerStyle(29); graph->SetMarkerSize(1.5); - graph->SetPoint(0, 1.7, 2.e-17); + graph->SetPoint(0,1.7,2.e-17); graph->Draw("LP"); - graph = new TGraph(1, dum, dum); + graph = new TGraph(1,dum,dum); graph->SetMarkerColor(6); graph->SetMarkerStyle(8); graph->SetMarkerSize(1.1); - graph->SetPoint(0, 1.7, 4.e-18); + graph->SetPoint(0,1.7,4.e-18); graph->Draw("LP"); pad2->cd(); - pad2->Range(-0.43642, -23.75, 3.92778, -6.25); + pad2->Range(-0.43642,-23.75,3.92778,-6.25); pad2->SetLogx(); pad2->SetLogy(); - pad2->DrawFrame(1, 1e-22, 3100, 1e-8); + pad2->DrawFrame(1,1e-22,3100,1e-8); pad2->GetFrame()->SetFillColor(19); - TGraph *gr = new TGraph(NLOOP, Z, HZ); + TGraph *gr = new TGraph(NLOOP,Z,HZ); gr->SetTitle("HZ vs Z"); gr->SetFillColor(19); gr->SetLineColor(9); @@ -213,107 +212,109 @@ void gr303_zdemo() t2.SetTextColor(36); t2.SetTextSize(0.08); t2.SetTextAlign(12); - t2.DrawLatex(0.6, 0.85, "p - p"); + t2.DrawLatex(0.6,0.85,"p - p"); t2.SetTextSize(0.05); - t2.DrawLatex(0.6, 0.79, "Direct #gamma"); - t2.DrawLatex(0.6, 0.75, "#theta = 90^{o}"); + t2.DrawLatex(0.6,0.79,"Direct #gamma"); + t2.DrawLatex(0.6,0.75,"#theta = 90^{o}"); - t2.DrawLatex(0.70, 0.55, "H(z)"); - t2.DrawLatex(0.68, 0.50, "(barn)"); + t2.DrawLatex(0.70,0.55,"H(z)"); + t2.DrawLatex(0.68,0.50,"(barn)"); t2.SetTextSize(0.045); t2.SetTextColor(46); - t2.DrawLatex(0.20, 0.30, "#sqrt{s}, GeV"); - t2.DrawLatex(0.22, 0.26, "63"); - t2.DrawLatex(0.22, 0.22, "200"); - t2.DrawLatex(0.22, 0.18, "500"); + t2.DrawLatex(0.20,0.30,"#sqrt{s}, GeV"); + t2.DrawLatex(0.22,0.26,"63"); + t2.DrawLatex(0.22,0.22,"200"); + t2.DrawLatex(0.22,0.18,"500"); t2.SetTextSize(0.05); t2.SetTextColor(1); - t2.DrawLatex(0.88, 0.06, "z"); + t2.DrawLatex(0.88,0.06,"z"); c1->Modified(); c1->Update(); } -void hz_calc(Float_t ENERG, Float_t DENS, Float_t TGRAD, Float_t PTMIN, Float_t PTMAX, Float_t DELP) +void hz_calc(Float_t ENERG, Float_t DENS, Float_t TGRAD, Float_t PTMIN, + Float_t PTMAX, Float_t DELP) { - Int_t I; - - Float_t GM1 = 0.00001; - Float_t GM2 = 0.00001; - Float_t A1 = 1.; - Float_t A2 = 1.; - Float_t ALX = 2.; - Float_t BETA = 1.; - Float_t KF1 = 8.E-7; - Float_t KF2 = 5.215; - - Float_t MN = 0.9383; - Float_t DEGRAD = 0.01745329; - - Float_t EB1, EB2, PB1, PB2, MB1, MB2, M1, M2; - Float_t DNDETA; - - Float_t P1P2, P1P3, P2P3; - Float_t Y1, Y2, S, SMIN, SX1, SX2, SX1X2, DELM; - Float_t Y1X1, Y1X2, Y2X1, Y2X2, Y2X1X2, Y1X1X2; - Float_t KX1, KX2, ZX1, ZX2; - Float_t H1; - - Float_t PTOT, THET, ETOT, X1, X2; - - DNDETA = DENS; - MB1 = MN * A1; - MB2 = MN * A2; - EB1 = ENERG / 2. * A1; - EB2 = ENERG / 2. * A2; - M1 = GM1; - M2 = GM2; - THET = TGRAD * DEGRAD; - NLOOP = (PTMAX - PTMIN) / DELP; - - for (I = 0; I < NLOOP; I++) { - PT[I] = PTMIN + I * DELP; - PTOT = PT[I] / sin(THET); - - ETOT = sqrt(M1 * M1 + PTOT * PTOT); - PB1 = sqrt(EB1 * EB1 - MB1 * MB1); - PB2 = sqrt(EB2 * EB2 - MB2 * MB2); - P2P3 = EB2 * ETOT + PB2 * PTOT * cos(THET); - P1P2 = EB2 * EB1 + PB2 * PB1; - P1P3 = EB1 * ETOT - PB1 * PTOT * cos(THET); - - X1 = P2P3 / P1P2; - X2 = P1P3 / P1P2; - Y1 = X1 + sqrt(X1 * X2 * (1. - X1) / (1. - X2)); - Y2 = X2 + sqrt(X1 * X2 * (1. - X2) / (1. - X1)); - - S = (MB1 * MB1) + 2. * P1P2 + (MB2 * MB2); - SMIN = 4. * ((MB1 * MB1) * (X1 * X1) + 2. * X1 * X2 * P1P2 + (MB2 * MB2) * (X2 * X2)); - SX1 = 4. * (2 * (MB1 * MB1) * X1 + 2 * X2 * P1P2); - SX2 = 4. * (2 * (MB2 * MB2) * X2 + 2 * X1 * P1P2); - SX1X2 = 4. * (2 * P1P2); - DELM = pow((1. - Y1) * (1. - Y2), ALX); - - Z[I] = sqrt(SMIN) / DELM / pow(DNDETA, BETA); - - Y1X1 = 1. + X2 * (1 - 2. * X1) / (2. * (Y1 - X1) * (1. - X2)); - Y1X2 = X1 * (1 - X1) / (2. * (Y1 - X1) * (1. - X2) * (1. - X2)); - Y2X1 = X2 * (1 - X2) / (2. * (Y2 - X2) * (1. - X1) * (1. - X1)); - Y2X2 = 1. + X1 * (1 - 2. * X2) / (2. * (Y2 - X2) * (1. - X1)); - Y2X1X2 = Y2X1 * ((1. - 2. * X2) / (X2 * (1 - X2)) - (Y2X2 - 1.) / (Y2 - X2)); - Y1X1X2 = Y1X2 * ((1. - 2. * X1) / (X1 * (1 - X1)) - (Y1X1 - 1.) / (Y1 - X1)); - - KX1 = -DELM * (Y1X1 * ALX / (1. - Y1) + Y2X1 * ALX / (1. - Y2)); - KX2 = -DELM * (Y2X2 * ALX / (1. - Y2) + Y1X2 * ALX / (1. - Y1)); - ZX1 = Z[I] * (SX1 / (2. * SMIN) - KX1 / DELM); - ZX2 = Z[I] * (SX2 / (2. * SMIN) - KX2 / DELM); - - H1 = ZX1 * ZX2; - - HZ[I] = KF1 / pow(Z[I], KF2); - INVSIG[I] = (HZ[I] * H1 * 16.) / S; - } + Int_t I; + + Float_t GM1 = 0.00001; + Float_t GM2 = 0.00001; + Float_t A1 = 1.; + Float_t A2 = 1.; + Float_t ALX = 2.; + Float_t BETA = 1.; + Float_t KF1 = 8.E-7; + Float_t KF2 = 5.215; + + Float_t MN = 0.9383; + Float_t DEGRAD=0.01745329; + + Float_t EB1, EB2, PB1, PB2, MB1, MB2, M1, M2; + Float_t DNDETA; + + Float_t P1P2, P1P3, P2P3; + Float_t Y1, Y2, S, SMIN, SX1, SX2, SX1X2, DELM; + Float_t Y1X1, Y1X2, Y2X1, Y2X2, Y2X1X2, Y1X1X2; + Float_t KX1, KX2, ZX1, ZX2; + Float_t H1; + + Float_t PTOT, THET, ETOT, X1, X2; + + DNDETA= DENS; + MB1 = MN*A1; + MB2 = MN*A2; + EB1 = ENERG/2.*A1; + EB2 = ENERG/2.*A2; + M1 = GM1; + M2 = GM2; + THET = TGRAD*DEGRAD; + NLOOP = (PTMAX-PTMIN)/DELP; + + for (I=0; I