CMS 3D CMS Logo

Reco.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 _pp_
4 
5 Scenario supporting proton collisions
6 
7 """
8 from __future__ import print_function
9 
10 import os
11 import sys
12 
14 from Configuration.DataProcessing.Utils import stepALCAPRODUCER,stepSKIMPRODUCER,addMonitoring,dictIO,dqmIOSource,harvestingMode,dqmSeq,gtNameAndConnect
15 import FWCore.ParameterSet.Config as cms
16 from Configuration.DataProcessing.RecoTLR import customisePrompt,customiseExpress
17 
18 class Reco(Scenario):
19  def __init__(self):
20  Scenario.__init__(self)
21  self.recoSeq=''
22  self.addEI=False
23  self.cbSc=self.__class__.__name__
24  self.promptModifiers = cms.ModifierChain()
25  self.expressModifiers = cms.ModifierChain()
26  self.visModifiers = cms.ModifierChain()
27  """
28  _pp_
29 
30  Implement configuration building for data processing for proton
31  collision data taking
32 
33  """
34 
35 
36  def _checkRepackedFlag(self, options, **args):
37  if 'repacked' in args:
38  if args['repacked'] == True:
39  options.isRepacked = True
40  else:
41  options.isRepacked = False
42 
43 
44 
45  def promptReco(self, globalTag, **args):
46  """
47  _promptReco_
48 
49  Proton collision data taking prompt reco
50 
51  """
52  step = stepALCAPRODUCER(args['skims'])
53  PhysicsSkimStep = ''
54  if ("PhysicsSkims" in args) :
55  PhysicsSkimStep = stepSKIMPRODUCER(args['PhysicsSkims'])
56  dqmStep = dqmSeq(args,'')
57  options = Options()
58  options.__dict__.update(defaultOptions.__dict__)
59  options.scenario = self.cbSc
60  if ('nThreads' in args) :
61  options.nThreads=args['nThreads']
62 
63  miniAODStep=''
64 
65 # if miniAOD is asked for - then retrieve the miniaod config
66  if 'outputs' in args:
67  for a in args['outputs']:
68  if a['dataTier'] == 'MINIAOD':
69  miniAODStep=',PAT'
70 
71  """
72  Unscheduled for all
73  """
74  options.runUnscheduled=True
75 
76  self._checkRepackedFlag(options, **args)
77 
78  if 'customs' in args:
79  options.customisation_file=args['customs']
80 
81  eiStep=''
82  if self.addEI:
83  eiStep=',EI'
84 
85  options.step = 'RAW2DIGI,L1Reco,RECO'+self.recoSeq+eiStep+step+PhysicsSkimStep+miniAODStep+',DQM'+dqmStep+',ENDJOB'
86 
87  dictIO(options,args)
88  options.conditions = gtNameAndConnect(globalTag, args)
89 
90  process = cms.Process('RECO', cms.ModifierChain(self.eras, self.promptModifiers) )
91  cb = ConfigBuilder(options, process = process, with_output = True)
92 
93  # Input source
94  process.source = cms.Source("PoolSource",
95  fileNames = cms.untracked.vstring()
96  )
97  cb.prepare()
98 
99  addMonitoring(process)
100 
101  return process
102 
103 
104  def expressProcessing(self, globalTag, **args):
105  """
106  _expressProcessing_
107 
108  Proton collision data taking express processing
109 
110  """
111  skims = args['skims']
112  # the AlCaReco skims for PCL should only run during AlCaSkimming step which uses the same configuration on the Tier0 side, for this reason we drop them here
113  pclWkflws = [x for x in skims if "PromptCalibProd" in x]
114  for wfl in pclWkflws:
115  skims.remove(wfl)
116 
117  step = stepALCAPRODUCER(skims)
118  dqmStep= dqmSeq(args,'')
119  options = Options()
120  options.__dict__.update(defaultOptions.__dict__)
121  options.scenario = self.cbSc
122  if ('nThreads' in args) :
123  options.nThreads=args['nThreads']
124 
125  eiStep=''
126  if self.addEI:
127  eiStep=',EI'
128 
129  options.step = 'RAW2DIGI,L1Reco,RECO'+self.recoSeq+eiStep+step+',DQM'+dqmStep+',ENDJOB'
130 
131  dictIO(options,args)
132  options.conditions = gtNameAndConnect(globalTag, args)
133 
134 
135  options.filein = 'tobeoverwritten.xyz'
136  if 'inputSource' in args:
137  options.filetype = args['inputSource']
138  process = cms.Process('RECO', cms.ModifierChain(self.eras, self.expressModifiers) )
139 
140  if 'customs' in args:
141  options.customisation_file=args['customs']
142 
143  self._checkRepackedFlag(options,**args)
144 
145  cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
146 
147  cb.prepare()
148 
149  addMonitoring(process)
150 
151  return process
152 
153 
154  def visualizationProcessing(self, globalTag, **args):
155  """
156  _visualizationProcessing_
157 
158  """
159 
160  options = Options()
161  options.__dict__.update(defaultOptions.__dict__)
162  options.scenario = self.cbSc
163  # FIXME: do we need L1Reco here?
164  options.step =''
165  if 'preFilter' in args:
166  options.step +='FILTER:'+args['preFilter']+','
167 
168  eiStep=''
169  if self.addEI:
170  eiStep=',EI'
171 
172  options.step += 'RAW2DIGI,L1Reco,RECO'+eiStep+',ENDJOB'
173 
174 
175  dictIO(options,args)
176  options.conditions = gtNameAndConnect(globalTag, args)
177  options.timeoutOutput = True
178  # FIXME: maybe can go...maybe not
179  options.filein = 'tobeoverwritten.xyz'
180 
181  if 'inputSource' in args:
182  options.filetype = args['inputSource']
183  else:
184  # this is the default as this is what is needed on the OnlineCluster
185  options.filetype = 'DQMDAQ'
186 
187  print("Using %s source"%options.filetype)
188 
189  process = cms.Process('RECO', cms.ModifierChain(self.eras, self.visModifiers) )
190 
191  if 'customs' in args:
192  options.customisation_file=args['customs']
193 
194  self._checkRepackedFlag(options, **args)
195 
196  cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
197 
198  cb.prepare()
199 
200 
201 
202 
203  # FIXME: not sure abou this one...drop for the moment
204  # addMonitoring(process)
205 
206  return process
207 
208 
209 
210 
211  def alcaSkim(self, skims, **args):
212  """
213  _alcaSkim_
214 
215  AlcaReco processing & skims for proton collisions
216 
217  """
218 
219  step = ""
220  pclWflws = [x for x in skims if "PromptCalibProd" in x]
221  skims = [x for x in skims if x not in pclWflws]
222 
223  if len(pclWflws):
224  step += 'ALCA:'+('+'.join(pclWflws))
225 
226  if len( skims ) > 0:
227  if step != "":
228  step += ","
229  step += "ALCAOUTPUT:"+('+'.join(skims))
230 
231  options = Options()
232  options.__dict__.update(defaultOptions.__dict__)
233  options.scenario = self.cbSc
234  options.step = step
235  options.conditions = args['globaltag'] if 'globaltag' in args else 'None'
236  if 'globalTagConnect' in args and args['globalTagConnect'] != '':
237  options.conditions += ','+args['globalTagConnect']
238 
239  options.triggerResultsProcess = 'RECO'
240 
241  if 'customs' in args:
242  options.customisation_file=args['customs']
243 
244  process = cms.Process('ALCA', self.eras)
245  cb = ConfigBuilder(options, process = process)
246 
247  # Input source
248  process.source = cms.Source(
249  "PoolSource",
250  fileNames = cms.untracked.vstring()
251  )
252 
253  cb.prepare()
254 
255  # FIXME: dirty hack..any way around this?
256  # Tier0 needs the dataset used for ALCAHARVEST step to be a different data-tier
257  for wfl in pclWflws:
258  methodToCall = getattr(process, 'ALCARECOStream'+wfl)
259  methodToCall.dataset.dataTier = cms.untracked.string('ALCAPROMPT')
260 
261  return process
262 
263 
264  def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
265  """
266  _dqmHarvesting_
267 
268  Proton collisions data taking DQM Harvesting
269 
270  """
271  options = defaultOptions
272  options.scenario = self.cbSc
273  options.step = "HARVESTING"+dqmSeq(args,':dqmHarvesting')
274  options.name = "EDMtoMEConvert"
275  options.conditions = gtNameAndConnect(globalTag, args)
276 
277  process = cms.Process("HARVESTING", self.eras)
278  process.source = dqmIOSource(args)
279 
280  if 'customs' in args:
281  options.customisation_file=args['customs']
282 
283  configBuilder = ConfigBuilder(options, process = process)
284  configBuilder.prepare()
285 
286  harvestingMode(process,datasetName,args,rANDl=False)
287  return process
288 
289 
290  def alcaHarvesting(self, globalTag, datasetName, **args):
291  """
292  _alcaHarvesting_
293 
294  Proton collisions data taking AlCa Harvesting
295 
296  """
297  skims = []
298  if 'skims' in args:
299  skims = args['skims']
300 
301 
302  if 'alcapromptdataset' in args:
303  skims.append('@'+args['alcapromptdataset'])
304 
305  if len(skims) == 0: return None
306  options = defaultOptions
307  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
308  options.step = "ALCAHARVEST:"+('+'.join(skims))
309  options.name = "ALCAHARVEST"
310  options.conditions = gtNameAndConnect(globalTag, args)
311 
312  process = cms.Process("ALCAHARVEST", self.eras)
313  process.source = cms.Source("PoolSource")
314 
315  if 'customs' in args:
316  options.customisation_file=args['customs']
317 
318  configBuilder = ConfigBuilder(options, process = process)
319  configBuilder.prepare()
320 
321  #
322  # customise process for particular job
323  #
324  process.source.processingMode = cms.untracked.string('RunsAndLumis')
325  process.source.fileNames = cms.untracked(cms.vstring())
326  process.maxEvents.input = -1
327  process.dqmSaver.workflow = datasetName
328 
329  return process
330 
331  def skimming(self, skims, globalTag,**options):
332  """
333  _skimming_
334 
335  skimming method overload for the prompt skiming
336 
337  """
338  options = defaultOptions
339  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
340  options.step = "SKIM:"+('+'.join(skims))
341  options.name = "SKIM"
342  options.conditions = gtNameAndConnect(globalTag, args)
343  process = cms.Process("SKIM", self.eras)
344  process.source = cms.Source("PoolSource")
345 
346  if 'customs' in args:
347  options.customisation_file=args['customs']
348 
349  configBuilder = ConfigBuilder(options, process = process)
350  configBuilder.prepare()
351 
352  return process
353 
354  """
355  def repack(self, **args):
356  options = defaultOptions
357  dictIO(options,args)
358  options.filein='file.dat'
359  options.filetype='DAT'
360  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
361  process = cms.Process('REPACK', self.eras)
362  cb = ConfigBuilder(options, process = process, with_output = True,with_input=True)
363  cb.prepare()
364  print cb.pythonCfgCode
365  return process
366  """
Reco.Reco.expressModifiers
expressModifiers
Definition: Reco.py:25
Utils.dqmSeq
def dqmSeq(args, default)
Definition: Utils.py:129
Reco.Reco._checkRepackedFlag
def _checkRepackedFlag(self, options, **args)
Definition: Reco.py:36
Reco.Reco
Definition: Reco.py:18
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
Reco.Reco.dqmHarvesting
def dqmHarvesting(self, datasetName, runNumber, globalTag, **args)
Definition: Reco.py:264
ConfigBuilder
Definition: ConfigBuilder.py:1
Reco.Reco.visModifiers
visModifiers
Definition: Reco.py:26
Utils.stepALCAPRODUCER
def stepALCAPRODUCER(skims)
Definition: Utils.py:9
Utils.addMonitoring
def addMonitoring(process)
Definition: Utils.py:38
Reco.Reco.alcaSkim
def alcaSkim(self, skims, **args)
Definition: Reco.py:211
Reco.Reco.promptReco
def promptReco(self, globalTag, **args)
Definition: Reco.py:45
Reco.Reco.__init__
def __init__(self)
Definition: Reco.py:19
Utils.dictIO
def dictIO(options, args)
Definition: Utils.py:121
Reco.Reco.promptModifiers
promptModifiers
Definition: Reco.py:24
Reco.Reco.expressProcessing
def expressProcessing(self, globalTag, **args)
Definition: Reco.py:104
Scenario
Definition: Scenario.py:1
Reco.Reco.recoSeq
recoSeq
Definition: Reco.py:21
Utils.harvestingMode
def harvestingMode(process, datasetName, args, rANDl=True)
Definition: Utils.py:114
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
Reco.Reco.alcaHarvesting
def alcaHarvesting(self, globalTag, datasetName, **args)
Definition: Reco.py:290
Utils.gtNameAndConnect
def gtNameAndConnect(globalTag, args)
Definition: Utils.py:135
Reco.Reco.addEI
addEI
Definition: Reco.py:22
Reco.Reco.cbSc
cbSc
Definition: Reco.py:23
Reco.Reco.visualizationProcessing
def visualizationProcessing(self, globalTag, **args)
Definition: Reco.py:154
Utils.stepSKIMPRODUCER
def stepSKIMPRODUCER(PhysicsSkims)
Definition: Utils.py:24
Utils.dqmIOSource
def dqmIOSource(args)
Definition: Utils.py:103
Reco.Reco.skimming
def skimming(self, skims, globalTag, **options)
Definition: Reco.py:331
Scenario