Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-06 08:10:20

0001 float text_size = 0.04;
0002 
0003 float alpha = 0.2;
0004 string black_color = "#000000";
0005 string red_color = "#fe0100";
0006 string orange_color = "#FF9E00";
0007 string yellow_color = "#F7D619";
0008 string green_color = "#0a9900";
0009 string blue_color = "#0800ff";
0010 string cyan_color = "#00FBFF";
0011 string indigo_color = "#7402D1";
0012 string purple_color = "#DA19F7";
0013 
0014 struct data_point
0015 {
0016   double x_centroid {0};
0017   double x_low {0};
0018   double x_high {0};
0019 
0020   double y_centroid {0};
0021   double y_stat_err {0};
0022   double y_syst_err_low {0};
0023   double y_syst_err_high {0};
0024 };
0025 
0026 class plot_info
0027 {
0028   public:
0029     string legend_info = "Dummy legend information";
0030     string color = black_color;
0031     int marker = 8;
0032     unsigned int nPoints = 1;
0033     vector<double> x_centroids;
0034     vector<double> x_lows;
0035     vector<double> x_highs;
0036     vector<double> y_centroids;
0037     vector<double> y_stat_errs;
0038     vector<double> y_syst_err_lows;
0039     vector<double> y_syst_err_highs;
0040 
0041     plot_info(string constructor_legend_info, string constructor_color, int constructor_marker, vector<data_point> constructor_data)
0042     {
0043       legend_info = constructor_legend_info;
0044       color = constructor_color;
0045       marker = constructor_marker;
0046       nPoints = constructor_data.size();
0047       for (data_point this_data : constructor_data)
0048       {
0049          x_centroids.push_back(this_data.x_centroid);
0050          x_lows.push_back(this_data.x_centroid - this_data.x_low);
0051          x_highs.push_back(this_data.x_high - this_data.x_centroid);
0052          y_centroids.push_back(this_data.y_centroid);
0053          y_stat_errs.push_back(this_data.y_stat_err);
0054          y_syst_err_lows.push_back(this_data.y_syst_err_low);
0055          y_syst_err_highs.push_back(this_data.y_syst_err_high);
0056       }
0057     }
0058 };
0059 
0060 TGraphMultiErrors* makeGraph(plot_info this_info)
0061 {
0062   auto graph = new TGraphMultiErrors("", "", this_info.nPoints,
0063                                      &this_info.x_centroids[0],
0064                                      &this_info.y_centroids[0],
0065                                      &this_info.x_lows[0],
0066                                      &this_info.x_highs[0],
0067                                      &this_info.y_stat_errs[0],
0068                                      &this_info.y_stat_errs[0]);
0069   graph->AddYError(this_info.nPoints, &this_info.y_syst_err_lows[0], &this_info.y_syst_err_highs[0]);
0070   Int_t ci = TColor::GetColor(this_info.color.c_str());
0071   graph->SetMarkerColor(ci);
0072   graph->SetMarkerSize(2);
0073   graph->SetLineColor(ci);
0074   graph->SetFillColor(ci);
0075   graph->SetMarkerStyle(this_info.marker);
0076   graph->GetAttLine(0)->SetLineColor(ci);
0077   graph->GetAttLine(1)->SetLineColor(ci);
0078   graph->GetAttFill(1)->SetFillStyle(1001);
0079   graph->GetAttFill(1)->SetFillColorAlpha(ci, alpha);
0080 
0081   return graph;
0082 }
0083 
0084 void makeLine(float min, float max)
0085 {
0086   //Add line at y = 1
0087   TF1 *line = new TF1("line", "pol1", min, max);
0088   line->SetParameters(1, 0);
0089   line->SetLineColor(1);
0090   line->SetLineStyle(2);
0091   line->SetLineWidth(2);
0092   line->Draw("SAME");
0093 }