# Calculating detector efficiency using DETECT card

**URL:** <https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295>\
**Category:** Scoring\
**Created:** [14 June 2022 08:48 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295 "2022-06-14T08:48:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahdi](https://fluka-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mahdi](https://fluka-forum.web.cern.ch/u/mahdi)\
**Post date:** [14 June 2022 08:48 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/1 "2022-06-14T08:48:32Z")

</div>

Dear FLUKA expert,  
I am trying to calculate the efficiency of a gas-filled detector using the DETECT card.  
The beam is a cold neutron beam(E=3.7 meV).  
The detector consists of a 10B layer followed by Ar-CO2 gas.  
I am interested in the deposited energy from 4He and 7Li. I studied the post about comscw.f at  
[https://fluka-forum.web.cern.ch/t/how-to-score-pulse-amplitude-spectrum-of-special-particle-such-as-proton-triton-alpha/1176/14](https://fluka-forum.web.cern.ch/t/how-to-score-pulse-amplitude-spectrum-of-special-particle-such-as-proton-triton-alpha/1176/14)

My questions are:  
1- How can I define 7Li correctly in the comscw.f and in the input file?  
2-When I run the input file, the results of the two DETECT cards are the same which means the comscw.f is not activated. How can I activate this logic?

Here are the files.  
Any comment is appreciated.

[GEM.inp](https://fluka-forum.web.cern.ch/uploads/short-url/8C0ehUACCD90gkbO6F1J6gekImm.inp) (2.2 KB)

[comscw.f](https://fluka-forum.web.cern.ch/uploads/short-url/3HQrSZQ6oOOaf1CJwqsX6upCzBB.f) (5.4 KB)

---

<div class="post-metadata">

**Author:** ![Mihaela\_Parvu](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/mihaela_parvu/32/4005_2.png) [@Mihaela\_Parvu](https://fluka-forum.web.cern.ch/u/Mihaela_Parvu)\
**Post date:** [14 June 2022 09:52 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/2 "2022-06-14T09:52:00Z")

</div>

> [@mahdi](#):
>
> 2-When I run the input file, the results of the two DETECT cards are the same which means the comscw.f is not activated. How can I activate this logic?

Dear @mahdi,

Did you compile the .f file and select it in the run tab? I am asking because when I run your input I can see the difference between the two spectra (see the attached file).

 ![image](https://fluka-forum.web.cern.ch/uploads/default/original/2X/0/03dad42a4128ff45e0abfc3e09943608982734c3.png)  
 ![Comparison](https://fluka-forum.web.cern.ch/uploads/default/original/2X/e/e27be0bc479a9e45714d51d5ee45c09f2cbc81a5.png)

---

<div class="post-metadata">

**Author:** ![mahdi](https://fluka-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mahdi](https://fluka-forum.web.cern.ch/u/mahdi)\
**Post date:** [14 June 2022 10:29 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/3 "2022-06-14T10:29:50Z")

</div>

Dear @Mihaela_Parvu,  
It was exactly what I did not do. Thank you for your comment. It worked while there is some difference between my results and your plot.

 ![Capture](https://fluka-forum.web.cern.ch/uploads/default/original/2X/8/8915703acc99a453b0cc6cd3a8b3e000aaf5dc9b.jpeg)

However, I am still not sure:  
1- if I defined the 7Li correctly in the files.  
2- What is the final unit of these DETECT cards? Because my primary beam is a neutron and now the 4He and 7Li are scored.

3-In other Monte Carlo codes, the efficiency is obtained by simply summing all counts divided per total primary. Is it correct to do so in FLUKA and DETECT cards?

Help from any dear member is really appreciated.

---

<div class="post-metadata">

**Author:** ![Mihaela\_Parvu](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/mihaela_parvu/32/4005_2.png) [@Mihaela\_Parvu](https://fluka-forum.web.cern.ch/u/Mihaela_Parvu)\
**Post date:** [16 June 2022 08:16 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/4 "2022-06-16T08:16:29Z")

</div>

Dear @mahdi,

I modified your comscw.f adding the following lines in order to also check the particle that is scored and it looks ok (maybe somebody else can also check to see if it is correct).

> [@mahdi](#):
>
> 1- if I defined the 7Li correctly in the files.

- 

```
alpha
IF (TITDET(JSCRNG).EQ."He4" .AND. JTRACK.EQ.-6) THEN
LSCZER = .TRUE.

```

- 

```
Heavy ion
ELSE IF(TITDET(JSCRNG).EQ."Li7" .and. JTRACK.EQ.-2 .and. ICHRGE(-2).EQ.3) THEN
LSCZER = .TRUE.
WRITE(70,*) 'daugther is Li-7'
ELSE IF(JTRACK.EQ.-2 .and. ICHRGE(-2).NE.3) THEN
WRITE(70,*) 'daugther', IBARCH(-2), ICHRGE(-2)

```

> [@mahdi](#):
>
> 2- What is the final unit of these DETECT cards? Because my primary beam is a neutron and now the 4He and 7Li are scored.

The output of [DETECT](https://flukafiles.web.cern.ch/manual/chapters/description_input/description_options/detect.html?highlight=detect#detect) is a distribution of energy deposited per event in the region(s) making up the detector.

Regards,  
Mihaela

---

<div class="post-metadata">

**Author:** ![mahdi](https://fluka-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mahdi](https://fluka-forum.web.cern.ch/u/mahdi)\
**Post date:** [17 June 2022 01:26 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/5 "2022-06-17T01:26:38Z")

</div>

Thank you @Mihaela_Parvu,  
could you please upload the modified comscw.f?  
Because I face the error _undefined reference to `icharge\_’_  
during compilation.

Bests,  
Mahdi

---

<div class="post-metadata">

**Author:** ![Mihaela\_Parvu](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/mihaela_parvu/32/4005_2.png) [@Mihaela\_Parvu](https://fluka-forum.web.cern.ch/u/Mihaela_Parvu)\
**Post date:** [17 June 2022 04:54 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/6 "2022-06-17T04:54:43Z")

</div>

> [@mahdi](#):
>
> Because I face the error _undefined reference to `icharge\_’_  
> during compilation.

This is because you need to add

```
  INCLUDE 'paprop.inc'

```

Here is the file.  
[comscw.f](https://fluka-forum.web.cern.ch/uploads/short-url/wTnUhY08vMi1hI8Ddxz8XnVcN9O.f) (5.6 KB)

---

<div class="post-metadata">

**Author:** ![mahdi](https://fluka-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mahdi](https://fluka-forum.web.cern.ch/u/mahdi)\
**Post date:** [17 June 2022 07:19 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/7 "2022-06-17T07:19:03Z")

</div>

Thanks for sharing the file @Mihaela_Parvu.

However, something is weird to me.  
I ran the input file using compiled comscw.f, and without using it (just a normal FLUKA run), I see that the results of 4He in the first case and the results from the second case are exactly similar.  
I assume that the normal FLUKA run includes the deposited energy from the primary beam plus the secondary particles (indicated All in the figure below).

It seems that my comscw.f does not separate 4He contribution so  
4He deposited energy with comscw.f = total deposited energy (without comscw.f)

Here is a plot of the results. That flat line at low energy is also questionable.

 ![resuts](https://fluka-forum.web.cern.ch/uploads/default/original/2X/9/92f99bab9c3caf4ca3c33c617bf50e9597bdda78.png)

Thanks in advance for any help.  
Mahdi

---

<div class="post-metadata">

**Author:** ![ceruttif](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/ceruttif/32/23_2.png) [@ceruttif](https://fluka-forum.web.cern.ch/u/ceruttif)\
**Post date:** [17 June 2022 08:32 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/8 "2022-06-17T08:32:13Z")

</div>

> [@mahdi](#):
>
> That flat line at low energy is also questionable.

This is because you adopt a logarithmic scale for a linear energy binning. Just untick the Log box when you plot in Flair.

With three DETECT cards, labelled ‘He4’, ‘Li7’ and ‘all’, respectively, you will get three different curves. Note that, due to the logic implemented in _comscw_, the one labelled ‘He4’ will actually **exclude** the He4 contribution (LSCZER = .TRUE. means ‘do not score’). The same for the Li7 one, actually excluding the Li7 contribution, and keeping the He4 contribution instead.

Your PART-THR card is wrong and ineffective. Look at the transport thresholds printed in the output file: they all stay at the default value of 100 keV. This is because you apply it from particle -2 (HEAVYION, which by the way cannot be used in PART-THR, since in fact HEAVYION take the same threshold as 4-HELIUM, in energy per nucleon) to particle -4 (TRITON), and such an interval is empty (going from -2 to -4 in step of +1 does not include anything). Replace HEAVYION with 4-HELIUM.

---

<div class="post-metadata">

**Author:** ![mahdi](https://fluka-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mahdi](https://fluka-forum.web.cern.ch/u/mahdi)\
**Post date:** [17 June 2022 09:43 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/9 "2022-06-17T09:43:08Z")

</div>

Dear @ceruttif  
Thank you for your comments I was thinking reverse !

I corrected the plot according to what you mentioned including changing the thresholds.

But what I am confused about is that:  
If I do not use the _comscw_, it means deposited energy from the primary beam as well as secondary particles is scored, is that right? So that deposited energy=energy from the primary beam(neutron)+energy from 4He+energy from 7Li  
If so, why when I run FLUKA without _comscw_, the result is equal to 7Li (using _comscw_)?  
Am I misunderstanding something?

The efficiency then is the integration of counts/all primaries, is that also correct?

 ![resuts](https://fluka-forum.web.cern.ch/uploads/default/original/2X/2/222bd4123d382171a5c875367f8adbd0878f2e4e.png)

Sorry for asking many questions.  
I appreciate your comments.

---

<div class="post-metadata">

**Author:** ![ceruttif](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/ceruttif/32/23_2.png) [@ceruttif](https://fluka-forum.web.cern.ch/u/ceruttif)\
**Post date:** [17 June 2022 16:09 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/10 "2022-06-17T16:09:26Z")

</div>

In reality as in the simulation, there is no energy deposition by the neutron itself in the absence of capture and production of 4He and 7Li, which are the particles ionizing the gas.

> [@mahdi](#):
>
> why when I run FLUKA without _comscw_, the result is equal to 7Li (using _comscw_)?  
> Am I misunderstanding something?

Apparently you are doing something wrong due to some inconsistencies between your input file and the comscw routine, or at plotting level. With [GEM.inp](https://fluka-forum.web.cern.ch/uploads/short-url/o4AKS3CQawxWhg7ibB2u7mj1xWR.inp) and [comscw-rev.f](https://fluka-forum.web.cern.ch/uploads/short-url/d7NKNZH8KddVlyXvevE1xdiw3Fd.f), one gets three different curves, as mentioned above, with the not filtered one (all) matching the sum of the other two (He4 and Li7), due to the fact that for kinematics reasons (momentum conservation) only one of the two fragments reaches the gas, and not both together.

> [@mahdi](#):
>
> The efficiency then is the integration of counts/all primaries, is that also correct?

Resulting counts are already divided by the number of primaries. To get the efficiency, you need to sum them (above the detection threshold).

---

<div class="post-metadata">

**Author:** ![mahdi](https://fluka-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mahdi](https://fluka-forum.web.cern.ch/u/mahdi)\
**Post date:** [18 June 2022 11:14 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/11 "2022-06-18T11:14:14Z")

</div>

Dear @ceruttif ,  
Thank you so much for modifying the comscw and input file.  
Now the results are similar to what I expected.  
I also compared the FLUKA results with the PHITS Monte Carlo code, and now they are much more consistent together.  
Some differences appear at low energies, particularly for heavier ion (7Li). It seems that the interactions at low energies might be more complex than at high energies.  
However, the total efficiency is almost similar: `Eff_FLUKA=12.8% ` and `Eff_PHITS=12.7%` for the detection threshold of 20 keV.  
Here are the compared results:

 ![deposit](https://fluka-forum.web.cern.ch/uploads/default/original/2X/4/4b1f9f5732d251e80bff9fa394276adc50d573dd.png)

Thanks to you all for helping me with this issue.  
Mahdi

---

<div class="post-metadata">

**Author:** ![rversaci](https://fluka-forum.web.cern.ch/letter_avatar_proxy/v4/letter/r/cc9497/32.png) [@rversaci](https://fluka-forum.web.cern.ch/u/rversaci)\
**Post date:** [18 June 2022 15:15 UTC](https://fluka-forum.web.cern.ch/t/calculating-detector-efficiency-using-detect-card/3295/12 "2022-06-18T15:15:13Z")

</div>

Closed on 18 June 2022 15:15 UTC


