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