modified: TrackRecon.C

modified:   scratch/overlay_2d.C
This commit is contained in:
Vignesh Sitaraman 2026-09-02 09:44:36 -04:00
parent 4d9145d532
commit ffb1c1a960
2 changed files with 40 additions and 30 deletions

View File

@ -4026,7 +4026,7 @@ static void reaction_ax_core(HistPlotter *plotter, const std::vector<Event> &Si_
beam_energy_at_vertex, ebeam_kin_2235keV, folderPrefix + "ETrackvsKin_assumed");
else if (beam_energy_at_vertex < 24.0)
{
plotter->Fill2D(rx + "_ETrack_vs_EKin3498kev" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
plotter->Fill2D(rx + "_ETrack_vs_EKin3498keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
beam_energy_at_vertex, ebeam_kin_3498keV, folderPrefix + "ETrackvsKin_assumed");
plotter->Fill2D(rx + "_ETrack_vs_EKin3774keV" + ejtag + t + sfx, 400, 0, beamE0 * 1.5, 400, 0, beamE0 * 1.5,
beam_energy_at_vertex, ebeam_kin_3774keV, folderPrefix + "ETrackvsKin_assumed");

View File

@ -9,34 +9,41 @@
#include <iostream>
#include <vector>
void overlay_2d(TString rootFile, TString histsCSV, TString labelsCSV, TString xAxisLabel, TString yAxisLabel) {
void overlay_2d(TString rootFile, TString histsCSV, TString labelsCSV, TString xAxisLabel, TString yAxisLabel)
{
gROOT->SetStyle("Plain");
gStyle->SetOptStat(0);
TObjArray* histArr = histsCSV.Tokenize(",");
TObjArray* labelArr = labelsCSV.Tokenize(",");
TObjArray *histArr = histsCSV.Tokenize(",");
TObjArray *labelArr = labelsCSV.Tokenize(",");
// Standard ANASEN color sequence
int colors[] = {kBlack, kRed+1, kAzure+2, kGreen+2, kMagenta+1};
std::vector<TH2*> hists;
int colors[] = {kBlack, kRed + 1, kAzure + 2, kGreen + 2, kMagenta + 1};
std::vector<TH2 *> hists;
TFile *f = TFile::Open(rootFile, "READ");
if (!f || f->IsZombie()) return;
if (!f || f->IsZombie())
return;
for (int i = 0; i < histArr->GetEntriesFast(); i++) {
TString hName = ((TObjString*)histArr->At(i))->GetString();
for (int i = 0; i < histArr->GetEntriesFast(); i++)
{
TString hName = ((TObjString *)histArr->At(i))->GetString();
TH2 *h = (TH2 *)f->Get(hName);
if (h) {
if (h)
{
TH2 *clone = (TH2 *)h->Clone(Form("h_%d", i));
clone->SetDirectory(0); // Detach from file
hists.push_back(clone);
} else {
}
else
{
std::cerr << "Warning: Could not find " << hName << "\n";
}
}
f->Close();
if (hists.empty()) return;
if (hists.empty())
return;
TCanvas *c = new TCanvas("c", "", 1800, 1800);
c->SetLeftMargin(0.12);
@ -52,30 +59,33 @@ void overlay_2d(TString rootFile, TString histsCSV, TString labelsCSV, TString x
leg->SetFillColor(kWhite);
leg->SetTextSize(0.03);
for (size_t i = 0; i < hists.size(); i++) {
for (size_t i = 0; i < hists.size(); i++)
{
hists[i]->SetMarkerColor(colors[i % 5]);
hists[i]->SetMarkerStyle(6); // Small dot for scatter
if (i == 0) {
if (i == 0)
{
hists[i]->GetXaxis()->SetTitle(xAxisLabel);
hists[i]->GetYaxis()->SetTitle(yAxisLabel);
hists[i]->GetXaxis()->CenterTitle();
hists[i]->GetYaxis()->CenterTitle();
hists[i]->Draw("colz");
// Draw the y = x diagonal dashed line
TF1 *diag = new TF1("diag", "x", -1000, 1000);
diag->SetLineStyle(2);
diag->SetLineColor(kGray+2);
diag->Draw("same");
} else {
}
else
{
hists[i]->Draw("colz same");
}
TString label = ((TObjString*)labelArr->At(i))->GetString();
TString label = ((TObjString *)labelArr->At(i))->GetString();
leg->AddEntry(hists[i], label.Data(), "p");
}
// Draw the y = x diagonal dashed line
TF1 *diag = new TF1("diag", "x", -1000, 1000);
diag->SetLineStyle(2);
diag->SetLineColor(kGray + 2);
diag->Draw("same");
leg->Draw();
c->SaveAs("kinematic_states_overlay.png");