#include "plot_utils.C" string outputpath = "output/"; string label = "Light Response [mV]"; TObjArray statsboxes; TPaveStats * stats1; /*********************************************************************/ // Plot single scan with a TGraph /*********************************************************************/ void plot_single_scan (string filename="/lstore/titan/LOMaC/shared/tilemeter/data/DLight/Scan_Runs/s-n_colunas_2022101104.txt", string legends="PEN Jul22"){ string runnumber = get_runnumber(filename); string noisename = "/lstore/titan/LOMaC/shared/tilemeter/data/DLight/Scan_Runs/ruido_" + runnumber + ".txt"; // Set plot style gROOT->SetStyle("ATLAS"); gStyle->SetOptStat(111111); gStyle->SetOptFit(1111); std::cout << "HELLO!" << std::endl; // Full address of the file to be analyzed cout << filename << endl; cout << noisename << endl; //string runnumber = get_runnumber(filename); cout << "runnumber is " << runnumber << endl; // GRAPH // TGraphErrors * g = new TGraphErrors(); // Function to read the input file and fill the graph g = read_scan_file(filename, runnumber); style_definition marker = {20, 2, 0.75}; style_definition line = {0, 2, 2}; TLegend *leg = new TLegend(0.0,0.85,1.42,1.0,"", "NDC"); TLegend *legn = new TLegend(0.0,0.69,1.42,0.84,"", "NDC"); leg->SetBorderSize(0); legn->SetBorderSize(0); leg->SetMargin(0.05); legn->SetMargin(0.05); bool legrunnumber = true; g->SetName(runnumber.c_str()); g->GetXaxis()->SetTitle("Position in x [steps]"); g->GetYaxis()->SetTitle(label.c_str()); g->SetMarkerStyle(marker.style); g->SetMarkerColor(marker.color); g->SetLineColor(marker.color); g->SetMarkerSize(marker.size); g->SetMaximum(g->GetHistogram()->GetMaximum()*1.20); if (legrunnumber) leg->AddEntry(g,(runnumber + " " + legends).c_str()); else leg->AddEntry(g, legends.c_str()); // NOISE GRAPH // TGraphErrors * gn = read_noise_file(noisename, runnumber); if (legrunnumber) legn->AddEntry(gn,("noise_" + runnumber + " " + legends).c_str()); else legn->AddEntry(gn, legends.c_str()); TCanvas * c = new TCanvas ( ); if(!gn){ TPad * pad1 = new TPad("pad1", "pad1", 0.0, 0.0, 0.7, 1.0); pad1->SetGridx(); // Vertical grid pad1->Draw(); // Draw the upper pad: pad1 pad1->cd(); // pad1 becomes the current pad g->Draw("AP"); c->cd(); } else{ gn->SetName(runnumber.c_str()); gn->GetXaxis()->SetTitle("Position in x [steps]"); gn->GetYaxis()->SetTitle("Noise [mV]"); gn->SetMarkerStyle(22); gn->SetMarkerColor(marker.color); gn->SetLineColor(marker.color); gn->SetMarkerSize(marker.size); TF1 *fgn = new TF1("fit", "pol1",700, 8000); fgn->SetLineColor(line.color); fgn->SetLineWidth(4); TPad * pad1 = new TPad("pad1", "pad1", 0.0, 0.3, 0.7, 1.0); pad1->SetBottomMargin(0); pad1->SetGridx(); pad1->Draw(); pad1->cd(); g->Draw("AP"); c->cd(); TPad *pad2 = new TPad("pad2", "pad2", 0.0, 0.0, 0.7, 0.3); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.2); pad2->SetGridx(); pad2->Draw(); pad2->cd(); gn->Draw("AP"); gn->Fit(fgn, "R"); gPad->Update(); stats1 = (TPaveStats *)gn->GetListOfFunctions()->FindObject("stats"); TPaveStats* temp = (TPaveStats*)stats1->Clone(); statsboxes.AddLast(temp); temp->SetTextColor(1); temp->SetX1NDC(0.0); temp->SetX2NDC(0.6); temp->SetY1NDC(0.5); temp->SetY2NDC(0.74); temp->Draw(); gPad->Update(); c->Update(); c->cd(); // Y axis ratio plot settings (gn) gn->GetYaxis()->SetTitleSize(20); gn->GetYaxis()->SetTitleFont(43); gn->GetYaxis()->SetTitleOffset(1.55); gn->GetYaxis()->SetLabelFont(43); gn->GetYaxis()->SetLabelSize(26); // X axis ratio plot settings gn->GetXaxis()->SetTitleSize(20); gn->GetXaxis()->SetTitleFont(43); gn->GetXaxis()->SetTitleOffset(3.8); gn->GetXaxis()->SetLabelFont(43); gn->GetXaxis()->SetLabelSize(26); // Y axis ratio plot settings (g) g->GetYaxis()->SetTitleSize(20); g->GetYaxis()->SetTitleFont(43); g->GetYaxis()->SetTitleOffset(1.55); } TPad *pad3 = new TPad("pad3", "pad3", 0.7, 0.0, 1.0, 1.0); pad3->SetTopMargin(0); pad3->Draw(); pad3->cd(); leg->Draw("AP"); ((TPaveStats*)statsboxes.At(0))->Draw(); string plotname = get_shortname(filename)+"_scan_control_noise_graph.png"; c->Print((outputpath+plotname).c_str()); }