From c4557c2b26aea43030d03b324f0c6130cd10fe47 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Sat, 14 Jan 2023 13:16:31 -0500 Subject: [PATCH 1/5] Fix bug in CompassFile where m_nHits is uninitialized for CoMPASS empty (2byte) files --- src/evb/CompassFile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/evb/CompassFile.cpp b/src/evb/CompassFile.cpp index 80b1d9e..08cb2d2 100644 --- a/src/evb/CompassFile.cpp +++ b/src/evb/CompassFile.cpp @@ -42,6 +42,7 @@ namespace EventBuilder { m_eofFlag = false; m_hitUsedFlag = true; m_filename = filename; + m_nHits = 0; m_file->open(m_filename, std::ios::binary | std::ios::in); m_file->seekg(0, std::ios_base::end); m_size = m_file->tellg(); From 4886c497a3564a313334ba144d44f03cada08fc8 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Mon, 16 Jan 2023 10:30:02 -0500 Subject: [PATCH 2/5] Fix bug where merged dir was not set --- src/evb/EVBWorkspace.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/evb/EVBWorkspace.cpp b/src/evb/EVBWorkspace.cpp index e0675b8..1455bb6 100644 --- a/src/evb/EVBWorkspace.cpp +++ b/src/evb/EVBWorkspace.cpp @@ -58,6 +58,7 @@ namespace EventBuilder { m_analyzedDir = m_workspace + "analyzed/"; m_histogramDir = m_workspace + "histograms/"; m_cutDir = m_workspace + "cuts/"; + m_mergedDir = m_workspace + "merged/"; //Check all subdirectories. Terminate if any of them are bad m_isValid = CheckSubDirectory(m_binaryDir); @@ -79,6 +80,9 @@ namespace EventBuilder { if(!m_isValid) return; m_isValid = CheckSubDirectory(m_cutDir); + if(!m_isValid) + return; + m_isValid = CheckSubDirectory(m_mergedDir); } std::string EVBWorkspace::GetBinaryRun(int run) From a264eea63c2a669255722d38968024b64867ecf2 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Mon, 16 Jan 2023 11:32:00 -0500 Subject: [PATCH 3/5] Fix bug with merging where TChain::Merge implicitly took ownership of TFile and auto close and deleted --- src/evb/EVBWorkspace.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/evb/EVBWorkspace.cpp b/src/evb/EVBWorkspace.cpp index 1455bb6..213ce11 100644 --- a/src/evb/EVBWorkspace.cpp +++ b/src/evb/EVBWorkspace.cpp @@ -191,7 +191,7 @@ namespace EventBuilder { return false; TFile* output = TFile::Open(outputname.c_str(), "RECREATE"); - if(!output->IsOpen()) + if(!output || !output->IsOpen()) { EVB_ERROR("Could not open output file {0} for merge", outputname); output->Close(); @@ -200,8 +200,15 @@ namespace EventBuilder { TChain* chain = new TChain("SPSTree", "SPSTree"); for(auto& entry : files) + { + EVB_INFO("Merging file: {0}", entry); chain->Add(entry.c_str()); - chain->Merge(output, 0, "fast"); + } + //Note: TChain merge is kinda fucked. It requires a file passed in, which it then implicitly takes ownership of. + //By passing the keep option, we tell TChain we want to keep ownership of the file (otherwise it will automatically close and delete) + //We need ownership because the Merge function does not do a good job of handling errors explicitly. + chain->Merge(output, 0, "fast|keep"); + output->Close(); return true; } From e9c50331f7b1d3320e318f1d574795af1fb3013e Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Mon, 16 Jan 2023 11:58:19 -0500 Subject: [PATCH 4/5] Fix typo in analyzed file collection --- src/evb/EVBWorkspace.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/evb/EVBWorkspace.cpp b/src/evb/EVBWorkspace.cpp index 213ce11..d751bb3 100644 --- a/src/evb/EVBWorkspace.cpp +++ b/src/evb/EVBWorkspace.cpp @@ -130,9 +130,11 @@ namespace EventBuilder { std::vector list; std::string temp; for(int run=runMin; run<=runMax; run++) + { temp = GetAnalyzedRun(run); if(!temp.empty()) list.push_back(temp); + } return list; } From 45763dce6680d2825785a0333e4c94d224db1385 Mon Sep 17 00:00:00 2001 From: gwm17 Date: Wed, 17 May 2023 16:37:11 -0400 Subject: [PATCH 5/5] Fix typo in plotter, resolve #7 --- src/evb/SFPPlotter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evb/SFPPlotter.cpp b/src/evb/SFPPlotter.cpp index 3752199..c5e05a0 100644 --- a/src/evb/SFPPlotter.cpp +++ b/src/evb/SFPPlotter.cpp @@ -54,7 +54,7 @@ namespace EventBuilder { /*Makes histograms where only rejection is unset data*/ void SFPPlotter::MakeUncutHistograms(const ProcessedEvent& ev, THashTable* table) { - MyFill(table,"x1NoCuts_bothplanes",600,-300,300,ev.x2); + MyFill(table,"x1NoCuts_bothplanes",600,-300,300,ev.x1); MyFill(table,"x2NoCuts_bothplanes",600,-300,300,ev.x2); MyFill(table,"xavgNoCuts_bothplanes",600,-300,300,ev.xavg); MyFill(table,"xavgNoCuts_theta_bothplanes",600,-300,300,ev.xavg,100,0,TMath::Pi()/2.,ev.theta);