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