main.fom.formula : can I edit this

Asked by SUBHASISH BEHERA

Dear Benj,

Greetings! Trust all is well.

Question based on "Normal mode": I was trying to add a new formula to the "main.fom.formula".
So I did edit these files:
1- "madanalysis/layout/fom_calculation.py "
2- "madanalysis/configuration/fom_configuration.py"

where I was trying to add a formula described in eq-6.5, 6.6 of (your paper) "https://arxiv.org/pdf/2011.02547.pdf".
Can I calculate the "z" from MadAnalysis5 in normal mode?

Question information

Language:
English Edit question
Status:
Solved
For:
MadAnalysis 5 Edit question
Assignee:
No assignee Edit question
Solved by:
Jack Y. Araz
Solved:
Last query:
Last reply:
Revision history for this message
Jack Y. Araz (jackaraz) said :
#1

Hi

Currently, it's not possible to add new FoM functions through normal mode but you can always include your specific configuration by modifying `~/madanalysis5/madanalysis/configuration/fom_configuration.py`.

Cheers
Jack

Revision history for this message
SUBHASISH BEHERA (subhparasara) said :
#2

Dear Jack,

Thank you for your reply.
So, I was trying to edit "main.fom.formula = 5" in the "madanalysis/configuration/fom_configuration.py" and trying to set "set main.fom.formula = 5" and "set main.fom.x = 0.1" in the script in normal mode. Then I got the following output/error:

=================================
MA5: *******************************************************
MA5: Checking SampleAnalyzer output...
MA5: Extracting data from the output files...
MA5: Preparing data for the reports ...
MA5: Generating all plots ...
MA5: Generating the HMTL report ...
Traceback (most recent call last):
  File "./bin/ma5", line 70, in <module>
    madanalysis.core.launcher.LaunchMA5(version, date, ma5dir)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/core/launcher.py", line 428, in LaunchMA5
    repeat = MainSession(mode,arglist,ma5dir,version,date)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/core/launcher.py", line 320, in MainSession
    interpreter.load()
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/interpreter/interpreter_base.py", line 72, in load
    stop = self.onecmd(line)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/interpreter/interpreter.py", line 293, in do_submit
    self.cmd_submit.do(self.split_arg(line),self.history)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/interpreter/cmd_submit.py", line 63, in do
    return self.do_submit(args,history)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/interpreter/cmd_submit.py", line 216, in do_submit
    self.CreateReports(args,history,layout)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/interpreter/cmd_submit.py", line 277, in CreateReports
    layout.GenerateReport(history,htmlpath,ReportFormatType.HTML)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/layout/layout.py", line 1268, in GenerateReport
    self.WriteFinalTable(report,cutinfo)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/layout/layout.py", line 557, in WriteFinalTable
    self.cutflow.signal.Ntotal.error)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/layout/cutflow.py", line 65, in calculateBSratio
    return self.fom.Compute(S,eS,B,eB)
  File "/Users/subhparasara/RESEARCH/PACKAGES_USED/MADANALYSIS5/MA_v18/madanalysis/layout/fom_calculation.py", line 60, in Compute
    value.mean = float(S/abs(S)*sqrt( 2*[ (S+B)*log( (S+B)*(B+(self.x)**2)/(B**2+(S+B)*(self.x)**2) ) - B**2/(self.x)**2 * log( 1 + (self.x)**2*S/B/(B+(self.x)**2) ) ]))
TypeError: a float is required

=================================

Is this the error due to my input or something wrong is happening here ?

Thanks,
Subhasish

Revision history for this message
Jack Y. Araz (jackaraz) said :
#3

Hi Subhasish

You have a bracket in the equation "[ ... ]" in python this means a list, it can not be converted to float.

cheers
jack

Revision history for this message
SUBHASISH BEHERA (subhparasara) said :
#4

Dear Jack,
That was really silly from my side.
Many thanks for identifying the issue.

In addition, can I add this formula and give a tag "7" instead of the oritinal tag "5"?
If that is the case, can I give the x value as we did for "5" WITHOUT ANY FURTHER EDIT IN THE FILES?

Thanks,
Subhasish

Revision history for this message
SUBHASISH BEHERA (subhparasara) said :
#5

Dear Jack,

In addition, I did able to add "7" as my user input formula but unable to calculate the error in it.
Will this error be useful and how can I calculate the error, in general? <- you can give some idea by considering the following for tag "5":

Formula:

            elif self.formula==5:
                value.mean = S/sqrt(S+B+(self.x*B)**2)

Error:

            elif self.formula==5:
                value.error = 1./(2*pow(S+B+self.x*B**2,3./2.))*\
                             sqrt((S+2*B+2*self.x*B**2)**2*ES**2+S**2*(2*self.x*B+1)**2*EB**2)

Thanks,
Subhasish

Revision history for this message
Jack Y. Araz (jackaraz) said :
#6

Hi Subhasish

If you want to add a new formulae as 7 you also need to extend the list in `~/madanalysis5/madanalysis/configuration/fom_configuration.py` :

```
    userVariables = { "formula" : ['1','2','3','4','5','6','7'] }

    # 1: S/B
    # 2: S/sqrt(B)
    # 3: S/(S+B)
    # 4: S/sqrt(S+B)
    # 5: S/sqrt(S+B+(xB)**2)
    # 6: sqrt(2)*sqrt((S+B)log(1+S/B)-S)
    # 7: my new fom

    allformula = [ 'S/B', 'S/sqrt(B)', 'S/(S+B)', 'S/sqrt(S+B)', 'S/sqrt(S+B+(xB)**2)',\
                   'sqrt(2)*sqrt((S+B)log(1+S/B)-S)', 'my new fom']
```

all FoM formulae are controlled from there hence if these won't match with the number of FoM that you provide it won't work. After that, you can use it as you do with other formulae. You can simply add your error and use x as done in the other equations.

cheers
jack

Revision history for this message
SUBHASISH BEHERA (subhparasara) said :
#7

Dear Jack,

Many thanks for the detailed answer.
My final question in the same thread would be as follow:

Like in case of tag "5" for the
Formula:
            elif self.formula==5:
                value.mean = S/sqrt(S+B+(self.x*B)**2)

Error calculated was :

            elif self.formula==5:
                value.error = 1./(2*pow(S+B+self.x*B**2,3./2.))*\
                             sqrt((S+2*B+2*self.x*B**2)**2*ES**2+S**2*(2*self.x*B+1)**2*EB**2)

** So, can you give some references about the error calculations as done above?

Thanks,
Subhasish

Revision history for this message
Best Jack Y. Araz (jackaraz) said :
#8

Hi Subhasish

Its standard poisson based hypothesis test I’m sure you can find ton of resources through google.


Jack Y. Araz

> On Mar 3, 2021, at 10:55 AM, SUBHASISH BEHERA <email address hidden> wrote:
>
> [EXTERNAL EMAIL]
>
> Question #695789 on MadAnalysis 5 changed:
> https://answers.launchpad.net/madanalysis5/+question/695789
>
> Status: Answered => Open
>
> SUBHASISH BEHERA is still having a problem:
> Dear Jack,
>
> Many thanks for the detailed answer.
> My final question in the same thread would be as follow:
>
> Like in case of tag "5" for the
> Formula:
> elif self.formula==5:
> value.mean = S/sqrt(S+B+(self.x*B)**2)
>
> Error calculated was :
>
> elif self.formula==5:
> value.error = 1./(2*pow(S+B+self.x*B**2,3./2.))*\
> sqrt((S+2*B+2*self.x*B**2)**2*ES**2+S**2*(2*self.x*B+1)**2*EB**2)
>
> ** So, can you give some references about the error calculations as done
> above?
>
>
> Thanks,
> Subhasish
>
> --
> You received this question notification because you are an answer
> contact for MadAnalysis 5.

Revision history for this message
SUBHASISH BEHERA (subhparasara) said :
#9

Dear Jack,

That is fine. Thanks for everything. Have a good day.

Revision history for this message
SUBHASISH BEHERA (subhparasara) said :
#10

Thanks Jack Y. Araz, that solved my question.