Skip to content

Commit b86e4b7

Browse files
committed
Add a few more CSV-based detector efficiency file formats that can be read in.
Also, added the Efficeincy CSV files being able to be drag-n-dropped onto the app - to then create a dialog to finish inputting the relevant info.
1 parent 3226664 commit b86e4b7

File tree

7 files changed

+1023
-4
lines changed

7 files changed

+1023
-4
lines changed

InterSpec/DetectorPeakResponse.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ class DetectorPeakResponse
239239

240240
/** From ANGLE .outx file. */
241241
AngleOutx = 11,
242+
243+
/** From a drag-and-dropped efficiency CSV file (gamEff, Run_effoutput, or standalone
244+
GADRAS Efficiency.csv).
245+
*/
246+
UserImportedEfficiencyCsvDrf = 12,
242247
};//enum DrfSource
243248

244249
public:
@@ -522,6 +527,44 @@ class DetectorPeakResponse
522527
*/
523528
static std::shared_ptr<DetectorPeakResponse> parseAngleOutxFile( std::istream &input );
524529

530+
/** Result struct from parsing an efficiency CSV file. */
531+
struct EffCsvParseResult
532+
{
533+
std::shared_ptr<DetectorPeakResponse> drf;
534+
535+
/** Whether the detected format was a GADRAS Efficiency.csv (has "(%" on line 2).
536+
If true, the dialog should offer optional Detector.dat upload for diameter/setback.
537+
*/
538+
bool is_gadras_format;
539+
};//struct EffCsvParseResult
540+
541+
/** Parses a CSV file containing energy-efficiency pairs.
542+
543+
Auto-detects three formats:
544+
- GADRAS Efficiency.csv: Has "(%" on second line. Efficiency in column 2 as percentage.
545+
- gamEff CSV: Header has "efficiency" (case-insensitive). 2-column fractional (0-1).
546+
- Run_effoutput CSV: Multi-column with "Eff" column header. Fractional efficiency.
547+
548+
Returns the DRF with FixedGeomTotalAct geometry and kEnergyEfficiencyPairs form
549+
(caller should reinterpret geometry via dialog).
550+
551+
Throws std::runtime_error if the file cannot be parsed as any supported format.
552+
*/
553+
static EffCsvParseResult parseEfficiencyCsvFile( std::istream &input );
554+
555+
/** Parses a GADRAS Detector.dat file to extract detector diameter and setback.
556+
557+
Handles both legacy text and newer XML Detector.dat formats.
558+
559+
@param detDatFile Input stream for the Detector.dat file.
560+
@param[out] diameter Detector diameter in PhysicalUnits.
561+
@param[out] setback Detector setback in PhysicalUnits, or 0 if not found.
562+
563+
Throws std::runtime_error if the file cannot be parsed.
564+
*/
565+
static void parseDetectorDatGeometry( std::istream &detDatFile,
566+
float &diameter, float &setback );
567+
525568
/** Converts between the fixed geometry types of EffGeometryType.
526569
527570
@param quantity Either the surface area or mass (in units of PhysicalUnits), depending on value to `to_type`.

InterSpec/SpecMeasManager.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,12 @@ class SpecMeasManager : public Wt::WObject
237237

238238
/** Handles the user dropping a .ECC file from ISOCS, or a .outx file from ANGLE. */
239239
bool handleEccFile( std::istream &input, SimpleDialog *dialog );
240-
240+
241+
/** Handles the user dropping an efficiency CSV file (GADRAS Efficiency.csv,
242+
gamEff CSV, or Run_effoutput CSV).
243+
*/
244+
bool handleEfficiencyCsvFile( std::istream &input, SimpleDialog *dialog );
245+
241246
/** Some input files contain duplicate data - we will ask the user how they want to handle
242247
this, first handling "Derived Data", then "Multiple Energy Calibration Types", then
243248
"Multiple Virtual Detectors"

InterSpec_resources/app_text/SpecMeasManager.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@
142142
<message id="smm-outx-curve">ANGLE Efficiency Calibration Curve DRF</message>
143143
<message id="smm-outx-error">Error creating DRF from ANGLE .outx: {1}</message>
144144

145+
<!-- Text for dialog when user drag-n-drop an efficiency CSV file onto app -->
146+
<message id="smm-eff-csv-curve">Efficiency CSV Curve DRF</message>
147+
<message id="smm-eff-csv-error">Error creating DRF from efficiency CSV: {1}</message>
148+
<message id="smm-eff-csv-det-dat-label">Detector.dat (optional)</message>
149+
<message id="smm-eff-csv-intrinsic">Intrinsic Efficiency</message>
150+
<message id="smm-eff-csv-abs-eff">Absolute Efficiency</message>
151+
145152
<!-- Text for dialog when user drag-n-drop the Activity/Shielding fit file onto app -->
146153
<message id="smm-act-shield-xml">Activity/Shielding XML</message>
147154
<message id="smm-act-shield-use">Use this Activity/Shielding fit setup?</message>

InterSpec_resources/static_text/faqs/faqs.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,13 @@
12181218
<ul>
12191219
<li>DRFs created using the &quot;Make Detector Response&quot;, in <code>CSV</code>, <code>XML</code>, <code>URI</code>, or <code>QR-code</code> form</li>
12201220
<li>From <a target="_blank" href="https://rsicc.ornl.gov/PackageDetail.aspx?p=GADRAS-DRF-18.8.13&amp;id=P00610&amp;cpu=PCX86&amp;v=04&amp;t=Gamma%20Detector%20Response%20and%20Analysis%20Software–Detector%20Response%20Function.">GADRAS-DRF</a></li>
1221-
<li>In a couple <code>CSV</code>/<code>TSV</code> formats</li>
1221+
<li>In a couple <code>CSV</code>/<code>TSV</code> formats
1222+
<ul>
1223+
<li>Files with a variant of at least &quot;Energy&quot; and &quot;Efficiency&quot; header column</li>
1224+
<li>See <code>data/common_drfs.tsv</code> for a format that holds multiple detectors</li>
1225+
</ul>
1226+
</li>
1227+
<li><code>.outx</code> files produced by <a target="_blank" href="https://www.angle.me">Angle</a></li>
12221228
<li><code>.ECC</code> files produced by
12231229
<a target="_blank" href="https://www.mirion.com/products/technologies/spectroscopy-scientific-analysis/gamma-spectroscopy/gamma-spectroscopy-software/lab-applications/s573-isocs-calibration-software">Mirion ISOCS</a>
12241230
</li>

0 commit comments

Comments
 (0)