CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
UserOptions_cff.py
Go to the documentation of this file.
1 from __future__ import print_function
2 #
3 # configuration file fragment containing user choices
4 # for release to run, sample and data type to use in
5 # a cfg file
6 #
7 
8 #
9 
10 import FWCore.ParameterSet.Config as cms
11 import sys
12 
13 
14 
15 
16 
17 # number of events to be run (-1 for all)
18 maxNumberEvents = 10
19 maxNumberEvents = -1
20 
21 # useRelValSample: choose the type of sample used:
22 # True to use MC RelVal
23 # False to use data
24 
25 # default value
26 useRelValSample = False
27 #
28 # comment/uncomment the next line to choose sample type
29 # (un-commented selects MC RelVal)
30 #useRelValSample=True
31 
32 if useRelValSample == False :
33 
34  # choose the global tag type
35  # WARNING: global mess in global tag management,
36  # must be chosen per sample
37  # must be checked in the release
38  #
39  globalTag = '75X_dataRun2_HLT_v2'
40 
41  # choose one sample identifier from the list of data samples
42  #
43  sampleIdentifier = '251162'
44  #sampleIdentifier = '165633-CAFDQM'
45  #sampleIdentifier = '191833_RAW'
46  #sampleIdentifier = '205666.A.storageManager'
47 
48 else :
49  # choose the global tag type
50  # WARNING: global mess in global tag management,
51  # must be chosen per sample
52  # must be checked in the release
53  #
54  globalTag = 'auto:run1_mc'
55  #globalTag = 'auto:MCRUN2_72_V3A'
56  #globalTag = 'auto:run1_mc_hi'
57 
58  # choose (pre)release used to produce the RelVal samples
59  sampleFromRelease = 'CMSSW_7_5_0'
60 
61  # RelVals samples - add the "short name" of the dataset e.g. /RelValLM1_sfts/...
62  #
63  #dataset = 'RelValMinBias'
64  dataset = 'RelValTTbar'
65 
66  # data type
67  #
68  dataType = 'RAW'
69  #dataType = 'RECO'
70 
71 # change to True to use local files
72 # the type of file must be matched by hand
73 
74 useLocalFiles = False
75 #useLocalFiles = True
76 
77 # override default global tag - expert choice, do it only if you know what you do
78 overrideGlobalTag = False
79 #overrideGlobalTag = True
80 
81 if overrideGlobalTag == True :
82  myGlobalTag = 'GR_P_V28'
83 
84 
85 
86 #
87 errorUserOptions = False
88 
89 # initialize list of files, of secondary files, list of selected events and luminosity segments
90 readFiles = cms.untracked.vstring()
91 secFiles = cms.untracked.vstring()
92 selectedEvents = cms.untracked.VEventRange()
93 selectedLumis= cms.untracked.VLuminosityBlockRange()
94 
95 # type of sample used (True for RelVal, False for data)
96 
97 if (useRelValSample == True) and (useLocalFiles == False) :
98 
99  #
100 
101  print(" Release: ", sampleFromRelease)
102  print(" Dataset: ", dataset)
103  print(" Data type: ", dataType)
104  print()
105 
106  useDAS = True
107 
108  if useDAS :
109  import das_client
110  import os
111 
112  # query DAS
113 
114  myQuery = 'dataset release=' + sampleFromRelease
115  dasClientCommand = 'das_client.py --limit=0 --format=plain --query='+'"'+myQuery+'"'
116  datasets = os.popen(dasClientCommand)
117 
118 
119  # adjust strings for dataset and sampleFromRelease to search the dataset exact name
120  dataset = '/' + dataset + '/'
121  sampleFromRelease = sampleFromRelease +'-'
122 
123  if 'start' in globalTag :
124  gTag = 'START'
125  elif 'mc' in globalTag :
126  gTag = 'MC'
127  else :
128  gTag =''
129 
130  datasetName = ''
131  for line in datasets.readlines() :
132  if dataset in line :
133  if sampleFromRelease in line :
134  if gTag in line :
135  if dataType in line :
136  if 'ALCA' not in line :
137  datasetName = line.strip(' \n')
138  # print datasetName
139 
140  # print datasetName
141 
142  if datasetName == '' :
143  print("\n No dataset found.")
144  errorUserOptions = True
145 
146  if not errorUserOptions :
147 
148  myQuery = 'file dataset=' + '"' + datasetName + '"'
149  dasClientCommand = 'das_client.py --limit=0 --format=plain --query=' + '"' + myQuery + '"'
150  data = os.popen(dasClientCommand)
151  filePaths = data.readlines()
152 
153 
154  print('\n das_client using the query')
155  print(' ', myQuery)
156  print(' retrieved the following files\n')
157 
158  for line in filePaths :
159  print(' ', line)
160 
161  readFiles.extend(filePaths);
162 
163 
164  # nothing added to secondary files by DAS
165  secFiles.extend([
166  ])
167 
168 
169 
170 
171 elif (useRelValSample == False) and (useLocalFiles == False) :
172 
173  # data
174 
175  if sampleIdentifier == '191833_RAW' :
176  runNumber = '191833'
177  dataset = '/DoubleElectron/Run2012A-v1/RAW'
178  dataType = 'RAW'
179  useDAS = True
180  selectedLumis= cms.untracked.VLuminosityBlockRange(
181  '191833:1'
182  )
183  selectedEvents = cms.untracked.VEventRange(
184  '191833:256674',
185  '191833:588211'
186  )
187 
188  elif sampleIdentifier == '251162' :
189  runNumber = '251162'
190  dataset = '/Run2015B/DoubleMuon/RAW'
191  dataType = 'RAW'
192  useDAS = False
193  readFiles.extend( [
194  '/store/data/Run2015B/DoubleMuon/RAW/v1/000/251/162/00000/9A6A3CB4-AD25-E511-84E5-02163E01264D.root'
195  ] );
196 
197 
198  elif sampleIdentifier == '191833_RECO' :
199  runNumber = '191833'
200  dataset = '/DoubleElectron/Run2012A-PromptReco-v1/RECO'
201  dataType = 'RECO'
202  useDAS = True
203  selectedLumis= cms.untracked.VLuminosityBlockRange(
204  '191833:1'
205  )
206  selectedEvents = cms.untracked.VEventRange(
207  '191833:256674',
208  '191833:588211'
209  )
210 
211  elif sampleIdentifier == '191833_AOD' :
212  runNumber = '191833'
213  dataset = '/DoubleElectron/Run2012A-PromptReco-v1/AOD'
214  dataType = 'RECO'
215  useDAS = True
216  selectedLumis= cms.untracked.VLuminosityBlockRange(
217  '191833:1'
218  )
219  selectedEvents = cms.untracked.VEventRange(
220  '191833:256674',
221  '191833:588211'
222  )
223 
224  # splash events 2012
225  elif sampleIdentifier == '187858' :
226  runNumber = '187858'
227  dataset = '/Commissioning/Commissioning12-v1/RAW'
228  dataType = 'RAW'
229  useDAS = True
230  selectedLumis= cms.untracked.VLuminosityBlockRange(
231  '187858:394',
232  '187858:499'
233  )
234  selectedEvents = cms.untracked.VEventRange(
235  '187858:3244833',
236  '187858:4094284'
237  )
238 
239  # high PU run 2011
240  elif sampleIdentifier == '179828' :
241  runNumber = '179828'
242  dataset = '/ZeroBiasHPF0/Run2011B-v1/RAW'
243  dataType = 'RAW'
244  useDAS = True
245 
246 
247  elif sampleIdentifier == '165633-CAFDQM' :
248  runNumber = '165633'
249  dataset = '/ZeroBiasHPF0/Run2011B-v1/RAW'
250  dataType = 'RAW'
251  useDAS = False
252  readFiles.extend( [
253  'file:/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/DQMTest/MinimumBias__RAW__v1__165633__1CC420EE-B686-E011-A788-0030487CD6E8.root'
254  ]);
255 
256 
257  elif sampleIdentifier == '137028' :
258  runNumber = '137028'
259  dataset = '/Run2010A/ZeroBias/RECO-v2'
260  dataType = 'RECO'
261  useDAS = False
262  readFiles.extend( [
263  '/store/data/Run2010A/ZeroBias/RECO/v2/000/137/028/08BF857D-2471-DF11-9CEB-003048D2BBF0.root'
264  ] );
265 
266 
267  elif sampleIdentifier == 'StreamFile_105760' :
268  runNumber = '105760'
269  dataset = 'A_Stream'
270  dataType = 'StreamFile'
271  useDAS = False
272  readFiles.extend( [
273  'file:/lookarea_SM/MWGR_29.00105760.0001.A.storageManager.00.0000.dat'
274  ] );
275 
276  # run with L1 GT data - emulator disagreements for the selectedEvents
277  elif sampleIdentifier == '205666.A.storageManager' :
278  runNumber = '205666'
279  dataset = 'A.storageManager'
280  dataType = 'StreamFile'
281  useDAS = False
282 
283  selectedEvents = cms.untracked.VEventRange(
284  '205666:101:125069341',
285  '205666:161:238160322',
286  '205666:281:443371795',
287  '205666:341:537654884',
288  '205666:361:567121052'
289  )
290 
291  readFiles.extend( [
292 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0001.A.storageManager.00.0000.dat',
293 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0021.A.storageManager.01.0000.dat',
294 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0041.A.storageManager.02.0000.dat',
295 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0061.A.storageManager.03.0000.dat',
296 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0081.A.storageManager.04.0000.dat',
297  'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0101.A.storageManager.05.0000.dat',
298 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0121.A.storageManager.06.0000.dat',
299 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0141.A.storageManager.07.0000.dat',
300  'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0161.A.storageManager.08.0000.dat',
301 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0181.A.storageManager.09.0000.dat',
302 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0201.A.storageManager.10.0000.dat',
303 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0221.A.storageManager.11.0000.dat',
304 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0241.A.storageManager.12.0000.dat',
305 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0261.A.storageManager.13.0000.dat',
306  'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0281.A.storageManager.14.0000.dat',
307 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0301.A.storageManager.15.0000.dat',
308 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0321.A.storageManager.00.0000.dat',
309  'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0341.A.storageManager.01.0000.dat',
310  'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0361.A.storageManager.02.0000.dat',
311 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0381.A.storageManager.03.0000.dat',
312 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0401.A.storageManager.04.0000.dat',
313 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0421.A.storageManager.05.0000.dat',
314 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0441.A.storageManager.06.0000.dat',
315 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0461.A.storageManager.07.0000.dat',
316 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0481.A.storageManager.08.0000.dat',
317 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0501.A.storageManager.09.0000.dat',
318 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0521.A.storageManager.10.0000.dat',
319 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0541.A.storageManager.11.0000.dat',
320 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0561.A.storageManager.12.0000.dat',
321 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0581.A.storageManager.13.0000.dat',
322 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0601.A.storageManager.14.0000.dat',
323 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0621.A.storageManager.15.0000.dat',
324 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0641.A.storageManager.00.0000.dat',
325 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0661.A.storageManager.01.0000.dat',
326 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0681.A.storageManager.02.0000.dat',
327 # 'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0701.A.storageManager.03.0000.dat',
328  'file:/afs/cern.ch/user/g/ghete/work/L1Trigger/data/Data.00205666.0721.A.storageManager.04.0000.dat'
329  ]);
330 
331 
332  else :
333  print('Error: sample identifier ', sampleIdentifier, ' not defined.\n')
334  errorUserOptions = True
335  runNumber = '0'
336  dataset = 'None'
337  dataType = 'None'
338  useDAS = False
339 
340 
341  #
342  # end of data samples
343  #
344 
345  print(" Run number: ", runNumber)
346  print(" Dataset: ", dataset)
347  print(" Data type: ", dataType)
348 
349  if useDAS :
350  import das_client
351  import os
352 
353  # query DAS
354  myQuery = 'file dataset=' + dataset + ' run=' + runNumber
355  dasClientCommand = 'das_client.py --limit=0 --format=plain --query='+'"'+myQuery+'"'
356  data = os.popen(dasClientCommand)
357  filePaths = data.readlines()
358 
359 
360  print('\n das_client using the query')
361  print(' ', myQuery)
362  print(' retrieved the following files\n')
363 
364  for line in filePaths :
365  print(' ', line)
366 
367  readFiles.extend(filePaths);
368 
369 
370  # nothing added to secondary files by DAS
371  secFiles.extend([
372  ])
373 
374 
375 
376 else :
377  # local file(s)
378 
379 
380  if sampleIdentifier == 'dummy' :
381  dataType = 'RAW'
382  readFiles.extend( [
383  'file:/afs/cern.ch/user/g/ghete/scratch0/CmsswTestFiles/LocalFile_source.root'
384  ]);
385 
386  secFiles.extend([
387  ])
388 
389  print('Local file(s)', readFiles)
390 
391 if overrideGlobalTag == True :
392  globalTag = myGlobalTag
393 
394 if globalTag.count('auto') :
395  from Configuration.AlCa.autoCond import autoCond
396  useGlobalTag = autoCond[globalTag.replace('auto:', '')]
397 else :
398  useGlobalTag = globalTag
399 
400 print("\n Using global tag ", useGlobalTag, "\n")
401 
402 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47