test
CMS 3D CMS Logo

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