Print the parent particle information corresponding to the current particle

Hello Chen,

your code is mostly right. Let me add a quick comment first. You correctly declare a logical initialization flag:

LOGICAL LFCOPE
DATA LFCOPE / .FALSE. /

Unfortunately, this flag is used both in the entries USDRAW and BXDRAW. Normally, you should enter first in the former, which then switches off the flag also for BXDRAW. This can explain why the .98 file is not appearing after the simulation.

Now let’s focus on the core of the problem. In the USDRAW entry you tell FLUKA to save the parent particle information in ISPUSR and SPAUSR variables only if the interaction took place in ‘DETUP’.
Therefore, all the interactions outside this region do not save any information.

To print out non-zero numbers in your .88 file, you would require two interactions in sequence in your geometry: the first one did not have any information saved (each variable is 0). After the first interaction, the secondary produced has the information of the parent particle. Now, if one of these secondaries interacts again in the same region, you save correctly the information.

To understand what happens in concrete with your simulation, I would need your inputfile to observe the geometry. My naive guess is that particles go into the detector area, interact once and then they leave.

I would suggest restructuring your routine saving the parent information outside of the if condition. Let me know if this solves your problems.

      IF ( MREG .EQ. NUPSTR ) THEN
     
*       current particles attributes		 
         WRITE ( 89, * ) NCASE,ICODE,JTRACK,LTRACK, XSCO, YSCO, ZSCO,ETRACK
		 
*       the number of secondary particles and the corresponding particle ID		 
         WRITE ( 89, * ) NP, (KPART(I),I=1,NP)
		 
*       parent particles attributes	  
         WRITE ( 88, * ) ISPUSR(1),ISPUSR(2),ISPUSR(3),ISPUSR(4),SPAUSR(1),SPAUSR(2),SPAUSR(3),SPAUSR(4)
		 
*		Storing information about parent particles for secondary particles
      END IF
      ISPUSR(1) = NCASE
      ISPUSR(2) = ICODE
      ISPUSR(3) = JTRACK
      ISPUSR(4) = LTRACK
      	 
      SPAUSR(1) = XSCO
      SPAUSR(2) = YSCO
      SPAUSR(3) = ZSCO
      SPAUSR(4) = ETRACK

As a personal final suggestion, I would encourage you to avoid using tabs and using just spaces. This, with a uniform indentation, strongly helps you in working with user routines.

Cheers,
Daniele