modified: TrackRecon.C

modified:   run_17F.sh
	renamed:    scratch/make_pretty.C -> scratch/make_prettyplots.C
This commit is contained in:
Vignesh Sitaraman 2026-06-04 08:15:16 -04:00
parent 1fb12d2f46
commit 6104c6f7a9
3 changed files with 58 additions and 61 deletions

View File

@ -822,33 +822,50 @@ Bool_t TrackRecon::Process(Long64_t entry)
ctr += 1;
}
double ts_rf = -987654321;
double ts_needle = -987654321;
double ts_mcp = -987654321;
bool found_rf = false;
bool found_mcp = false;
bool found_needle = false;
for (int j = 0; j < misc.multi; j++)
for (auto sx3event : SX3_Events)
{
plotter->Fill1D("channels_misc", 20, 0, 20, misc.ch[j], "misc");
if (misc.ch[j] == 2)
{ // Needle
ts_needle = static_cast<double>(misc.t[j]) + static_cast<double>(misc.tf[j]);
found_needle = 1;
double ts_rf = -987654321;
double ts_needle = -987654321;
double ts_mcp = -987654321;
double ts_sx3 = static_cast<double>(sx3event.Time1) + (rnd.Uniform(16.0) - 8.0);
bool found_rf = false;
bool found_mcp = false;
bool found_needle = false;
for (int j = 0; j < misc.multi; j++)
{
plotter->Fill1D("channels_misc_sx3", 20, 0, 20, misc.ch[j], "misc");
if (misc.ch[j] == 2)
{ // Needle
plotter->Fill2D("needle_vs_sx3E", 800, 0, 16384, 800, 0, 10, misc.e[j], sx3event.Energy1, "misc");
ts_needle = static_cast<double>(misc.t[j]) + static_cast<double>(misc.tf[j]);
found_needle = 1;
plotter->Fill1D("dt_sx3_needle", 800, -2000, 2000, ts_sx3 - ts_needle, "misc");
}
if (misc.ch[j] == 3)
{ // RF
ts_rf = static_cast<double>(misc.t[j]) + static_cast<double>(misc.tf[j]);
found_rf = 1;
plotter->Fill1D("dt_sx3_rf", 800, -2000, 2000, ts_sx3 - ts_rf, "misc");
}
if (misc.ch[j] == 4)
{ // mcp
ts_mcp = static_cast<double>(misc.t[j]) + static_cast<double>(misc.tf[j]);
found_mcp = 1;
plotter->Fill1D("dt_sx3_mcp", 800, -2000, 2000, ts_sx3 - ts_mcp, "misc");
}
}
if (misc.ch[j] == 3)
{ // RF
ts_rf = static_cast<double>(misc.t[j]) + static_cast<double>(misc.tf[j]);
found_rf = 1;
if (found_rf && found_mcp)
{
if (ctr == 0)
plotter->Fill1D("dt_rf_mcp_sx3", 500, -1000, 1000, ts_rf - ts_mcp, "misc");
double dt_rf_mcp = ts_rf - ts_mcp;
double dt_sx3_rf = ts_sx3 - ts_rf;
double dt_sx3_mcp = ts_sx3 - ts_mcp;
plotter->Fill2D("dt(sx3,rf)_vs_(rf,mcp)", 640, -2000, 2000, 640, -2000, 2000, dt_sx3_rf, dt_rf_mcp, "misc");
plotter->Fill2D("dt_(sx3,mcp)_vs_(sx3,rf)", 640, -1400, 2000, 640, -2000, 2000, dt_sx3_mcp, dt_sx3_rf, "misc");
plotter->Fill2D("dt_(sx3,mcp)_vs_(rf,mcp)", 640, -1400, -600, 640, -2000, 2000, dt_sx3_mcp, dt_rf_mcp, "misc");
}
if (misc.ch[j] == 4)
{ // mcp
ts_mcp = static_cast<double>(misc.t[j]) + static_cast<double>(misc.tf[j]);
found_mcp = 1;
}
plotter->Fill1D("dt_rf_mcp_qqq", 500, -1000, 1000, ts_rf - ts_mcp, "misc");
ctr += 1;
}
}

View File

@ -20,7 +20,7 @@ function run_once() {
}
export -f run_once
run_once 351
run_once 52
# parallel -j 6 --ctag run_once {1} ::: {350..400}
rm output_17F.root
hadd -j 4 -k output_17F.root 17F_output/results_run3*.root

View File

@ -62,10 +62,7 @@ void SetStyle() {
gStyle->SetNumberContours(255);
}
// ---------------------------------------------------------------------------
// make_pretty()
// ---------------------------------------------------------------------------
void make_pretty(const char* rootFile,
void make_prettyplots(const char* rootFile,
const char* histName,
const char* xlabel = "",
const char* ylabel = "") {
@ -86,11 +83,6 @@ void make_pretty(const char* rootFile,
return;
}
// --- Clone and detach BEFORE closing the file ---------------------------
// ROOT ties every histogram to the TDirectory of the file it came from.
// When f->Close() is called, ROOT deletes all objects in that directory —
// including the clone — unless SetDirectory(0) is called first to detach
// it. Drawing a deleted object causes the segfault you are seeing.
TObject* clone = obj->Clone(Form("%s_clone", histName));
if (!clone) {
std::cerr << "ERROR: Clone failed for '" << histName << "'\n";
@ -113,43 +105,31 @@ void make_pretty(const char* rootFile,
// Widen right margin for the colz palette bar
if (is2D) gPad->SetRightMargin(0.13);
// --- Draw ---------------------------------------------------------------
if (is2D) {
TH2* h = (TH2*)clone;
h->SetStats(0);
h->GetXaxis()->SetTitle("");
h->GetYaxis()->SetTitle("");
h->GetXaxis()->SetTitle(xlabel);
h->GetYaxis()->SetTitle(ylabel);
h->GetXaxis()->SetTitleOffset(0.9);
h->GetYaxis()->SetTitleOffset(1.4);
h->GetXaxis()->CenterTitle(true);
h->GetYaxis()->CenterTitle(true);
h->Draw("colz");
} else {
TH1* h = (TH1*)clone;
h->SetStats(0);
h->SetLineColor(kBlue+1);
h->SetFillColorAlpha(kBlue+1, 0.25);
h->SetFillStyle(1001);
h->GetXaxis()->SetTitle("");
h->GetYaxis()->SetTitle("");
h->SetLineColor(kAzure-5);
h->SetLineWidth(3);
h->GetXaxis()->SetTitle(xlabel);
h->GetYaxis()->SetTitle(ylabel);
h->GetXaxis()->SetTitleOffset(0.9);
h->GetYaxis()->SetTitleOffset(1.4);
h->GetXaxis()->CenterTitle(true);
h->GetYaxis()->CenterTitle(true);
h->Draw("hist");
}
// --- Axis labels via TLatex (full typographic control) ------------------
TLatex tex;
tex.SetNDC();
tex.SetTextFont(42);
tex.SetTextSize(0.050);
// X: y=0.06 sits just below the tick numbers inside the bottom margin (0.13).
// Y: x=0.08 sits just left of the tick numbers inside the left margin (0.14).
// Increase either value to push the label further from the axis.
if (strlen(xlabel) > 0)
tex.DrawLatex(0.46, 0.05, xlabel);
if (strlen(ylabel) > 0) {
tex.SetTextAngle(90);
tex.DrawLatex(0.08, 0.40, ylabel);
tex.SetTextAngle(0);
}
// --- Save ---------------------------------------------------------------
// Build output path: same directory as input file, named after the histogram
std::string inPath(rootFile);