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 options.register( 'gridJob',
00108 False,
00109 VarParsing.VarParsing.multiplicity.singleton,
00110 VarParsing.VarParsing.varType.bool,
00111 "Set to true makes some modifications to enable to run on grid. On the analysis has the same effect of running in batch, but has also other features."
00112 )
00113
00114
00115
00116
00117
00118
00119
00120
00121 options.register( 'nJobs',
00122 0,
00123 VarParsing.VarParsing.multiplicity.singleton,
00124 VarParsing.VarParsing.varType.int,
00125 "Number of jobs to submit to LXBatch. [Batchmode only]"
00126 )
00127
00128 options.register( 'copyToCastorDir',
00129 "",
00130 VarParsing.VarParsing.multiplicity.singleton,
00131 VarParsing.VarParsing.varType.string,
00132 "If writeEDMFile is specified, copy the edmOutputFile to castor. Specify <home> to use your home dir. [Batchmode only]"
00133 )
00134
00135 options.register( 'lxbatchQueue',
00136 '8nh',
00137 VarParsing.VarParsing.multiplicity.singleton,
00138 VarParsing.VarParsing.varType.string,
00139 "LXBatch queue (8nm, 1nh, 8nh, 1nd, 1nw) [Batchmode only]"
00140 )
00141
00142 allowedOptions['lxbatchQueue'] = ['8nm', '1nh', '8nh', '1nd', '1nw']
00143
00144
00145 def checkOptionsForBadInput():
00146
00147 for optionName, allowedValues in allowedOptions.iteritems():
00148 if not getattr(options, optionName) in allowedValues:
00149 print "Bad input to option: %s" % optionName
00150 sys.exit()
00151
00152 def calledBycmsRun():
00153 ''' Returns true of this python file is being called via cmsRun '''
00154 if sys.argv[0].find('cmsRun') == -1:
00155 return False
00156 else:
00157 return True
00158
00159 def CMSSWEnvironmentIsCurrent():
00160 ''' Make sure that our CMSSW environment doesn't point ot another release!'''
00161 if ReleaseBase != os.path.commonprefix([ReleaseBase, os.getcwd()]):
00162 return False
00163 else:
00164 return True
00165
00166 def returnOptionsString():
00167 ''' format the options to be passed on the command line. Used when submitting batch jobs'''
00168 outputString = ""
00169 for optionsName, optionValue in options.__dict__['_singletons'].iteritems():
00170 outputString += " %s=%s" % (optionsName, optionValue)
00171
00172 for optionsName, optionValues in options.__dict__['_lists'].iteritems():
00173 for anOption in optionValues:
00174 outputString += " %s=%s" % (optionsName, anOption)
00175 return outputString