Ticket #10254 (closed: fixed)

Opened 6 years ago

Last modified 5 years ago

IntegratePeaksMD should be fixed for tube gaps

Reported by: Vickie Lynch Owned by: Vickie Lynch
Priority: major Milestone: Release 3.3
Component: Framework Keywords:
Cc: saviciat@…, martyn.gigg@… Blocked By:
Blocking: #10339 Tester: Owen Arnold

Description

Tube gaps should not be counted as edges. This is a request for CORELLI.

Change History

comment:1 Changed 6 years ago by Vickie Lynch

Refs #10254 new edge integration parameter

Changeset: 15d35effff8c9ec9159ce1e10c1fa69736959303

comment:2 Changed 6 years ago by Vickie Lynch

Refs #10254 fix doxygen warning

Changeset: cd50bdd6f1416cdf135d1bc9f8398ddd83f465e6

comment:3 Changed 6 years ago by Owen Arnold

Pascal has suggested solving this problem by repeating the ray tracing around around a circle to determine if there are neighbouring tubes, or if this is really an edge of a bank. Read - a ray with thickness.

The solution should work for non-rectangular detector instruments. Such as WISH.

comment:4 Changed 6 years ago by Vickie Lynch

Refs #10254 IntegrateEllipsoids should work for weighted events

Changeset: 3e2d956e907084661a1bc9fd36e2c96cedd6cd35

comment:5 Changed 6 years ago by Andrei Savici

Here is what I propose:

  1. Define edges for each instrument. For CORELLI, tubes 1 and 16, and pixels 0 and 255.
  2. Get Q in the lab frame for every peak, call it C
  3. For every point on the edge, the trajectory in reciprocal space is a straight line, going through O=V3D(0,0,0). Calculate a point at a large momentum, say k=100. Q in the lab frame E=V3D(-k*sin(tt)*cos(ph),-k*sin(tt)*sin(ph),k-k*cos(ph)).
  4. Normalize E to 1: E=E*(1./E.norm())
  5. The distance from C to OE is given by dv=C-E*(C.scalar_prod(E))
  6. If dv.norm<integration_radius, one of the detector trajectories on the edge is too close to the peak

Also, I would apply this method to all masked pixels. If there are masked pixels trajectories inside an integration volume, the peak must be rejected. Here is a short python script, not very efficient, takes about 10-20 seconds on my laptop.

from numpy import *
w=Load(Filename='TOPAZ_3680_10_sec_40.peaks')
i=w.getInstrument()
kmax=100.		
for pind in range(w.getNumberPeaks()):
	C=w.getPeak(pind).getQLabFrame() #peak position
	for bank in range(3,17):
		for p in range(256):
			d1=i[bank][0][p] #detectors on the edge 1
			d2=i[bank][255][p]#detectors on the edge 2
			d3=i[bank][p][0]#detectors on the edge 3
			d4=i[bank][p][255]#detectors on the edge 4
			#the rest is only for edge 1, but just copy, paste, replace index for the other edges
			tt1=d1.getTwoTheta(V3D(0,0,0),V3D(0,0,1)) #two theta
			ph1=d1.getPhi() #phi
			E1=V3D(-kmax*sin(tt1)*cos(ph1),-kmax*sin(tt1)*sin(ph1),kmax-kmax*cos(tt1)) #end of trajectory
			E1=E1*(1./E1.norm()) #normalize
			distv=C-E1*(C.scalar_prod(E1)) #distance to the trajectory as a vector
			if distv.norm()<0.1:
				print w.getPeak(pind).getHKL()
				break
		else:
			continue
		break
	else:
		continue

comment:6 Changed 6 years ago by Owen Arnold

In principle this looks good. Here are some things to consider:

  • Is there a better way to select kmax rather than hard-coding some large value?
  • Need to have a general way to find the edges as this should work for lots of different instrument types.
  • Missing from the above, script, but you mention it in the instructions, you should fetch out the actual peak integration radius in qlab.
  • Would be nice to have this feature coded outside of IntegratePeaksMD, so that it could be used in other places.

Other than that, this looks like a much better method than the current ray-tracing routines.

comment:7 Changed 6 years ago by Owen Arnold

  • Cc saviciat@…, martyn.gigg@… added

comment:8 Changed 6 years ago by Andrei Savici

  1. In reply to the first point, I realized that any value of k!=0 is ok. Probably the best is 1, to reduce the number of multiplications
  2. Probably the best way is instrument parameter file
  3. This would work equally well in q_sample, just need to multiply the E points by the goniometer matrix
  4. I think that it can be implemented as a separate algorithm, acting on the peak workspace only

comment:9 Changed 6 years ago by Vickie Lynch

Refs #10254 mask instrument of peaks workspace

Changeset: d0a46602396829c714684237936d2acb495b9c9e

comment:10 Changed 6 years ago by Vickie Lynch

Revert "Refs #10254 mask instrument of peaks workspace"

This reverts commit d0a46602396829c714684237936d2acb495b9c9e.

Changeset: 7c23871b933f48dd5262c3a0c2d7110b685b2ec8

comment:11 Changed 6 years ago by Vickie Lynch

Revert "Refs #10254 new edge integration parameter"

This reverts commit 15d35effff8c9ec9159ce1e10c1fa69736959303.

Changeset: 32338786ac52d4f86c277a2d4a34266a7d05f812

comment:12 Changed 6 years ago by Vickie Lynch

Refs #10254 hardcoded edges of TOPAZ working

Changeset: 3946217facb1a3f38929b6cd4a05a8e449a6b0d5

comment:13 Changed 6 years ago by Vickie Lynch

Refs #10254 mask edges of banks for all instruments

Changeset: 8de35338a7ffd1dea0e8e902e0984109506c5938

comment:14 Changed 6 years ago by Vickie Lynch

Refs #10254 add WISH to MaskBTP instruments

Changeset: 1b0ac109298eb9a6c1304769a5a80c1eb9bd340e

comment:15 Changed 6 years ago by Vickie Lynch

Refs #10254 tube gap in instrument parameter files

Changeset: ff4b43d801ef1e671cae6f734d6a4010889edbc2

comment:16 Changed 6 years ago by Vickie Lynch

Refs #10254 fix unit test

Changeset: e94fdd0b9dd734c52b6850366a860b88fb74a48c

comment:17 Changed 6 years ago by Vickie Lynch

Refs #10254 tabs to spaces

Changeset: 3ac88bda3da18ab55dfb24eedec655a97a7bc651

comment:18 Changed 6 years ago by Vickie Lynch

Refs #10254 fix conflict

Changeset: 0e04e636499901411f93caab055657d76c2dec55

comment:19 Changed 6 years ago by Vickie Lynch

Refs #10254 fix WISH systemtest

Changeset: cc703651b2aaae91fd7946eabaa1e6488cc47bee

comment:20 Changed 6 years ago by Martyn Gigg

Revert "Revert "Refs #10254 mask instrument of peaks workspace""

This reverts commit 7c23871b933f48dd5262c3a0c2d7110b685b2ec8.

Changeset: c12e71d7f57d0ed86659d33d24429101603b7974

comment:21 Changed 6 years ago by Vickie Lynch

Refs #10254 change html for docs

Changeset: d726d757ebcf060b7bb11fcd0af47adc1b8fbb09

comment:22 Changed 6 years ago by Vickie Lynch

Refs #10254 docs for IntegrateEllipse not specify raw events only

Changeset: 30c17e259b64d07faadd14abdd564caed16375c2

comment:23 Changed 6 years ago by Vickie Lynch

  • Status changed from new to assigned
  • Milestone changed from Backlog to Release 3.3

comment:24 Changed 6 years ago by Vickie Lynch

  • Status changed from assigned to inprogress

Refs #10254 should not average pixelIDs

Changeset: f13e1f941fcd23e6497182d07ce756ce7a8ef071

comment:25 Changed 6 years ago by Vickie Lynch

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

Test using python script attached to ticket 8369. Mantid gives a warning that peak 8 is off the detectors before these changes. You can see that a tube gap is inside the integration sphere of this peak. Ticket also fixes IntegrateEllipsoids for weighted events and adds a tube-gap parameter to the instrument that can find peaks centered on a tube gap. Documentation has been changed for all these changes.

comment:26 Changed 6 years ago by Owen Arnold

  • Status changed from verify to verifying
  • Tester set to Owen Arnold

comment:27 Changed 6 years ago by Owen Arnold

No warnings now on the WISH side. Tried the previous script, which was incorrectly marking peaks off the edge of the detector.

comment:28 Changed 6 years ago by Owen Arnold

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/10254_integrate_tube_gaps'

Full changeset: c65858707b23f5a11b3f9249a7b8e0501d487f85

comment:29 Changed 6 years ago by Owen Arnold

  • Blocking 10339 added

comment:30 Changed 6 years ago by Owen Arnold

Nice piece of work. Thanks a lot for this.

comment:31 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 11096

Note: See TracTickets for help on using tickets.