From 2470933b8d6bb9e50f1e42c91c8405b83f95b1ed Mon Sep 17 00:00:00 2001 From: Felix Hagemann Date: Wed, 22 Jul 2026 06:52:08 -0700 Subject: [PATCH 1/3] CHG: Assign correct DetIDs to strip detectors --- src/MModuleDepthCalibration.cxx | 6 +++++- src/MSubModuleChargeTransport.cxx | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/MModuleDepthCalibration.cxx b/src/MModuleDepthCalibration.cxx index adcb9044..fef7c651 100644 --- a/src/MModuleDepthCalibration.cxx +++ b/src/MModuleDepthCalibration.cxx @@ -441,10 +441,11 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) vector DetList = Geometry->GetDetectorList(); // Look through the Geometry and get the names and thicknesses of all the detectors. + unsigned int DetID = -1; for (unsigned int i = 0; i < DetList.size(); ++i) { // For now, DetID is in order of detectors, which puts contraints on how the geometry file should be written. // If using the card cage at UCSD, default to DetID=11. - unsigned int DetID = i; + if (m_UCSDOverride == true) { DetID = 11; } @@ -456,6 +457,9 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) MDVolume* vol = det->GetSensitiveVolume(0); string det_name = vol->GetName().GetString(); if (find(DetectorNames.begin(), DetectorNames.end(), det_name) == DetectorNames.end()) { + if (m_UCSDOverride == false){ + DetID += 1; + } DetectorNames.push_back(det_name); m_Thicknesses[DetID] = 2 * (det->GetStructuralSize().GetZ()); MDStrip3D* strip = dynamic_cast(det); diff --git a/src/MSubModuleChargeTransport.cxx b/src/MSubModuleChargeTransport.cxx index 7b410ce2..81af8ce5 100644 --- a/src/MSubModuleChargeTransport.cxx +++ b/src/MSubModuleChargeTransport.cxx @@ -80,10 +80,9 @@ bool MSubModuleChargeTransport::Initialize() vector DetList = m_Geometry->GetDetectorList(); // Look through the Geometry and get the names and thicknesses of all the detectors. + unsigned int DetID = -1; for(unsigned int i = 0; i < DetList.size(); ++i){ - unsigned int DetID = i; - MDDetector* det = DetList[i]; vector DetectorNames; if (det->GetTypeName() == "Strip3D") { @@ -91,6 +90,7 @@ bool MSubModuleChargeTransport::Initialize() MDVolume* vol = det->GetSensitiveVolume(0); string det_name = vol->GetName().GetString(); if (find(DetectorNames.begin(), DetectorNames.end(), det_name) == DetectorNames.end()) { + DetID += 1; DetectorNames.push_back(det_name); m_Thicknesses[DetID] = 2*(det->GetStructuralSize().GetZ()); MDStrip3D* strip = dynamic_cast(det); From a1b9e8310e1435842f8c984d51cbc9899e5d88ca Mon Sep 17 00:00:00 2001 From: Felix Hagemann Date: Tue, 28 Jul 2026 16:29:52 -0700 Subject: [PATCH 2/3] Add feedback --- src/MModuleDepthCalibration.cxx | 12 +++++------- src/MSubModuleChargeTransport.cxx | 10 +++++----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/MModuleDepthCalibration.cxx b/src/MModuleDepthCalibration.cxx index fef7c651..9a495f59 100644 --- a/src/MModuleDepthCalibration.cxx +++ b/src/MModuleDepthCalibration.cxx @@ -440,26 +440,23 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) // ie DetID=0 should be the 0th detector in m_Detectors, DetID=1 should the 1st, etc. vector DetList = Geometry->GetDetectorList(); - // Look through the Geometry and get the names and thicknesses of all the detectors. - unsigned int DetID = -1; + // Look through the Geometry and get the names and thicknesses of all Strip3D detectors. + vector DetectorNames; + unsigned int DetID = 0; + for (unsigned int i = 0; i < DetList.size(); ++i) { // For now, DetID is in order of detectors, which puts contraints on how the geometry file should be written. // If using the card cage at UCSD, default to DetID=11. - if (m_UCSDOverride == true) { DetID = 11; } MDDetector* det = DetList[i]; - vector DetectorNames; if (det->GetTypeName() == "Strip3D") { if (det->GetNSensitiveVolumes() == 1) { MDVolume* vol = det->GetSensitiveVolume(0); string det_name = vol->GetName().GetString(); if (find(DetectorNames.begin(), DetectorNames.end(), det_name) == DetectorNames.end()) { - if (m_UCSDOverride == false){ - DetID += 1; - } DetectorNames.push_back(det_name); m_Thicknesses[DetID] = 2 * (det->GetStructuralSize().GetZ()); MDStrip3D* strip = dynamic_cast(det); @@ -478,6 +475,7 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) } m_DetectorIDs.push_back(DetID); m_Detectors[DetID] = det; + DetID += 1; } else { if (g_Verbosity >= c_Error) { cout<<"ERROR in MModuleDepthCalibration::Initialize: Found a duplicate detector: "< DetList = m_Geometry->GetDetectorList(); - // Look through the Geometry and get the names and thicknesses of all the detectors. - unsigned int DetID = -1; + // Look through the Geometry and get the names and thicknesses of all Strip3D detectors. + vector DetectorNames; + unsigned int DetID = 0; + for(unsigned int i = 0; i < DetList.size(); ++i){ - MDDetector* det = DetList[i]; - vector DetectorNames; if (det->GetTypeName() == "Strip3D") { if (det->GetNSensitiveVolumes() == 1) { MDVolume* vol = det->GetSensitiveVolume(0); string det_name = vol->GetName().GetString(); if (find(DetectorNames.begin(), DetectorNames.end(), det_name) == DetectorNames.end()) { - DetID += 1; DetectorNames.push_back(det_name); m_Thicknesses[DetID] = 2*(det->GetStructuralSize().GetZ()); MDStrip3D* strip = dynamic_cast(det); @@ -125,6 +124,7 @@ bool MSubModuleChargeTransport::Initialize() } m_DetectorIDs.push_back(DetID); m_Detectors[DetID] = det; + DetID += 1; } else { cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a duplicate detector: " << det_name << endl; } From 877bf28085edf6ed989802075807c5460ae58cc4 Mon Sep 17 00:00:00 2001 From: Felix Hagemann Date: Tue, 4 Aug 2026 12:24:58 -0700 Subject: [PATCH 3/3] CHG: Verify `DetID` against detector name for COSI-SMEX-Payload mass model --- src/MModuleDepthCalibration.cxx | 31 ++++++++++++++++++++++++++----- src/MSubModuleChargeTransport.cxx | 31 ++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/MModuleDepthCalibration.cxx b/src/MModuleDepthCalibration.cxx index 9a495f59..3d5d3874 100644 --- a/src/MModuleDepthCalibration.cxx +++ b/src/MModuleDepthCalibration.cxx @@ -455,9 +455,30 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) if (det->GetTypeName() == "Strip3D") { if (det->GetNSensitiveVolumes() == 1) { MDVolume* vol = det->GetSensitiveVolume(0); - string det_name = vol->GetName().GetString(); - if (find(DetectorNames.begin(), DetectorNames.end(), det_name) == DetectorNames.end()) { - DetectorNames.push_back(det_name); + MString DetectorName = det->GetName(); + string DetName = DetectorName.GetString(); + + // Check that the DetID agrees with the naming scheme GeD_X + if (DetectorName.BeginsWith("GeD_") == true) { + DetectorName.RemoveAllInPlace("GeD_"); // The number after GeD is the COSI detector ID + if (DetID != DetectorName.ToUnsignedInt()) { + if (g_Verbosity >= c_Error) { + cout << "ERROR in MModuleDepthCalibration::Initialize: Non-matching DetID="<GetName() == "COSI-SMEX-Payload"){ + return false; + } + } + } else if (Geometry->GetName() == "COSI-SMEX-Payload") { + if (g_Verbosity >= c_Error) { + cout << "ERROR in MModuleDepthCalibration::Initialize: COSI-SMEX-Payload expects all Strip3D detectors to follow the name scheme GeD_X"<GetStructuralSize().GetZ()); MDStrip3D* strip = dynamic_cast(det); m_XPitches[DetID] = strip->GetPitchX(); @@ -466,7 +487,7 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) m_NYStrips[DetID] = strip->GetNStripsY(); if (g_Verbosity >= c_Info) { - cout << "Found detector " << det_name << " corresponding to DetID=" << DetID << "." << endl; + cout << "Found detector " << DetName << " corresponding to DetID=" << DetID << "." << endl; cout << "Detector thickness: " << m_Thicknesses[DetID] << endl; cout << "Number of X strips: " << m_NXStrips[DetID] << endl; cout << "Number of Y strips: " << m_NYStrips[DetID] << endl; @@ -478,7 +499,7 @@ bool MModuleDepthCalibration::LoadDetectorDimensions(MDGeometryQuest* Geometry) DetID += 1; } else { if (g_Verbosity >= c_Error) { - cout<<"ERROR in MModuleDepthCalibration::Initialize: Found a duplicate detector: "<GetTypeName() == "Strip3D") { if (det->GetNSensitiveVolumes() == 1) { MDVolume* vol = det->GetSensitiveVolume(0); - string det_name = vol->GetName().GetString(); - if (find(DetectorNames.begin(), DetectorNames.end(), det_name) == DetectorNames.end()) { - DetectorNames.push_back(det_name); + MString DetectorName = det->GetName(); + string DetName = DetectorName.GetString(); + + // Check that the DetID agrees with the naming scheme GeD_X + if (DetectorName.BeginsWith("GeD_") == true) { + DetectorName.RemoveAllInPlace("GeD_"); // The number after GeD is the COSI detector ID + if (DetID != DetectorName.ToUnsignedInt()) { + if (g_Verbosity >= c_Error) { + cout << "ERROR in MModuleDepthCalibration::Initialize: Non-matching DetID="<GetName() == "COSI-SMEX-Payload"){ + return false; + } + } + } else if (m_Geometry->GetName() == "COSI-SMEX-Payload") { + if (g_Verbosity >= c_Error) { + cout << "ERROR in MModuleDepthCalibration::Initialize: COSI-SMEX-Payload expects all Strip3D detectors to follow the name scheme GeD_X"<GetStructuralSize().GetZ()); MDStrip3D* strip = dynamic_cast(det); m_XPitches[DetID] = strip->GetPitchX(); @@ -112,7 +133,7 @@ bool MSubModuleChargeTransport::Initialize() } if (g_Verbosity >= c_Info) { - cout << "Found detector " << det_name << " corresponding to DetID=" << DetID << "." << endl; + cout << "Found detector " << DetName << " corresponding to DetID=" << DetID << "." << endl; cout << "Detector width (X): " << m_XWidths[DetID] << endl; cout << "Detector width (Y): " << m_YWidths[DetID] << endl; cout << "Detector radius (R): " << m_Radii[DetID] << endl; @@ -126,7 +147,7 @@ bool MSubModuleChargeTransport::Initialize() m_Detectors[DetID] = det; DetID += 1; } else { - cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a duplicate detector: " << det_name << endl; + cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a duplicate detector: " << DetName << endl; } } else { cout << "ERROR in MSubModuleChargeTransport::Initialize: Found a Strip3D detector with " << det->GetNSensitiveVolumes() << " Sensitive Volumes." << endl;