mantidproject / mantid

Main repository for Mantid code
https://www.mantidproject.org
GNU General Public License v3.0
210 stars 121 forks source link

improve auto-select normalization for MDHistoWorkspace #12832

Closed quantumsteve closed 8 years ago

quantumsteve commented 9 years ago

Setting NumEventsNormalization for diffraction returns an incorrect result. @AndreiSavici suggests that for MDHistoWorkspace, NumEventsNormalization should only be used if the instrument is inelastic and there is no MDNorm algorithm in the history.

I think the best place to implement this logic is in MDHistoWorkspace::displayNormalization().

OwenArnold commented 9 years ago

@Andrei, @quantumsteve. I have some questions. Is this blocking the move to newer ParaView in any way? Secondly, yes as steve suggests, we can customise MDHistoWorkspace::displayNormalization(). Rather than trying to parse history looking for MDNorm, should we set this property appropriately as part of MDNorm ?

quantumsteve commented 9 years ago

@OwenArnold This is NOT blocking our move to newer ParaView. At the same time, this needs to be addressed before it affects a substantial number of users.

AndreiSavici commented 9 years ago

@quantumsteve , @OwenArnold I like the idea of setting the flag as part of MDNorm. Then the default should be none. ConvertToMD should check in the inelastic case if you start from a workspace2D (NumEventsNormalization) or events (NoNormalization)

OwenArnold commented 9 years ago

@AndreiSavici. Ok sounds like a plan. When I get this done I'll assign you as the tester.

OwenArnold commented 9 years ago

@quantumsteve I'll up the priority of this. I'm working on another critical issue at the moment, but I'll put this next in line.

OwenArnold commented 9 years ago

@AndreiSavici. Could you please clarify the rules for this?

> NumEventsNormalization should only be used if the instrument is inelastic

Is this really technique dependent?
> and there is no MDNorm algorithm in the history
Are we just trying to determine if Normalization has already been applied?
AndreiSavici commented 9 years ago

@OwenArnold NumEventsNormalization was the only way to get S(Q,w) for inelastic scattering, and it relies on the matrix workspace going into ConvertToMD to be a Workspace2D histogrammed in energy transfer. The number of events in this case is not neutron events, but number of histogram bins corresponding to scattering in a particular Q,w MDBox. If you do diffraction, you measure only S(Q), so no energy transfer. If you use events in the ConvertToMD, the number of events normalization yields always 1 (unless you weighted the events). On a regular grid, the MDNorm algorithms correctly calculate the normalization, so you can measure your S(Q,w) with events (not carry around a lot of empty bins). Even if one measures with histograms in w, the MDNorm yields a similar number to number of events normalization, so you should not normalize twice.

OwenArnold commented 9 years ago

In ConvertToMD:

  1. Check that we have an Input Workspace2D ..* Check that we are converting in InElastic mode ..* If both of the above are true. Set the Normalization to NumEvents
  2. Otherwise set the normalization to be None

In the MDNorm Normalization algorithms. Overwrite Normalization type to be None. Already accounts for number of events.

AndreiSavici commented 9 years ago

In ConvertToMD check first if the mode is elastic. If yes, set to volume normalization (so you can see Bragg peaks in diffraction). If no, check if input is Workspace2D. If yes, set to # events normalization, else set to no normalization. MDNorm is OK

OwenArnold commented 9 years ago

@andrei. Regarding what you've said above. For diffraction volume normalization is a good idea when you have an MDEventWorkspace (box size varies). When you bin your diffraction workspace to a regular grid MDHistoWorkspace, then volume normalization has no effect other than to uniformly scale the data.

Also, for MDEventWorkspaces shouldn't we always be normalizing by volume? It seems wrong not to take the volume of each voxel into account.

Sorry to be a pain about this, but I want to make sure we agree on the rules for the default.

OwenArnold commented 8 years ago

Steps to complete:

  1. Make the MDHistoWorkspace take and return the display normalization as a setting
  2. Make MDHistoWorkspace persist the above information
  3. Make the MDEventWorkspace able to carry the display normalisation it will pass on
  4. Make the MDEventWorkspace persist the information to pass to the MDHistoWorkspace
  5. Use the rules outlined by @Andrei above to modify ConvertToMD such that generated MDEventWorskpaces are set with the display normalization settings they will pass on to future MDHistoWorkspaces
  6. In MDNormDirectSC, set the normalization on the output MDHistoWorkspace to be None.

The next task would then be to make the SliceViewer query the displayNormalization of input workspaces and use it to set the default normalization (probably a separate ticket).