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