CMS 3D CMS Logo

ValidationOptions_cff.py
Go to the documentation of this file.
1 from __future__ import print_function
2 import os
3 import sys
4 try:
5  ReleaseBase = os.path.join(os.environ['CMSSW_BASE'], "src")
6  ReleaseVersion = os.environ['CMSSW_VERSION']
7 except KeyError:
8  print("CMSSW enviroment not set, please run cmsenv!")
9  sys.exit()
10 
11 import FWCore.ParameterSet.Config as cms
12 import FWCore.ParameterSet.VarParsing as VarParsing
13 
14 #options = VarParsing.VarParsing ('standard')
16 
17 allowedOptions = {}
18 
19 options.register( 'maxEvents',
20  -1,
21  VarParsing.VarParsing.multiplicity.singleton,
22  VarParsing.VarParsing.varType.int,
23  "Specify events to run."
24  )
25 
26 options.register( 'eventType',
27  "ZTT",
28  VarParsing.VarParsing.multiplicity.singleton,
29  VarParsing.VarParsing.varType.string,
30  #"If true, generate and validate Z-TauTau (hadronic only) events. Otherwise, generate QCD FlatPt 15-3000 events."
31  "Specify the type of events to validate. (and generate, if using fast or fullsim)\
32  \n\t\tOptions:\
33  \n\t\t\tZTT\
34  \n\t\t\tQCD\
35  \n\t\t\tZEE\
36  \n\t\t\tZMM\
37  \n\t\t\tZTTFastSim\
38  \n\t\t\tZEEFastSim\
39  \n\t\t\tRealData (Jets faking taus)\
40  \n\t\t\tRealMuonsData (Iso Muons faking taus)\
41  \n\t\t\tRealElectronsData (Iso Electrons faking taus)\n"
42  )
43 
44 allowedOptions['eventType'] = [ 'ZTT', 'QCD', 'ZEE', 'ZMM', 'RealData', 'RealMuonsData', 'RealElectronsData','ZTTFastSim','ZEEFastSim']
45 
46 options.register( 'label',
47  "none",
48  VarParsing.VarParsing.multiplicity.singleton,
49  VarParsing.VarParsing.varType.string,
50  "Validation output files will be stored in folder Validation_<label>. The root file will also use this label.\n"
51  )
52 
53 options.register( 'dataSource',
54  'recoFiles',
55  VarParsing.VarParsing.multiplicity.singleton,
56  VarParsing.VarParsing.varType.string,
57  "Specify where the data should come from. \n\t\tOptions: \
58  \n\t\t\trecoFiles:\t\t\tGet data from [sourceFile] (must have RECO)\
59  \n\t\t\trecoFiles+PFTau:\t\tGet reco data as above, and rerun PFTau with current tags \
60  \n\t\t\tdigiFiles:\t\t\tGet data from [sourceFile] (must have DIGI) and rerun RECO \
61  \n\t\t\tfastsim:\t\t\tRun FastSim \
62  \n\t\t\tfullsim:\t\t\tGen-Sim-Digi-Reco-Validate!\n"
63  )
64 
65 allowedOptions['dataSource'] = ['recoFiles', 'recoFiles+PFTau', 'fastsim', 'digiFiles', 'fullsim']
66 
67 options.register( 'sourceFile',
68  'none',
69  VarParsing.VarParsing.multiplicity.singleton,
70  VarParsing.VarParsing.varType.string,
71  "Specify a file containing events to read if using the recoFiles or digiFiles options. If left as none files will be taken from\
72  \n\t\t\trecoFiles:\t\t\tGet data from [sourceFile]EventSource_<eventType>_RECO_cff.py \
73  \n\t\t\tdigiFiles:\t\t\tGet data from EventSource_<eventType>_DIGI_cff.py \n"
74  )
75 
76 options.register( 'conditions',
77  'whatever',
78  VarParsing.VarParsing.multiplicity.singleton,
79  VarParsing.VarParsing.varType.string,
80  "Specify global tag for conditions. If left as default ('whatever'), whatever is defined in Configuration.FrontierConditions_GlobalTag_cff will be taken\n"
81  )
82 
83 options.register( 'myModifications',
84  'none',
85  VarParsing.VarParsing.multiplicity.list,
86  VarParsing.VarParsing.varType.string,
87  "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"
88  )
89 
90 options.register( 'batchNumber',
91  -1,
92  VarParsing.VarParsing.multiplicity.singleton,
93  VarParsing.VarParsing.varType.int,
94  "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 \
95  set."
96  )
97 
98 options.register( 'writeEDMFile',
99  "",
100  VarParsing.VarParsing.multiplicity.singleton,
101  VarParsing.VarParsing.varType.string,
102  "Specify an (optional) output file. Batch number and .root suffix will be appended. Event content will PFTau RECO content along with genParticles"
103  )
104 
105 options.register( 'edmFileContents',
106  "AODSim",
107  VarParsing.VarParsing.multiplicity.list,
108  VarParsing.VarParsing.varType.string,
109  "Specify event content. Not yet implemented"
110  )
111 
112 options.register( 'gridJob',
113  False,
114  VarParsing.VarParsing.multiplicity.singleton,
115  VarParsing.VarParsing.varType.bool,
116  "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."
117  )
118 
119 
124 
125 # add options for number of batchJobs
126 options.register( 'nJobs',
127  0,
128  VarParsing.VarParsing.multiplicity.singleton,
129  VarParsing.VarParsing.varType.int,
130  "Number of jobs to submit to LXBatch. [Batchmode only]"
131  )
132 
133 options.register( 'copyToCastorDir',
134  "",
135  VarParsing.VarParsing.multiplicity.singleton,
136  VarParsing.VarParsing.varType.string,
137  "If writeEDMFile is specified, copy the edmOutputFile to castor. Specify <home> to use your home dir. [Batchmode only]"
138  )
139 
140 options.register( 'lxbatchQueue',
141  '8nh',
142  VarParsing.VarParsing.multiplicity.singleton,
143  VarParsing.VarParsing.varType.string,
144  "LXBatch queue (8nm, 1nh, 8nh, 1nd, 1nw) [Batchmode only]"
145  )
146 
147 allowedOptions['lxbatchQueue'] = ['8nm', '1nh', '8nh', '1nd', '1nw']
148 
149 
151  # Sanity check
152  for optionName, allowedValues in allowedOptions.items():
153  if not getattr(options, optionName) in allowedValues:
154  print("Bad input to option: %s" % optionName)
155  sys.exit()
156 
158  ''' Returns true of this python file is being called via cmsRun '''
159  if sys.argv[0].find('cmsRun') == -1:
160  return False
161  else:
162  return True
163 
165  ''' Make sure that our CMSSW environment doesn't point ot another release!'''
166  if ReleaseBase != os.path.commonprefix([ReleaseBase, os.getcwd()]):
167  return False
168  else:
169  return True
170 
172  ''' format the options to be passed on the command line. Used when submitting batch jobs'''
173  outputString = ""
174  for optionsName, optionValue in options.__dict__['_singletons'].items():
175  outputString += " %s=%s" % (optionsName, optionValue)
176 
177  for optionsName, optionValues in options.__dict__['_lists'].items():
178  for anOption in optionValues:
179  outputString += " %s=%s" % (optionsName, anOption)
180  return outputString
ValidationOptions_cff.checkOptionsForBadInput
def checkOptionsForBadInput()
Definition: ValidationOptions_cff.py:150
ValidationOptions_cff.calledBycmsRun
def calledBycmsRun()
Definition: ValidationOptions_cff.py:157
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
ValidationOptions_cff.returnOptionsString
def returnOptionsString()
Definition: ValidationOptions_cff.py:171
VarParsing.VarParsing
Definition: VarParsing.py:9
ValidationOptions_cff.CMSSWEnvironmentIsCurrent
def CMSSWEnvironmentIsCurrent()
Definition: ValidationOptions_cff.py:164