Exemple #1
0
def include(includes_set):
    """
    It takes a string or a list of strings and returns a list of 
    FWCore.ParameterSet.parseConfig._ConfigReturn objects.
    In the package directory it creates ASCII files in which the objects are coded. If 
    the files exist already it symply loads them.
    """

    func_id = '[fragments.include]'

    #packagedir=os.environ["CMSSW_BASE"]+"/src/Configuration/PyReleaseValidation/data/"
    packagedir = './'
    #Trasform the includes_set in a list
    if not isinstance(includes_set, list):
        includes_set = [includes_set]

    object_list = []
    for cf_file_name in includes_set:
        pkl_file_name = packagedir + os.path.basename(
            cf_file_name)[:-4] + ".pkl"

        cf_file_fullpath = ""
        # Check the paths of the cffs
        for path in os.environ["CMSSW_SEARCH_PATH"].split(":"):
            cf_file_fullpath = path + "/" + cf_file_name
            if os.path.exists(cf_file_fullpath):
                break

        pkl_file_exists = os.path.exists(pkl_file_name)
        # Check the dates of teh cff and the corresponding pickle
        cff_age = 0
        pkl_age = 0
        if pkl_file_exists:
            cff_age = os.path.getctime(cf_file_fullpath)
            pkl_age = os.path.getctime(pkl_file_name)
            if cff_age > pkl_age:
                print(_yellow(func_id) + " Pickle object older than file ...")

        if not pkl_file_exists or cff_age > pkl_age:
            obj = cms.include(cf_file_name)
            file = open(pkl_file_name, "w")
            pickle.dump(obj, file)
            file.close()
            print(
                _yellow(func_id) + " Pickle object for " + cf_file_fullpath +
                " dumped as " + pkl_file_name + "...")
        # load the pkl files.
        file = open(pkl_file_name, "r")
        object_list.append(pickle.load(file))
        file.close()
        print(
            _yellow(func_id) + " Pickle object for " + cf_file_fullpath +
            " loaded ...")

    return object_list
Exemple #2
0
def include(includes_set):
    """
    It takes a string or a list of strings and returns a list of 
    FWCore.ParameterSet.parseConfig._ConfigReturn objects.
    In the package directory it creates ASCII files in which the objects are coded. If 
    the files exist already it symply loads them.
    """
    
    func_id='[fragments.include]'
        
    #packagedir=os.environ["CMSSW_BASE"]+"/src/Configuration/PyReleaseValidation/data/"
    packagedir='./'
    #Trasform the includes_set in a list
    if not isinstance(includes_set,list):
        includes_set=[includes_set]
    
    object_list=[]    
    for cf_file_name in includes_set:
        pkl_file_name=packagedir+os.path.basename(cf_file_name)[:-4]+".pkl"
        
        cf_file_fullpath=""
        # Check the paths of the cffs
        for path in os.environ["CMSSW_SEARCH_PATH"].split(":"):
            cf_file_fullpath=path+"/"+cf_file_name
            if os.path.exists(cf_file_fullpath):
                break
        
        pkl_file_exists=os.path.exists(pkl_file_name)               
        # Check the dates of teh cff and the corresponding pickle
        cff_age=0
        pkl_age=0
        if pkl_file_exists:
            cff_age=os.path.getctime(cf_file_fullpath)
            pkl_age=os.path.getctime(pkl_file_name)
            if cff_age>pkl_age:
                print _yellow(func_id)+" Pickle object older than file ..."
        
       
        if not pkl_file_exists or cff_age>pkl_age:
          obj=cms.include(cf_file_name)
          file=open(pkl_file_name,"w")
          pickle.dump(obj,file)   
          file.close()
          print _yellow(func_id)+" Pickle object for "+cf_file_fullpath+" dumped as "+pkl_file_name+"..."
        # load the pkl files.                       
        file=open(pkl_file_name,"r")
        object_list.append(pickle.load(file))
        file.close()
        print _yellow(func_id)+" Pickle object for "+cf_file_fullpath+" loaded ..."
    
    return object_list
Exemple #3
0
def pickleParameterSet(parameter_set):
    """

    pickle parameter set

    """

    # load parameter-set
    try:
        process = cms.include(parameter_set)
    except Exception,ex:
        print ''
        print 'ParameterSet: ',parameter_set,'could not be converted to python dictionary, error msg:',str(ex)
        print ''
        sys.exit(1)
Exemple #4
0
def pickleParameterSet(parameter_set):
    """

    pickle parameter set

    """

    # load parameter-set
    try:
        process = cms.include(parameter_set)
    except Exception, ex:
        print ''
        print 'ParameterSet: ', parameter_set, 'could not be converted to python dictionary, error msg:', str(
            ex)
        print ''
        sys.exit(1)
def pickleParameterSet(parameter_set):
    """

    pickle parameter set

    """

    import FWCore.ParameterSet.Config as cms
    import pickle

    # load parameter-set
    try:
        process = cms.include(parameter_set)
    except:
        print ''
        print 'ParameterSet: ',parameter_set,'could not be converted to python dictionary'
        print ''
        sys.exit(1)

    # pickle parameter-set by replacing cfg extension with pkl extension
    file = open(parameter_set.replace('cfg','pkl'),'w')
    pickle.dump(process,file)
def pickleParameterSet(parameter_set):
    """

    pickle parameter set

    """

    import FWCore.ParameterSet.Config as cms
    import pickle

    # load parameter-set
    try:
        process = cms.include(parameter_set)
    except:
        print ''
        print 'ParameterSet: ', parameter_set, 'could not be converted to python dictionary'
        print ''
        sys.exit(1)

    # pickle parameter-set by replacing cfg extension with pkl extension
    file = open(parameter_set.replace('cfg', 'pkl'), 'w')
    pickle.dump(process, file)
Exemple #7
0
    allUsedOutputModules = []
    for module in allEndPathModules:
        if isinstance(module, cms.OutputModule):
            allUsedOutputModules.append(module)
    return allUsedOutputModules



##########################
if __name__ == "__main__":

    if len(sys.argv) < 2:
        print "usage: testSkimConfig <filenames>"

    for scriptName in sys.argv[1:]:      
        print "Checking skim config file", scriptName

        process = cms.include(scriptName)
        #print "+ python parseable"
    
        print "checking", len (process._Process__outputmodules), "output modules"
        for outputModuleName in process._Process__outputmodules:
            print "  ", outputModuleName
            outputModule = getattr(process, outputModuleName)
            checkOutputModuleConfig(outputModule)

        usedOutputs = extractUsedOutputs(process)
        print "Actually used: ", len(usedOutputs)
        for module in usedOutputs:
            print "  ", module.label()
    allUsedOutputModules = []
    for module in allEndPathModules:
        if isinstance(module, cms.OutputModule):
            allUsedOutputModules.append(module)
    return allUsedOutputModules


##########################
if __name__ == "__main__":

    if len(sys.argv) < 2:
        print "usage: testSkimConfig <filenames>"

    for scriptName in sys.argv[1:]:
        print "Checking skim config file", scriptName

        process = cms.include(scriptName)
        #print "+ python parseable"

        print "checking", len(
            process._Process__outputmodules), "output modules"
        for outputModuleName in process._Process__outputmodules:
            print "  ", outputModuleName
            outputModule = getattr(process, outputModuleName)
            checkOutputModuleConfig(outputModule)

        usedOutputs = extractUsedOutputs(process)
        print "Actually used: ", len(usedOutputs)
        for module in usedOutputs:
            print "  ", module.label()
Exemple #9
0
# bring in the cms configuration classes
import FWCore.ParameterSet.Config as cms

process = cms.Process("Dump")
process.extend(cms.include("FWCore/MessageLogger/data/MessageLogger.cfi"))

process.analysis = cms.EDAnalyzer("ditausAnalysis")
# process.analysis.srcLabel = cms.string('source')
# evenctual output file, now hard-coded
# process.analysis.rootfile = cms.untracked(cms.string('miniTree.root'))

# eventual bad runs: uncomment and fill as you want
# bad = [ 1, 2]
bad = []

input_files = cms.vstring()
# loop from i = 1 to i < 100
for i in range(1, 100):
    if i not in bad:
        input_files.append("rfio:/castor/cern.ch/user/d/deguio/HLT/Z_DiElectron_HLT/Z_DiElectron_HLT_%d.root" % i)


process.source = cms.Source("PoolSource", fileNames=cms.untracked(input_files), maxEvents=cms.untracked(cms.int32(-1)))

process.p = cms.Path(process.analysis)


ofile = open("last_config_dump.log", "w")
ofile.write(process.dumpConfig())
ofile.close()