Energy deposition: DETECT or MGDRAW

Dear FLUKA community

I’m interested in scoring the energy deposition in more than one detector (or region) at a time, but obtaining this information event-by-event, in order to apply the smearing of the data outside FLUKA (and not repeat the simulation every time).

Up to this moment, I’ve learned that there are two different ways to obtain the energy deposition event-by-event:

1) With the MGDRAW subroutine. I declared TRULL, set it =0 at the beginning, and then saved the “spot” energy depositions with the RULL variable in the ENDRAW entry. Afterwards, in the main part of MGDRAW, I save also the DTRACK(J) for the energy deposition events along the track.

I mainly included, as a test, in MGDRAW main body:

  TRULL = 0. 
    IF (MREG.EQ.2) THEN
     DO J = 1,MTRACK
      TRULL =  TRULL + DTRACK(J)
     ENDDO
    ENDIF

and in the ENDRAW entry:

  ENTRY ENDRAW ( ICODE, MREG, RULL, XSCO, YSCO, ZSCO )
   IF (MREG.EQ.2) THEN
    TRULL = TRULL + RULL
   END IF
  RETURN

and, at the end of the event, I basically save and update TRULL=0 for the next event:

ENTRY EEDRAW ( ICODE )
IF ( .NOT. LFCOPE ) THEN
LFCOPE = .TRUE.
OPEN ( UNIT = 46, FILE = “F01_EnDep.tab”, STATUS = ‘UNKNOWN’)
ENDIF
IF ( TRULL.GT.0 ) THEN
WRITE(46,*) TRULL
END IF
TRULL = 0.
RETURN

With this approach, I only get the energy depositions from the ENDRAW entry, which I checked by commenting this part of the code and obtaining zero as a result (thus not collectiong the DTRACK(J) part). Is there something wrong with this approach? Why I’m not collecting anything with DTRACK(J)?

2) Using the DETECT card. With this I got the energy deposition correctly (further compared with Geant4), but I wanted to intervene in order to get the information event-by-event. For this, I found a previous post: Gaussian Energy Broadening
There, it is indicated to use the usreou.f subroutine to intervene at the end of each event, and that the energy deposited as scored by the DETECT card is stored in ACCUMP and ACCUMN (which is the difference?). It is also further explained how to perform the smearing, but I would like to do it outside FLUKA, so I tried to save the ACCUMP and ACCUMN for each event. I did it as follows (probably wrong way):

  OPEN ( UNIT = 46, FILE = "F01_EnDep.tab", STATUS = 'UNKNOWN')
  IF (MREG.EQ.2) THEN
  IF (ACCUMP(NDTCM2) .NE. ZERZER.AND.ACCUMN(NDTCM2).NE.ZERZER) THEN
  WRITE(46,*) MREG, ACCUMP(NDTCM2), ACCUMN(NDTCM2)
  ENDIF
  ENDIF

I tried to score the region as well, because I do not know how to separate the energy depositions if I have (as is my case) four DETECT cards in the input file. Nevertheless, all I got was a list of zeros.

Is there any easiest or recommended way to obtain the energy deposition event-by-event in the regions of interest? Any information would be greatly appreciated.

I attach the files, in case you need to take a look.

Thank you all in advance!

10-2020-Clearance-Box.inp (7.6 KB) mgdraw.f (4.1 KB) usreou.f (2.4 KB)

1 Like

Dear Federico,

Upon a first glance, one notes the following:

i) An EVENTBIN per region is most likely what you need. See the the FLUKA
manual documentation to get started with the EVENTBIN card.

ii) You pass a USERDUMP card requesting to look at only local losses. Also,
your attempted logics to examine DTRACK in the main entry of your mgdraw.f
appeared to be inside an IF block that was only invoked once (if at all!).
Select in Flair e.g. “Score All” in the USERDUMP card.

iii) Also, your main mgdraw.f subroutine entry was lacking a RETURN statement,
which is not what you want.

iv) At a first glance I am not sure that your logics of initializing TRULL with the
continuous energy losses in the main entry of subroutine MGDRAW, then
complementing TRULL with the losses in ENDRAW so as to write it out in
the end with EEDRAW will work (but I can be wrong).

See the attached mgdraw.f:

mgdraw_federico.f (15.0 KB)

which differs minimally from the distributed one under src/user/mgdraw.f
(make a diff to see the changes): it writes out continuous energy depositions
(in the main entry of subroutine MGDRAW) and discrete ones (in entry
ENDRAW), the output being in the *.97 and *.98 files. You can do your
bookkeeping/analysis offline. Incidentally, it assumes a USERDUMP card
in your input a la

USERDUMP        100.       49.        0.                              Dump

…the first and third WHATs being the important ones. Adapt as needed.

v) The detect card accumulates energy deposition in positive-defined
and negative-defined regions in the arrays ACCUMP() and ACCUMN(),
respectively. See the DETECT card section of manual to see what
positive and negative means in this context (the sign distinguishes
coincidence/anti-coincidence scoring). Since in your case you have no
anti-coincidence set up, ACCUMN() should all be zero. And you should see
the first four elements of ACCUMP (corresponding to the four DETECT
cards you’ve passed to score energy deposition in regions
F01,F02,F03,F04) occasionally non-zero. So in your case you should print out
ACCUMP(1), ACCUMP(2), ACCUMP(3), ACCUMP(4) instead of your attempted
ACCUMP(NDTCM2).

vi) Once you’re comfortable with a correctly set up mgdraw.f, I’d say this
is the option that gives you the most flexibility/comfort for event-by-event
energy deposition analyses. But keep in mind that an EVENTBIN per
region could be as helpful / more comfortable.

Cheers,

Cesc

Dear Francesc

Thank you very much for your detailed answer. It is a really good point to start working. I will try to follow up your recommendations, and sorry for the many mistakes I sent with my files!

Kind regards,
Federico