modified: TrackRecon.C
modified: scratch/overlay_2d.C
This commit is contained in:
parent
4d9145d532
commit
ffb1c1a960
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -9,39 +9,46 @@
|
|||
#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(",");
|
||||
|
||||
// Standard ANASEN color sequence
|
||||
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;
|
||||
TObjArray *histArr = histsCSV.Tokenize(",");
|
||||
TObjArray *labelArr = labelsCSV.Tokenize(",");
|
||||
|
||||
for (int i = 0; i < histArr->GetEntriesFast(); i++) {
|
||||
TString hName = ((TObjString*)histArr->At(i))->GetString();
|
||||
// Standard ANASEN color sequence
|
||||
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;
|
||||
|
||||
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);
|
||||
c->SetBottomMargin(0.12);
|
||||
|
||||
|
||||
// Turn on the X and Y grid lines
|
||||
c->SetGridx(1);
|
||||
c->SetGridy(1);
|
||||
|
|
@ -52,32 +59,35 @@ 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");
|
||||
std::cout << "Saved: kinematic_states_overlay.png\n";
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user