new file: RunTimeSummary.C

new file:   Timing_Summary_Matplotlib.png
	modified:   TrackRecon.C
	modified:   process_mapped_run.sh
This commit is contained in:
Vignesh Sitaraman 2026-02-09 16:11:07 -05:00
parent 56cc900b61
commit 9f949edd00
4 changed files with 173 additions and 26 deletions

140
RunTimeSummary.C Normal file
View File

@ -0,0 +1,140 @@
#include <TFile.h>
#include <TH1.h>
#include <TH2.h>
#include <TString.h>
#include <TSystem.h>
#include <TCanvas.h>
#include <iostream>
void RunTimeSummary(int startRun, int endRun)
{
TString fileDir = "/mnt/d/Remapped_files/17F_data/root_data/";
TString histName = "AnodeQQQ_Time";
TString filePattern = "Run_%03d_mapped_histograms.root";
TString filePatternAlt = "ProtonRun_%d_mapped_histograms.root";
TString filePatternAlt2 = "Source_%d_mapped_histograms.root";
int nBinsTime = 0;
double timeMin = 0, timeMax = 0;
bool foundRef = false;
for (int r = startRun; r <= endRun; r++)
{
TString tempName;
// 1. Try Pattern 1: Run_XXX...
tempName = fileDir + Form(filePattern, r);
if (gSystem->AccessPathName(tempName))
{ // Returns true if MISSING
// 2. Try Pattern 2: ProtonRun_X...
tempName = fileDir + Form(filePatternAlt, r);
if (gSystem->AccessPathName(tempName))
{
// 3. Try Pattern 3: Source_X...
tempName = fileDir + Form(filePatternAlt2, r);
if (gSystem->AccessPathName(tempName))
{
// All 3 patterns failed. Skip this run.
continue;
}
}
}
// If we get here, 'tempName' holds the valid filename that was found
TFile *fTemp = TFile::Open(tempName);
if (!fTemp || fTemp->IsZombie())
{
if (fTemp)
delete fTemp;
continue;
}
TH1F *hRef = (TH1F *)fTemp->Get(histName);
if (hRef)
{
nBinsTime = hRef->GetNbinsX();
timeMin = hRef->GetXaxis()->GetXmin();
timeMax = hRef->GetXaxis()->GetXmax();
foundRef = true;
delete hRef;
fTemp->Close();
delete fTemp;
printf("Reference found in Run %d: %d bins, Range [%.1f, %.1f]\n", r, nBinsTime, timeMin, timeMax);
break;
}
fTemp->Close();
delete fTemp;
}
if (!foundRef)
{
printf("Error: No valid histograms found in the entire range. Exiting.\n");
return;
}
int nRuns = endRun - startRun + 1;
TH2F *hSummary = new TH2F("hSummary",
Form("Timing Summary (Runs %d-%d);Timing;Run Number", startRun, endRun),
nBinsTime, timeMin, timeMax,
nRuns, startRun, endRun + 1);
for (int run = startRun; run <= endRun; run++)
{
TString filename = fileDir + Form(filePattern, run);
if (gSystem->AccessPathName(filename))
continue;
TFile *fin = TFile::Open(filename);
if (!fin || fin->IsZombie())
{
if (fin)
delete fin;
continue;
}
TH1F *hin = (TH1F *)fin->Get(histName);
if (hin)
{
// Determine which ROW (Y-bin) corresponds to this Run
// Note: ROOT bins start at 1.
// If startRun=10 and run=10 -> binY=1.
int binY_Run = run - startRun + 1;
// Loop through the Time bins (X-bins in the 1D hist)
for (int binX_Time = 1; binX_Time <= hin->GetNbinsX(); binX_Time++)
{
double content = hin->GetBinContent(binX_Time);
// Copy content to: (Time, Run)
if (content > 0)
{
hSummary->SetBinContent(binX_Time, binY_Run, content);
}
}
delete hin;
}
fin->Close();
delete fin;
if ((run - startRun) % 10 == 0)
printf("Stitched Run %d...\n", run);
}
TFile *fOut = new TFile("SummaryPlot.root", "RECREATE");
hSummary->Write();
TCanvas *c1 = new TCanvas("c1", "Time Summary Plot", 1000, 800);
hSummary->SetStats(0);
hSummary->Draw("COLZ");
printf("Done! Saved to SummaryPlot.root\n");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

View File

@ -42,15 +42,16 @@ bool HitNonZero;
bool sx3ecut; bool sx3ecut;
bool qqqEcut; bool qqqEcut;
void TrackRecon::Begin(TTree * tree) void TrackRecon::Begin(TTree *tree)
{ //get file name { // get file name
std::cout<<tree->GetCurrentFile()->GetName()<<std::endl; std::cout << tree->GetCurrentFile()->GetName() << std::endl;
//get substring from file name to identify run number // get substring from file name to identify run number
TString option = GetOption(); TString option = GetOption();
std::string treefilename(tree->GetCurrentFile()->GetName()); std::string treefilename(tree->GetCurrentFile()->GetName());
plotter = new HistPlotter(treefilename.substr(0,treefilename.length()-std::string(".root").length())+"_histograms.root", "TFILE"); plotter = new HistPlotter(treefilename.substr(0, treefilename.length() - std::string(".root").length()) + "_histograms.root", "TFILE");
// plotter = new HistPlotter("Analyzer.root", "TFILE");
pw_contr.ConstructGeo(); pw_contr.ConstructGeo();
pwinstance.ConstructGeo(); pwinstance.ConstructGeo();
@ -88,7 +89,7 @@ void TrackRecon::Begin(TTree * tree)
Crossover[i][j][0].y = pwinstance.An[i].first.Y() + alpha * a.Y(); Crossover[i][j][0].y = pwinstance.An[i].first.Y() + alpha * a.Y();
Crossover[i][j][0].z = pwinstance.An[i].first.Z() + alpha * a.Z(); Crossover[i][j][0].z = pwinstance.An[i].first.Z() + alpha * a.Z();
if (Crossover[i][j][0].z < -190 || Crossover[i][j][0].z > 190) if (Crossover[i][j][0].z < -190 || Crossover[i][j][0].z > 190 || (i + j) % 24 == 12)
{ {
Crossover[i][j][0].z = 9999999; Crossover[i][j][0].z = 9999999;
} }
@ -99,7 +100,7 @@ void TrackRecon::Begin(TTree * tree)
} }
// Load PC Calibrations // Load PC Calibrations
std::ifstream inputFile("slope_intercept_results.txt"); std::ifstream inputFile("slope_intercept_results.dat");
if (inputFile.is_open()) if (inputFile.is_open())
{ {
std::string line; std::string line;
@ -324,7 +325,7 @@ Bool_t TrackRecon::Process(Long64_t entry)
plotter->Fill2D("DelT_Vs_QQQRingECal", 500, -2500, 2500, 1000, 0, 10, tRing - static_cast<double>(pc.t[k]), eRingMeV, "hTiming"); plotter->Fill2D("DelT_Vs_QQQRingECal", 500, -2500, 2500, 1000, 0, 10, tRing - static_cast<double>(pc.t[k]), eRingMeV, "hTiming");
plotter->Fill2D("CalibratedQQQEvsAnodeE_R", 1000, 0, 10, 2000, 0, 30000, eRingMeV, pc.e[k], "hPCQQQ"); plotter->Fill2D("CalibratedQQQEvsAnodeE_R", 1000, 0, 10, 2000, 0, 30000, eRingMeV, pc.e[k], "hPCQQQ");
plotter->Fill2D("CalibratedQQQEvsAnodeE_W", 1000, 0, 10, 2000, 0, 30000, eWedgeMeV, pc.e[k], "hPCQQQ"); plotter->Fill2D("CalibratedQQQEvsAnodeE_W", 1000, 0, 10, 2000, 0, 30000, eWedgeMeV, pc.e[k], "hPCQQQ");
if (tRing - static_cast<double>(pc.t[k]) < -150 && tRing - static_cast<double>(pc.t[k]) > -450) // 27Al if (tRing - static_cast<double>(pc.t[k]) < -150) // 27Al
// if (tRing - static_cast<double>(pc.t[k]) < -75 && tRing - static_cast<double>(pc.t[k]) > -145) // 17F // if (tRing - static_cast<double>(pc.t[k]) < -75 && tRing - static_cast<double>(pc.t[k]) > -145) // 17F
{ {
PCQQQTimeCut = true; PCQQQTimeCut = true;
@ -338,7 +339,7 @@ Bool_t TrackRecon::Process(Long64_t entry)
} }
double theta = -TMath::Pi() / 2 + 2 * TMath::Pi() / 16 / 4. * (qqq.id[i] * 16 + chWedge + 0.5); double theta = -TMath::Pi() / 2 + 2 * TMath::Pi() / 16 / 4. * (qqq.id[i] * 16 + chWedge + 0.5);
double rho = 50. + 40. / 16. * (chRing + 0.5); double rho = 50. + 50. / 16. * (chRing + 0.5);
plotter->Fill2D("QQQPolarPlot", 16 * 4, -TMath::Pi(), TMath::Pi(), 32, 40, 100, theta, rho, "hCalQQQ"); plotter->Fill2D("QQQPolarPlot", 16 * 4, -TMath::Pi(), TMath::Pi(), 32, 40, 100, theta, rho, "hCalQQQ");
plotter->Fill2D("QQQCartesianPlot", 200, -100, 100, 200, -100, 100, rho * TMath::Cos(theta), rho * TMath::Sin(theta), "hCalQQQ"); plotter->Fill2D("QQQCartesianPlot", 200, -100, 100, 200, -100, 100, rho * TMath::Cos(theta), rho * TMath::Sin(theta), "hCalQQQ");
@ -507,7 +508,7 @@ Bool_t TrackRecon::Process(Long64_t entry)
; ;
// to ignore events with no valid crossover points // to ignore events with no valid crossover points
else else
anodeIntersection = TVector3(x, y, -z); anodeIntersection = TVector3(x, y, z);
// std::cout << "Anode Intersection: " << anodeIntersection.X() << ", " << anodeIntersection.Y() << ", " << anodeIntersection.Z() << std::endl; // std::cout << "Anode Intersection: " << anodeIntersection.X() << ", " << anodeIntersection.Y() << ", " << anodeIntersection.Z() << std::endl;
} }
bool PCQQQPhiCut = false; bool PCQQQPhiCut = false;
@ -517,36 +518,41 @@ Bool_t TrackRecon::Process(Long64_t entry)
PCQQQPhiCut = true; PCQQQPhiCut = true;
} }
// for (double Tz = -190; Tz <= 190; Tz += 10.0) for (double AIz = 20; AIz <= 100; AIz += 5.0)
// { {
// TVector3 TargetPos(0, 0, Tz); TVector3 TargetPos(0, 0, AIz);
// plotter->Fill2D("Inttheta_vs_QQQtheta_TC" + std::to_string(PCQQQTimeCut) + "_TZ" + std::to_string(Tz), 90, 0, 180, 120, 0, 180, (anodeIntersection - TargetPos).Theta() * 180. / TMath::Pi(), (hitPos - TargetPos).Theta() * 180. / TMath::Pi(), "TPosVariation"); if (PCQQQPhiCut && anodeIntersection.Perp() != 0 && cathodeHits.size() >= 2)
// } // TVector3 anodePosAtZ(anodeIntersection.X() * (AIz / anodeIntersection.Z()), anodeIntersection.Y() * (AIz / anodeIntersection.Z()), AIz);
// TVector3 anodePosAtZ(anodeIntersection.X(), anodeIntersection.Y(),anodeIntersection.Z() + AIz);
plotter->Fill2D("Inttheta_vs_QQQtheta_TC" + std::to_string(PCQQQTimeCut) + "_TZ" + std::to_string(AIz), 180, 0, 180, 90, 0, 90, (anodeIntersection - TargetPos).Theta() * 180. / TMath::Pi(),
(hitPos - TargetPos).Theta() * 180. / TMath::Pi(), "TPosVariation");
}
if (anodeIntersection.Z() != 0) if (anodeIntersection.Perp() != 0)
{ {
plotter->Fill1D("PC_Z_Projection", 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ"); plotter->Fill1D("PC_Z_Projection", 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ");
plotter->Fill2D("Z_Proj_VsDelTime", 600, -300, 300, 200, -2000, 2000, anodeIntersection.Z(), anodeT - cathodeT, "hPCzQQQ"); plotter->Fill2D("Z_Proj_VsDelTime", 600, -300, 300, 200, -2000, 2000, anodeIntersection.Z(), anodeT - cathodeT, "hPCzQQQ");
plotter->Fill2D("IntPhi_vs_QQQphi", 100, -200, 200, 80, -200, 200, anodeIntersection.Phi() * 180. / TMath::Pi(), hitPos.Phi() * 180. / TMath::Pi(), "hPCQQQ"); plotter->Fill2D("IntPhi_vs_QQQphi", 100, -200, 200, 80, -200, 200, anodeIntersection.Phi() * 180. / TMath::Pi(), hitPos.Phi() * 180. / TMath::Pi(), "hPCQQQ");
plotter->Fill1D("IntRho", 200, 0, 100, anodeIntersection.Perp(), "hRawPC");
plotter->Fill2D("Inttheta_vs_QQQtheta", 90, 0, 180, 20, 0, 45, anodeIntersection.Theta() * 180. / TMath::Pi(), hitPos.Theta() * 180. / TMath::Pi(), "hPCQQQ"); plotter->Fill2D("Inttheta_vs_QQQtheta", 90, 0, 180, 20, 0, 45, anodeIntersection.Theta() * 180. / TMath::Pi(), hitPos.Theta() * 180. / TMath::Pi(), "hPCQQQ");
plotter->Fill2D("Inttheta_vs_QQQtheta_TC" + std::to_string(PCQQQTimeCut), 90, 0, 180, 20, 0, 45, anodeIntersection.Theta() * 180. / TMath::Pi(), hitPos.Theta() * 180. / TMath::Pi(), "hPCQQQ"); plotter->Fill2D("Inttheta_vs_QQQtheta_TC" + std::to_string(PCQQQTimeCut), 90, 0, 180, 20, 0, 45, anodeIntersection.Theta() * 180. / TMath::Pi(), hitPos.Theta() * 180. / TMath::Pi(), "hPCQQQ");
plotter->Fill2D("IntPhi_vs_QQQphi_TC" + std::to_string(PCQQQTimeCut) + "PhiC" + std::to_string(PCQQQPhiCut), 100, -200, 200, 80, -200, 200, anodeIntersection.Phi() * 180. / TMath::Pi(), hitPos.Phi() * 180. / TMath::Pi(), "hPCQQQ"); plotter->Fill2D("IntPhi_vs_QQQphi_TC" + std::to_string(PCQQQTimeCut) + "PhiC" + std::to_string(PCQQQPhiCut), 100, -200, 200, 80, -200, 200, anodeIntersection.Phi() * 180. / TMath::Pi(), hitPos.Phi() * 180. / TMath::Pi(), "hPCQQQ");
} }
if (anodeIntersection.Z() != 0 && cathodeHits.size() >= 2) if (anodeIntersection.Perp() != 0 && cathodeHits.size() >= 2)
plotter->Fill1D("PC_Z_Projection_TC" + std::to_string(PCQQQTimeCut) + "PhiC" + std::to_string(PCQQQPhiCut), 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ"); plotter->Fill1D("PC_Z_Projection_TC" + std::to_string(PCQQQTimeCut) + "PhiC" + std::to_string(PCQQQPhiCut), 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ");
if (anodeIntersection.Z() != 0 && cathodeHits.size() == 1) if (anodeIntersection.Perp() != 0 && cathodeHits.size() == 1)
{ {
plotter->Fill1D("PC_Z_proj_1C", 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ"); plotter->Fill1D("PC_Z_proj_1C", 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ");
plotter->Fill2D("IntersectionPhi_vs_AnodeZ_1C", 400, -200, 200, 600, -300, 300, anodeIntersection.Phi() * 180. / TMath::Pi(), anodeIntersection.Z(), "hPCzQQQ"); plotter->Fill2D("IntersectionPhi_vs_AnodeZ_1C", 400, -200, 200, 600, -300, 300, anodeIntersection.Phi() * 180. / TMath::Pi(), anodeIntersection.Z(), "hPCzQQQ");
} }
if (anodeIntersection.Z() != 0 && cathodeHits.size() == 2) if (anodeIntersection.Perp() != 0 && cathodeHits.size() == 2)
{ {
plotter->Fill1D("PC_Z_proj_2C", 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ"); plotter->Fill1D("PC_Z_proj_2C", 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ");
plotter->Fill2D("IntersectionPhi_vs_AnodeZ_2C", 400, -200, 200, 600, -300, 300, anodeIntersection.Phi() * 180. / TMath::Pi(), anodeIntersection.Z(), "hGMPC"); plotter->Fill2D("IntersectionPhi_vs_AnodeZ_2C", 400, -200, 200, 600, -300, 300, anodeIntersection.Phi() * 180. / TMath::Pi(), anodeIntersection.Z(), "hGMPC");
} }
if (anodeIntersection.Z() != 0 && cathodeHits.size() > 2) if (anodeIntersection.Perp() != 0 && cathodeHits.size() > 2)
{ {
plotter->Fill1D("PC_Z_proj_nC", 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ"); plotter->Fill1D("PC_Z_proj_nC", 600, -300, 300, anodeIntersection.Z(), "hPCzQQQ");
plotter->Fill2D("IntersectionPhi_vs_AnodeZ_nC", 400, -200, 200, 600, -300, 300, anodeIntersection.Phi() * 180. / TMath::Pi(), anodeIntersection.Z(), "hGMPC"); plotter->Fill2D("IntersectionPhi_vs_AnodeZ_nC", 400, -200, 200, 600, -300, 300, anodeIntersection.Phi() * 180. / TMath::Pi(), anodeIntersection.Z(), "hGMPC");
@ -691,11 +697,12 @@ Bool_t TrackRecon::Process(Long64_t entry)
plotter->Fill2D("PC_Z_vs_QQQRing_Det" + std::to_string(qqqID), 600, -300, 300, 16, 0, 16, anodeIntersection.Z(), chRing, "hPCQQQ"); plotter->Fill2D("PC_Z_vs_QQQRing_Det" + std::to_string(qqqID), 600, -300, 300, 16, 0, 16, anodeIntersection.Z(), chRing, "hPCQQQ");
for (int k = 0; k < pc.multi; k++) for (int k = 0; k < pc.multi; k++)
{ {
if(pc.index[k] >= 24) if (pc.index[k] >= 24)
continue; continue;
plotter->Fill2D("CalibratedQQQE_RvsAnodeE_TC" + std::to_string(PCQQQTimeCut) + "PhiC" + std::to_string(PCQQQPhiCut), 1000, 0, 10, 2000, 0, 30000, eRingMeV, pc.e[k], "hPCQQQ"); plotter->Fill2D("CalibratedQQQE_RvsAnodeE_TC" + std::to_string(PCQQQTimeCut) + "PhiC" + std::to_string(PCQQQPhiCut), 1000, 0, 10, 2000, 0, 30000, eRingMeV, pc.e[k], "hPCQQQ");
plotter->Fill2D("CalibratedQQQE_WvsAnodeE_TC" + std::to_string(PCQQQTimeCut) + "PhiC" + std::to_string(PCQQQPhiCut), 1000, 0, 10, 2000, 0, 30000, eWedgeMeV, pc.e[k], "hPCQQQ"); plotter->Fill2D("CalibratedQQQE_WvsAnodeE_TC" + std::to_string(PCQQQTimeCut) + "PhiC" + std::to_string(PCQQQPhiCut), 1000, 0, 10, 2000, 0, 30000, eWedgeMeV, pc.e[k], "hPCQQQ");
plotter->Fill2D("AnodeQQQ_dTimevsdPhi", 200, -2000, 2000, 80, -200, 200, tRing - static_cast<double>(pc.t[k]), (hitPos.Phi()-anodeIntersection.Phi()) * 180. / TMath::Pi(), "hTiming"); plotter->Fill2D("AnodeQQQ_dTimevsdPhi", 200, -2000, 2000, 80, -200, 200, tRing - static_cast<double>(pc.t[k]), (hitPos.Phi() - anodeIntersection.Phi()) * 180. / TMath::Pi(), "hTiming");
plotter->Fill1D("AnodeQQQ_Time", 200, -2000, 2000, tRing - static_cast<double>(pc.t[k]));
} }
} }
} }

View File

@ -3,7 +3,7 @@
# ========================================== # ==========================================
# CONFIGURATION # CONFIGURATION
# ========================================== # ==========================================
DATA_DIR="/mnt/d/Remapped_files/17F_data/root_data" DATA_DIR="/mnt/d/Remapped_files/27Al_data/root_data"
MACRO="TrackRecon.C" MACRO="TrackRecon.C"
# SAFETY SETTINGS # SAFETY SETTINGS