Ticket #8416 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Quantification: Fix cut when taken using foreground only

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: blocker Milestone: Release 3.1
Component: Direct Inelastic Keywords:
Cc: Blocked By:
Blocking: Tester: Roman Tolchenov

Description

Using the foreground only and taking cuts through the Sr122 model does not yield exact matches to tobyfit. This needs to be investigated.

Attachments

TobyFitSlice.png (176.9 KB) - added by Martyn Gigg 7 years ago.

Change History

comment:1 Changed 7 years ago by Martyn Gigg

  • Status changed from new to inprogress

Minor cleanup of creation of simulated convolved MD workspace.

Refs #8416

Changeset: 16514f470880f01937eca6a9ae5803df5bde387e

comment:2 Changed 7 years ago by Martyn Gigg

Foreground model now assumes input Q is in the lab frame, not sample.

Refs #8416

Changeset: c56a28d8d57d9151af92615fbb831a59ca3bb968

comment:3 Changed 7 years ago by Martyn Gigg

ResolutionModel now expects input coords in cartesian crystal frame.

This is the default output of ConvertToMD. Internally it rotates to/from lab frame to perform the resolution calculation. Refs #8416

Changeset: ab00aa7aa8fe3137a55d24035f76dbc5ff65cb44

comment:4 Changed 7 years ago by Martyn Gigg

Add a quantification model that simply returns a Q coordinate.

Used mainly for debugging transformations. Refs #8416

Changeset: db0ee648d38f05140d600360a985a2b19a8ae3d0

comment:5 Changed 7 years ago by Martyn Gigg

Default to overwrite existing workspace in simulation.

Refs #8416

Changeset: 702fc70ee5cac7c8bc660613bc1f64627f3c795e

comment:6 Changed 7 years ago by Martyn Gigg

Add unity option to QCoordinate.

Refs #8416

Changeset: fef38d95d0b6fd15afe659f45c1adffbe3c1ff65

comment:7 Changed 7 years ago by Martyn Gigg

Correct property count in test.

Refs #8416

Changeset: 7e55948b01ee58663c347d4244dfa986222ffdcf

comment:8 Changed 7 years ago by Martyn Gigg

Fix const-correctness in MDHistWorkspace.

Refs #8416

Changeset: 5ef3b1a969d3c617d5a4a2de0caf702597f4c29e

comment:9 Changed 7 years ago by Martyn Gigg

Fix normalization by events in MDHistWorkspaceIterator.

It had not been implemented at all when the events field was added to the MDHistoWorkspace! Refs #8416

Changeset: 25d46faee338d44f0fb4d6fd4ea36f711b418d2e

comment:10 Changed 7 years ago by Martyn Gigg

Fix bounding box of cached detector to taking into account grouping.

Refs #8416

Changeset: 1cc2efe187cfa96e210ddada4c505450609921be

comment:11 Changed 7 years ago by Martyn Gigg

Fixes for TobyFit simulation require ref results update.

Refs #8416

Changeset: 8afe53c1877baf89f34b881b27d34b718677f941

comment:12 Changed 7 years ago by Martyn Gigg

Fix CachedExperimentInfoTest

Refs #8416

Changeset: 5262240245ec94ba31c1b44577715f1a496d9b3a

comment:13 Changed 7 years ago by Martyn Gigg

  • Status changed from inprogress to verify
  • Resolution set to fixed

Branch: bugfix/8416_quantification_fg_only in BOTH code && systemtests repositories

Tester:

def create_cuboid_xml(xlength,ylength,zlength):
    xml = """<cuboid id="sample0">
<left-front-bottom-point x="%(xpt)f" y="-%(ypt)f" z="-%(zpt)f"  />
<left-front-top-point  x="%(xpt)f" y="-%(ypt)f" z="%(zpt)f"  />
<left-back-bottom-point  x="-%(xpt)f" y="-%(ypt)f" z="-%(zpt)f"  />
<right-front-bottom-point  x="%(xpt)f" y="%(ypt)f" z="-%(zpt)f"  />
</cuboid>
<algebra val="sample0" />
"""
    return xml % {"xpt": xlength/2.0,"ypt":ylength/2.0,"zpt":zlength/2.0}


def do_simul():
    ei = 300.
    bins = [-30,3,279]
    temperature = 6. 
    chopper_speed = 600.
      
    # Oriented lattice & goniometer.
    alatt = 5.57
    blatt = 5.51
    clatt = 12.298
    uvec = [9.700000e-03,9.800000e-03,9.996000e-01]
    vvec = [9.992000e-01,-3.460000e-02,-4.580000e-02]

    omega = 0.0
    alpha = 0.0
    beta = 0.0
    gamma = 0.0

    # sample dimensions
    sx = 0.05 # Perp
    sy = 0.025 # Up direction
    sz = 0.04 # Beam direction

    # Crystal mosaic
    eta_sig = 4.0

    fake_data = CreateSimulationWorkspace(Instrument='MERLIN',
                                          BinParams=bins,UnitX='DeltaE',
                                          DetectorTableFilename='MER06398.raw')

    ##
    ## Required log entries, can be taken from real ones by placing an instrument parameter of the same
    ## name pointing to the log name
    ##
    AddSampleLog(Workspace=fake_data, LogName='Ei',LogText=str(ei), LogType="Number")
    AddSampleLog(Workspace=fake_data, LogName='temperature_log',LogText=str(temperature), LogType="Number")
    AddSampleLog(Workspace=fake_data, LogName='chopper_speed_log',LogText=str(chopper_speed), LogType="Number")
    AddSampleLog(Workspace=fake_data, LogName='eta_sigma',LogText=str(eta_sig), LogType="Number")
    
    ##
    ## Sample shape
    ##
    CreateSampleShape(InputWorkspace=fake_data, ShapeXML=create_cuboid_xml(sx,sy,sz))
    
    ##
    ## Chopper & Moderator models. 
    ##
    CreateModeratorModel(Workspace=fake_data,ModelType='IkedaCarpenterModerator',
                         Parameters="TiltAngle=32,TauF=2.7,TauS=0,R=0")
    CreateChopperModel(Workspace=fake_data,ModelType='FermiChopperModel',
                       Parameters="AngularVelocity=chopper_speed_log,ChopperRadius=0.049,SlitThickness=0.0023,SlitRadius=1.3,Ei=Ei,JitterSigma=0.0")
    
    ##
    ## UB matrix
    ##
    SetUB(Workspace=fake_data,a=alatt,b=blatt,c=clatt,u=uvec,v=vvec)
    
    ##
    ## Sample rotation. Simulate 1 run at zero degrees psi
    ##
    
    psi = 0.0
    AddSampleLog(Workspace=fake_data,LogName='psi',LogText=str(psi),LogType='Number')
    SetGoniometer(Workspace=fake_data,Axis0="psi,0,1,0,1")
    
    # Create the MD workspace
    qscale = 'Q in A^-1'
    fake_md = ConvertToMD(InputWorkspace=fake_data, QDimensions="Q3D", QConversionScales=qscale,
                          SplitInto=[3], SplitThreshold=100,
                      MinValues="-15,-15,-15,-30", MaxValues="25,25,25,279",OverwriteExisting=True)
    
    # Run the simulation.
    resol_model = "TobyFitResolutionModel"
    xsec_model = "Strontium122"
    parameters = "Seff=0.7,J1a=38.7,J1b=-5.0,J2=27.3,SJc=10.0,GammaSlope=0.08,MultEps=0,TwinType=0,MCLoopMin=10,MCLoopMax=10,MCType=1" # Use sobol & restart each pixel to ensure reproducible result
    simulated = SimulateResolutionConvolvedModel(InputWorkspace=fake_md,
                                                 ResolutionFunction=resol_model,
                                                 ForegroundModel=xsec_model,
                                                 Parameters=parameters)
    # Take a slice
    slice_ws = BinMD(InputWorkspace=simulated,
                  AlignedDim0='[H,0,0], -12.000000, 9.000000, 100',
                  AlignedDim1='[0,K,0], -6.000000, 7.000000, 100',
                  AlignedDim2='[0,0,L], 0.000000, 6.000000, 1',
                  AlignedDim3='DeltaE, 100.000000, 150.000000, 1')
####################################################

do_simul()

Run the above script, the raw file is in the systemtests/Data, to produce a simulated MDEventWorkspace along with a cut out of it,slice_ws. View the cut with the slice viewer, set the normalization to normalize by events and it should look like the attached image.

Changed 7 years ago by Martyn Gigg

comment:14 Changed 7 years ago by Roman Tolchenov

  • Status changed from verify to verifying
  • Tester set to Roman Tolchenov

comment:15 Changed 7 years ago by Roman Tolchenov

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/bugfix/8416_quantification_fg_only'

Full changeset: 9211d6094aa3dbfe2e5edc249e2f08f1f7e6a882

comment:16 Changed 7 years ago by Martyn Gigg

Merge remote-tracking branch 'origin/bugfix/8416_quantification_fg_only'

Full changeset: 8fbc2462eff4ff55933f6c8e0778a43b8c0901ad

comment:17 Changed 7 years ago by Nick Draper

  • Component changed from Framework to Direct Inelastic

comment:18 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 9260

Note: See TracTickets for help on using tickets.