From 7891aaebca520bcf79fd78bcfaaa0c13b96e6c28 Mon Sep 17 00:00:00 2001 From: vsitaraman Date: Fri, 5 Jun 2026 15:41:32 -0400 Subject: [PATCH] modified: scratch/scan_rf_timing.C output images instead of gif --- scratch/scan_rf_timing.C | 52 +++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/scratch/scan_rf_timing.C b/scratch/scan_rf_timing.C index ff7c53d..3996ace 100644 --- a/scratch/scan_rf_timing.C +++ b/scratch/scan_rf_timing.C @@ -1,29 +1,22 @@ #include "TFile.h" #include "TH1.h" #include "TCanvas.h" +#include "TLine.h" #include "TSystem.h" #include "TROOT.h" #include #include + void scan_rf_timing(int startRun = 350, int endRun = 370) { - TCanvas *c = new TCanvas("c1", "RF-MCP Timing Animation", 0, 0, 1600, 800); + TCanvas *c = new TCanvas("c1", "RF-MCP Timing Images", 0, 0, 1600, 800); c->Divide(2, 1); - // Array of distinct colors to cycle through int colors[] = {kBlack, kRed, kBlue, kGreen+2, kMagenta, kCyan+1, kOrange+7, kSpring+4, kViolet+2, kAzure+2, kTeal-1, kPink+2}; int nColors = 12; std::vector files; - - // Define the output file name - const char* gifFile = "rf_timing_animation.gif"; - - // Safety check: ROOT appends to GIFs. We must delete any old version - // before starting, otherwise it will just add new frames to the old file! - gSystem->Unlink(gifFile); - int colorIdx = 0; for (int i = startRun; i <= endRun; i++) { @@ -39,51 +32,56 @@ void scan_rf_timing(int startRun = 350, int endRun = 370) { int color = colors[colorIdx % nColors]; colorIdx++; - // --- Pad 1: Inner Ring 1 --- + // --- Pad 1: Inner Ring --- c->cd(1); c->GetPad(1)->SetGrid(1, 1); TH1F *h1 = (TH1F*)(f->Get("misc/dt_rf_mcp_qqq_innerring1")); if (h1) { h1->SetDirectory(0); h1->Rebin(2); - h1->SetTitle(Form("Run %d: Inner Ring 1 Timing", i)); + h1->SetTitle(Form("Run %d: Inner Ring Timing", i)); h1->SetLineColor(color); h1->SetLineWidth(3); h1->Draw("hist"); + + c->Update(); + TLine *line1 = new TLine(105.189, gPad->GetUymin(), 105.189, gPad->GetUymax()); + line1->SetLineColor(kRed); + line1->SetLineStyle(2); // Dashed + line1->SetLineWidth(2); + line1->Draw(); } - // --- Pad 2: Inner Ring 0 --- + // --- Pad 2: Outer Ring --- c->cd(2); c->GetPad(2)->SetGrid(1, 1); TH1F *h0 = (TH1F*)(f->Get("misc/dt_rf_mcp_qqq_innerring0")); if (h0) { h0->SetDirectory(0); h0->Rebin(2); - h0->SetTitle(Form("Run %d: Inner Ring 0 Timing", i)); + h0->SetTitle(Form("Run %d: Outer Ring Timing", i)); h0->SetLineColor(color); h0->SetLineWidth(3); h0->Draw("hist"); + + c->Update(); + TLine *line0 = new TLine(105.189, gPad->GetUymin(), 105.189, gPad->GetUymax()); + line0->SetLineColor(kRed); + line0->SetLineStyle(2); // Dashed + line0->SetLineWidth(2); + line0->Draw(); } - // Update the canvas to reflect the new drawn histograms c->cd(1); c->Modified(); c->Update(); c->cd(2); c->Modified(); c->Update(); - std::cout << "Adding Run " << i << " to GIF..." << std::endl; - - // --- ADD FRAME TO GIF --- - // The "+50" tells ROOT to append this frame and wait 50 centiseconds (0.5 seconds) - c->Print(Form("%s+50", gifFile)); + TString outName = Form("rf_timing_run%03d.png", i); + c->SaveAs(outName); + std::cout << "Saved: " << outName << std::endl; } - // --- SEAL THE GIF --- - // The "++" tells ROOT we are done adding frames and it should finalize the file - c->Print(Form("%s++", gifFile)); + std::cout << "\n=== IMAGE GENERATION COMPLETE ===" << std::endl; - std::cout << "\n=== GIF GENERATION COMPLETE ===" << std::endl; - std::cout << "Saved as: " << gifFile << std::endl; - - // Safely clean up memory for (auto file : files) { if (file) file->Close(); }