Ejemplo n.º 1
0
    def CheckOptionalProcessingPackages(self):
        # Optional packages
        self.logger.info(
            "Checking optional packages devoted to data processing:")
        checker2 = ConfigChecker(self.archi_info, self.user_info,
                                 self.session_info, self.script, self.debug)

        #        self.archi_info.has_zlib              = checker2.checkZLIB()
        if not self.checker.Execute('zlib'):
            return False
        if not self.checker.Execute('fastjet'):
            return False
        if not self.checker.Execute('root'):
            return False
        self.archi_info.has_delphes = checker2.checkDelphes()
        self.archi_info.has_delphesMA5tune = checker2.checkDelphesMA5tune()
        return True
Ejemplo n.º 2
0
    def Activate(self):
        # output =  1: activation successfull.
        # output =  0: nothing is done.
        # output = -1: error
        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)
        if hasdelphes:
            # Paths
            delpath = os.path.normpath(
                self.main.archi_info.delphes_lib_paths[0])
            deldeac = delpath.replace("DEACT_", "")
            self.main.archi_info.delphes_lib = self.main.archi_info.delphes_lib.replace(
                "DEACT_", "")
            self.main.archi_info.delphes_original_libs =\
               [x.replace("DEACT_","") for x in self.main.archi_info.delphes_original_libs]
            self.main.archi_info.delphes_inc_paths =\
                [ x.replace("DEACT_","") for x in self.main.archi_info.delphes_inc_paths ]
            if len(self.main.archi_info.delphes_inc_paths) > 2:
                del self.main.archi_info.delphes_inc_paths[-1]
                del self.main.archi_info.delphes_inc_paths[-1]
            self.main.archi_info.delphes_lib_paths =\
                list(set([ x.replace("DEACT_","") for x in self.main.archi_info.delphes_lib_paths ]))
            # do we have to activate delphes?
            if not 'DEACT' in delpath:
                return 0
            self.logger.warning("Delphes is deactivated. Activating it.")

            # naming
            shutil.move(delpath, deldeac)

            # Compiler setup
            compiler = LibraryWriter('lib', self.main)
            ncores = compiler.get_ncores2()

            from madanalysis.build.setup_writer import SetupWriter
            SetupWriter.WriteSetupFile(
                True, self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/',
                self.main.archi_info)
            SetupWriter.WriteSetupFile(
                False, self.main.archi_info.ma5dir + '/tools/SampleAnalyzer/',
                self.main.archi_info)

            #             if ncores>1:
            #                 strcores='-j'+str(ncores)
            ToBuild = ['delphes', 'root', 'process']

            # Makefile
            self.main.archi_info.has_delphes = True
            self.main.archi_info.delphes_priority = True
            dpath = os.path.normpath(
                os.path.join(self.main.archi_info.ma5dir, 'tools', 'delphes'))
            mylib = os.path.normpath(os.path.join(dpath, 'libDelphes.so'))
            self.main.archi_info.libraries['Delphes'] = mylib + ":" + str(
                os.stat(mylib).st_mtime)
            self.main.archi_info.toLDPATH1 = [
                x for x in self.main.archi_info.toLDPATH1 if not 'MA5tune' in x
            ]
            self.main.archi_info.toLDPATH1.append(dpath)

            for mypackage in ToBuild:
                if not compiler.WriteMakefileForInterfaces(mypackage):
                    self.logger.error("library building aborted.")
                    return -1

            # Cleaning
            for mypackage in ToBuild:
                myfolder = 'Process'
                if mypackage != 'process':
                    myfolder = 'Interfaces'
                if not compiler.MrProper(
                        mypackage, self.main.archi_info.ma5dir +
                        '/tools/SampleAnalyzer/' + myfolder):
                    self.logger.error("Library '" + mypackage +
                                      "' precleaning aborted.")
                    return -1

            # Compiling
            for mypackage in ToBuild:
                myfolder = 'Process'
                if mypackage != 'process':
                    myfolder = 'Interfaces'
                if not compiler.Compile(
                        ncores, mypackage, self.main.archi_info.ma5dir +
                        '/tools/SampleAnalyzer/' + myfolder):
                    self.logger.error("Library '" + mypackage +
                                      "' compilation aborted.")
                    return -1

            # Linking
            for mypackage in ToBuild:
                myfolder = 'Process'
                if mypackage != 'process':
                    myfolder = 'Interfaces'
                if not compiler.Link(
                        mypackage, self.main.archi_info.ma5dir +
                        '/tools/SampleAnalyzer/' + myfolder):
                    self.logger.error("Library '" + mypackage +
                                      "' linking aborted.")
                    return -1

            # Checking
            for mypackage in ToBuild:
                if mypackage == 'process':
                    myfolder = 'Lib/libprocess_for_ma5.so'
                elif mypackage == 'root':
                    myfolder = 'Lib/libroot_for_ma5.so'
                else:
                    myfolder = 'Lib/libdelphes_for_ma5.so'
                if not os.path.isfile(self.main.archi_info.ma5dir +
                                      '/tools/SampleAnalyzer/' + myfolder):
                    self.logger.error("Library '" + mypackage +
                                      "' checking aborted.")
                    return -1

            # Cleaning
            for mypackage in ToBuild:
                myfolder = 'Process'
                if mypackage != 'process':
                    myfolder = 'Interfaces'
                if not compiler.Clean(
                        mypackage, self.main.archi_info.ma5dir +
                        '/tools/SampleAnalyzer/' + myfolder):
                    self.logger.error("Library '" + mypackage +
                                      "' cleaning aborted.")
                    return -1

            # Paths
            lev = self.logger.getEffectiveLevel()
            self.logger.setLevel(100)
            checkup = CheckUp(self.main.archi_info, self.main.session_info,
                              False, self.main.script)
            if not checkup.SetFolder():
                self.logger.error("Problem with the path updates.")
                return -1

            if not self.main.archi_info.save(self.main.archi_info.ma5dir +
                                             '/tools/architecture.ma5'):
                return -1
            if not self.main.CheckConfig():
                return -1
            self.logger.setLevel(lev)

        return 1
Ejemplo n.º 3
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