Пример #1
0
    def ImportUFO(self,filename):
        self.logger.info("UFO model folder is detected")

        # UFO mode is forbidden in RECO level
        if self.main.mode==MA5RunningType.RECO:
            self.logger.error("cannot import particles in MA5 reconstructed mode")
            return False
        
        # Other modes : parton and hadron
        self.logger.info("Import all particles defined in the model ...")
        cmd_define = CmdDefine(self.main)
        
        ufo = UFOReader(filename,cmd_define)
        if not ufo.OpenParticle():
            return False
        if not ufo.ReadParticle():
            return False
        if not ufo.CloseParticle():
            return False
        if not ufo.OpenParameter():
            return False
        if not ufo.ReadParameter():
            return False
        if not ufo.CloseParameter():
            return False

        if len(ufo.parts.parts)==0:
            self.logger.warning("UFO model contained no particles")
            return

        # Reseting only particles, kept multiparticles
        self.main.multiparticles.ResetParticles()

        # Use new particles
        ufo.CreateParticle()
Пример #2
0
    def ImportJob(self, filename, myinterpreter):
        logging.info("SampleAnalyzer job folder is detected")
        logging.info("Restore MadAnalysis configuration used for this job ...")

        # Ask question
        if not self.main.forced:
            logging.warning(
                "You are going to reinitialize MadAnalysis 5. The current configuration will be lost."
            )
            logging.warning("Are you sure to do that ? (Y/N)")
            allowed_answers = ['n', 'no', 'y', 'yes']
            answer = ""
            while answer not in allowed_answers:
                answer = raw_input("Answer : ")
                answer = answer.lower()
            if answer == "no" or answer == "n":
                return False

        self.main.datasets.Reset()

        # Reset selection
        self.main.selection.Reset()

        # Reset main
        self.main.ResetParameters()

        # Reset multiparticles
        self.main.multiparticles.Reset()

        # Opening a CmdDefine
        cmd_define = CmdDefine(self.main)

        # Loading particles
        input = ParticleReader(self.main.ma5dir, cmd_define, self.main.mode)
        input.Load()
        input = MultiparticleReader(self.main.ma5dir, cmd_define,
                                    self.main.mode)
        input.Load()

        # Reset history
        myinterpreter.history = []

        # Load script
        myinterpreter.load(filename + '/history.ma5')

        # Saving job name as global variable
        self.main.lastjob_name = filename
        self.main.lastjob_status = False

        # Extract info from ROOT file
        if not self.extract(filename):
            return

        # Initialize selection for generating report
        self.main.selection.RefreshStat()

        # Status = GOOD
        self.main.lastjob_status = True
Пример #3
0
    def ResetMultiparticles(self):

        # Reset multiparticles
        self.main.multiparticles.Reset()

        # Opening a CmdDefine
        cmd_define = CmdDefine(self.main)

        # Loading particles
        input = ParticleReader(self.main.archi_info.ma5dir,cmd_define,self.main.mode)
        input.Load()
        input = MultiparticleReader(self.main.archi_info.ma5dir,cmd_define,self.main.mode,self.main.forced)
        input.Load()
Пример #4
0
    def __init__(self, main, *arg, **opt):

        # Calling constructor from InterpreterBase
        InterpreterBase.__init__(self, *arg, **opt)

        # Getting back main
        self.main = main

        # Getting back all commands
        self.cmd_set = CmdSet(main)
        self.cmd_define = CmdDefine(main)
        self.cmd_display = CmdDisplay(main)
        self.cmd_display_datasets = CmdDisplayDatasets(main)
        self.cmd_display_particles = CmdDisplayParticles(main)
        self.cmd_display_multiparticles = CmdDisplayMultiparticles(main)
        self.cmd_import = CmdImport(main)
        self.cmd_remove = CmdRemove(main)
        self.cmd_swap = CmdSwap(main)
        self.cmd_plot = CmdPlot(main)
        self.cmd_reject = CmdCut(main, CutType.REJECT)
        self.cmd_select = CmdCut(main, CutType.SELECT)
        self.cmd_preview = CmdPreview(main)
        self.cmd_reset = CmdReset(main)
        self.cmd_open = CmdOpen(main)
        self.cmd_submit = CmdSubmit(main)
        self.cmd_resubmit = CmdSubmit(main, resubmit=True)
        self.cmd_generate_latex         = CmdGenerate(main,\
                                                      ReportFormatType.LATEX)
        self.cmd_generate_pdflatex      = CmdGenerate(main,\
                                                      ReportFormatType.PDFLATEX)
        self.cmd_generate_html          = CmdGenerate(main,\
                                                      ReportFormatType.HTML)
        self.cmd_install = CmdInstall(main)

        # Initializing multiparticle
        self.InitializeParticle()
        self.InitializeMultiparticle()

        # Importing history
        self.history_file = os.path.normpath(self.main.ma5dir + '/.ma5history')
        try:
            readline.read_history_file(self.history_file)
        except:
            pass
Пример #5
0
    def ImportJob(self, filename, myinterpreter, history):
        self.logger.info("SampleAnalyzer job folder is detected")
        self.logger.info(
            "Restore MadAnalysis configuration used for this job ...")

        # Ask question
        if not self.main.forced:
            self.logger.warning(
                "You are going to reinitialize MadAnalysis 5. The current configuration will be lost."
            )
            self.logger.warning("Are you sure to do that ? (Y/N)")
            allowed_answers = ['n', 'no', 'y', 'yes']
            answer = ""
            while answer not in allowed_answers:
                answer = raw_input("Answer: ")
                answer = answer.lower()
            if answer == "no" or answer == "n":
                return False

        self.main.datasets.Reset()

        # Reset selection
        self.main.selection.Reset()

        # Reset main
        self.main.ResetParameters()

        # Reset multiparticles
        self.main.multiparticles.Reset()

        # Opening a CmdDefine
        cmd_define = CmdDefine(self.main)

        # Loading particles
        input = ParticleReader(self.main.archi_info.ma5dir, cmd_define,
                               self.main.mode)
        input.Load()
        input = MultiparticleReader(self.main.archi_info.ma5dir, cmd_define,
                                    self.main.mode, self.main.forced)
        input.Load()

        # Reset history
        myinterpreter.history = []

        # Load script
        myinterpreter.load(filename + '/history.ma5')

        # Saving job name as global variable
        self.main.lastjob_name = filename
        self.main.lastjob_status = False

        # Extract info from ROOT file
        layout = Layout(self.main)
        if not self.extract(filename, layout):
            return

        # Initialize selection for generating report
        self.main.selection.RefreshStat()

        # Status = GOOD
        self.main.lastjob_status = True

        # Computing
        layout.Initialize()

        # Cleaning the directories
        if not FolderWriter.RemoveDirectory(self.main.lastjob_name + '/HTML',
                                            False):
            return
        if self.main.session_info.has_pdflatex:
            if not FolderWriter.RemoveDirectory(
                    self.main.lastjob_name + '/PDF', False):
                return
        if self.main.session_info.has_latex:
            if not FolderWriter.RemoveDirectory(
                    self.main.lastjob_name + '/DVI', False):
                return

        # Creating the reports
        self.CreateReports([self.main.lastjob_name], history, layout)
Пример #6
0
    def do_main(self, args):

        # Looking for '='
        if args[1] != '=':
            logging.getLogger('MA5').error(
                "syntax error with the command 'set'.")
            self.help()
            return

        # Looking for one dot in the name
        object = args[0]
        #        object = object.lower()
        object = object.replace('fastsim.bjet_id.', 'fastsim.bjet_idXXX')
        object = object.replace('fastsim.tau_id.', 'fastsim.tau_idXXX')
        objs = object.split('.')
        for i in range(len(objs)):
            objs[i] = objs[i].replace('XXX', '.')

        if len(objs) == 2 and objs[0].lower() == 'main' and objs[1].lower(
        ) == 'recast':
            user_info = UserInfo()
            user_info.ReadUserOptions(
                self.main.archi_info.ma5dir +
                '/madanalysis/input/installation_options.dat')
            checker = ConfigChecker(self.main.archi_info, user_info,
                                    self.main.session_info, self.main.script,
                                    False)
            hasdelphes = checker.checkDelphes(True)
            hasMA5tune = checker.checkDelphesMA5tune(True)
            hasPAD = checker.checkPAD()
            hasPADtune = checker.checkPADForMA5tune()
            self.main.recasting.user_SetParameter(
                "status", args[2], self.main.mode,
                self.main.archi_info.has_root, hasdelphes, hasMA5tune,
                self.main.datasets, hasPAD, hasPADtune)
            if args[2] == 'on' and self.main.fastsim.package != 'none':
                logging.getLogger('MA5').warning(
                    "Fastsim package switched off and internally handled")
                self.main.fastsim.package = "none"
        elif len(objs) == 2 and objs[0].lower() == 'main':
            if objs[1] == 'mode' and args[2] == 'parton':
                self.main.mode = MA5RunningType.PARTON
                self.main.ResetParameters()
                self.main.AutoSetGraphicalRenderer()
                self.main.InitObservables(self.main.mode)
                lvl = logging.getLogger('MA5').getEffectiveLevel()
                logging.getLogger('MA5').setLevel(100)
                self.main.multiparticles.Reset()
                cmd_define = CmdDefine(self.main)
                input = ParticleReader(self.main.archi_info.ma5dir, cmd_define,
                                       self.main.mode, self.main.forced)
                input.Load()
                input = MultiparticleReader(self.main.archi_info.ma5dir,
                                            cmd_define, self.main.mode,
                                            self.main.forced)
                input.Load()
                logging.getLogger('MA5').setLevel(lvl)
            else:
                self.main.user_SetParameter(objs[1], args[2])
        elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower(
        ) == 'isolation':
            self.main.isolation.user_SetParameter(objs[2], args[2])
        elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower(
        ) == 'fom':
            self.main.fom.user_SetParameter(objs[2], args[2])
        elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower(
        ) == 'merging':
            self.main.merging.user_SetParameter(
                objs[2], args[2], self.main.mode,
                self.main.archi_info.has_fastjet)
        elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower(
        ) == 'fastsim':
            user_info = UserInfo()
            user_info.ReadUserOptions(
                self.main.archi_info.ma5dir +
                '/madanalysis/input/installation_options.dat')
            checker = ConfigChecker(self.main.archi_info, user_info,
                                    self.main.session_info, self.main.script,
                                    False)
            hasdelphes = checker.checkDelphes(True)
            hasMA5tune = checker.checkDelphesMA5tune(True)
            self.main.fastsim.user_SetParameter(
                objs[2], args[2], self.main.datasets, self.main.mode,
                self.main.archi_info.has_fastjet, hasdelphes, hasMA5tune)
            if objs[2] == 'package' and args[2] in [
                    'fastjet', 'delphes', 'delphesMA5tune'
            ] and self.main.recasting.status == 'on':
                logging.getLogger('MA5').warning("Recasting mode switched off")
                self.main.recasting.status = "off"
        elif len(objs) == 3 and objs[0].lower() == 'main' and objs[1].lower(
        ) == 'recast':
            user_info = UserInfo()
            user_info.ReadUserOptions(
                self.main.archi_info.ma5dir +
                '/madanalysis/input/installation_options.dat')
            checker = ConfigChecker(self.main.archi_info, user_info,
                                    self.main.session_info, self.main.script,
                                    False)
            hasdelphes = checker.checkDelphes(True)
            hasMA5tune = checker.checkDelphesMA5tune(True)
            hasPAD = checker.checkPAD()
            hasPADtune = checker.checkPADForMA5tune()
            self.main.recasting.user_SetParameter(
                objs[2], args[2], self.main.mode,
                self.main.archi_info.has_root, hasdelphes, hasMA5tune,
                self.main.datasets, hasPAD, hasPADtune)
        else:
            logging.getLogger('MA5').error(
                "syntax error with the command 'set'.")
            self.help()
            return