Modifying user.cpp

Asked by Amin Aboubrahim on 2017-12-18

Hi Benjamin,

I am using MA5 in reco mode to read SM and signal ROOT samples and then apply cuts and plot histograms. Each run takes around 6 hours. I am wondering if I can modify user.cpp each time I change my cuts and avoid reading the samples all over again.
So my questions:
1) Is it possible to modify user.cpp to change cuts? If yes, how to rerun user.cpp and get the output again?
2) Can I apply MT2 in user.cpp?

Thank you very much,
Amin

Question information

Language:
English Edit question
Status:
Solved
For:
MadAnalysis 5 Edit question
Assignee:
No assignee Edit question
Solved by:
Benjamin Fuks
Solved:
2017-12-21
Last query:
2017-12-21
Last reply:
2017-12-21
Benjamin Fuks (fuks) said : #1

HI Amin,

> 1) Is it possible to modify user.cpp to change cuts? If yes, how to rerun user.cpp and get the output again?
Yes. Please follow the instructions for the expert mode of the program (see 1405.3982 and 1407.3278).

> 2) Can I apply MT2 in user.cpp?
Yes. Same references as above,

Cheers,

Benjamin

Amin Aboubrahim (amin83) said : #2

Hi Benjamin,

Thank you for providing the references. I read through but there is no explanation on how to re-run user.cpp after doing some changes to it. Are there other tutorials available?

Thank you,
Amin

Benjamin Fuks (fuks) said : #3

Hi Amin,

Well, you make the code and execute it (please have a look to the original manual too).

Cheers,

Benj

> On 18 Dec 2017, at 19:52 , Amin Aboubrahim <email address hidden> wrote:
>
> Question #661927 on MadAnalysis 5 changed:
> https://answers.launchpad.net/madanalysis5/+question/661927
>
> Status: Answered => Open
>
> Amin Aboubrahim is still having a problem:
> Hi Benjamin,
>
> Thank you for providing the references. I read through but there is no
> explanation on how to re-run user.cpp after doing some changes to it.
> Are there other tutorials available?
>
> Thank you,
> Amin
>
> --
> You received this question notification because you are an answer
> contact for MadAnalysis 5.

Amin Aboubrahim (amin83) said : #4

Hi Benjamin,

I am looking at the manual 1206.1599 where it explains how to re-run a previously created analysis after changing selection cuts.
It asks to "import <dirname>" then launch "resubmit". Once I import the analysis directory it gives this error:

Traceback (most recent call last):
  File "./ma5", line 70, in <module>
    madanalysis.core.launcher.LaunchMA5(version, date, ma5dir)
  File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/core/launcher.py", line 394, in LaunchMA5
    repeat = MainSession(mode,arglist,ma5dir,version,date)
  File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/core/launcher.py", line 299, in MainSession
    interpreter.cmdloop()
  File "/usr/lib/python2.7/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/interpreter/interpreter.py", line 192, in do_import
    self.cmd_import.do(self.split_arg(line),self,self.history)
  File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/interpreter/cmd_import.py", line 79, in do
    self.ImportJob(filename,myinterpreter,history)
  File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/interpreter/cmd_import.py", line 173, in ImportJob
    myinterpreter.load(filename+'/history.ma5')
TypeError: load() takes exactly 1 argument (2 given)

What's the reason for this?
Also, the manual says that a ROOT file is created for the analysis so it can be accessed later. I don't see any ROOT file in the directory. Am I looking at a dated manual?

Thanks a lot,
Amin

Benjamin Fuks (fuks) said : #5

Hi Amit,

You cannot import a dirname at the moment. This part of the manual is outdated, and we are actually planning to reallow for this method, soon in the future.

Regards,

Benjamin

> On 20 Dec 2017, at 04:47 , Amin Aboubrahim <email address hidden> wrote:
>
> Question #661927 on MadAnalysis 5 changed:
> https://answers.launchpad.net/madanalysis5/+question/661927
>
> Status: Answered => Open
>
> Amin Aboubrahim is still having a problem:
> Hi Benjamin,
>
> I am looking at the manual 1206.1599 where it explains how to re-run a previously created analysis after changing selection cuts.
> It asks to "import <dirname>" then launch "resubmit". Once I import the analysis directory it gives this error:
>
> Traceback (most recent call last):
> File "./ma5", line 70, in <module>
> madanalysis.core.launcher.LaunchMA5(version, date, ma5dir)
> File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/core/launcher.py", line 394, in LaunchMA5
> repeat = MainSession(mode,arglist,ma5dir,version,date)
> File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/core/launcher.py", line 299, in MainSession
> interpreter.cmdloop()
> File "/usr/lib/python2.7/cmd.py", line 142, in cmdloop
> stop = self.onecmd(line)
> File "/usr/lib/python2.7/cmd.py", line 221, in onecmd
> return func(arg)
> File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/interpreter/interpreter.py", line 192, in do_import
> self.cmd_import.do(self.split_arg(line),self,self.history)
> File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/interpreter/cmd_import.py", line 79, in do
> self.ImportJob(filename,myinterpreter,history)
> File "/home/amin/Documents/MG5_aMC_v2_6_0/HEPTools/madanalysis5/madanalysis5/madanalysis/interpreter/cmd_import.py", line 173, in ImportJob
> myinterpreter.load(filename+'/history.ma5')
> TypeError: load() takes exactly 1 argument (2 given)
>
> What's the reason for this?
> Also, the manual says that a ROOT file is created for the analysis so it can be accessed later. I don't see any ROOT file in the directory. Am I looking at a dated manual?
>
> Thanks a lot,
> Amin
>
> --
> You received this question notification because you are an answer
> contact for MadAnalysis 5.

Amin Aboubrahim (amin83) said : #6

Hi Benjamin,

Sorry for pressing the issue further but since importing dirname and resubmit is no longer supported then I really don't know (and can't find) how to rerun analysis after doing some changes. All what the manuals explain is how to start an analysis in expert mode and then run it with SAMPLEANALYZER using MadAnalysis5job. However, in my situation, I already have an analysis done in the non-expert mode and all I want is to rerun after doing some changes. The old manual explains this situation using import and resubmit but apparently this is no longer possible.

Thanks again,
Amin

Best Benjamin Fuks (fuks) said : #7

Hi Amin,

1. You change user.cpp
2. You go into Build, and then source the file setup.xxx where xxx is chosen according to your system
3. you type make
4. you execute Madanalysis5Job with the appropriate input file.
5. You can browse the output and check the new results.

Cheers,

Benjamin

PS: resubmit is supported…. only the import of a directory is not.

> On 20 Dec 2017, at 18:08 , Amin Aboubrahim <email address hidden> wrote:
>
> Question #661927 on MadAnalysis 5 changed:
> https://answers.launchpad.net/madanalysis5/+question/661927
>
> Status: Answered => Open
>
> Amin Aboubrahim is still having a problem:
> Hi Benjamin,
>
> Sorry for pressing the issue further but since importing dirname and
> resubmit is no longer supported then I really don't know (and can't
> find) how to rerun analysis after doing some changes. All what the
> manuals explain is how to start an analysis in expert mode and then run
> it with SAMPLEANALYZER using MadAnalysis5job. However, in my situation,
> I already have an analysis done in the non-expert mode and all I want is
> to rerun after doing some changes. The old manual explains this
> situation using import and resubmit but apparently this is no longer
> possible.
>
> Thanks again,
> Amin
>
> --
> You received this question notification because you are an answer
> contact for MadAnalysis 5.

Amin Aboubrahim (amin83) said : #8

Thank you Benjamin.
I have read these steps in the manual but I thought this is not what I was looking for since step 4 requires Madanalysis5Job to read the input file containing the paths to the ROOT files. My thoughts were that one can modify user.cpp and rerun MA5 without the need to read again all the ROOT files but it seems I have misunderstood. When running Madanalysis5Job <inputfile>, it started reading all the ROOT files. It seems that when run, MA5 only stores information from ROOT files temporarily.
I have used resubmit before but as long as MA5 prompt is still open after the initial run is done.

All the best,
Amin

Benjamin Fuks (fuks) said : #9

Hi Amin,

> When running Madanalysis5Job <inputfile>, it started reading all the ROOT files. It seems that when run, MA5 only stores information from ROOT files temporarily.
No, everything is stored. There is an Output folder at the same level as the Build folder. Everything is in there.

> I have used resubmit before but as long as MA5 prompt is still open after the initial run is done.
Yep, this is how it should be used

Cheers,

Benjamin

Amin Aboubrahim (amin83) said : #10

Hi Benjamin,

> No, everything is stored. There is an Output folder at the same level as the Build folder. Everything is in there.
Yes, I have seen this folder. If all details of the ROOT samples are there then why does running Madanalysis5Job result in the ROOT files being read all over again. In other words, why can't MA5 use the content of this folder instead of reading the samples all over again? (Of course I mean when you exit MA5 prompt and you no longer can use resubmit).

Best,
Amin

Benjamin Fuks (fuks) said : #11

Hi Amin,

> Yes, I have seen this folder. If all details of the ROOT samples are there then why does running Madanalysis5Job result in the ROOT files being read all over again. In other words, why can't MA5 use the content of this folder instead of reading the samples all over again? (Of course I mean when you exit MA5 prompt and you no longer can use resubmit).

If you change the programn, you need to re-execute it no?

Cheers,

B>

Amin Aboubrahim (amin83) said : #12

Hi Benjamin,

Well that was one of my first questions in this thread:
> I am wondering if I can modify user.cpp each time I change my cuts and avoid reading the samples all over again.

But maybe I didn't make it clear. In all cases, I guess I can make use of the resubmit to save time.

Thank you again.
Amin

Amin Aboubrahim (amin83) said : #13

Thanks Benjamin Fuks, that solved my question.