CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Validation/RecoTau/python/ValidationOptions_cff.py

Go to the documentation of this file.
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 #options = VarParsing.VarParsing ('standard')
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                   #"If true, generate and validate Z-TauTau (hadronic only) events. Otherwise, generate QCD FlatPt 15-3000 events."
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\
00036                         \n\t\t\tZTTFastSim\
00037                         \n\t\t\tZEEFastSim\
00038                         \n\t\t\tRealData          (Jets faking taus)\
00039                         \n\t\t\tRealMuonsData     (Iso Muons faking taus)\
00040                         \n\t\t\tRealElectronsData (Iso Electrons faking taus)\n"
00041                  )
00042 
00043 allowedOptions['eventType'] = [ 'ZTT', 'QCD', 'ZEE', 'ZMM', 'RealData', 'RealMuonsData', 'RealElectronsData','ZTTFastSim','ZEEFastSim']
00044 
00045 options.register( 'label',
00046                   "none",
00047                   VarParsing.VarParsing.multiplicity.singleton,
00048                   VarParsing.VarParsing.varType.string,
00049                   "Validation output files will be stored in folder Validation_<label>.  The root file will also use this label.\n"
00050                  )
00051 
00052 options.register( 'dataSource',
00053                   'recoFiles',
00054                   VarParsing.VarParsing.multiplicity.singleton,
00055                   VarParsing.VarParsing.varType.string,
00056                   "Specify where the data should come from. \n\t\tOptions: \
00057                         \n\t\t\trecoFiles:\t\t\tGet data from [sourceFile] (must have RECO)\
00058                         \n\t\t\trecoFiles+PFTau:\t\tGet reco data as above, and rerun PFTau with current tags \
00059                         \n\t\t\trecoFiles+PFTau+CaloTau:\t\tRun CaloTau too \
00060                         \n\t\t\tdigiFiles:\t\t\tGet data from [sourceFile] (must have DIGI) and rerun RECO \
00061                         \n\t\t\tfastsim:\t\t\tRun fastsim \
00062                         \n\t\t\tfullsim:\t\t\tGen-Sim-Digi-Reco-Validate!\n"
00063                   )
00064 
00065 allowedOptions['dataSource'] = ['recoFiles', 'recoFiles+PFTau', 'recoFiles+PFTau+CaloTau', 'recoFiles+CaloTau', 'recoFiles+CaloTau+PFTau', 'fastsim', 'digiFiles', 'fullsim']
00066 
00067 options.register( 'sourceFile',
00068                   'none',
00069                   VarParsing.VarParsing.multiplicity.singleton,
00070                   VarParsing.VarParsing.varType.string,
00071                   "Specify a file containing events to read if using the recoFiles or digiFiles options. If left as none files will be taken from\
00072                         \n\t\t\trecoFiles:\t\t\tGet data from [sourceFile]EventSource_<eventType>_RECO_cff.py \
00073                         \n\t\t\tdigiFiles:\t\t\tGet data from EventSource_<eventType>_DIGI_cff.py \n"
00074                   )
00075 
00076 options.register( 'conditions',
00077                   'whatever',
00078                   VarParsing.VarParsing.multiplicity.singleton,
00079                   VarParsing.VarParsing.varType.string,
00080                   "Specify global tag for conditions.  If left as default ('whatever'), whatever is defined in Configuration.FrontierConditions_GlobalTag_cff will be taken\n"
00081                 )
00082 
00083 options.register( 'myModifications',
00084                   'none',
00085                   VarParsing.VarParsing.multiplicity.list,
00086                   VarParsing.VarParsing.varType.string,
00087                   "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"
00088                   )
00089 
00090 options.register( 'batchNumber',
00091                   -1,
00092                   VarParsing.VarParsing.multiplicity.singleton,
00093                   VarParsing.VarParsing.varType.int,
00094                   "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 \
00095                    set."
00096                )
00097 
00098 options.register( 'writeEDMFile',
00099                   "",
00100                   VarParsing.VarParsing.multiplicity.singleton,
00101                   VarParsing.VarParsing.varType.string,
00102                   "Specify an (optional) output file.  Batch number and .root suffix will be appended. Event content will PFTau RECO content along with genParticles"
00103                )
00104 
00105 options.register( 'edmFileContents',
00106                   "AODSim",
00107                   VarParsing.VarParsing.multiplicity.list,
00108                   VarParsing.VarParsing.varType.string,
00109                   "Specify event content. Not yet implemented"
00110                 )
00111 
00112 options.register( 'gridJob',
00113                   False,
00114                   VarParsing.VarParsing.multiplicity.singleton,
00115                   VarParsing.VarParsing.varType.bool,
00116                   "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."
00117                 )
00118 
00119 ################################
00120 #
00121 #        Batchmode options
00122 #
00123 ################################
00124 
00125 # add options for number of batchJobs
00126 options.register( 'nJobs',
00127                   0,
00128                   VarParsing.VarParsing.multiplicity.singleton,
00129                   VarParsing.VarParsing.varType.int,
00130                   "Number of jobs to submit to LXBatch. [Batchmode only]"
00131                 )
00132 
00133 options.register( 'copyToCastorDir',
00134                   "",
00135                   VarParsing.VarParsing.multiplicity.singleton,
00136                   VarParsing.VarParsing.varType.string,
00137                   "If writeEDMFile is specified, copy the edmOutputFile to castor.  Specify <home> to use your home dir. [Batchmode only]"
00138                 )
00139 
00140 options.register( 'lxbatchQueue',
00141                   '8nh',
00142                   VarParsing.VarParsing.multiplicity.singleton,
00143                   VarParsing.VarParsing.varType.string,
00144                   "LXBatch queue (8nm, 1nh, 8nh, 1nd, 1nw) [Batchmode only]"
00145                 )
00146 
00147 allowedOptions['lxbatchQueue'] = ['8nm', '1nh', '8nh', '1nd', '1nw']
00148 
00149 
00150 def checkOptionsForBadInput():
00151    # Sanity check
00152    for optionName, allowedValues in allowedOptions.iteritems():
00153       if not getattr(options, optionName) in allowedValues:
00154          print "Bad input to option: %s" % optionName
00155          sys.exit()
00156 
00157 def calledBycmsRun():
00158    ''' Returns true of this python file is being called via cmsRun '''
00159    if sys.argv[0].find('cmsRun') == -1:
00160       return False
00161    else:
00162       return True
00163 
00164 def CMSSWEnvironmentIsCurrent():
00165    ''' Make sure that our CMSSW environment doesn't point ot another release!'''
00166    if ReleaseBase != os.path.commonprefix([ReleaseBase, os.getcwd()]):
00167       return False
00168    else:
00169       return True
00170 
00171 def returnOptionsString():
00172    ''' format the options to be passed on the command line.  Used when submitting batch jobs'''
00173    outputString = ""
00174    for optionsName, optionValue in options.__dict__['_singletons'].iteritems():
00175       outputString += " %s=%s" % (optionsName, optionValue)
00176 
00177    for optionsName, optionValues in options.__dict__['_lists'].iteritems():
00178       for anOption in optionValues:
00179          outputString += " %s=%s" % (optionsName, anOption) 
00180    return outputString