Energy of positrons at the instant of pair production -- MGDRAW

Dear Users
I am trying to record the energy of positron when they are created via pair production. Let me explain the simulation setup. A beam of thermal neutron is incident on cadmium. The resulting capture gammas are incident on a tungsten mesh. These gamma photons will cause pair production in the tungsten mesh.
I am trying to record the kinetic energy of positrons right at the instant that they are born. To do this, I have set the transport threshold for positrons in the EMFCUT really high at 1 GeV. The production cut is set at 511 keV. Then in mgdraw file, I write the energy of the positron before it is killed (due to high transport threshold) using ENDDRAW. The code is-
ENTRY ENDRAW ( ICODE, MREG, RULL, XSCO, YSCO, ZSCO )
IF ( .NOT. LFCOPE ) THEN
LFCOPE = .TRUE.
OPEN ( UNIT = 88, FILE = “collfile”, STATUS = ‘UNKNOWN’)
END IF
CALL GEOR2N ( MREG, MRGNAM, IERR1 )
IF(MRGNAM .EQ. “WMesh1”) THEN
IF(JTRACK .EQ. 4) WRITE(88,’(1P,4G25.15)’)
& XSCO, RULL
END IF
RETURN

The question is- Is this a correct way of recording the positron’s KE right after its birth or is their another better way?

I am attaching the input file and mgdraw file.
thanks for your attention
sincerely
saurabh mukherjee
mgdraw_pos_yield.f (3.4 KB)
TungstenMesh_neutron-MGDRAW.inp (7.6 KB)

Dear Saurabh,

It would probably be best to consider entry USDRAW in mgdraw.f.

You can intercept the pair production event by filtering for ICODE=217
and then look up the energy of the positron (see array TKI from common
GENSTK in genstk.inc; you’ll need the element i such that
KPART(i).EQ.4).

With this approach you don’t have to make potentially distorting
threshold tricks.

Cheers,

Cesc

PS: check the 511 keV total energy threshold. This corresponds to 0
kinetic energy and will be overridden anyway.

Dear Cesc
Thank you for the reply. I have never used USDRAW. I will take some time to understand it. After that I will post my results. Thank you for pointing me in correct direction.
sincerely
saurabh