From c6ee96dd66c96d149a846d9daadb31e2496adee3 Mon Sep 17 00:00:00 2001 From: ckierans Date: Tue, 14 Apr 2026 01:04:54 -0400 Subject: [PATCH 1/3] Updated to comply with Andreas's recent cleanup Included option to save QA-flagged events Cherry-picked this commit from PR148 to apply seperately --- include/MGUIOptionsEventSaver.h | 3 +++ include/MModuleEventSaver.h | 8 ++++++++ include/MReadOutAssembly.h | 2 ++ src/MGUIOptionsEventSaver.cxx | 5 +++++ src/MModuleDepthCalibration.cxx | 2 -- src/MModuleEventSaver.cxx | 10 ++++++++++ src/MReadOutAssembly.cxx | 26 +++++++++++++++++++++++++- 7 files changed, 53 insertions(+), 3 deletions(-) diff --git a/include/MGUIOptionsEventSaver.h b/include/MGUIOptionsEventSaver.h index fe466302..a6f79050 100644 --- a/include/MGUIOptionsEventSaver.h +++ b/include/MGUIOptionsEventSaver.h @@ -81,6 +81,9 @@ class MGUIOptionsEventSaver : public MGUIOptions //! Checkbutton to save or reject bad events TGCheckButton* m_SaveBadEvents; + //! Checkbutton to save or reject quality flag events + TGCheckButton* m_SavePoorQualityEvents; + //! Checkbutton to save veto events TGCheckButton* m_SaveVetoEvents; diff --git a/include/MModuleEventSaver.h b/include/MModuleEventSaver.h index e3f1d952..44064268 100644 --- a/include/MModuleEventSaver.h +++ b/include/MModuleEventSaver.h @@ -63,6 +63,11 @@ class MModuleEventSaver : public MModule //! Set whether the Bad events should be saved void SetSaveBadEvents(bool SaveBadEvents) { m_SaveBadEvents = SaveBadEvents; } + //! Return true if the Poor Quality events should be saved + bool GetSavePoorQualityEvents() const { return m_SavePoorQualityEvents; } + //! Set whether the Poor Quality events should be saved + void SetSavePoorQualityEvents(bool SavePoorQualityEvents) { m_SavePoorQualityEvents = SavePoorQualityEvents; } + //! Return true if the Veto events should be saved bool GetSaveVetoEvents() const { return m_SaveVetoEvents; } //! Set whether the Veto events should be saved @@ -193,6 +198,9 @@ class MModuleEventSaver : public MModule //! Save bad events bool m_SaveBadEvents; + //! Save poor quality events + bool m_SavePoorQualityEvents; + //! Save Veto events bool m_SaveVetoEvents; diff --git a/include/MReadOutAssembly.h b/include/MReadOutAssembly.h index e0e63765..91002736 100644 --- a/include/MReadOutAssembly.h +++ b/include/MReadOutAssembly.h @@ -260,6 +260,8 @@ class MReadOutAssembly : public MReadOutSequence //! Return true if any error flag is set or the event has been filtered out //! Veto and quality flags do not affect this result bool IsBad() const; + //! Returns true if any of the Quality flags have been set + bool IsPoorQuality() const; //! Set a specific analysis progress void SetAnalysisProgress(uint64_t Progress) { m_AnalysisProgress |= Progress; } diff --git a/src/MGUIOptionsEventSaver.cxx b/src/MGUIOptionsEventSaver.cxx index ab913a43..832203e4 100644 --- a/src/MGUIOptionsEventSaver.cxx +++ b/src/MGUIOptionsEventSaver.cxx @@ -108,6 +108,10 @@ void MGUIOptionsEventSaver::Create() m_SaveBadEvents->SetOn(dynamic_cast(m_Module)->GetSaveBadEvents()); GeneralFrame->AddFrame(m_SaveBadEvents, FirstLabelLayout); + m_SavePoorQualityEvents = new TGCheckButton(GeneralFrame, "Save events with quality flag (QA)", 1); + m_SavePoorQualityEvents->SetOn(dynamic_cast(m_Module)->GetSavePoorQualityEvents()); + GeneralFrame->AddFrame(m_SavePoorQualityEvents, FirstLabelLayout); + m_SaveVetoEvents = new TGCheckButton(GeneralFrame, "Save guard ring and shield veto events (Veto)", 1); m_SaveVetoEvents->SetOn(dynamic_cast(m_Module)->GetSaveVetoEvents()); GeneralFrame->AddFrame(m_SaveVetoEvents, TightButtonLayout); @@ -229,6 +233,7 @@ bool MGUIOptionsEventSaver::OnApply() dynamic_cast(m_Module)->SetFileName(m_FileSelector->GetFileName()); dynamic_cast(m_Module)->SetSaveBadEvents(m_SaveBadEvents->IsOn()); + dynamic_cast(m_Module)->SetSavePoorQualityEvents(m_SavePoorQualityEvents->IsOn()); dynamic_cast(m_Module)->SetSaveVetoEvents(m_SaveVetoEvents->IsOn()); dynamic_cast(m_Module)->SetAddTimeTag(m_AddTimeTag->IsOn()); dynamic_cast(m_Module)->SetSplitFile(m_SplitFile->IsOn()); diff --git a/src/MModuleDepthCalibration.cxx b/src/MModuleDepthCalibration.cxx index adcb9044..8f07283d 100644 --- a/src/MModuleDepthCalibration.cxx +++ b/src/MModuleDepthCalibration.cxx @@ -516,8 +516,6 @@ bool MModuleDepthCalibration::LoadCoeffsFile(MString FileName) std::vector Tokens = Line.Tokenize(","); if (Tokens.size() == 5) { int PixelCode = Tokens[0].ToInt(); - double Stretch = Tokens[1].ToDouble(); - double Offset = Tokens[2].ToDouble(); double CTD_FWHM = Tokens[3].ToDouble() * 2.355; double Chi2 = Tokens[4].ToDouble(); // Previous iteration of depth calibration read in "Scale" instead of ctd resolution. diff --git a/src/MModuleEventSaver.cxx b/src/MModuleEventSaver.cxx index dc7671c3..c1ff7e08 100644 --- a/src/MModuleEventSaver.cxx +++ b/src/MModuleEventSaver.cxx @@ -75,6 +75,7 @@ MModuleEventSaver::MModuleEventSaver() : MModule() m_InternalFileName = ""; m_Zip = false; m_SaveBadEvents = true; + m_SavePoorQualityEvents = true; m_SaveVetoEvents = true; m_AddTimeTag = false; @@ -345,6 +346,10 @@ bool MModuleEventSaver::AnalyzeEvent(MReadOutAssembly* Event) if (Event->IsBad() == true) return true; } + if (m_SavePoorQualityEvents == false) { + if (Event->IsPoorQuality() == true) return true; + } + if (m_SaveVetoEvents == false) { if (Event->IsVeto() == true) return true; } @@ -415,6 +420,10 @@ bool MModuleEventSaver::ReadXmlConfiguration(MXmlNode* Node) if (SaveBadEventsNode != 0) { m_SaveBadEvents = SaveBadEventsNode->GetValueAsBoolean(); } + MXmlNode* SavePoorQualityEventsNode = Node->GetNode("SavePoorQualityEvents"); + if (SavePoorQualityEventsNode != 0) { + m_SavePoorQualityEvents = SavePoorQualityEventsNode->GetValueAsBoolean(); + } MXmlNode* SaveVetoEventsNode = Node->GetNode("SaveVetoEvents"); if (SaveVetoEventsNode != 0) { m_SaveVetoEvents = SaveVetoEventsNode->GetValueAsBoolean(); @@ -480,6 +489,7 @@ MXmlNode* MModuleEventSaver::CreateXmlConfiguration() new MXmlNode(Node, "FileName", m_FileName); new MXmlNode(Node, "Mode", m_Mode); new MXmlNode(Node, "SaveBadEvents", m_SaveBadEvents); + new MXmlNode(Node, "SavePoorQualityEvents", m_SavePoorQualityEvents); new MXmlNode(Node, "SaveVetoEvents", m_SaveVetoEvents); new MXmlNode(Node, "AddTimeTag", m_AddTimeTag); new MXmlNode(Node, "SplitFile", m_SplitFile); diff --git a/src/MReadOutAssembly.cxx b/src/MReadOutAssembly.cxx index 6f7e4901..6c68d457 100644 --- a/src/MReadOutAssembly.cxx +++ b/src/MReadOutAssembly.cxx @@ -632,7 +632,14 @@ void MReadOutAssembly::StreamEvta(ostream& S) } for (unsigned int h = 0; h < m_Hits.size(); ++h) { - m_Hits[h]->StreamEvta(S); + + // Don't print Guard Ring hits as normal strip hits as they don't have positions defined + // the corresponding energy is saved in the StripPairing QA message + if (m_Hits[h]->GetGuardRingHitFlag() == true) { + continue; + } else { + m_Hits[h]->StreamEvta(S); + } } S<<"CC NStripHits "< Date: Tue, 19 May 2026 00:38:23 -0400 Subject: [PATCH 2/3] Fixed missing lines after cherry pick --- src/MModuleDepthCalibration.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MModuleDepthCalibration.cxx b/src/MModuleDepthCalibration.cxx index 8f07283d..adcb9044 100644 --- a/src/MModuleDepthCalibration.cxx +++ b/src/MModuleDepthCalibration.cxx @@ -516,6 +516,8 @@ bool MModuleDepthCalibration::LoadCoeffsFile(MString FileName) std::vector Tokens = Line.Tokenize(","); if (Tokens.size() == 5) { int PixelCode = Tokens[0].ToInt(); + double Stretch = Tokens[1].ToDouble(); + double Offset = Tokens[2].ToDouble(); double CTD_FWHM = Tokens[3].ToDouble() * 2.355; double Chi2 = Tokens[4].ToDouble(); // Previous iteration of depth calibration read in "Scale" instead of ctd resolution. From bed9b7dd84cc0da6163a0494c65ce81f96b06989 Mon Sep 17 00:00:00 2001 From: ckierans Date: Tue, 19 May 2026 00:43:28 -0400 Subject: [PATCH 3/3] Button layout --- src/MGUIOptionsEventSaver.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MGUIOptionsEventSaver.cxx b/src/MGUIOptionsEventSaver.cxx index 832203e4..20328f33 100644 --- a/src/MGUIOptionsEventSaver.cxx +++ b/src/MGUIOptionsEventSaver.cxx @@ -110,7 +110,7 @@ void MGUIOptionsEventSaver::Create() m_SavePoorQualityEvents = new TGCheckButton(GeneralFrame, "Save events with quality flag (QA)", 1); m_SavePoorQualityEvents->SetOn(dynamic_cast(m_Module)->GetSavePoorQualityEvents()); - GeneralFrame->AddFrame(m_SavePoorQualityEvents, FirstLabelLayout); + GeneralFrame->AddFrame(m_SavePoorQualityEvents, TightButtonLayout); m_SaveVetoEvents = new TGCheckButton(GeneralFrame, "Save guard ring and shield veto events (Veto)", 1); m_SaveVetoEvents->SetOn(dynamic_cast(m_Module)->GetSaveVetoEvents());