00001 import os
00002 import sys
00003 try:
00004 ReleaseBase = os.path.join(os.environ['CMSSW_BASE'], "src")
00005 ReleaseVersion = os.environ['CMSSW_VERSION']
00006 except KeyError:
00007 print "CMSSW enviroment not set, please run cmsenv!"
00008 sys.exit()
00009
00010 import FWCore.ParameterSet.Config as cms
00011 import FWCore.ParameterSet.VarParsing as VarParsing
00012
00013
00014 options = VarParsing.VarParsing ()
00015
00016 allowedOptions = {}
00017
00018 options.register( 'maxEvents',
00019 -1,
00020 VarParsing.VarParsing.multiplicity.singleton,
00021 VarParsing.VarParsing.varType.int,
00022 "Specify events to run."
00023 )
00024
00025 options.register( 'eventType',
00026 "ZTT",
00027 VarParsing.VarParsing.multiplicity.singleton,
00028 VarParsing.VarParsing.varType.string,
00029
00030 "Specify the type of events to validate. (and generate, if using fast or fullsim)\
00031 \n\t\tOptions:\
00032 \n\t\t\tZTT\
00033 \n\t\t\tQCD\
00034 \n\t\t\tZEE\
00035 \n\t\t\tZMM\n"
00036 )
00037
00038 allowedOptions['eventType'] = [ 'ZTT', 'QCD', 'ZEE', 'ZMM' ]
00039
00040 options.register( 'label',
00041 "none",
00042 VarParsing.VarParsing.multiplicity.singleton,
00043 VarParsing.VarParsing.varType.string,
00044 "Validation output files will be stored in folder Validation_<label>. The root file will also use this label.\n"
00045 )
00046
00047 options.register( 'dataSource',
00048 'recoFiles',
00049 VarParsing.VarParsing.multiplicity.singleton,
00050 VarParsing.VarParsing.varType.string,
00051 "Specify where the data should come from. \n\t\tOptions: \
00052 \n\t\t\trecoFiles:\t\t\tGet data from [sourceFile] (must have RECO)\
00053 \n\t\t\trecoFiles+PFTau:\t\tGet reco data as above, and rerun PFTau with current tags \
00054 \n\t\t\trecoFiles+PFTau+CaloTau:\t\tRun CaloTau too \
00055 \n\t\t\tdigiFiles:\t\t\tGet data from [sourceFile] (must have DIGI) and rerun RECO \
00056 \n\t\t\tfastsim:\t\t\tRun fastsim \
00057 \n\t\t\tfullsim:\t\t\tGen-Sim-Digi-Reco-Validate!\n"
00058 )
00059
00060 allowedOptions['dataSource'] = ['recoFiles', 'recoFiles+PFTau', 'recoFiles+PFTau+CaloTau', 'recoFiles+CaloTau', 'recoFiles+CaloTau+PFTau', 'fastsim', 'digiFiles', 'fullsim']
00061
00062 options.register( 'sourceFile',
00063 'none',
00064 VarParsing.VarParsing.multiplicity.singleton,
00065 VarParsing.VarParsing.varType.string,
00066 "Specify a file containing events to read if using the recoFiles or digiFiles options. If left as none files will be taken from\
00067 \n\t\t\trecoFiles:\t\t\tGet data from [sourceFile]EventSource_<eventType>_RECO_cff.py \
00068 \n\t\t\tdigiFiles:\t\t\tGet data from EventSource_<eventType>_DIGI_cff.py \n"
00069 )
00070
00071 options.register( 'conditions',
00072 'whatever',
00073 VarParsing.VarParsing.multiplicity.singleton,
00074 VarParsing.VarParsing.varType.string,
00075 "Specify global tag for conditions. If left as default ('whatever'), whatever is defined in Configuration.FrontierConditions_GlobalTag_cff will be taken\n"
00076 )
00077
00078 options.register( 'myModifications',
00079 'none',
00080 VarParsing.VarParsing.multiplicity.list,
00081 VarParsing.VarParsing.varType.string,
00082 "Specify one (or more) files to be loaded in the process. You can use this to modifiy cfi parameters from their defaults. See ExampleModification_cfi.py"
00083 )
00084
00085 options.register( 'batchNumber',
00086 -1,
00087 VarParsing.VarParsing.multiplicity.singleton,
00088 VarParsing.VarParsing.varType.int,
00089 "Run in batch mode: add batch number to output file, dont' compute efficiency, and change random seed. If running from files, skipEvents will automatically be \
00090 set."
00091 )
00092
00093 options.register( 'writeEDMFile',
00094 "",
00095 VarParsing.VarParsing.multiplicity.singleton,
00096 VarParsing.VarParsing.varType.string,
00097 "Specify an (optional) output file. Batch number and .root suffix will be appended. Event content will PFTau RECO content along with genParticles"
00098 )
00099
00100 options.register( 'edmFileContents',
00101 "AODSim",
00102 VarParsing.VarParsing.multiplicity.list,
00103 VarParsing.VarParsing.varType.string,
00104 "Specify event content. Not yet implemented"
00105 )
00106
00107
00108
00109
00110
00111
00112
00113
00114 options.register( 'nJobs',
00115 0,
00116 VarParsing.VarParsing.multiplicity.singleton,
00117 VarParsing.VarParsing.varType.int,
00118 "Number of jobs to submit to LXBatch. [Batchmode only]"
00119 )
00120
00121 options.register( 'copyToCastorDir',
00122 "",
00123 VarParsing.VarParsing.multiplicity.singleton,
00124 VarParsing.VarParsing.varType.string,
00125 "If writeEDMFile is specified, copy the edmOutputFile to castor. Specify <home> to use your home dir. [Batchmode only]"
00126 )
00127
00128 options.register( 'lxbatchQueue',
00129 '8nh',
00130 VarParsing.VarParsing.multiplicity.singleton,
00131 VarParsing.VarParsing.varType.string,
00132 "LXBatch queue (8nm, 1nh, 8nh, 1nd, 1nw) [Batchmode only]"
00133 )
00134
00135 allowedOptions['lxbatchQueue'] = ['8nm', '1nh', '8nh', '1nd', '1nw']
00136
00137
00138 def checkOptionsForBadInput():
00139
00140 for optionName, allowedValues in allowedOptions.iteritems():
00141 if not getattr(options, optionName) in allowedValues:
00142 print "Bad input to option: %s" % optionName
00143 sys.exit()
00144
00145 def calledBycmsRun():
00146 ''' Returns true of this python file is being called via cmsRun '''
00147 if sys.argv[0].find('cmsRun') == -1:
00148 return False
00149 else:
00150 return True
00151
00152 def CMSSWEnvironmentIsCurrent():
00153 ''' Make sure that our CMSSW environment doesn't point ot another release!'''
00154 if ReleaseBase != os.path.commonprefix([ReleaseBase, os.getcwd()]):
00155 return False
00156 else:
00157 return True
00158
00159 def returnOptionsString():
00160 ''' format the options to be passed on the command line. Used when submitting batch jobs'''
00161 outputString = ""
00162 for optionsName, optionValue in options.__dict__['_singletons'].iteritems():
00163 outputString += " %s=%s" % (optionsName, optionValue)
00164
00165 for optionsName, optionValues in options.__dict__['_lists'].iteritems():
00166 for anOption in optionValues:
00167 outputString += " %s=%s" % (optionsName, anOption)
00168 return outputString