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  self._checkRepackedFlag(options, **args)
72 
73  if 'customs' in args:
74  options.customisation_file=args['customs']
75 
76  eiStep=''
77  if self.addEI:
78  eiStep=',EI'
79 
80  options.step = 'RAW2DIGI,L1Reco,RECO'+self.recoSeq+eiStep+step+PhysicsSkimStep+miniAODStep+',DQM'+dqmStep+',ENDJOB'
81 
82  dictIO(options,args)
83  options.conditions = gtNameAndConnect(globalTag, args)
84 
85  process = cms.Process('RECO', cms.ModifierChain(self.eras, self.promptModifiers) )
86  cb = ConfigBuilder(options, process = process, with_output = True)
87 
88  # Input source
89  process.source = cms.Source("PoolSource",
90  fileNames = cms.untracked.vstring()
91  )
92  cb.prepare()
93 
94  addMonitoring(process)
95 
96  return process
97 
98 
99  def expressProcessing(self, globalTag, **args):
100  """
101  _expressProcessing_
102 
103  Proton collision data taking express processing
104 
105  """
106  skims = args['skims']
107  # 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
108  pclWkflws = [x for x in skims if "PromptCalibProd" in x]
109  for wfl in pclWkflws:
110  skims.remove(wfl)
111 
112  step = stepALCAPRODUCER(skims)
113  dqmStep= dqmSeq(args,'')
114  options = Options()
115  options.__dict__.update(defaultOptions.__dict__)
116  options.scenario = self.cbSc
117  if ('nThreads' in args) :
118  options.nThreads=args['nThreads']
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 = [x for x in skims if x not in pclWflws]
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  """
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:259
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:206
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
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Reco.Reco.promptModifiers
promptModifiers
Definition: Reco.py:24
Reco.Reco.expressProcessing
def expressProcessing(self, globalTag, **args)
Definition: Reco.py:99
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
Reco.Reco.alcaHarvesting
def alcaHarvesting(self, globalTag, datasetName, **args)
Definition: Reco.py:285
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:149
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:326
Scenario