CMS 3D CMS Logo

Reco.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
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.cbSc=self.__class__.__name__
23  self.promptModifiers = cms.ModifierChain()
24  self.expressModifiers = cms.ModifierChain()
25  self.visModifiers = cms.ModifierChain()
26  """
27  _pp_
28 
29  Implement configuration building for data processing for proton
30  collision data taking
31 
32  """
33 
34 
35  def _checkRepackedFlag(self, options, **args):
36  if 'repacked' in args:
37  if args['repacked'] == True:
38  options.isRepacked = True
39  else:
40  options.isRepacked = False
41 
42 
43 
44  def promptReco(self, globalTag, **args):
45  """
46  _promptReco_
47 
48  Proton collision data taking prompt reco
49 
50  """
51  step = stepALCAPRODUCER(args['skims'])
52  PhysicsSkimStep = ''
53  if ("PhysicsSkims" in args) :
54  PhysicsSkimStep = stepSKIMPRODUCER(args['PhysicsSkims'])
55  dqmStep = dqmSeq(args,'')
56  options = Options()
57  options.__dict__.update(defaultOptions.__dict__)
58  options.scenario = self.cbSc
59  if ('nThreads' in args) :
60  options.nThreads=args['nThreads']
61 
62  miniAODStep = ''
63  nanoAODStep = ''
64 
65  if 'outputs' in args:
66  print(args['outputs'])
67  for a in args['outputs']:
68  if a['dataTier'] == 'MINIAOD':
69  miniAODStep = ',PAT'
70  if a['dataTier'] in ['NANOAOD', 'NANOEDMAOD']:
71  nanoAODStep = ',NANO'
72 
73  self._checkRepackedFlag(options, **args)
74 
75  if 'customs' in args:
76  options.customisation_file=args['customs']
77 
78  eiStep=''
79 
80  options.step = 'RAW2DIGI,L1Reco,RECO'
81  options.step += self.recoSeq + eiStep + step + PhysicsSkimStep
82  options.step += miniAODStep + nanoAODStep
83  options.step += ',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  if ('nThreads' in args) :
121  options.nThreads=args['nThreads']
122 
123  eiStep=''
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 
166  if 'beamSplashRun' in args:
167  options.step += 'RAW2DIGI,L1Reco,RECO'+args['beamSplashRun']+',ENDJOB'
168  print("Using RECO%s step in visualizationProcessing" % args['beamSplashRun'])
169  else :
170  options.step += 'RAW2DIGI,L1Reco,RECO'+eiStep+',ENDJOB'
171 
172 
173 
174  dictIO(options,args)
175  options.conditions = gtNameAndConnect(globalTag, args)
176  options.timeoutOutput = True
177  # FIXME: maybe can go...maybe not
178  options.filein = 'tobeoverwritten.xyz'
179 
180  if 'inputSource' in args:
181  options.filetype = args['inputSource']
182  else:
183  # this is the default as this is what is needed on the OnlineCluster
184  options.filetype = 'DQMDAQ'
185 
186  print("Using %s source"%options.filetype)
187 
188  process = cms.Process('RECO', cms.ModifierChain(self.eras, self.visModifiers) )
189 
190  if 'customs' in args:
191  options.customisation_file=args['customs']
192 
193  self._checkRepackedFlag(options, **args)
194 
195  cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
196 
197  cb.prepare()
198 
199 
200 
201 
202  # FIXME: not sure abou this one...drop for the moment
203  # addMonitoring(process)
204 
205  return process
206 
207 
208 
209 
210  def alcaSkim(self, skims, **args):
211  """
212  _alcaSkim_
213 
214  AlcaReco processing & skims for proton collisions
215 
216  """
217 
218  step = ""
219  pclWflws = [x for x in skims if "PromptCalibProd" in x]
220  skims = [x for x in skims if x not in pclWflws]
221 
222  if len(pclWflws):
223  step += 'ALCA:'+('+'.join(pclWflws))
224 
225  if len( skims ) > 0:
226  if step != "":
227  step += ","
228  step += "ALCAOUTPUT:"+('+'.join(skims))
229 
230  options = Options()
231  options.__dict__.update(defaultOptions.__dict__)
232  options.scenario = self.cbSc
233  options.step = step
234  options.conditions = args['globaltag'] if 'globaltag' in args else 'None'
235  if 'globalTagConnect' in args and args['globalTagConnect'] != '':
236  options.conditions += ','+args['globalTagConnect']
237 
238  options.triggerResultsProcess = 'RECO'
239 
240  if 'customs' in args:
241  options.customisation_file=args['customs']
242 
243  process = cms.Process('ALCA', self.eras)
244  cb = ConfigBuilder(options, process = process)
245 
246  # Input source
247  process.source = cms.Source(
248  "PoolSource",
249  fileNames = cms.untracked.vstring()
250  )
251 
252  cb.prepare()
253 
254  # FIXME: dirty hack..any way around this?
255  # Tier0 needs the dataset used for ALCAHARVEST step to be a different data-tier
256  for wfl in pclWflws:
257  methodToCall = getattr(process, 'ALCARECOStream'+wfl)
258  methodToCall.dataset.dataTier = cms.untracked.string('ALCAPROMPT')
259 
260  return process
261 
262 
263  def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
264  """
265  _dqmHarvesting_
266 
267  Proton collisions data taking DQM Harvesting
268 
269  """
270  options = defaultOptions
271  options.scenario = self.cbSc
272  options.step = "HARVESTING"+dqmSeq(args,':dqmHarvesting')
273  options.name = "EDMtoMEConvert"
274  options.conditions = gtNameAndConnect(globalTag, args)
275 
276  process = cms.Process("HARVESTING", self.eras)
277  process.source = dqmIOSource(args)
278 
279  if 'customs' in args:
280  options.customisation_file=args['customs']
281 
282  configBuilder = ConfigBuilder(options, process = process)
283  configBuilder.prepare()
284 
285  harvestingMode(process,datasetName,args,rANDl=False)
286  return process
287 
288 
289  def alcaHarvesting(self, globalTag, datasetName, **args):
290  """
291  _alcaHarvesting_
292 
293  Proton collisions data taking AlCa Harvesting
294 
295  """
296  skims = []
297  if 'skims' in args:
298  skims = args['skims']
299 
300 
301  if 'alcapromptdataset' in args:
302  skims.append('@'+args['alcapromptdataset'])
303 
304  if len(skims) == 0: return None
305  options = defaultOptions
306  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
307  options.step = "ALCAHARVEST:"+('+'.join(skims))
308  options.name = "ALCAHARVEST"
309  options.conditions = gtNameAndConnect(globalTag, args)
310 
311  process = cms.Process("ALCAHARVEST", self.eras)
312  process.source = cms.Source("PoolSource")
313 
314  if 'customs' in args:
315  options.customisation_file=args['customs']
316 
317  configBuilder = ConfigBuilder(options, process = process)
318  configBuilder.prepare()
319 
320  #
321  # customise process for particular job
322  #
323  process.source.processingMode = cms.untracked.string('RunsAndLumis')
324  process.source.fileNames = cms.untracked(cms.vstring())
325  process.maxEvents.input = -1
326  process.dqmSaver.workflow = datasetName
327 
328  return process
329 
330  def skimming(self, skims, globalTag,**options):
331  """
332  _skimming_
333 
334  skimming method overload for the prompt skiming
335 
336  """
337  options = defaultOptions
338  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
339  options.step = "SKIM:"+('+'.join(skims))
340  options.name = "SKIM"
341  options.conditions = gtNameAndConnect(globalTag, args)
342  process = cms.Process("SKIM", self.eras)
343  process.source = cms.Source("PoolSource")
344 
345  if 'customs' in args:
346  options.customisation_file=args['customs']
347 
348  configBuilder = ConfigBuilder(options, process = process)
349  configBuilder.prepare()
350 
351  return process
352 
353  """
354  def repack(self, **args):
355  options = defaultOptions
356  dictIO(options,args)
357  options.filein='file.dat'
358  options.filetype='DAT'
359  options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
360  process = cms.Process('REPACK', self.eras)
361  cb = ConfigBuilder(options, process = process, with_output = True,with_input=True)
362  cb.prepare()
363  print cb.pythonCfgCode
364  return process
365  """
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:330
visModifiers
Definition: Reco.py:25
def dqmSeq(args, default)
Definition: Utils.py:129
def gtNameAndConnect(globalTag, args)
Definition: Utils.py:135
def expressProcessing(self, globalTag, args)
Definition: Reco.py:102
expressModifiers
Definition: Reco.py:24
def visualizationProcessing(self, globalTag, args)
Definition: Reco.py:150
def alcaSkim(self, skims, args)
Definition: Reco.py:210
def dictIO(options, args)
Definition: Utils.py:121
def alcaHarvesting(self, globalTag, datasetName, args)
Definition: Reco.py:289
promptModifiers
Definition: Reco.py:23
def addMonitoring(process)
Definition: Utils.py:38
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def stepALCAPRODUCER(skims)
Definition: Utils.py:9
def promptReco(self, globalTag, args)
Definition: Reco.py:44
def __init__(self)
Definition: Reco.py:19
def dqmHarvesting(self, datasetName, runNumber, globalTag, args)
Definition: Reco.py:263
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
recoSeq
Definition: Reco.py:21
def _checkRepackedFlag(self, options, args)
Definition: Reco.py:35
def dqmIOSource(args)
Definition: Utils.py:103
cbSc
Definition: Reco.py:22