@@ -29,6 +29,7 @@ static const std::string SPIN_STATES{"SpinStates"};
29
29
static const std::string EFFICIENCIES{" Efficiencies" };
30
30
static const std::string INPUT_WS{" InputWorkspaces" };
31
31
static const std::string OUTPUT_WS{" OutputWorkspace" };
32
+ static const std::string ADD_SPIN_STATE_LOG{" AddSpinStateToLog" };
32
33
} // namespace Prop
33
34
34
35
/* *
@@ -340,6 +341,9 @@ void PolarizationCorrectionWildes::init() {
340
341
std::make_unique<API::WorkspaceProperty<API::MatrixWorkspace>>(Prop::EFFICIENCIES, " " , Kernel::Direction::Input),
341
342
" A workspace containing the efficiency factors P1, P2, F1 and F2 as "
342
343
" histograms" );
344
+ declareProperty (
345
+ Prop::ADD_SPIN_STATE_LOG, false ,
346
+ " Whether to add the final spin state into the sample log of each child workspace in the output group." );
343
347
}
344
348
345
349
// ----------------------------------------------------------------------------------------------
@@ -348,6 +352,8 @@ void PolarizationCorrectionWildes::init() {
348
352
void PolarizationCorrectionWildes::exec () {
349
353
const std::string flipperProperty = getProperty (Prop::FLIPPERS);
350
354
const auto flippers = PolarizationCorrectionsHelpers::splitSpinStateString (flipperProperty);
355
+ // Check if the input flipper configuration includes an analyser
356
+ const bool hasAnalyser = flippers.front ().size () > 1 ;
351
357
const auto inputs = mapInputsToDirections (flippers);
352
358
checkConsistentNumberHistograms (inputs);
353
359
const EfficiencyMap efficiencies = efficiencyFactors ();
@@ -358,8 +364,7 @@ void PolarizationCorrectionWildes::exec() {
358
364
outputs = directBeamCorrections (inputs, efficiencies);
359
365
break ;
360
366
case 2 :
361
- // Check if the input flipper configuration includes an analyser
362
- if (flippers.front ().size () > 1 ) {
367
+ if (hasAnalyser) {
363
368
outputs = twoInputCorrections (inputs, efficiencies);
364
369
} else {
365
370
outputs = analyzerlessCorrections (inputs, efficiencies);
@@ -371,7 +376,7 @@ void PolarizationCorrectionWildes::exec() {
371
376
case 4 :
372
377
outputs = fullCorrections (inputs, efficiencies);
373
378
}
374
- setProperty (Prop::OUTPUT_WS, groupOutput (outputs));
379
+ setProperty (Prop::OUTPUT_WS, groupOutput (outputs, hasAnalyser ));
375
380
}
376
381
377
382
/* *
@@ -513,27 +518,35 @@ void PolarizationCorrectionWildes::checkConsistentX(const WorkspaceMap &inputs,
513
518
* The workspaces will be published in the ADS, their names appended by
514
519
* appropriate suffices.
515
520
* @param outputs a set of workspaces to group
521
+ * @param hasAnalyser whether the flipper configuration included an analyser.
516
522
* @return a group workspace
517
523
*/
518
- API::WorkspaceGroup_sptr PolarizationCorrectionWildes::groupOutput (const WorkspaceMap &outputs) {
524
+ API::WorkspaceGroup_sptr PolarizationCorrectionWildes::groupOutput (const WorkspaceMap &outputs,
525
+ const bool hasAnalyser) {
519
526
const auto &outWSName = getPropertyValue (Prop::OUTPUT_WS);
520
527
auto spinStateOrder = getPropertyValue (Prop::SPIN_STATES);
528
+ const bool addSpinStateLog = getProperty (Prop::ADD_SPIN_STATE_LOG);
529
+
521
530
std::vector<std::string> names;
522
531
if (!spinStateOrder.empty ()) {
523
532
names.resize (PolarizationCorrectionsHelpers::splitSpinStateString (spinStateOrder).size ());
524
533
}
525
534
526
535
if (outputs.ppWS ) {
527
- addSpinStateOutput (names, spinStateOrder, outWSName, outputs.ppWS , SpinStateConfigurationsWildes::PLUS_PLUS);
536
+ addSpinStateOutput (names, spinStateOrder, outWSName, outputs.ppWS , SpinStateConfigurationsWildes::PLUS_PLUS,
537
+ addSpinStateLog, hasAnalyser);
528
538
}
529
539
if (outputs.pmWS ) {
530
- addSpinStateOutput (names, spinStateOrder, outWSName, outputs.pmWS , SpinStateConfigurationsWildes::PLUS_MINUS);
540
+ addSpinStateOutput (names, spinStateOrder, outWSName, outputs.pmWS , SpinStateConfigurationsWildes::PLUS_MINUS,
541
+ addSpinStateLog, hasAnalyser);
531
542
}
532
543
if (outputs.mpWS ) {
533
- addSpinStateOutput (names, spinStateOrder, outWSName, outputs.mpWS , SpinStateConfigurationsWildes::MINUS_PLUS);
544
+ addSpinStateOutput (names, spinStateOrder, outWSName, outputs.mpWS , SpinStateConfigurationsWildes::MINUS_PLUS,
545
+ addSpinStateLog, hasAnalyser);
534
546
}
535
547
if (outputs.mmWS ) {
536
- addSpinStateOutput (names, spinStateOrder, outWSName, outputs.mmWS , SpinStateConfigurationsWildes::MINUS_MINUS);
548
+ addSpinStateOutput (names, spinStateOrder, outWSName, outputs.mmWS , SpinStateConfigurationsWildes::MINUS_MINUS,
549
+ addSpinStateLog, hasAnalyser);
537
550
}
538
551
539
552
auto group = createChildAlgorithm (" GroupWorkspaces" );
@@ -547,16 +560,24 @@ API::WorkspaceGroup_sptr PolarizationCorrectionWildes::groupOutput(const Workspa
547
560
548
561
/* *
549
562
* Add an output name in the correct position in the vector and to the ADS.
563
+ * Optionally adds a spin state log to the output workspace.
550
564
* @param names A list of the names of the workspaces the algorithm has generated.
551
565
* @param spinStateOrder The order the output should be in.
552
566
* @param baseName The base name for the output workspaces ("BASENAME_SPINSTATE" e.g "OUTNAME_+-")
553
567
* @param ws The workspace to add to the vector and ADS.
554
568
* @param spinState The spin state the workspace represents.
569
+ * @param addSpinStateLog Whether to add a sample log to the output workspace giving the spin state using the
570
+ * Reflectometry ORSO notation.
571
+ * @param hasAnalyser Whether the flipper configuration included an analyser.
555
572
*/
556
573
void PolarizationCorrectionWildes::addSpinStateOutput (std::vector<std::string> &names,
557
574
const std::string &spinStateOrder, const std::string &baseName,
558
- const API::MatrixWorkspace_sptr &ws,
559
- const std::string &spinState) {
575
+ const API::MatrixWorkspace_sptr &ws, const std::string &spinState,
576
+ const bool addSpinStateLog, const bool hasAnalyser) {
577
+ if (addSpinStateLog) {
578
+ addSpinStateLogToWs (ws, spinState, hasAnalyser);
579
+ }
580
+
560
581
if (spinStateOrder.empty ()) {
561
582
names.emplace_back (baseName + " _" + spinState);
562
583
API::AnalysisDataService::Instance ().addOrReplace (names.back (), ws);
@@ -573,6 +594,29 @@ void PolarizationCorrectionWildes::addSpinStateOutput(std::vector<std::string> &
573
594
}
574
595
}
575
596
597
+ /* *
598
+ * Adds a sample log to the workspace that gives the spin state of the data using Reflectometry ORSO notation.
599
+ * @param ws The workspace to add the sample log to.
600
+ * @param spinState The spin state the workspace represents.
601
+ * @param hasAnalyser Whether the flipper configuration included an analyser.
602
+ */
603
+ void PolarizationCorrectionWildes::addSpinStateLogToWs (const API::MatrixWorkspace_sptr &ws,
604
+ const std::string &spinState, const bool hasAnalyser) {
605
+ if (!hasAnalyser) {
606
+ if (spinState == SpinStateConfigurationsWildes::PLUS_PLUS) {
607
+ SpinStatesORSO::addORSOLogForSpinState (ws, SpinStateConfigurationsWildes::PLUS);
608
+ return ;
609
+ }
610
+
611
+ if (spinState == SpinStateConfigurationsWildes::MINUS_MINUS) {
612
+ SpinStatesORSO::addORSOLogForSpinState (ws, SpinStateConfigurationsWildes::MINUS);
613
+ return ;
614
+ }
615
+ }
616
+
617
+ SpinStatesORSO::addORSOLogForSpinState (ws, spinState);
618
+ }
619
+
576
620
/* *
577
621
* Make a convenience access object to the efficiency factors.
578
622
* @return an EfficiencyMap object
0 commit comments